|
|
@@ -144,12 +144,20 @@ class UserCouponLogic extends BaseLogic
|
|
|
{
|
|
|
try{
|
|
|
$category_coupon_ids = CouponCategory::where('goods_category_id',$params['goods_category_id'])->column('coupon_id');
|
|
|
- $goods_coupon_ids = !empty($params['goods_id'])?CouponGoods::where('goods_id',$params['goods_id'])->column('coupon_id'):[];
|
|
|
- $coupon_ids = array_merge($category_coupon_ids,$goods_coupon_ids);
|
|
|
+ $goods_coupon_ids = !empty($params['goods_id'])?CouponGoods::where('goods_id',$params['goods_id'])->column('coupon_id'):'';
|
|
|
$data = CouponRules::where('remaining_count','>',0)
|
|
|
->where('coupon_type',1)
|
|
|
- ->whereIn('id',$coupon_ids)
|
|
|
->where('voucher_status',1)
|
|
|
+ ->where(function($query) use ($category_coupon_ids, $goods_coupon_ids) {
|
|
|
+ $query->whereOr(function($query1) use ($goods_coupon_ids) {
|
|
|
+ $query1->whereIn('id', $goods_coupon_ids)
|
|
|
+ ->where('coupon_target', 'goods');
|
|
|
+ });
|
|
|
+ $query->whereOr(function($query2) use ($category_coupon_ids) {
|
|
|
+ $query2->whereIn('id', $category_coupon_ids)
|
|
|
+ ->where('coupon_target', 'category');
|
|
|
+ });
|
|
|
+ })
|
|
|
->append(['discount_ratio_text'])
|
|
|
->order(['id' => 'desc'])
|
|
|
->field(['code','amount','amount_require','discount_ratio','server_category_name',
|