コード例 #1
0
 public function actionAutomaticreceiving7()
 {
     set_time_limit(0);
     $model = new Order();
     $list = $model->find()->where(['orderStatus' => 2])->all();
     //查出所有已发货的订单
     $res = [];
     foreach ($list as $k => $v) {
         $status = $v->orderExpressInfo->status;
         $updateTime = null;
         if (isset($v->orderExpressInfo->updateTime) && !empty($v->orderExpressInfo->updateTime)) {
             $updateTime = $v->orderExpressInfo->updateTime;
         }
         $updateTime = strtotime($updateTime);
         if ($updateTime && $status == 4) {
             $interval = strtotime(date('Y-m-d H:i:s', time())) - $updateTime;
             $day = $interval / 86400;
             //60s*60min*24h
             if ($day > 7) {
                 array_push($res, ['id' => $v->id, 'orderStatus' => 3]);
             }
         }
     }
     $model->updateOrderStatusByBatch($res);
     //系统自动确认收货(批量)
 }