|
|
@@ -1143,7 +1143,7 @@ class OrderService extends BaseService
|
|
|
|
|
|
// 处理
|
|
|
DB::beginTransaction();
|
|
|
- if(!$this->model->where(['id'=> $id,'mark'=>1])->update(['status'=> 5,'refund_status'=>1,'refund_type'=> $refundType,'refund_remark'=> $refundRemark,'update_time'=>time()])){
|
|
|
+ if(!$this->model->where(['id'=> $id,'mark'=>1])->update(['status'=> 5,'refund_status'=>1,'temp_status'=> $status,'refund_type'=> $refundType,'refund_remark'=> $refundRemark,'update_time'=>time()])){
|
|
|
$this->error = 2917;
|
|
|
DB::rollBack();
|
|
|
return false;
|
|
|
@@ -1169,49 +1169,69 @@ class OrderService extends BaseService
|
|
|
public function refundCancel($userId, $params)
|
|
|
{
|
|
|
$id = isset($params['id']) ? $params['id'] : 0;
|
|
|
- $merchId = isset($params['merch_id']) ? $params['merch_id'] : 0; // 商家
|
|
|
- $mechId = isset($params['mech_id']) ? $params['mech_id'] : 0; //技师
|
|
|
$info = $this->model->where(['id' => $id, 'mark' => 1])
|
|
|
- ->select(['id','user_id','merch_id','pay_money','coupon_id','status','refund_status','refund_temp_status','pay_time'])
|
|
|
+ ->select(['id','user_id','merch_id','order_no','pay_money','coupon_id','status','refund_status','refund_temp_status','pay_time'])
|
|
|
->first();
|
|
|
$status = isset($info['status']) ? $info['status'] : 0;
|
|
|
+ $orderNo = isset($info['order_no']) ? $info['order_no'] : '';
|
|
|
$orderUserId = isset($info['user_id']) ? $info['user_id'] : 0;
|
|
|
- $orderMerchId = isset($info['merch_id']) ? $info['merch_id'] : 0;
|
|
|
- $orderMechId = isset($info['source_id']) ? $info['source_id'] : 0;
|
|
|
$refundStatus = isset($info['refund_status']) ? $info['refund_status'] : 0;
|
|
|
$tempStatus = isset($info['refund_temp_status']) ? $info['refund_temp_status'] : 0;
|
|
|
if (!$id || empty($info)) {
|
|
|
- $this->error = 2656;
|
|
|
+ $this->error = 2912;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- var_dump($info);
|
|
|
- return false;
|
|
|
// 非法操作
|
|
|
- if($merchId != $orderMerchId && $userId != $orderUserId && $mechId != $orderMechId){
|
|
|
- $this->error = 2667;
|
|
|
+ if($userId != $orderUserId){
|
|
|
+ $this->error = 2913;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if($status != 5){
|
|
|
- $this->error = 2668;
|
|
|
+ $this->error = 2914;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if($refundStatus<=0){
|
|
|
- $this->error = 2669;
|
|
|
+ if($refundStatus != 1){
|
|
|
+ $this->error = 2927;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 售后商品
|
|
|
+ $platAfterNo = OrderGoodsModel::where(['order_no'=> $orderNo])->whereIn('refund_status',[1,2])->value('plat_after_no');
|
|
|
+ if(empty($platAfterNo)){
|
|
|
+ $this->error = 2928;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 取消售后
|
|
|
+ $result = SupplyService::make()->getApiData('applyAfterCancel',['after_order_no'=> $platAfterNo,'explain'=>'用户取消']);
|
|
|
+ if(!$result){
|
|
|
+ $this->error = SupplyService::make()->getError();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 处理
|
|
|
- $updateData = ['status'=> $info['reception_at']? 3:2,'refund_status'=>0,'refund_remark'=> '','update_time'=>time()];
|
|
|
+ DB::beginTransaction();
|
|
|
+ $updateData = ['status'=> $tempStatus,'refund_status'=>0,'refund_remark'=> '','update_time'=>time()];
|
|
|
if(!$this->model->where(['id'=> $id,'mark'=>1])->update($updateData)){
|
|
|
- $this->error = 2670;
|
|
|
+ DB::rollBack();
|
|
|
+ $this->error = 2929;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $this->error = 2671;
|
|
|
- return true;
|
|
|
+ if(!OrderGoodsModel::where(['order_no'=> $orderNo,'plat_after_no'=>$platAfterNo])->update(['refund_status'=>0,'update_time'=>time()])){
|
|
|
+ $this->error = 2929;
|
|
|
+ DB::rollBack();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ DB::commit();
|
|
|
+ $statusArr = [1=>'待付款',2=>'待发货',3=>'待收货',4=>'已完成',5=>'已售后'];
|
|
|
+ $this->error = 2930;
|
|
|
+ return ['status'=> $tempStatus,'refund_text'=>'','status_text'=>isset($statusArr[$tempStatus])? $statusArr[$tempStatus]:''];
|
|
|
}
|
|
|
|
|
|
/**
|