mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
库存扣减
This commit is contained in:
parent
5b73d0641e
commit
d1b2d06c6b
@ -16,7 +16,7 @@ class KttOrderSyncStatus extends Command
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ktt:order_sync_status';
|
protected $signature = 'ktt:order_sync_status {ids?}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -43,14 +43,21 @@ class KttOrderSyncStatus extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
|
$ids = $this->argument('ids');
|
||||||
|
if (!empty($ids)) {
|
||||||
|
$ids = explode(",", $ids);
|
||||||
|
}
|
||||||
$startTime = Carbon::now()->subDays(15)->getPreciseTimestamp(3);
|
$startTime = Carbon::now()->subDays(15)->getPreciseTimestamp(3);
|
||||||
BusinessOrder::query()->where('confirm_at', '>=', $startTime)
|
BusinessOrder::query()->when($ids, function ($query) use ($ids) {
|
||||||
->where('shipping_status',BusinessOrderShippingStatus::UNSHIP)
|
$query->whereIn('id',$ids);
|
||||||
->where('cancel_status',0)
|
})
|
||||||
->chunk(200, function ($orders){
|
->where('confirm_at', '>=', $startTime)
|
||||||
|
->where('shipping_status', BusinessOrderShippingStatus::UNSHIP)
|
||||||
|
->where('cancel_status', 0)
|
||||||
|
->chunk(200, function ($orders) {
|
||||||
foreach ($orders as $order) {
|
foreach ($orders as $order) {
|
||||||
$shop = Shop::query()->find($order['shop_id']);
|
$shop = Shop::query()->find($order['shop_id']);
|
||||||
if(!empty($shop)){
|
if (!empty($shop)) {
|
||||||
BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order);
|
BusinessFactory::init()->make($shop->plat_id)->setShop($shop)->queryStatusAndSync($order);
|
||||||
usleep(10);
|
usleep(10);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,6 +196,11 @@ class KuaiTuanTuan extends BusinessClient
|
|||||||
$order->cancel_status = $queryOrder['cancel_status'];
|
$order->cancel_status = $queryOrder['cancel_status'];
|
||||||
$needUpdate = true;
|
$needUpdate = true;
|
||||||
}
|
}
|
||||||
|
if ($order->after_sales_status!= $queryOrder['cancel_status']) {
|
||||||
|
//售后状态更新
|
||||||
|
$order->after_sales_status = $queryOrder['after_sales_status'];
|
||||||
|
$needUpdate = true;
|
||||||
|
}
|
||||||
if ($needUpdate) {
|
if ($needUpdate) {
|
||||||
$goodsSkuNum = 0;
|
$goodsSkuNum = 0;
|
||||||
foreach ($queryOrder['sub_order_list'] as $item) {
|
foreach ($queryOrder['sub_order_list'] as $item) {
|
||||||
|
|||||||
@ -121,6 +121,7 @@ class GoodSkuService
|
|||||||
->select("external_sku_id", DB::raw("SUM(goods_number) - SUM(already_cancel_number) as number"))
|
->select("external_sku_id", DB::raw("SUM(goods_number) - SUM(already_cancel_number) as number"))
|
||||||
->whereIn("external_sku_id", $externalSkuIds)
|
->whereIn("external_sku_id", $externalSkuIds)
|
||||||
->where("b.shipping_status", "=", BusinessOrderShippingStatus::UNSHIP)
|
->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)
|
->where("business_order_items.created_at", ">=", $startTime)->where("business_order_items.cancel_status", "=", 0)
|
||||||
->groupBy('external_sku_id')->get()->toArray();
|
->groupBy('external_sku_id')->get()->toArray();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user