|
|
@@ -49,7 +49,7 @@ class OrderPackageReceivedSyncService
|
|
|
//sf
|
|
|
if (array_key_exists('SF', $logisticNumbers)) {
|
|
|
$SFLogisticNumbers = $logisticNumbers['SF'];
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-SF", $SFLogisticNumbers);
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-SF", '');
|
|
|
foreach ($SFLogisticNumbers as $logisticNumber) {
|
|
|
LogisticSFSync::dispatch($logisticNumber);
|
|
|
}
|
|
|
@@ -57,7 +57,7 @@ class OrderPackageReceivedSyncService
|
|
|
//更新中通
|
|
|
if (array_key_exists('ZTO', $logisticNumbers)) {
|
|
|
$ZTOLogisticNumbers = $logisticNumbers['ZTO'];
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-ZTO", $ZTOLogisticNumbers);
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-ZTO", '');
|
|
|
foreach ($ZTOLogisticNumbers as $logisticNumber) {
|
|
|
LogisticZopSync::dispatch($logisticNumber);
|
|
|
}
|
|
|
@@ -65,40 +65,77 @@ class OrderPackageReceivedSyncService
|
|
|
//更新韵达
|
|
|
if (array_key_exists('YUNDA', $logisticNumbers)) {
|
|
|
$YDLogisticNumbers = $logisticNumbers['YUNDA'];
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YUNDA", $YDLogisticNumbers);
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YUNDA", '');
|
|
|
foreach ($YDLogisticNumbers as $logistic_number) {
|
|
|
LogisticYDSync::dispatch($logistic_number);
|
|
|
}
|
|
|
}
|
|
|
//更新圆通
|
|
|
- if (array_key_exists('YTO', $logisticNumbers)) {
|
|
|
- $YTOLogisticNumbers = $logisticNumbers['YTO'];
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", $YTOLogisticNumbers);
|
|
|
- foreach ($YTOLogisticNumbers as $logistic_number) {
|
|
|
- LogisticYTOSync::dispatch($logistic_number);
|
|
|
- }
|
|
|
- }
|
|
|
+// if (array_key_exists('YTO', $logisticNumbers)) {
|
|
|
+// $YTOLogisticNumbers = $logisticNumbers['YTO'];
|
|
|
+// LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", $YTOLogisticNumbers);
|
|
|
+// foreach ($YTOLogisticNumbers as $logistic_number) {
|
|
|
+// LogisticYTOSync::dispatch($logistic_number);
|
|
|
+// }
|
|
|
+// }
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public function syncLogisticRouteByAliJiSu()
|
|
|
{
|
|
|
- ini_set('max_execution_time', 60);
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "阿里同步快递信息定时方法", '');
|
|
|
+ ini_set('max_execution_time', 2 * 60 * 60);
|
|
|
$query = OrderPackage::query()
|
|
|
->select(['logistic_number', 'order_id'])
|
|
|
->whereIn('order_id',function ($query){
|
|
|
$query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
|
|
|
- $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->whereNotIn('belong_company',['顺丰','中通','韵达','圆通']);
|
|
|
+ $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->whereNotIn('belong_company',['顺丰','中通','韵达','圆通','京东']);
|
|
|
});
|
|
|
});
|
|
|
$query = $query->where('sent_at', '>=', now()->subDays(20))
|
|
|
->whereNull('received_at');
|
|
|
$query->chunk(200, function ($orderPackages) {
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-阿里公用接口", json_encode($orderPackages));
|
|
|
foreach ($orderPackages as $orderPackage){
|
|
|
if ($orderPackage && $orderPackage->logistic_number)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
|
|
|
}
|
|
|
});
|
|
|
+ $this->syncLogisticRouteJD();
|
|
|
+ }
|
|
|
+ public function syncLogisticRouteJD(){
|
|
|
+ ini_set('max_execution_time', 60);
|
|
|
+ $query = OrderPackage::query()
|
|
|
+ ->select(['logistic_number', 'order_id'])
|
|
|
+ ->whereIn('order_id',function ($query){
|
|
|
+ $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
|
|
|
+ $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->where('belong_company','京东');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ $query = $query->where('created_at', '>=', now()->subDays(20))
|
|
|
+ ->whereNull('received_at')->where('logistic_number','like','JD%');
|
|
|
+ $query->chunk(200, function ($orderPackages) {
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-JD", json_encode($orderPackages));
|
|
|
+ foreach ($orderPackages as $orderPackage){
|
|
|
+ if ($orderPackage && $orderPackage->logistic_number)LogisticAliJiSuSync::dispatch($orderPackage->logistic_number);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ public function syncLogisticRouteYTO(){
|
|
|
+ ini_set('max_execution_time', 120);
|
|
|
+ $query = OrderPackage::query()
|
|
|
+ ->select(['logistic_number', 'order_id'])
|
|
|
+ ->whereIn('order_id',function ($query){
|
|
|
+ $query->from('orders')->selectRaw('id')->whereIn('logistic_id',function ($builder){
|
|
|
+ $builder->from('logistics')->selectRaw('id')->where('type','!=','物流')->where('belong_company','圆通');
|
|
|
+ });
|
|
|
+ });
|
|
|
+ $query = $query->where('sent_at', '>=', now()->subDays(20))
|
|
|
+ ->whereNull('received_at');
|
|
|
+ $query->chunk(1000, function ($orderPackages) {
|
|
|
+ LogService::log(OrderPackageReceivedSyncService::class, "同步快递信息定时方法-YTO", json_encode($orderPackages));
|
|
|
+ foreach ($orderPackages as $orderPackage){
|
|
|
+ if ($orderPackage && $orderPackage->logistic_number)LogisticYTOSync::dispatch($orderPackage->logistic_number);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
/**
|
|
|
* 根据传递的承运商与快递单号更新快递信息
|
|
|
@@ -190,7 +227,6 @@ class OrderPackageReceivedSyncService
|
|
|
try {
|
|
|
$logisticCode = $orderPackage->order->logistic->code;
|
|
|
} catch (Exception $e) {
|
|
|
- LogService::log(OrderPackageReceivedSyncService::class, "快递同步按照承运商分组异常", $orderPackage->id);
|
|
|
continue;
|
|
|
}
|
|
|
$key = config('api_logistic.logistic.' . $logisticCode);
|
|
|
@@ -211,6 +247,7 @@ class OrderPackageReceivedSyncService
|
|
|
public function setExceptionType(array $data, $lastRouteDate): array
|
|
|
{
|
|
|
//设置默认异常为否
|
|
|
+
|
|
|
$data['exception_type'] = '无';
|
|
|
$data['exception'] = '否';
|
|
|
$logistic_number = $data['logistic_number'];
|
|
|
@@ -325,7 +362,7 @@ class OrderPackageReceivedSyncService
|
|
|
$conclusion |= ($last_routed_duration > $SHORT_RESPONSE_HOURS && $last_routed_duration < $LONG_RESPONSE_HOURS) ? $IS_SHORT_NO_RESPONSE : 0;
|
|
|
$conclusion |= ($last_routed_duration > $LONG_RESPONSE_HOURS) ? $IS_LONG_NO_RESPONSE : 0;
|
|
|
$conclusion |= ($last_routed_duration > $SENDING_RESPONSE_HOURS && $data['status'] == '派送中') ? $IS_SENDING_NO_RESPONSE : 0;
|
|
|
- $conclusion |= ($delivered_duration > $HAVEN_SECOND_GOT_HOURS && $data['routes_length'] < 3) ? $IS_SECOND_ROUTE_HAVE : 0;//和出库时间比较 超过指定时间,路由信息小于三条
|
|
|
+ $conclusion |= ($delivered_duration > $HAVEN_SECOND_GOT_HOURS && $data['routes_length'] < 3) ? $IS_SECOND_ROUTE_HAVE : 0;//超过指定时间,路由信息小于两条
|
|
|
return $conclusion;
|
|
|
})();
|
|
|
switch ($conclusion) {
|
|
|
@@ -352,7 +389,7 @@ class OrderPackageReceivedSyncService
|
|
|
}
|
|
|
if ($conclusion
|
|
|
== ($conclusion | $IS_SECOND_ROUTE_HAVE)) {
|
|
|
- $data['exception_type'] = '揽件异常';
|
|
|
+ $data['exception_type'] = '派件异常';
|
|
|
$data['exception'] = '是';
|
|
|
|
|
|
}
|