xieruidong 2 年之前
父节点
当前提交
8e8dc81ca5
共有 2 个文件被更改,包括 20 次插入1 次删除
  1. 11 1
      application/api/controller/mall/Orders.php
  2. 9 0
      application/common/model/Refund.php

+ 11 - 1
application/api/controller/mall/Orders.php

@@ -322,10 +322,19 @@ class Orders extends Api
             'num|数量'=>['require','integer','egt:0',"elt:{$orderInfo['num']}"],
             'num_install|安装数量'=>['require','integer','egt:0',"elt:{$orderInfo['num_install']}"],
         ]);
+        $address=null;
         if($config['type'][$data['refund_type']]) {
+            $type=$config['type'][$data['refund_type']];
             $this->_validate([
-                'refund_by|退货方式' => ['require', 'integer', 'in:' . implode(',', array_keys($config['type'][$data['refund_type']]))],
+                'refund_by|退货方式' => ['require', 'integer', 'in:' . implode(',', array_keys($type))],
             ]);
+            if($config['req_address'] && !empty($config['req_address'][$type])){
+                $this->_validate([
+                    'address_id|地址' => ['require', 'integer'],
+                ]);
+                $addressModel=$user->address()->find($data['address_id']);
+                $address=$addressModel->toArray();
+            }
         }else{
             $data['refund_by']=null;
         }
@@ -385,6 +394,7 @@ class Orders extends Api
             'fix_order_id'=>$fix_order_id,
             'refund_status'=>Refund::REFUND_ING,
             'audit_remark'=>null,
+            'address'=>$address,
         ]);
         if($isEdit){
             $refund->save($will);

+ 9 - 0
application/common/model/Refund.php

@@ -14,6 +14,7 @@ use Yansongda\Supports\Arr;
  * @property Orders orders
  * @property User user
  * @property LogisticsCompany com
+ * @property UserAddress address
  * @property int refund_status
  * @property int refund_type
  * @property int create_time
@@ -73,6 +74,9 @@ class Refund Extends Model
         self::REFUND_CANCEL=>'已取消',
         self::REFUND_OVER=>'处理完成',
     ];
+    protected $type=[
+        'address'=>'json',
+    ];
     /**
      * @return string[]
      */
@@ -161,6 +165,7 @@ class Refund Extends Model
                 $refundConfig['req_order'] = [
                     self::REFUND_TYPE_MONEY=>false,
                 ];
+                $refundConfig['req_address'] = null;
                 $refundConfig['reason'] = array_values(Refund::getReasons());
                 list($amount_single, $amount_install_single) = RefundService::setOrderInfo($orderInfo, $orderInfo['num'], $orderInfo['num_install'])->amount();
                 $refundConfig['amount_single'] = $amount_single;
@@ -236,6 +241,10 @@ class Refund Extends Model
                         self::REFUND_TYPE_ALL=>false,
                     ];
                 }
+                $refundConfig['req_address'] = [
+                    self::TH_TYPE_SELF_SEND=>false,
+                    self::TH_TYPE_SENDER=>true,
+                ];
 
                 $refundConfig['reason'] = array_values(Refund::getReasons());
                 list($amount_single, $amount_install_single) = RefundService::setOrderInfo($orderInfo, $orderInfo['num'], $orderInfo['num_install'])->amount();