xieruidong 2 年之前
父节点
当前提交
f2d803647d

+ 11 - 0
application/api/controller/mall/Index.php

@@ -5,6 +5,7 @@ namespace app\api\controller\mall;
 use app\common\controller\Api;
 use app\common\model\Category;
 use app\common\model\GoodsInstallLink;
+use app\common\model\LogisticsCompany;
 use app\common\validate\KillService;
 use think\db\Query;
 use app\common\model\Goods;
@@ -63,4 +64,14 @@ class Index extends Api
         $info['goods']= Goods::filterHot()->order('hot_at','desc')->limit(3)->select();
         $this->success('',$info);
     }
+
+    /**
+     * 快递公司
+     * @ApiReturnParams (name=id,description=id)
+     * @ApiReturnParams (name=name,description=公司名称)
+     */
+    public function logistics_company(){
+        $list=LogisticsCompany::all();
+        $this->success('',$list);
+    }
 }

+ 26 - 0
application/api/controller/mall/OrderRefund.php

@@ -3,6 +3,8 @@
 namespace app\api\controller\mall;
 
 use app\common\controller\Api;
+use think\Db;
+
 /**
  * 订单退款
  * @inheritdoc
@@ -25,4 +27,28 @@ class OrderRefund extends Api
             ->findOrFail($data['order_info_id']);
         $this->success('',$orderInfo);
     }
+    /**
+     * 寄回物品
+     * @ApiParams (name=refund_id,description="售后ID")
+     * @ApiParams (name=user_trans_com_id,description="快递公司ID")
+     * @ApiParams (name=user_trans_no,description="快递单号")
+     */
+    public function back_goods(){
+        $user=$this->auth->getUser();
+        $data=$this->_validate([
+            'refund_id'=>['require'],
+            'user_trans_com_id'=>['require'],
+            'user_trans_no'=>['require'],
+        ]);
+        Db::startTrans();
+        $refund=$user->refund()->lock(true)->findOrFail($data['refund_id']);
+        if(!$refund->is_goods_back){
+            $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->save();
+        $this->success('',$refund);
+    }
 }

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

@@ -19,8 +19,11 @@ use Yansongda\Supports\Arr;
  * @property int audit_time
  * @property int over_time
  * @property int rm_time
+ * @property int user_trans_com_id
+ * @property string user_trans_no
  * @property bool is_wait_audit
  * @property bool has_money
+ * @property bool is_goods_back
  * @property string audit_remark
  * @property float amount_last
  * @method static static|Query FilterRefund($status=null)
@@ -31,6 +34,7 @@ class Refund Extends Model
     protected $name='order_info_refund';
     protected $append=[
         'timeline',
+        'is_goods_back',
     ];
     const REFUND_ING=100;
     const REFUND_PASS=200;
@@ -61,11 +65,11 @@ class Refund Extends Model
     const REFUND_TYPE_ALL=2;
     const REFUND_TYPE_HHBX=5;
     public static $refundTypes=[
-        self::REFUND_TYPE_MONEY=>'仅退款',
+        self::REFUND_TYPE_MONEY=>'取消订单',
         self::REFUND_TYPE_ALL=>'退款退货',
         self::REFUND_TYPE_HHBX=>'换货/维修',
     ];
-    public static $refundTypeGoods=[self::REFUND_TYPE_ALL,];
+    public static $refundTypeGoods=[self::REFUND_TYPE_ALL,self::REFUND_TYPE_HHBX];
     public static $refundTypeMoney=[self::REFUND_TYPE_MONEY,self::REFUND_TYPE_ALL];
     const REASON_QU=1;
     public static $reasons=[
@@ -378,6 +382,9 @@ class Refund Extends Model
     public function gethasMoneyAttr($_,$model){
         return $this->isRefundMoney();
     }
+    public function getIsGoodsBackAttr($_,$model){
+        return $this->refund_status==self::REFUND_PASS && in_array($this->refund_type,self::getRefundTypeGoods());
+    }
     public function getTimelineAttr(){
         $arr=[
             [

文件差异内容过多而无法显示
+ 318 - 160
public/api.html


部分文件因为文件数量过多而无法显示