|
|
@@ -40,21 +40,34 @@ class CouponRulesLists extends BaseAdminDataLists implements ListsSearchInterfac
|
|
|
public function setSearch(): array
|
|
|
{
|
|
|
return [
|
|
|
- '=' => ['amount', 'amount_require', 'max_deductible_price', 'mold_type', 'server_category_name', 'coupon_type','voucher_status', 'voucher_count'],
|
|
|
- '%like%' => ['event_name'],
|
|
|
+ '=' => ['amount', 'amount_require', 'max_deductible_price', 'mold_type', 'server_category_name', 'coupon_type','voucher_status'],
|
|
|
+ '%like%' => ['event_name','code'],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
public function queryWhere()
|
|
|
{
|
|
|
$where = [];
|
|
|
- if(isset($this->params['begin_use']) && !empty($this->params['begin_use'])){
|
|
|
- $time = [strtotime($this->params['begin_use'][0]), strtotime($this->params['begin_use'][1])];
|
|
|
- $where[] = ['begin_use', 'between', $time];
|
|
|
+ if(isset($this->params['min_expire_time']) && is_numeric($this->params['min_expire_time'])){
|
|
|
+ $where[] = ['expire_time', '>=', $this->params['min_expire_time']];
|
|
|
}
|
|
|
- if(isset($this->params['expire_time']) && !empty($this->params['expire_time'])){
|
|
|
- $time = [strtotime($this->params['expire_time'][0]), strtotime($this->params['expire_time'][1])];
|
|
|
- $where[] = ['expire_time', 'between', $time];
|
|
|
+ if(isset($this->params['max_expire_time']) && is_numeric($this->params['min_expire_time'])){
|
|
|
+ $where[] = ['expire_time', '<=', $this->params['min_expire_time']];
|
|
|
+ }
|
|
|
+ if(isset($this->params['min_expire_time']) && is_numeric($this->params['min_expire_time'])){
|
|
|
+ $where[] = ['expire_time', '>=', $this->params['min_expire_time']];
|
|
|
+ }
|
|
|
+ if(isset($this->params['min_voucher_count']) && is_numeric($this->params['min_voucher_count'])){
|
|
|
+ $where[] = ['voucher_count', '>=', $this->params['min_voucher_count']];
|
|
|
+ }
|
|
|
+ if(isset($this->params['max_voucher_count']) && is_numeric($this->params['max_voucher_count'])){
|
|
|
+ $where[] = ['voucher_count', '<=', $this->params['max_voucher_count']];
|
|
|
+ }
|
|
|
+ if(isset($this->params['min_remaining_count']) && is_numeric($this->params['min_remaining_count'])){
|
|
|
+ $where[] = ['remaining_count', '>=', $this->params['min_remaining_count']];
|
|
|
+ }
|
|
|
+ if(isset($this->params['max_remaining_count']) && is_numeric($this->params['max_remaining_count'])){
|
|
|
+ $where[] = ['remaining_count', '<=', $this->params['max_remaining_count']];
|
|
|
}
|
|
|
if(isset($this->params['goods_category_ids']) && !empty($this->params['goods_category_ids'])){
|
|
|
$categoryIds =[];
|
|
|
@@ -87,15 +100,13 @@ class CouponRulesLists extends BaseAdminDataLists implements ListsSearchInterfac
|
|
|
$query->field('id,name');
|
|
|
}])->where($this->searchWhere)
|
|
|
->where($this->queryWhere())
|
|
|
- ->field(['id', 'amount', 'coupon_type','amount_require', 'begin_use', 'discount_ratio', 'event_name', 'expire_time', 'max_deductible_price', 'mold_type', 'server_category_name', 'voucher_status', 'voucher_count'])
|
|
|
+ ->field(['id','code', 'amount', 'coupon_type','amount_require', 'discount_ratio', 'event_name', 'expire_time', 'max_deductible_price', 'mold_type', 'server_category_name', 'voucher_status', 'voucher_count','remaining_count'])
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
->order(['id' => 'desc'])
|
|
|
->select()
|
|
|
->toArray();
|
|
|
foreach($data as $k => $v){
|
|
|
$v['goods_category_ids'] = array_column($v['couponWithCategory'],'id');
|
|
|
- $v['begin_use'] = $v['begin_use'] ? date('Y-m-d H:i:s',$v['begin_use']) :null;
|
|
|
- $v['expire_time'] = $v['begin_use'] ?date('Y-m-d H:i:s',$v['expire_time']) :null;
|
|
|
$data[$k] = $v;
|
|
|
}
|
|
|
return $data;
|