|
|
@@ -22,7 +22,7 @@ class ExpressOrder extends Command
|
|
|
$output->writeln("开始更新快递信息====>" . getDateFull());
|
|
|
$nextPage = 1;
|
|
|
while (is_numeric($nextPage)) {
|
|
|
- $resp = (new SaasOrderExpress)->where(["status" => 0])->with(['orders' => function ($query) {
|
|
|
+ $resp = (new SaasOrderExpress)->where('status',0)->where("create_at","<",date('Y-m-d')." 00:00:00")->with(['orders' => function ($query) {
|
|
|
$query->field("*")->with(['poi']);
|
|
|
}])->page($nextPage,10)->select();
|
|
|
if ($resp->isEmpty()) {
|
|
|
@@ -35,35 +35,65 @@ class ExpressOrder extends Command
|
|
|
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(date("Y-m-d {$startTime}:00"));
|
|
|
- $endTimeStamp = strtotime(date("Y-m-d {$endTime}:00"));
|
|
|
- echo "开始时间:{$startTimeStamp};结束时间:{$endTimeStamp}\n";
|
|
|
- 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;
|
|
|
- }
|
|
|
+ [$state,$expressData] = $this->getExpressData($item['express_sn'],$item['mobile']);
|
|
|
+ if ($state) {
|
|
|
+ $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']]);
|
|
|
+ }
|
|
|
+ $expressUpData = [
|
|
|
+ 'last_at' => getDateFull(),
|
|
|
+ 'last_msg' => $expressData['logisticsStatusDesc'],
|
|
|
+ 'content' => json_encode($expressData['logisticsTraceDetailList'])
|
|
|
+ ];
|
|
|
+ if ($isDone) { // 核销订单
|
|
|
+ $where = [];
|
|
|
+ if (str_contains($item['order_sn'], 'AL')) {
|
|
|
+ $where['out_order_no'] = $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());
|
|
|
+ $where['order_sn'] = $item['order_sn'];
|
|
|
}
|
|
|
+ (new SaasOrder)->where($where)->save(['is_done' => 1]);
|
|
|
+ $expressUpData['status'] = 1;
|
|
|
+ $output->writeln("订单可以核销=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
} else {
|
|
|
- $output->writeln("查询快递信息失败=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
+ $output->writeln("查询物流成功=={$item['express_sn']}=={$item['order_sn']}=={$expressData['logisticsStatusDesc']}==".getDateFull());
|
|
|
}
|
|
|
+ (new SaasOrderExpress)->where("id",$item['id'])->update($expressUpData);
|
|
|
} else {
|
|
|
- echo getDateFull()."==={$item['order_sn']}===不在核销时段==\n";
|
|
|
+ $output->writeln("查询快递信息失败=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
}
|
|
|
+// $startTime = $item['orders']['poi']['order_start']??'09:00';
|
|
|
+// $endTime = $item['orders']['poi']['order_end']??'22:30';
|
|
|
+// $startTimeStamp = strtotime(date("Y-m-d {$startTime}:00"));
|
|
|
+// $endTimeStamp = strtotime(date("Y-m-d {$endTime}:00"));
|
|
|
+// echo "开始时间:{$startTimeStamp};结束时间:{$endTimeStamp}\n";
|
|
|
+// 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 {
|
|
|
+// $output->writeln("查询快递信息失败=={$item['order_sn']}=={$item['express_sn']}==".getDateFull());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// echo getDateFull()."==={$item['order_sn']}===不在核销时段==\n";
|
|
|
+// }
|
|
|
}
|
|
|
$nextPage = $nextPage+1;
|
|
|
$output->writeln("进入下一页=={$nextPage}==".getDateFull());
|