feat: 修改仓库逻辑以优化库存产品价格计算

This commit is contained in:
mkm 2024-09-01 16:10:55 +08:00
parent e3b6bb9831
commit d85c837a9b

View File

@ -234,7 +234,6 @@ class WarehouseLogic extends BaseLogic
}
public static function stockProductPrice($parmas){
$arr1=WarehouseProductStorege::where('nums','>',0)->select();
foreach ($arr1 as $k=>$v){
$find=StoreProduct::where('id',$v['product_id'])->find();
@ -262,7 +261,7 @@ class WarehouseLogic extends BaseLogic
foreach ($arr3 as $k=>$v){
StoreProduct::where('id',$v['product_id'])->update(['stock'=>$v['nums']]);
}
$arr4=StoreBranchProduct::where('stock','>',0)->field('product_id,sum(stock) as stock')->select();
$arr4=StoreBranchProduct::where('stock','>',0)->field('product_id,sum(stock) as stock')->group('product_id')->order('stock desc')->select();
foreach ($arr4 as $k=>$v){
$find=StoreProduct::where('id',$v['product_id'])->find();
if($find){