refactor(purchase): 优化采购产品报价和仓库产品逻辑
- 新增 setStoreroomInfoTwo 方法,用于更新采购产品报价的买家数量 - 修改仓库产品更新逻辑,根据财务配置选择性更新价格字段 - 在预订单逻辑中添加 is_buyer 字段,用于区分买家类型
This commit is contained in:
parent
84fde23c25
commit
9fd586722a
@ -96,6 +96,12 @@ class PurchaseProductOfferController extends BaseAdminController
|
||||
PurchaseProductOfferLogic::setStoreroomInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
public function setStoreroomInfoTwo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
PurchaseProductOfferLogic::setStoreroomInfoTwo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 删除采购商品
|
||||
* @return \think\response\Json
|
||||
|
@ -58,6 +58,11 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
if ($order_type == 4) {
|
||||
throw new BusinessException('不能添加线上订单,线上订单只能转换');
|
||||
}
|
||||
if($order_type==7 ||$order_type==5){
|
||||
$is_buyer=1;
|
||||
}else{
|
||||
$is_buyer=-1;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$datas = [];
|
||||
@ -83,6 +88,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$datas[$k]['net_weight'] = $v['net_weight'] ?? '';
|
||||
$datas[$k]['cart_num'] = $v['nums'];
|
||||
$datas[$k]['accept_num'] = $v['nums'];
|
||||
$datas[$k]['is_buyer'] = $is_buyer;
|
||||
$datas[$k]['price'] = $v['price'];
|
||||
$datas[$k]['package'] = $v['package'] ?? '';
|
||||
$datas[$k]['total_price'] = $total_prices;
|
||||
|
@ -255,6 +255,18 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function setStoreroomInfoTwo(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseProductOffer::where('id', $params['id'])->update(['buyer_nums' => $params['buyer_nums']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 是否需采购
|
||||
*/
|
||||
|
@ -218,16 +218,26 @@ class WarehouseProductLogic extends BaseLogic
|
||||
$before_nums = $warehouseProductStorege['nums'];
|
||||
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
||||
}
|
||||
WarehouseProduct::where('id', $params['id'])->update([
|
||||
'nums' => $params['nums'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'pay_type' => $params['pay_type'],
|
||||
'nums' => $params['nums'],
|
||||
'purchase' => $params['purchase'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['nums'] * $params['purchase'],
|
||||
]);
|
||||
if($find['financial_pm']==1){
|
||||
$datas=[
|
||||
'nums' => $params['nums'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'pay_type' => $params['pay_type'],
|
||||
'purchase' => $params['purchase'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['total_price'],
|
||||
];
|
||||
}else{
|
||||
$datas=[
|
||||
'nums' => $params['nums'],
|
||||
'price' => $params['price'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['total_price'],
|
||||
];
|
||||
}
|
||||
WarehouseProduct::where('id', $params['id'])->update($datas);
|
||||
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||
if ($finds) {
|
||||
WarehouseOrder::where('id', $params['oid'])->update([
|
||||
|
Loading…
x
Reference in New Issue
Block a user