diff --git a/app/Console/Commands/KttOrderSyncStatus.php b/app/Console/Commands/KttOrderSyncStatus.php index 0c89e11..6912c03 100644 --- a/app/Console/Commands/KttOrderSyncStatus.php +++ b/app/Console/Commands/KttOrderSyncStatus.php @@ -16,7 +16,7 @@ class KttOrderSyncStatus extends Command * * @var string */ - protected $signature = 'ktt:order_sync_status'; + protected $signature = 'ktt:order_sync_status {ids?}'; /** * The console command description. @@ -43,18 +43,25 @@ class KttOrderSyncStatus extends Command */ public function handle() { + $ids = $this->argument('ids'); + if (!empty($ids)) { + $ids = explode(",", $ids); + } $startTime = Carbon::now()->subDays(15)->getPreciseTimestamp(3); - BusinessOrder::query()->where('confirm_at', '>=', $startTime) - ->where('shipping_status',BusinessOrderShippingStatus::UNSHIP) - ->where('cancel_status',0) - ->chunk(200, function ($orders){ - foreach ($orders as $order) { - $shop = Shop::query()->find($order['shop_id']); - if(!empty($shop)){ - BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order); - usleep(10); + BusinessOrder::query()->when($ids, function ($query) use ($ids) { + $query->whereIn('id',$ids); + }) + ->where('confirm_at', '>=', $startTime) + ->where('shipping_status', BusinessOrderShippingStatus::UNSHIP) + ->where('cancel_status', 0) + ->chunk(200, function ($orders) { + foreach ($orders as $order) { + $shop = Shop::query()->find($order['shop_id']); + if (!empty($shop)) { + BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order); + usleep(10); + } } - } - }); + }); } } diff --git a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php index a8be2d4..14b5099 100644 --- a/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php +++ b/app/Services/Business/KuaiTuanTuan/KuaiTuanTuan.php @@ -196,6 +196,11 @@ class KuaiTuanTuan extends BusinessClient $order->cancel_status = $queryOrder['cancel_status']; $needUpdate = true; } + if ($order->after_sales_status!= $queryOrder['cancel_status']) { + //售后状态更新 + $order->after_sales_status = $queryOrder['after_sales_status']; + $needUpdate = true; + } if ($needUpdate) { $goodsSkuNum = 0; foreach ($queryOrder['sub_order_list'] as $item) { diff --git a/app/Services/GoodSku/GoodSkuService.php b/app/Services/GoodSku/GoodSkuService.php index 8efb84c..d06096b 100644 --- a/app/Services/GoodSku/GoodSkuService.php +++ b/app/Services/GoodSku/GoodSkuService.php @@ -121,6 +121,7 @@ class GoodSkuService ->select("external_sku_id", DB::raw("SUM(goods_number) - SUM(already_cancel_number) as number")) ->whereIn("external_sku_id", $externalSkuIds) ->where("b.shipping_status", "=", BusinessOrderShippingStatus::UNSHIP) + ->where("b.after_sales_status", "!=", 2) ->where("business_order_items.created_at", ">=", $startTime)->where("business_order_items.cancel_status", "=", 0) ->groupBy('external_sku_id')->get()->toArray();