From d1b2d06c6b16084c572e41d15df1b86989aea9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BB=BA=E7=82=8A?= <924182103@qq.com> Date: Thu, 5 Dec 2024 19:03:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=89=A3=E5=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/KttOrderSyncStatus.php | 31 ++++++++++++------- .../Business/KuaiTuanTuan/KuaiTuanTuan.php | 5 +++ app/Services/GoodSku/GoodSkuService.php | 1 + 3 files changed, 25 insertions(+), 12 deletions(-) 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();