feat(StoreProductController): 根据库存状态调整商品添加逻辑
This commit is contained in:
parent
dd676bdc0c
commit
e87d906917
app/admin
@ -115,7 +115,6 @@ class StoreProductController extends BaseAdminController
|
|||||||
if ($count == 1) {
|
if ($count == 1) {
|
||||||
$store_id = $store_arr[0];
|
$store_id = $store_arr[0];
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
// $find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
|
||||||
$data = [
|
$data = [
|
||||||
'warehouse_id' => $warehouse_id,
|
'warehouse_id' => $warehouse_id,
|
||||||
'product_id' => $arr['id'],
|
'product_id' => $arr['id'],
|
||||||
@ -126,9 +125,13 @@ class StoreProductController extends BaseAdminController
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'admin_id' => $this->adminId,
|
'admin_id' => $this->adminId,
|
||||||
];
|
];
|
||||||
|
if ($arr['stock'] == 0) {
|
||||||
|
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||||
|
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
|
} else {
|
||||||
WarehouseProductLogic::add($data);
|
WarehouseProductLogic::add($data);
|
||||||
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
|
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
|
||||||
|
}
|
||||||
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
|
|
||||||
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
||||||
@ -146,8 +149,14 @@ class StoreProductController extends BaseAdminController
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'admin_id' => $this->adminId,
|
'admin_id' => $this->adminId,
|
||||||
];
|
];
|
||||||
|
if ($arr['stock'] == 0) {
|
||||||
|
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||||
|
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
|
} else {
|
||||||
WarehouseProductLogic::add($data);
|
WarehouseProductLogic::add($data);
|
||||||
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
|
StoreBranchProduct::where('product_id', $arr['id'])->where('store_id', $store_id)->inc('stock', $arr['stock'])->update();
|
||||||
|
}
|
||||||
|
|
||||||
// $find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
// $find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||||
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
// StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
||||||
|
@ -222,6 +222,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'bar_code'=> $params['bar_code'],
|
'bar_code'=> $params['bar_code'],
|
||||||
'purchase'=> $params['purchase'],
|
'purchase'=> $params['purchase'],
|
||||||
'rose'=> $params['rose']??0,
|
'rose'=> $params['rose']??0,
|
||||||
|
'image' => $params['image'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user