whitefang 1 год назад
Родитель
Сommit
beb4a28bf4

+ 3 - 1
app/api/logic/UserCouponLogic.php

@@ -92,7 +92,7 @@ class UserCouponLogic extends BaseLogic
                     $query->where(' expire_time >'. (time()-86400*7));
                 })
                 ->field(['id','code','amount','amount_require','begin_use','voucher_status','discount_ratio','event_name','expire_time','max_deductible_price','server_category_name','mold_type'])
-                ->append(['voucher_status_text'])
+                ->append(['voucher_status_text','discount_ratio_text'])
                 ->order(['id' => 'desc'])
                 ->select()
                 ->toArray();
@@ -129,6 +129,7 @@ class UserCouponLogic extends BaseLogic
                 $query->where('goods_category_id',$params['goods_category_id']);
             }])->where('remaining_count','>',0)
                 ->where('voucher_status',1)
+                ->append(['discount_ratio_text'])
                 ->order(['id' => 'desc'])
                 ->field(['code','amount','amount_require','discount_ratio','server_category_name',
                     'event_name','expire_time','max_deductible_price','mold_type',])
@@ -158,6 +159,7 @@ class UserCouponLogic extends BaseLogic
             }])->where('user_id',$params['user_id'])
                 ->where('voucher_count','>',0)
                 ->where('voucher_status',0)
+                ->append(['discount_ratio_text'])
                 ->where('amount_require','<=',$params['amount'])
                 ->visible(['id','amount','amount_require','begin_use','discount_ratio','event_name','expire_time','max_deductible_price','server_category_name','mold_type'])
                 ->select()->toArray();

+ 5 - 0
app/common/model/coupon/CouponRules.php

@@ -38,4 +38,9 @@ class CouponRules extends BaseModel
     {
         return $this->hasMany(CouponCategory::class, 'coupon_id', 'goods_category_id');
     }
+
+    public function getDiscountRatioTextAttr($value,$data)
+    {
+        return !empty($data['discount_ratio'])?$data['discount_ratio']*10:'';
+    }
 }

+ 5 - 0
app/common/model/coupon/UserCoupon.php

@@ -36,4 +36,9 @@ class UserCoupon extends BaseModel
         return $status[$data['voucher_status']] ?? '';
     }
 
+    public function getDiscountRatioTextAttr($value,$data)
+    {
+        return !empty($data['discount_ratio'])?$data['discount_ratio']*10:'';
+    }
+
 }