feat(StoreProductLogic, StoreStorageSend): 修改商品存储逻辑,重构库存计算与存储方式

This commit is contained in:
mkm 2024-06-09 16:04:45 +08:00
parent e7ad3655c3
commit 49d7b67ea9
2 changed files with 21 additions and 11 deletions

View File

@ -72,10 +72,16 @@ class StoreProductLogic extends BaseLogic
if ($params['is_store_all'] == 1) {
$store_arr = SystemStore::where('is_show', 1)->column('id');
Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]);
foreach($store_arr as $store_id){
Redis::send('store-storage', ['product_arr' => ['id'=>$res['id'],'stock'=>0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
}
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $store_arr]);
} else {
if (is_array($params['store_arr']) && count($params['store_arr']) > 0) {
Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]);
foreach($params['store_arr'] as $key =>$store_id){
Redis::send('store-storage', ['product_arr' => ['id'=>$res['id'],'stock'=>0], 'store_id' => $store_id, 'admin_id' => Request()->adminId]);
}
// Redis::send('copy-product', ['product_id' => $res['id'], 'store_arr' => $params['store_arr']]);
}
}

View File

@ -61,7 +61,9 @@ class StoreStorageSend implements Consumer
'bar_code' => $attr_value['bar_code']
];
StoreBranchProductAttrValue::create($arr);
if ($product_arr['stock'] > 0) {
$this->storage($find, $store_id, $admin_id, $product_arr);
}
Db::commit();
return true;
} catch (\Exception $e) {
@ -72,7 +74,9 @@ class StoreStorageSend implements Consumer
} else {
Db::startTrans();
try {
if ($product_arr['stock'] > 0) {
$this->storage($find, $store_id, $admin_id, $product_arr);
}
Db::commit();
return true;
} catch (\Exception $e) {