Commit 71ed8726 authored by hangjun83's avatar hangjun83

后端:增加: 是否取消采购订单

parent 0824f955
...@@ -79,6 +79,7 @@ class BhOrdersController extends Controller ...@@ -79,6 +79,7 @@ class BhOrdersController extends Controller
'refundNums.required' => "退货数量必填", 'refundNums.required' => "退货数量必填",
'handleFee.required' => "手续费费用必填", 'handleFee.required' => "手续费费用必填",
'transferPre.required' => "是否转预存必选", 'transferPre.required' => "是否转预存必选",
'cancelPorder.required' => "是否取消采购订单必选",
]; ];
$this->validateRequest($request, $message); $this->validateRequest($request, $message);
......
...@@ -125,6 +125,18 @@ class BhOrdersService ...@@ -125,6 +125,18 @@ class BhOrdersService
throw new \LogicException('该订单编号不存在!',500); throw new \LogicException('该订单编号不存在!',500);
} }
if($params['transfer_pre'] == true){
$params['transfer_pre'] = 1;
}else{
$params['transfer_pre'] = 0;
}
if($params['cancel_porder'] == true){
$params['cancel_porder'] = 1;
}else{
$params['cancel_porder'] = 0;
}
return app(BhSorderRefundRepository::class)->addRefundTask($params); return app(BhSorderRefundRepository::class)->addRefundTask($params);
} }
...@@ -163,6 +175,9 @@ class BhOrdersService ...@@ -163,6 +175,9 @@ class BhOrdersService
case 'transfer_pre' : case 'transfer_pre' :
$content = $content == '1' ? '是' : '否'; $content = $content == '1' ? '是' : '否';
$contentArr[] = '【是否转预存】:'.$content; break; $contentArr[] = '【是否转预存】:'.$content; break;
case 'cancel_porder' :
$content = $content == '1' ? '是' : '否';
$contentArr[] = '【是否取消采购订单】:'.$content; break;
} }
} }
...@@ -404,8 +419,9 @@ class BhOrdersService ...@@ -404,8 +419,9 @@ class BhOrdersService
if($item->pi_num < $refundInfo->refund_nums){ if($item->pi_num < $refundInfo->refund_nums){
throw new \LogicException('采购订单数量不足,无法退货!',500); throw new \LogicException('采购订单数量不足,无法退货!',500);
} }
// 如果退货数量小于采购订单数量 // 如果退货数量小于采购订单数量
if($item->pi_num > $refundInfo->refund_nums){ if($item->pi_num >= $refundInfo->refund_nums){
// 修改当前的数量和金额 // 修改当前的数量和金额
$poItemUpdateArr = []; $poItemUpdateArr = [];
$poNums = bcsub($item->pi_num, $refundInfo->refund_nums); $poNums = bcsub($item->pi_num, $refundInfo->refund_nums);
...@@ -436,8 +452,10 @@ class BhOrdersService ...@@ -436,8 +452,10 @@ class BhOrdersService
$newItem->update([ $newItem->update([
'pi_id' => $poItemsId 'pi_id' => $poItemsId
]); ]);
// 取消采购订单 if($refundInfo->cancel_porder == 1){
$this->cancelPorderItems($dbConnect,$poItemCreateArr['po_id'],$poItemsId); // 取消采购订单
$this->cancelPorderItems($dbConnect,$poItemCreateArr['po_id'],$poItemsId);
}
} }
} }
} }
...@@ -634,7 +652,7 @@ class BhOrdersService ...@@ -634,7 +652,7 @@ class BhOrdersService
if(!$pOrderItems){ if(!$pOrderItems){
throw new \LogicException('查询采购订单明细 ['.$sOrderItem['pi_id'].'] 数据不存在!',500); throw new \LogicException('查询采购订单明细 ['.$sOrderItem['pi_id'].'] 数据不存在!',500);
} }
if($pOrderItems->pi_status != 3){ if($pOrderItems->pi_status != 3 && $refundInfo->cancel_porder == 1){
throw new \LogicException('请先取消采购订单:'.$pOrderItems->po_no.'中的对应采购订单明细!'); throw new \LogicException('请先取消采购订单:'.$pOrderItems->po_no.'中的对应采购订单明细!');
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment