修改优惠卷查询方式
This commit is contained in:
parent
467957527b
commit
8b7c49c8c7
@ -110,15 +110,16 @@ class UserCoupon extends Model
|
|||||||
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
||||||
$params[] = ['valid_end_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'])
|
||||||
$query->where("coupon_client",1)
|
->whereHas('Coupon', function ($query) use ($inquiry_type) {
|
||||||
->where("coupon_status",1)
|
$query->where("coupon_client",1)
|
||||||
->where("application_scope",2)
|
->where("coupon_status",1)
|
||||||
->where(function ($query) use ($inquiry_type) {
|
->where("application_scope",2)
|
||||||
$query->orwhere("inquiry_type","like",'%' . $inquiry_type+1 . '%');
|
->where(function ($query) use ($inquiry_type) {
|
||||||
$query->orwhere("inquiry_type","like",'%1%');
|
$query->orwhere("inquiry_type","like",'%' . $inquiry_type+1 . '%');
|
||||||
});
|
$query->orwhere("inquiry_type","like",'%1%');
|
||||||
}])
|
});
|
||||||
|
})
|
||||||
->where($params)
|
->where($params)
|
||||||
->get($fields);
|
->get($fields);
|
||||||
}
|
}
|
||||||
@ -138,17 +139,18 @@ class UserCoupon extends Model
|
|||||||
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
||||||
$params[] = ['valid_end_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'])
|
||||||
$query->where("coupon_client",1)
|
->whereHas('Coupon', function ($query) use ($coupon_product_datas) {
|
||||||
->where("coupon_status",1)
|
$query->where("coupon_client",1)
|
||||||
->where("application_scope",2)
|
->where("coupon_status",1)
|
||||||
->whereIn("application_scope",[1,3,4,5])
|
->where("application_scope",2)
|
||||||
->where(function ($query) use ($coupon_product_datas) {
|
->whereIn("application_scope",[1,3,4,5])
|
||||||
foreach ($coupon_product_datas as $coupon_product_data){
|
->where(function ($query) use ($coupon_product_datas) {
|
||||||
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
|
foreach ($coupon_product_datas as $coupon_product_data){
|
||||||
}
|
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
|
||||||
});
|
}
|
||||||
}])
|
});
|
||||||
|
})
|
||||||
->where($params)
|
->where($params)
|
||||||
->get($fields);
|
->get($fields);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user