feat: 修改了库存统计和负库存更新逻辑
This commit is contained in:
parent
97c4cf60d5
commit
14ffe62487
@ -236,7 +236,8 @@ class WarehouseLogic extends BaseLogic
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function stockProductPrice($parmas){
|
public static function stockProductPrice($parmas)
|
||||||
|
{
|
||||||
$arr1 = WarehouseProductStorege::where('nums', '>', 0)->select();
|
$arr1 = WarehouseProductStorege::where('nums', '>', 0)->select();
|
||||||
foreach ($arr1 as $k => $v) {
|
foreach ($arr1 as $k => $v) {
|
||||||
$find = StoreProduct::where('id', $v['product_id'])->find();
|
$find = StoreProduct::where('id', $v['product_id'])->find();
|
||||||
@ -259,21 +260,15 @@ class WarehouseLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
StoreBranchProduct::where('id', $v['id'])->update(['total_price' => $total_price]);
|
StoreBranchProduct::where('id', $v['id'])->update(['total_price' => $total_price]);
|
||||||
}
|
}
|
||||||
$arr3=WarehouseProductStorege::where('nums','>',0)->field('product_id,sum(nums) as nums')->group('product_id')->select();
|
$arr3 = StoreProduct::where('stock', '>=', 0)->select();
|
||||||
foreach ($arr3 as $k => $v) {
|
foreach ($arr3 as $k => $v) {
|
||||||
StoreProduct::where('id',$v['product_id'])->update(['stock'=>$v['nums']]);
|
$stock = StoreBranchProduct::where('product_id', $v['id'])->where('stock', '>', 0)->sum('stock');
|
||||||
}
|
$nums = WarehouseProductStorege::where('nums', '>', 0)->where('product_id', $v['id'])->sum('nums');
|
||||||
$arr4=StoreBranchProduct::where('stock','>',0)->field('product_id,sum(stock) as stock')->group('product_id')->order('stock desc')->select();
|
$stock2 = bcadd($stock, $nums, 2);
|
||||||
foreach ($arr4 as $k=>$v){
|
bcmul($v['purchase'], $stock2, 2);
|
||||||
$find=StoreProduct::where('id',$v['product_id'])->find();
|
StoreProduct::where('id', $v['id'])->update(['stock' => $stock2, 'total_price' => $v]);
|
||||||
if($find){
|
|
||||||
$stock=bcadd($find['stock'],$v['stock'],2);
|
|
||||||
$find->total_price=bcmul($find['purchase'],$v['stock'],2);
|
|
||||||
$find->stock=$stock;
|
|
||||||
$find->save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user