Kaynağa Gözat

优惠券查询问题

whitefang 1 yıl önce
ebeveyn
işleme
3e47d9c529
1 değiştirilmiş dosya ile 4 ekleme ve 3 silme
  1. 4 3
      app/api/logic/UserCouponLogic.php

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

@@ -125,9 +125,10 @@ class UserCouponLogic extends BaseLogic
     public static function categoryCouponLists($params)
     public static function categoryCouponLists($params)
     {
     {
         try{
         try{
-            $data =  CouponRules::with(['couponCategory'=>function ($query) use ($params) {
-                $query->where('goods_category_id',$params['goods_category_id']);
-            }])->where('remaining_count','>',0)
+            $coupon_ids = CouponCategory::where('goods_category_id',$params['goods_category_id'])->column('coupon_id');
+
+            $data =  CouponRules::where('remaining_count','>',0)
+                ->whereIn('id',$coupon_ids)
                 ->where('voucher_status',1)
                 ->where('voucher_status',1)
                 ->append(['discount_ratio_text'])
                 ->append(['discount_ratio_text'])
                 ->order(['id' => 'desc'])
                 ->order(['id' => 'desc'])