feat(StoreProductController): 根据库存状态调整商品添加逻辑
This commit is contained in:
parent
dd676bdc0c
commit
e87d906917
@ -115,20 +115,23 @@ 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'],
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'financial_pm' => 0,
|
'financial_pm' => 0,
|
||||||
'batch' => 1,
|
'batch' => 1,
|
||||||
'nums' => $arr['stock'],
|
'nums' => $arr['stock'],
|
||||||
'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]);
|
||||||
@ -136,18 +139,24 @@ class StoreProductController extends BaseAdminController
|
|||||||
} else {
|
} else {
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
foreach ($store_arr as $k => $store_id) {
|
foreach ($store_arr as $k => $store_id) {
|
||||||
$data=[
|
$data = [
|
||||||
'warehouse_id'=>$warehouse_id,
|
'warehouse_id' => $warehouse_id,
|
||||||
'product_id' => $arr['id'],
|
'product_id' => $arr['id'],
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'financial_pm' => 0,
|
'financial_pm' => 0,
|
||||||
'batch' => 1,
|
'batch' => 1,
|
||||||
'nums' => $arr['stock'],
|
'nums' => $arr['stock'],
|
||||||
'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