fix(仓库): 修复商品退回时的库存和订单金额计算问题
- 在导出订单时,增加了对商品数量的判断,只导出数量大于 0 的商品 - 修复了商品退回时,仓库商品数量和总金额的计算逻辑 - 优化了数据库查询,减少了冗余的查询操作
This commit is contained in:
parent
aa2d91441b
commit
2537532c88
@ -621,7 +621,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
throw new BusinessException('订单未出库,不能导出出库单');
|
||||
}
|
||||
$order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name');
|
||||
$data= WarehouseProduct::where('oid',$order['outbound_id'])->select()->each(function ($item) {
|
||||
$data= WarehouseProduct::where('oid',$order['outbound_id'])->where('nums','>',0)->select()->each(function ($item) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,unit')->find();
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
$item['store_name'] = $find['store_name'];
|
||||
@ -630,8 +630,9 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$order['system_store_name'] = SystemStore::where('id', $order['store_id'])->value('name');
|
||||
$other_data = $order['other_data'];
|
||||
unset($order['other_data']);
|
||||
$code=WarehouseOrder::where('id', $order['outbound_id'])->value('code');
|
||||
$order['order_id']=$code??$order['order_id'];
|
||||
$find=WarehouseOrder::where('id', $order['outbound_id'])->find();
|
||||
$order['order_id']=$find['code'];
|
||||
$order['pay_price']=$find['total_price'];
|
||||
$file_path = $order_info->export($data, $order, $other_data);
|
||||
return $file_path;
|
||||
}
|
||||
|
@ -58,7 +58,17 @@ class WarehouseProductReturnLogic extends BaseLogic
|
||||
'total_price'=>bcmul($params['nums'],$find['price'],2),
|
||||
]);
|
||||
if($params['financial_pm']==1 &&$params['return_type']==1){
|
||||
$find->dec('nums',$params['nums'])->update();
|
||||
$nums=bcsub($find['nums'],$params['nums'],2);
|
||||
$total_price=0;
|
||||
if($nums>0){
|
||||
$total_price=bcmul($nums,$find['price'],2);
|
||||
|
||||
}
|
||||
$find->save(['nums'=>$nums,'total_price'=>$total_price]);
|
||||
if($nums>0){
|
||||
$total_price=WarehouseProduct::where('oid',$find['oid'])->sum('total_price');
|
||||
WarehouseOrder::where(['id'=>$find['oid']])->update(['total_price'=>$total_price]);
|
||||
}
|
||||
WarehouseProductStorege::where(['product_id'=>$find['product_id'],'warehouse_id'=>$find['warehouse_id']])->inc('nums',$params['nums'])->update();
|
||||
}elseif($params['financial_pm']==0 &&$params['return_type']==2){
|
||||
WarehouseProductStorege::where(['product_id'=>$find['product_id'],'warehouse_id'=>$find['warehouse_id']])->dec('nums',$params['nums'])->update();
|
||||
@ -70,6 +80,7 @@ class WarehouseProductReturnLogic extends BaseLogic
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user