Commit f72988bc authored by hangjun83's avatar hangjun83

修复bug

parent 8b86c936
......@@ -157,18 +157,12 @@ class BhOrdersService
$params['page_size'] = 10;
}
$request->attributes->add(['type' => 'sorder_refund']);
$repostiroy = app(BhSorderRefundRepository::class);
$repostiroy->pushCriteria(new BhSorderRefundCriteria($request));
$tasks = $repostiroy->customPaginate($params['page_size']);
$service = app(BhSorderRefundRepository::class);
$service->pushCriteria(new BhSorderRefundCriteria($request));
$tasks = $service->paginate($params['page_size']);
$returnRecord = [];
if($tasks){
$allItems = $tasks->items();
$allItems = collect($allItems)->map(function($item){
$item = $item->toArray();
$allItems = collect($tasks['data'])->map(function($item){
$contentArr= [];
$execArr = json_decode($item['exec_content'],true);
foreach($execArr as $key => $content){
......@@ -191,17 +185,13 @@ class BhOrdersService
$item['content_string'] = implode(' . ',$contentArr);
$item = array_merge($item,$execArr);
return $item;
});
// 获取当前角色的所有权限
$returnRecord['data'] = $this->formatKeysfromArray($allItems);
$returnRecord['current_page'] = $tasks->currentPage();
$returnRecord['total'] = $tasks->total();
$tasks['data'] = $allItems->toArray();
$tasks = $this->formatKeysfromArray($tasks);
}
return $returnRecord;
return $tasks;
}
/**
......@@ -240,8 +230,8 @@ class BhOrdersService
// 先处理源数据
$currentPrice = floatval($orderitem['si_discount']);
$currentAmount = floatval($orderitem['si_amount']);
// 减去退货数量,剩余的更新数量
$num = intval($orderitem['si_num']) - intval($refundInfo->refund_nums);
// 退货剩余数量
$num = intval($refundInfo->refund_nums);
if($num < 0){
throw new \LogicException('退货数量大于购买数量',500);
......@@ -273,7 +263,7 @@ class BhOrdersService
$updatedItem = [];
//如果取消的是全部
if($num == 0){
if(($num - $orderitem['si_num']) == 0){
// 如果需要手续费
if(isset($refundInfo->handle_fee) && $refundInfo->handle_fee > 0){
......@@ -306,7 +296,7 @@ class BhOrdersService
if(isset($refundInfo->handle_fee) && $refundInfo->handle_fee > 0){
$updateArr['si_amount'] = bcadd($updateArr['si_amount'] , $refundInfo->handle_fee,2);
}
$updateArr['si_discount'] = bcdiv($updateArr['si_amount'] , $num, 2);
$updateArr['si_discount'] = bcdiv($updateArr['si_amount'] ,$updateArr['si_num'] , 2);
// 新增
$createArr = $soItem;
......@@ -346,8 +336,9 @@ class BhOrdersService
//判断是否能除尽
if(!empty($updateArr)){
if($updateArr['si_amount'] != $currentAmount && abs(bcsub($currentAmount , $updateArr['si_amount'])) < 1){
$note[] = $soItem['si_id'] . '金额有小数';
$amount = bcmul($updateArr['si_discount'], $updateArr['si_num'], 2);
if($updateArr['si_amount'] != $amount){
$note[] = 'si_id = '.$soItem['si_id'] . '的数据有除不尽的情况,请手工处理';
}
}
......@@ -416,25 +407,25 @@ class BhOrdersService
}
$cancelRecord = [];
// 如果退货数量跟此明细数量相同
// 如果退货数量跟此明细数量相同,不需要拆分的情况下
if(!is_null($needUpdate)){
$dpUpdateArr = [];
$dpUpdateArr['si_id'] = $updatedItem['update']['si_id'];
$dpUpdateArr['si_id'] = $updatedItem['create']['si_id'];
// 如果有手续费,对价格进行更新
if($refundInfo->handle_fee > 0){
// 如果有手续费,将价格进行修改
/*foreach($dpdetail as $detail){
foreach($dpdetail as $detail){
if($detail->dpd_id != $needUpdate['dpd_id']){
$otherUpdate = [];
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $needUpdate['dpd_num'], 2);
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $detail->dpd_num, 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$dpdetail->dpd_id)
->where('dpd_id',$detail->dpd_id)
->update($otherUpdate);
}
}*/
}
//将取消的记录价格进行更新
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $needUpdate['dpd_num'], 2);
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $needUpdate['dpd_num'], 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$needUpdate['dpd_id'])
->update($dpUpdateArr);
......@@ -465,7 +456,7 @@ class BhOrdersService
if(count($dpdetailInfo) > 0){
foreach($dpdetailInfo as $info){
$otherUpdate = [];
$otherUpdate['dpd_amount'] = bcmul($updateArr['si_discount'], $info->dpd_num, 2);
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $info->dpd_num, 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$info->dpd_id)
->update($otherUpdate);
......@@ -606,7 +597,13 @@ class BhOrdersService
$num = $num - $re['dpd_num'];
$dpUpdateArr = [];
//$dpUpdateArr['si_id'] = $updatedItem['update']['si_id'];
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $re['dpd_num'], 2);
/*if($num > $re['dpd_num']){
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $re['dpd_num'], 2);
}else{
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $re['dpd_num'], 2);
}*/
$dpUpdateArr['si_id'] = $updatedItem['create']['si_id'];
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $re['dpd_num'], 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$re['dpd_id'])
->update($dpUpdateArr);
......@@ -619,7 +616,8 @@ class BhOrdersService
// 更新当前记录
$dpUpdateArr = [];
$dpUpdateArr['dpd_num'] = $re['dpd_num'] - $num;
$dpUpdateArr['dpd_amount'] = bcsub($updatedItem['total'], $updatedItem['create']['si_amount'], 2);
//$dpUpdateArr['dpd_amount'] = bcsub($updatedItem['total'], $updatedItem['update']['si_amount'], 2);
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $dpUpdateArr['dpd_num'], 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$re['dpd_id'])
->update($dpUpdateArr);
......
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