Commit be330efd authored by hangjun83's avatar hangjun83

修复bug

parent 5ea9a62a
...@@ -16,8 +16,11 @@ use App\Repositories\Contracts\BhPordersRepository; ...@@ -16,8 +16,11 @@ use App\Repositories\Contracts\BhPordersRepository;
use App\Repositories\Contracts\BhSoitemsRepository; use App\Repositories\Contracts\BhSoitemsRepository;
use App\Repositories\Contracts\BhSorderRefundRepository; use App\Repositories\Contracts\BhSorderRefundRepository;
use App\Repositories\Contracts\BhSordersRepository; use App\Repositories\Contracts\BhSordersRepository;
use App\Repositories\Contracts\SysLogRepository;
use App\Repositories\Contracts\ToolsTaskRepository;
use App\Repositories\Criteria\BhPordersCriteria; use App\Repositories\Criteria\BhPordersCriteria;
use App\Repositories\Criteria\BhSorderRefundCriteria; use App\Repositories\Criteria\BhSorderRefundCriteria;
use App\Repositories\Criteria\BhSorderRefundTaskLogCriteria;
use App\Repositories\Enums\ResponseCodeEnum; use App\Repositories\Enums\ResponseCodeEnum;
use App\Repositories\Models\AdminUsers; use App\Repositories\Models\AdminUsers;
use App\Repositories\Models\BhPorders; use App\Repositories\Models\BhPorders;
...@@ -237,7 +240,14 @@ class BhOrdersService ...@@ -237,7 +240,14 @@ class BhOrdersService
throw new \LogicException('退货数量大于购买数量',500); throw new \LogicException('退货数量大于购买数量',500);
} }
if($orderitem['si_num'] == $refundInfo->refund_nums){ // 统计有多少数量
$sum = $dbConnect->table('soitems')
->where('so_id',$orderitem['so_id'])
->where('si_id',$orderitem['si_id'])
->sum('si_num');
// 如果是全部退货并且没有手续费的情况
if($sum == $refundInfo->refund_nums && $refundInfo->handle_fee == 0){
throw new \LogicException('本功能不支持全部退货,如果需要全部退货请移步百化系统后台进行操作!',500); throw new \LogicException('本功能不支持全部退货,如果需要全部退货请移步百化系统后台进行操作!',500);
} }
...@@ -322,6 +332,7 @@ class BhOrdersService ...@@ -322,6 +332,7 @@ class BhOrdersService
throw new \LogicException('手续费异常,处理失败!',500); throw new \LogicException('手续费异常,处理失败!',500);
} }
} }
/*If(isset($refundInfo->handle_fee) && $refundInfo->handle_fee > 0){ /*If(isset($refundInfo->handle_fee) && $refundInfo->handle_fee > 0){
$updateArr['si_amount'] = bcadd($updateArr['si_amount'] , $refundInfo->handle_fee,2); $updateArr['si_amount'] = bcadd($updateArr['si_amount'] , $refundInfo->handle_fee,2);
} }
...@@ -379,7 +390,7 @@ class BhOrdersService ...@@ -379,7 +390,7 @@ class BhOrdersService
$updatedItem['total'] = $currentAmount; $updatedItem['total'] = $currentAmount;
//修改配货单记录 //修改配货单记录
if($dpdetail){ if($dpdetail){
$maxRecord = $minRecord = []; $maxRecord = $minRecord = [];
$needUpdate = null; $needUpdate = null;
...@@ -417,31 +428,47 @@ class BhOrdersService ...@@ -417,31 +428,47 @@ class BhOrdersService
// 如果退货数量跟此明细数量相同,不需要拆分的情况下 // 如果退货数量跟此明细数量相同,不需要拆分的情况下
if(!is_null($needUpdate)){ if(!is_null($needUpdate)){
$dpUpdateArr = []; $dpUpdateArr = [];
$dpUpdateArr['si_id'] = $updatedItem['create']['si_id'];
// 如果有手续费,对价格进行更新 // 如果有手续费,对价格进行更新
if($refundInfo->handle_fee > 0){ if($refundInfo->handle_fee > 0){
// 如果有手续费,将价格进行修改 // 如果是全部退货
foreach($dpdetail as $detail){ if($refundInfo->refund_nums == $needUpdate['dpd_num'] && count($dpdetail) == 1){
if($detail->dpd_id != $needUpdate['dpd_id']){ // 如果有手续费,将价格进行修改
$otherUpdate = []; foreach($dpdetail as $detail){
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $detail->dpd_num, 2); $otherUpdate = [];
$dbConnect->table('dpdetail') $otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $detail->dpd_num, 2);
->where('dpd_id',$detail->dpd_id) $dbConnect->table('dpdetail')
->update($otherUpdate); ->where('dpd_id',$detail->dpd_id)
} ->update($otherUpdate);
}
}else{
// 如果有手续费,将价格进行修改
foreach($dpdetail as $detail){
if($detail->dpd_id != $needUpdate['dpd_id']){
$otherUpdate = [];
$otherUpdate['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $detail->dpd_num, 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$detail->dpd_id)
->update($otherUpdate);
}
}
$dpUpdateArr['si_id'] = $updatedItem['create']['si_id'];
//将取消的记录价格进行更新
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $needUpdate['dpd_num'], 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$needUpdate['dpd_id'])
->update($dpUpdateArr);
} }
//将取消的记录价格进行更新
$dpUpdateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $needUpdate['dpd_num'], 2);
$dbConnect->table('dpdetail')
->where('dpd_id',$needUpdate['dpd_id'])
->update($dpUpdateArr);
} // 如果没有手续费,不对价格进行更新 } // 如果没有手续费,不对价格进行更新
else{ /*else{
echo "<pre>";
print_r($needUpdate);
exit;
$dbConnect->table('dpdetail') $dbConnect->table('dpdetail')
->where('dpd_id',$needUpdate['dpd_id']) ->where('dpd_id',$needUpdate['dpd_id'])
->update($dpUpdateArr); ->update($dpUpdateArr);
} }*/
}else{ }else{
asort($maxRecord); asort($maxRecord);
...@@ -452,8 +479,24 @@ class BhOrdersService ...@@ -452,8 +479,24 @@ class BhOrdersService
// minrecord有值,只有退货数量大于此条记录的数量时 // minrecord有值,只有退货数量大于此条记录的数量时
$cancelRecord = array_merge($cancelRecord,$this->handleDpdetailInfo($dbConnect,$num,$minRecord,$updatedItem,$refundInfo,'asort')); $cancelRecord = array_merge($cancelRecord,$this->handleDpdetailInfo($dbConnect,$num,$minRecord,$updatedItem,$refundInfo,'asort'));
$cancelRecord = array_merge($cancelRecord,$this->handleDpdetailInfo($dbConnect,$num,$maxRecord,$updatedItem,$refundInfo,'arsort')); $cancelRecord = array_merge($cancelRecord,$this->handleDpdetailInfo($dbConnect,$num,$maxRecord,$updatedItem,$refundInfo,'arsort'));
}
// 判断是否这次是全部取消
$dpCount = $dbConnect->table('dpdetail')
->where('si_id',$orderitem['si_id'])
->whereIn('dpd_id',$cancelRecord)->sum('dpd_num');
if($dpCount == 0 && $sum == $refundInfo->refund_nums){
$infos = $dbConnect->table('dpdetail')
->whereIn('dpd_id',$cancelRecord)->get();
foreach($infos->toArray() as $info){
$update = [];
$update['dpd_amount'] = bcmul($updatedItem['update']['si_discount'], $info->dpd_num, 2);
$update['si_id'] = $orderitem['si_id'];
$dbConnect->table('dpdetail')
->where('dpd_id',$info->dpd_id)
->update($update);
}
}
}
// 更新除了取消的记录以外的记录的价格 // 更新除了取消的记录以外的记录的价格
if(count($cancelRecord) > 0){ if(count($cancelRecord) > 0){
$dpdetailInfo = $dbConnect->table('dpdetail') $dpdetailInfo = $dbConnect->table('dpdetail')
...@@ -639,7 +682,6 @@ class BhOrdersService ...@@ -639,7 +682,6 @@ class BhOrdersService
$dpCreateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $num, 2); $dpCreateArr['dpd_amount'] = bcmul($updatedItem['create']['si_discount'], $num, 2);
$dpCreateArr['si_id'] = $updatedItem['create']['si_id']; $dpCreateArr['si_id'] = $updatedItem['create']['si_id'];
$dpId = $dbConnect->table('dpdetail')->insertGetId($dpCreateArr); $dpId = $dbConnect->table('dpdetail')->insertGetId($dpCreateArr);
$num = 0; $num = 0;
$cancelRecord[] = $dpId; $cancelRecord[] = $dpId;
} }
...@@ -975,19 +1017,14 @@ class BhOrdersService ...@@ -975,19 +1017,14 @@ class BhOrdersService
{ {
$params = $this->formatKeysfromArray($request->all(),'toUnderScore'); $params = $this->formatKeysfromArray($request->all(),'toUnderScore');
if(!isset($params['type']) || empty($params['type'])){
$this->bhPordersRepository->pushCriteria(new BhPordersCriteria($request)); $params['type'] = 'sorder_refund';
$pOrdersList = $this->bhPordersRepository->paginate($params['page_size']);
$returnRecord = [];
if($pOrdersList){
$record = $this->procOrderResponseData($pOrdersList->items());
} }
// 获取当前角色的所有权限
$returnRecord['data'] = $this->formatKeysfromArray($record);
$returnRecord['current_page'] = $pOrdersList->currentPage();
$returnRecord['total'] = $pOrdersList->total();
return $returnRecord; } $taskService = app(ToolsTaskRepository::class);
$taskLogsList = $taskService->getTaskLogsFromType($params['type'],$params['task_id']);
return $taskLogsList;
}
} }
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