xieruidong 2 年之前
父节点
当前提交
0be471b4ee

+ 6 - 5
application/api/controller/mall/OrderRefund.php

@@ -3,6 +3,7 @@
 namespace app\api\controller\mall;
 
 use app\common\controller\Api;
+use app\common\model\LogisticsCompany;
 use app\common\model\Refund;
 use think\Db;
 use think\db\Query;
@@ -54,11 +55,11 @@ class OrderRefund extends Api
         if(!$refund->self_back_goods){
             $this->error('操作失败');
         }
-        $refund->user_trans_com_id=$data['user_trans_com_id'];
-        $refund->user_trans_no=$data['user_trans_no'];
-        $refund->user_send_time=time();
-        $refund->refund_status=$refund::REFUND_JI;
-        $refund->save();
+        $com=LogisticsCompany::find($data['user_trans_com_id']);
+        if(!$com){
+            $this->error('公司不存在');
+        }
+        $refund->makeUserBackGoods($com,$data['user_trans_no']);
         Db::commit();
         $this->success('',$refund);
     }

+ 1 - 0
application/common/model/LogisticsCompany.php

@@ -7,6 +7,7 @@ use think\Model;
 /**
  * 会员余额日志模型
  * @property string code_kd100
+ * @property int id
  */
 class LogisticsCompany Extends Model
 {

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

@@ -339,6 +339,14 @@ class Refund Extends Model
             }
         }*/
     }
+    #用户寄回
+    public function makeUserBackGoods(LogisticsCompany $company,$trans_no){
+        $this->refund_status=static::REFUND_JI;
+        $this->user_trans_com_id=$company->id;
+        $this->user_trans_no=$trans_no;
+        $this->user_send_time=time();
+        $this->save();
+    }
     public function makeComplete(){
         $refund=$this;
         $refund->over_time=time();