mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
commit
53f04a2c7f
@ -27,14 +27,14 @@ class BusinessOrdersUpdate
|
|||||||
*/
|
*/
|
||||||
public function __construct(BusinessOrderItem $item, $num)
|
public function __construct(BusinessOrderItem $item, $num)
|
||||||
{
|
{
|
||||||
$this->businessOrderItem = $item;
|
$this->businessOrderItem = $item->toArray();
|
||||||
$this->num = $num;
|
$this->num = $num;
|
||||||
$this->updateStock();
|
$this->updateStock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateStock()
|
private function updateStock()
|
||||||
{
|
{
|
||||||
[$goodsCode, $skuCode] = explode('_', $this->businessOrderItem->external_sku_id);
|
[$goodsCode, $skuCode] = explode('_', $this->businessOrderItem['external_sku_id']);
|
||||||
$this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode)
|
$this->goodsSku = GoodsSku::query()->where('sku_code', $skuCode)
|
||||||
->with(['goods' => function ($query) use ($goodsCode) {
|
->with(['goods' => function ($query) use ($goodsCode) {
|
||||||
$query->where('goods_code', $goodsCode);
|
$query->where('goods_code', $goodsCode);
|
||||||
|
|||||||
@ -36,13 +36,13 @@ class StockUpdateListener
|
|||||||
foreach ($shops as $shop) {
|
foreach ($shops as $shop) {
|
||||||
if (isset($event->goodsSku)) {
|
if (isset($event->goodsSku)) {
|
||||||
$num = $event->goodsSku->stock;
|
$num = $event->goodsSku->stock;
|
||||||
$businessGoodsSku = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $event->goodsSku->goods['goods_code'] . '_' . $event->goodsSku->sku_code)->first();
|
$businessGoodsSku = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $event->goodsSku->goods['goods_code'] . '_' . $event->goodsSku->sku_code)->first()->toArray();
|
||||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku, $num, false);
|
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku, $num, false);
|
||||||
}
|
}
|
||||||
if (isset($event->goodsSkus)) {
|
if (isset($event->goodsSkus)) {
|
||||||
foreach ($event->goodsSkus as $goodsSku) {
|
foreach ($event->goodsSkus as $goodsSku) {
|
||||||
$num = $goodsSku->stock;
|
$num = $goodsSku->stock;
|
||||||
$businessGoodsSku = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $goodsSku->goods['goods_code'] . '_' . $goodsSku->sku_code)->first();
|
$businessGoodsSku = BusinessGoodsSku::query()->where('shop_id', $shop->id)->where('external_sku_id', $goodsSku->goods['goods_code'] . '_' . $goodsSku->sku_code)->first()->toArray();
|
||||||
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku, $num, false);
|
BusinessGoodsSkuIncrQuantity::dispatch($shop, $businessGoodsSku, $num, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,15 +37,15 @@ class UpdateBusinessGoodsStock implements ShouldQueue
|
|||||||
$log->module = 'goods';
|
$log->module = 'goods';
|
||||||
$log->action = 'PATCH';
|
$log->action = 'PATCH';
|
||||||
$log->target_type = 'goods_sku';
|
$log->target_type = 'goods_sku';
|
||||||
$log->target_id = $event->goodsSku->id;
|
$log->target_id = $event->goodsSku->id ?? 0;
|
||||||
$log->target_field = 'stock';
|
$log->target_field = 'stock';
|
||||||
$log->user_id = $event->businessOrderItem->shop_id;
|
$log->user_id = $event->businessOrderItem['shop_id'];
|
||||||
$log->message = ($event->businessOrderItem->external_sku_id ?: '商品') . '未找到';
|
$log->message = ($event->businessOrderItem['external_sku_id'] ?: '商品') . '未找到';
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$shops = Shop::query()->where('id', '<>', $event->businessOrderItem->shop_id)->where('status', 1)->get(['id', 'plat_id']);
|
$shops = Shop::query()->where('id', '<>', $event->businessOrderItem['shop_id'])->where('status', 1)->get(['id', 'plat_id']);
|
||||||
if (empty($shops)) {
|
if (empty($shops)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,7 @@ class KuaiTuanTuan extends BusinessClient
|
|||||||
|
|
||||||
public function incrQuantity($businessGoodsSku, $num, $incremental)
|
public function incrQuantity($businessGoodsSku, $num, $incremental)
|
||||||
{
|
{
|
||||||
[$type, $appendParams] = Goods::incrQuantity($businessGoodsSku->goods_id, $businessGoodsSku->sku_id, $num, $incremental ? 1 : 2);
|
[$type, $appendParams] = Goods::incrQuantity($businessGoodsSku['goods_id'], $businessGoodsSku['sku_id'], $num, $incremental ? 1 : 2);
|
||||||
$this->doRequest($type, $appendParams);
|
$this->doRequest($type, $appendParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,15 +16,15 @@ class Goods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function incrQuantity($shopId, $quantity, BusinessGoodsSku $businessGoods)
|
public static function incrQuantity($shopId, $quantity, $businessGoods)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'data' => [
|
'data' => [
|
||||||
'stock' => $quantity,
|
'stock' => $quantity,
|
||||||
'business_sku_id' => $businessGoods->sku_id,
|
'business_sku_id' => $businessGoods['sku_id'],
|
||||||
'business_goods_id' => $businessGoods->goods_id,
|
'business_goods_id' => $businessGoods['goods_id'],
|
||||||
'erp_shop_id' => $shopId,
|
'erp_shop_id' => $shopId,
|
||||||
'erp_sku_id' => $businessGoods->external_sku_id,
|
'erp_sku_id' => $businessGoods['external_sku_id'],
|
||||||
],
|
],
|
||||||
'type' => '更新库存',
|
'type' => '更新库存',
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user