whereRaw("CAST(UNIX_TIMESTAMP(card_deadline_datetime) as SIGNED) > 0") ->whereIn('card_status', ['INIT', 'WAITING', 'PENDING', 'USED']) ->select('card_id') ->get() ->toArray(); foreach ($cards as $card) { // 检查是否关联会员账户 $account = MemberAccount::where('member_account_nbr', $card['card_id'])->first(); if (!empty($account) && $account->member_account_status == 'ACTIVED') { $account->member_account_status = 'EXPIRED'; $account->save(); } $cardNow = Card::where('card_id', $card['card_id'])->first(); $cardNow->card_status = 'EXPIRED'; $cardExtendJson = []; if (!empty($cardNow->card_extend_json)) { $cardExtendJson = json_decode($cardNow->card_extend_json, true); } $cardExtendJson['expired_datetime'] = date('Y-m-d H:i:s'); $cardNow->card_extend_json = json_encode($cardExtendJson); $cardNow->save(); Log::info("储值卡:【" . $card['card_id'] . '】已过期'); } } public static $status = [ 'INIT' => '待分配', 'WAITING' => '已分配,待售', 'PENDING' => '已售,待激活', 'USED' => '已激活', 'DONE' => '使用完成', 'EXPIRED' => '已过期', 'PAUSED' => '冻结' ]; }