feat(admin): 设置仓库商品信息并优化订单处理逻辑
- 新增 PurchaseProductOfferController 中的 setStoreroomInfo 方法,用于设置仓库商品信息 - 修改 BeforehandOrderCartInfoLogic 中的处理逻辑,增加对总价格的判断和计算 - 在更新订单信息时,增加对出库单中商品价格和总价格的同步更新
This commit is contained in:
parent
f526e60841
commit
7a742331de
@ -83,6 +83,9 @@ class PurchaseProductOfferController extends BaseAdminController
|
|||||||
PurchaseProductOfferLogic::setBatchProcureInfo($params);
|
PurchaseProductOfferLogic::setBatchProcureInfo($params);
|
||||||
return $this->success('设置成功', [], 1, 1);
|
return $this->success('设置成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 设置仓库商品信息
|
||||||
|
*/
|
||||||
public function setStoreroomInfo()
|
public function setStoreroomInfo()
|
||||||
{
|
{
|
||||||
$params = $this->request->post();
|
$params = $this->request->post();
|
||||||
|
@ -8,6 +8,7 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\beforehand_order\BeforehandOrder;
|
use app\common\model\beforehand_order\BeforehandOrder;
|
||||||
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
use app\common\model\warehouse_order\WarehouseOrder;
|
use app\common\model\warehouse_order\WarehouseOrder;
|
||||||
|
use app\common\model\warehouse_product\WarehouseProduct;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
@ -100,9 +101,14 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
|
||||||
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
|
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
|
||||||
}
|
}
|
||||||
|
if($params['total_price']<=0){
|
||||||
|
$total_price=bcmul($params['purchases'],$params['nums'],2);
|
||||||
|
}else{
|
||||||
|
$total_price=$params['total_price'];
|
||||||
|
}
|
||||||
$find->save([
|
$find->save([
|
||||||
'price' => $params['purchases'],
|
'price' => $params['purchases'],
|
||||||
'total_price' => bcmul($params['purchases'],$params['nums'],2),
|
'total_price' => $total_price,
|
||||||
'cart_num' => $params['nums'],
|
'cart_num' => $params['nums'],
|
||||||
]);
|
]);
|
||||||
$bhoid = $params['bhoid'];
|
$bhoid = $params['bhoid'];
|
||||||
@ -110,7 +116,17 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
if($find['is_buyer']==1){
|
if($find['is_buyer']==1){
|
||||||
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
|
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
|
||||||
}
|
}
|
||||||
BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
|
$order=BeforehandOrder::where('id', $bhoid)->find();
|
||||||
|
$order->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
|
||||||
|
|
||||||
|
if($order['outbound_id']>0){
|
||||||
|
$wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find();
|
||||||
|
if($wp){
|
||||||
|
$wp->update(['price'=>$params['purchases'],'total_price'=>$total_price]);
|
||||||
|
$wp_total_price=WarehouseProduct::where('oid', $order['outbound_id'])->where('financial_pm',0)->sum('total_price');
|
||||||
|
WarehouseOrder::where('id', $order['outbound_id'])->update(['total_price' => $wp_total_price]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user