* @date 2020/7/14 15:41 * */ protected function configure() { $this->setName('render:mts') ->setDescription('render:mts'); } /** * 流程处理 * * @param Input $input * @param Output $output * @return int|void|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @author 许祖兴 < zuxing.xu@lettered.cn> * @date 2020/7/20 9:20 * */ protected function execute(Input $input, Output $output) { // 分别处理 foreach (['MissionOrder','TaxiOrder','SkillOrder','RescueOrder'] as $args){ //1.产品订单处理 查询订单 $orders = model('common/'. $args)->whereTime('created_at', 'month')->select()->toArray(); foreach ($orders as $order) { // 已结束或者已关闭不处理 if ($order['status'] == 4 || $order['status'] == 0) continue; // 按类型处理 switch ($order['status']) { case 1: // 待支付订单处理 // 读取配置 超时时间 (order_expired_at)小时 (下单时间戳+小时*时间戳 < 当前时间戳 超时) $order_expired_at = $this->config['store']['order_expired_at']; // 流程开始 if (($order['created_at'] + ($order_expired_at * 3600)) <= time()){ //关闭订单 model('common/'. $args)->updateBy($order['id'], [ 'status' => 0 ]); } break; case 2: // 自动服务 break; case 3: // 待确认处理 // 读取配置 自动确认时间 (order_confirm_at) 天数 (下单时间戳+天*时间戳 < 当前时间戳 超时) $order_confirm_at = $this->config['store']['order_confirm_at']; // 流程开始 if (($order['created_at'] + ($order_confirm_at * 86400)) <= time()) { // 结束订单 model('common/'. $args)->updateBy($order['id'], [ 'status' => 4 // 结束订单 ]); } break; } } } } }