mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 14:40:44 +00:00
库存扣减
This commit is contained in:
parent
cc24e05e1a
commit
5b73d0641e
@ -3,6 +3,8 @@
|
||||
namespace App\Services\Business\MiaoXuan;
|
||||
|
||||
use App\Models\BusinessGoodsSku;
|
||||
use App\Models\BusinessOrderItem;
|
||||
use App\Models\GoodsSku;
|
||||
use App\Services\Business\BusinessClient;
|
||||
|
||||
class MiaoXuan extends BusinessClient
|
||||
@ -41,9 +43,44 @@ class MiaoXuan extends BusinessClient
|
||||
public function queryStatusAndSync($order)
|
||||
{
|
||||
$appendParams = ["order_sn" => $order->order_sn, "type" => "erpQuery"];
|
||||
$url = 'http://shop.chutang66.com/miaoxuan/queryStatus';
|
||||
$res = $this->formDataPostRequest($url, $appendParams);
|
||||
$url = 'http://shop.dev.chutang66.com/miaoxuan/queryOrder';
|
||||
$queryOrder = $this->formDataPostRequest($url, $appendParams);
|
||||
$needUpdate = false;
|
||||
if ($order->shipping_status != $queryOrder['shipping_status']) {
|
||||
$order->shipping_status = $queryOrder['shipping_status'];
|
||||
$needUpdate = true;
|
||||
}
|
||||
if ($order->cancel_status != $queryOrder['cancel_status']) {
|
||||
$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) {
|
||||
$orderItem = BusinessOrderItem::firstOrNew(['shop_id' => $order->shop_id, 'business_order_id' => $order->id, 'goods_id' => $item['goods_id'], 'sku_id' => $item['sku_id']], $item);
|
||||
if ($item['external_sku_id']) {
|
||||
$goodsSku = GoodsSku::query()
|
||||
->with('combinationGoods')
|
||||
->where('external_sku_id', $item['external_sku_id'])
|
||||
->first('external_sku_id');
|
||||
$combinationNum = $goodsSku ? ($goodsSku->combinationGoods->count() ?: 1) : 1;
|
||||
$goodsSkuNum += $combinationNum;
|
||||
} else {
|
||||
$goodsSkuNum++;
|
||||
}
|
||||
|
||||
if (!empty($orderItem->id)) {
|
||||
$orderItem->update($item);
|
||||
}
|
||||
}
|
||||
$order->goods_sku_num = $goodsSkuNum;
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function batchIncrQuantity($businessGoodsSkus, $num, $incremental)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user