Commit e14afb75 authored by hangjun83's avatar hangjun83

如果拆分后的总价存在小数并且相减小于1,提示。

parent 4a0d1355
...@@ -34,15 +34,22 @@ class BhSorderRefundJob extends Job ...@@ -34,15 +34,22 @@ class BhSorderRefundJob extends Job
app(BhSorderRefundRepository::class)->update(['status' => 'running'],$this->refundInfo['id']); app(BhSorderRefundRepository::class)->update(['status' => 'running'],$this->refundInfo['id']);
$note = null;
$refundInfo = json_decode($this->refundInfo['exec_content']); $refundInfo = json_decode($this->refundInfo['exec_content']);
$service = app(BhOrdersService::class); $service = app(BhOrdersService::class);
$service->sOrderRefund($refundInfo); $service->sOrderRefund($refundInfo,$note);
//对任务进行更新 //对任务进行更新
$update = []; $update = [];
$update['status'] = 'finish'; $update['status'] = 'finish';
$update['exec_nums'] = $this->refundInfo['exec_nums'] + 1; $update['exec_nums'] = $this->refundInfo['exec_nums'] + 1;
$update['error_message'] = ''; $update['error_message'] = '';
if($note && count($note) > 0){
$update['error_message'] = json_encode($note,JSON_UNESCAPED_UNICODE);
}
}catch(\Exception $e){ }catch(\Exception $e){
//对任务进行更新 //对任务进行更新
$update = []; $update = [];
......
...@@ -222,13 +222,12 @@ class BhOrdersService ...@@ -222,13 +222,12 @@ class BhOrdersService
* 处理退货逻辑 * 处理退货逻辑
* @param $refundInfo * @param $refundInfo
*/ */
public function sOrderRefund($refundInfo) public function sOrderRefund($refundInfo,&$note)
{ {
$sOrder = app(BhSordersRepository::class)->getSorderItemsFromOrderNo($refundInfo->order_no); $sOrder = app(BhSordersRepository::class)->getSorderItemsFromOrderNo($refundInfo->order_no);
if(!$sOrder){ if(!$sOrder){
throw new \LogicException('该订单号不存在!',500); throw new \LogicException('该订单号不存在!',500);
} }
try{ try{
$dbConnect = DB::connection('bh_mysql'); $dbConnect = DB::connection('bh_mysql');
...@@ -264,6 +263,9 @@ class BhOrdersService ...@@ -264,6 +263,9 @@ class BhOrdersService
$service = app(BhSoitemsRepository::class); $service = app(BhSoitemsRepository::class);
$soItem = $service->findWhere(['si_id' => $orderitem['si_id'],'si_if_cancel' => 0]); $soItem = $service->findWhere(['si_id' => $orderitem['si_id'],'si_if_cancel' => 0]);
$soItem = current($soItem->toArray()); $soItem = current($soItem->toArray());
if(empty($soItem) || count($soItem) == 0) {
throw new \LogicException('购买项数据id:'.$orderitem['si_id'].'数据不存在或已取消!',500);
}
//更新原本数据 //更新原本数据
$updateArr = []; $updateArr = [];
...@@ -287,6 +289,11 @@ class BhOrdersService ...@@ -287,6 +289,11 @@ class BhOrdersService
$service->update($updateArr,$soItem['si_id']); $service->update($updateArr,$soItem['si_id']);
//判断是否能除尽
if($updateArr['si_amount'] != $currentAmount && abs(bcsub($currentAmount - $updateArr['si_amount'])) < 1){
$note[] = $soItem['si_id'] . '金额有小数';
}
// 如果数量等于0,更新原有的数据,不重新生成新的 // 如果数量等于0,更新原有的数据,不重新生成新的
$updatedItem = []; $updatedItem = [];
if($num == 0){ if($num == 0){
......
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