xieruidong 2 years ago
parent
commit
e5618cb224

+ 6 - 0
application/api/controller/mall/Orders.php

@@ -260,6 +260,12 @@ class Orders extends Api
         if(empty($config)){
             $this->error('该订单无法满足售后条件');
         }
+        if($config['refund_type']==Refund::REFUND_TYPE_ALL){
+            $refundCount=$orderInfo->refund()->where('refund_type',Refund::REFUND_TYPE_ALL)->count();
+            if($refundCount>=3){
+                $this->error('申请超过3次无法再次申请');
+            }
+        }
         $this->_validate([
             'refund_type|售后方式'=>['require','in:'.implode(',',array_filter(array_keys($config['refund_type'])))],
             'num|数量'=>['require','integer','gt:0',"elt:{$orderInfo['num']}"],

+ 3 - 0
application/common/model/OrderInfo.php

@@ -26,6 +26,9 @@ class OrderInfo extends Model
     public function refund(){
         return $this->belongsTo(Refund::class,'refund_id');
     }
+    public function refunds(){
+        return $this->hasMany(Refund::class,'order_info_id');
+    }
     public static function saveInfo(Orders $orders,$goods){
         $orderInfo=new self();
         $orderInfoGoods=OrderInfoGoods::create([