修改优惠卷查询方式

This commit is contained in:
wucongxing 2023-11-08 20:43:36 +08:00
parent 467957527b
commit 8b7c49c8c7

View File

@ -110,7 +110,8 @@ class UserCoupon extends Model
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
$params[] = ['valid_end_time', '>', date('Y-m-d H:i:s', time())]; // 过期使用时间
return self::with(['Coupon'=> function($query) use($inquiry_type){
return self::with(['Coupon'])
->whereHas('Coupon', function ($query) use ($inquiry_type) {
$query->where("coupon_client",1)
->where("coupon_status",1)
->where("application_scope",2)
@ -118,7 +119,7 @@ class UserCoupon extends Model
$query->orwhere("inquiry_type","like",'%' . $inquiry_type+1 . '%');
$query->orwhere("inquiry_type","like",'%1%');
});
}])
})
->where($params)
->get($fields);
}
@ -138,7 +139,8 @@ class UserCoupon extends Model
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
$params[] = ['valid_end_time', '>', date('Y-m-d H:i:s', time())]; // 过期使用时间
return self::with(['Coupon'=> function($query) use($coupon_product_datas){
return self::with(['Coupon'])
->whereHas('Coupon', function ($query) use ($coupon_product_datas) {
$query->where("coupon_client",1)
->where("coupon_status",1)
->where("application_scope",2)
@ -148,7 +150,7 @@ class UserCoupon extends Model
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
}
});
}])
})
->where($params)
->get($fields);
}