where('counting_month', \Carbon\Carbon::parse($counting_month)->toDateString()) ->where('owner_id', $owner_id)->where('type', $type); } /** * @param $counting_month * @param $owner_id * @param $type * @return int 1 已确认 2 未确认 */ public function isArchived($counting_month, $owner_id, $type): int { return $this->getSql($counting_month, $owner_id, $this->switchType($type))->exists() ? 1 : 2; } /** * 获取确认账单数据 * @param array $kvPairs * @return Builder|Model|object|null */ public function get(array $kvPairs) { return $this->getSql($kvPairs['counting_month'], $kvPairs['owner_id'], $this->switchType($kvPairs['type']))->first(); } /** * @param $type * @return int|mixed */ private function switchType($type) { //枚举转换 if (is_string($type)) { $type = OwnerBillReportArchive::$enums['type'][$type]; } return $type; } /** *查询没有确认的账单 */ public function getUnAchieved($counting_month, $owner_id): array { //TODO 5 => "包材费" // 8 => "卸货费" // 9 => "理赔费" //] $archives = OwnerBillReportArchive::query() ->where('counting_month', $counting_month) ->where('owner_id', $owner_id) ->pluck('type')->toArray(); $all = ['仓储费', '快递费-合计', '入库费-合计', '出库费-合计', '物流费', '包材费', '加工费', '杂项费', '卸货费', '理赔费',]; return array_diff($all, $archives); } }