xieruidong 2 years ago
parent
commit
51d613b75a

+ 9 - 1
application/api/controller/mall/OrderRefund.php

@@ -17,6 +17,14 @@ class OrderRefund extends Api
      * @ApiParams (name=order_info_id,description="子订单ID")
      * @ApiReturnParams (name=orders,description="订单对象")
      * @ApiReturnParams (name=refund,description="当前申请的售后信息,没有为null")
+     * @ApiReturnParams (name=refund[refund_type_text],description="申请类型")
+     * @ApiReturnParams (name=refund[num],description="退货数量")
+     * @ApiReturnParams (name=refund[num_install],description="安装数量")
+     * @ApiReturnParams (name=refund[amount],description="退货金额")
+     * @ApiReturnParams (name=refund[amount_install],description="安装金额")
+     * @ApiReturnParams (name=refund[refund_by_text],description="退货方式")
+     * @ApiReturnParams (name=refund[reason_text],description="售后原因")
+     * @ApiReturnParams (name=refund[reason2],description="备注")
      * @ApiReturnParams (name=refunds,description="售后记录")
      */
     public function show(){
@@ -26,7 +34,7 @@ class OrderRefund extends Api
         $user=$this->auth->getUser();
         $orderInfo=$user
             ->orderInfo()
-            ->with(['refund','refunds','orders'])
+            ->with(['refund','refunds','orders','orders.info'])
             ->findOrFail($data['order_info_id']);
         $this->success('',$orderInfo);
     }

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

@@ -30,6 +30,8 @@ use Yansongda\Supports\Arr;
  * @property bool need_complete
  * @property string audit_remark
  * @property string order_no
+ * @property string refund_type_text
+ * @property string refund_by_text
  * @property float amount_last
  * @method static static|Query FilterRefund($status=null)
  * @method static static|Query FilterTs()
@@ -45,6 +47,9 @@ class Refund Extends Model
         'need_tk',
         'is_pass',
         'need_complete',
+        'refund_type_text',
+        'refund_by_text',
+        'reason_text',
     ];
     const REFUND_ING=100;
     const REFUND_PASS=200;
@@ -415,6 +420,21 @@ class Refund Extends Model
     public function getRefundStatusTextAttr($_,$model){
         return Arr::get(self::getRefundStatus(),$model['refund_status']);
     }
+    public function getRefundTypeTextAttr($_,$model){
+        return Arr::get(self::getRefundTypes(),$model['refund_type']);
+    }
+    public function getRefundByTextAttr($_,$model){
+        if(!$model['refund_by']){
+            return null;
+        }
+        return Arr::get(self::getRefundBys(),$model['refund_by'])['value'];
+    }
+    public function getReasonTextAttr($_,$model){
+        if(!$model['reason1']){
+            return null;
+        }
+        return Arr::get(self::getReasons(),$model['reason1'])['value'];
+    }
     #是否可以已收货
     public function getNeedRecAttr($_,$model){
         return $this->is_goods_back && $this->user_send_time;
@@ -479,6 +499,9 @@ class Refund Extends Model
     {
         self::beforeInsert(function (self $refund){
             $refund['refund_status']=self::REFUND_ING;
+            if($refund->refund_type==self::REFUND_TYPE_HHBX){
+                $refund['fix_order_no']=order_no('wx');
+            }
         });
         self::afterUpdate(function (self $refund){
             if($refund->refund_status==self::REFUND_PASS && $refund->isRefundMoney()){