|
@@ -22,26 +22,46 @@ class ExpressOrder extends Command
|
|
|
$output->writeln("开始更新快递信息====>" . getDateFull());
|
|
$output->writeln("开始更新快递信息====>" . getDateFull());
|
|
|
$nextPage = 1;
|
|
$nextPage = 1;
|
|
|
while (is_numeric($nextPage)) {
|
|
while (is_numeric($nextPage)) {
|
|
|
- $resp = (new SaasOrderExpress)->where(["status" => 0])->with(['orders'])->page($nextPage,10)->select();
|
|
|
|
|
|
|
+ $resp = (new SaasOrderExpress)->where(["status" => 0])->with(['orders' => function ($query) {
|
|
|
|
|
+ $query->with(['poi']);
|
|
|
|
|
+ }])->page($nextPage,10)->select();
|
|
|
if ($resp->isEmpty()) {
|
|
if ($resp->isEmpty()) {
|
|
|
$output->writeln("没有任务啦==".getDateFull());
|
|
$output->writeln("没有任务啦==".getDateFull());
|
|
|
$nextPage = null;
|
|
$nextPage = null;
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-// $orderMode = (new SaasOrder);
|
|
|
|
|
foreach ($resp as $item) {
|
|
foreach ($resp as $item) {
|
|
|
- [$state,$expressData] = $this->getExpressData($item['express_sn'],$item['mobile']);
|
|
|
|
|
- if ($state && $item['orders']['is_error'] == 0) {
|
|
|
|
|
- if (in_array($expressData['logisticsStatusDesc'],['派件中',"已签收"])) { // 核销订单
|
|
|
|
|
- $output->writeln("订单进入核销=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
|
|
- (new SaasOrderExpress)->where("id",$item['id'])->update(['status' => 1,'last_at' => getDateFull(),'last_msg' => $expressData['logisticsStatusDesc'],'content' => json_encode($expressData['logisticsTraceDetailList'])]);
|
|
|
|
|
- Redis::send("order-done",['order' => $item['order_sn']]);
|
|
|
|
|
|
|
+ if (empty($item['orders']['poi'])) {
|
|
|
|
|
+ echo getDateFull()."=={$item['order_sn']}==订单对应商家不存在===\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ $startTime = $item['orders']['poi']['order_start']??'09:00';
|
|
|
|
|
+ $endTime = $item['orders']['poi']['order_end']??'22:30';
|
|
|
|
|
+ $startTimeStamp = strtotime("Y-m-d {$startTime}:00");
|
|
|
|
|
+ $endTimeStamp = strtotime("Y-m-d {$endTime}:00");
|
|
|
|
|
+ if (time() > $startTimeStamp && time() < $endTimeStamp) {
|
|
|
|
|
+ [$state,$expressData] = $this->getExpressData($item['express_sn'],$item['mobile']);
|
|
|
|
|
+ if ($state && $item['orders']['is_error'] == 0) {
|
|
|
|
|
+ $isDone = false;
|
|
|
|
|
+ foreach ($expressData['logisticsTraceDetailList'] as $sk){
|
|
|
|
|
+ if (in_array($sk['logisticsStatus'],['DELIVERING','AGENT_SIGN','SIGN'])) {
|
|
|
|
|
+ $isDone = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// if (in_array($expressData['logisticsStatusDesc'],['派件中',"已签收"])) { // 核销订单
|
|
|
|
|
+ if ($isDone) { // 核销订单
|
|
|
|
|
+ $output->writeln("订单进入核销=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
|
|
+ (new SaasOrderExpress)->where("id",$item['id'])->update(['status' => 1,'last_at' => getDateFull(),'last_msg' => $expressData['logisticsStatusDesc'],'content' => json_encode($expressData['logisticsTraceDetailList'])]);
|
|
|
|
|
+ Redis::send("order-done",['order' => $item['order_sn']]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ (new SaasOrderExpress)->where("id",$item['id'])->update(['last_msg' => $expressData['logisticsStatusDesc'],'last_at' => getDateFull(),'content' => json_encode($expressData['logisticsTraceDetailList'])]);
|
|
|
|
|
+ $output->writeln("查询物流成功=={$item['order_sn']}=={$expressData['logisticsStatusDesc']}==".getDateFull());
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- (new SaasOrderExpress)->where("id",$item['id'])->update(['last_msg' => $expressData['logisticsStatusDesc'],'last_at' => getDateFull(),'content' => json_encode($expressData['logisticsTraceDetailList'])]);
|
|
|
|
|
- $output->writeln("查询物流成功=={$item['order_sn']}=={$expressData['logisticsStatusDesc']}==".getDateFull());
|
|
|
|
|
|
|
+ $output->writeln("查询快递信息失败=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- $output->writeln("查询快递信息失败=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
|
|
|
|
+ echo getDateFull()."==={$item['order_sn']}===不在核销时段==\n";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$nextPage = $nextPage+1;
|
|
$nextPage = $nextPage+1;
|