request->isAjax && Yii::$app->request->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params, [ [['page', 'bonus_status', 'user_id'], 'integer'], [['created_at', 'nickname', 'bonus_time'], 'safe'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where = [ ['=', 'mall_id', $this->mall_id], ['=', 'status', StatusEnum::ENABLED], ]; if ($params['bonus_status'] !== '' && $params['bonus_status'] !== null) { $where[] = ['=', 'bonus_status', $params['bonus_status']]; } if ($params['nickname']) { $user_ids = User::find() ->orWhere(['like', 'nickname', "%" . $params['nickname'] . "%", false]) ->orWhere(['like', 'mobile', "%" . $params['nickname'] . "%", false]) ->select('id') ->asArray() ->column(); $where[] = ['in', 'user_id', $user_ids]; } if ($params['user_id']) { $where[] = ['=', 'user_id', (int)$params['user_id']]; } // 创建时间 $start_time = strtotime($params['created_at'][0] ?? 0); $end_time = strtotime($params['created_at'][1] ?? 0); if ($start_time > 0 && $end_time > 0 && $end_time >= $start_time) { $where[] = ['>=', 'created_at', $start_time]; $where[] = ['<=', 'created_at', $end_time]; } // 结算时间 $bonus_start = strtotime($params['bonus_time'][0] ?? 0); $bonus_end = strtotime($params['bonus_time'][1] ?? 0); if ($start_time > 0 && $end_time > 0 && $end_time >= $start_time) { $where[] = ['>=', 'created_at', $bonus_start]; $where[] = ['<=', 'created_at', $bonus_end]; } $condition = ['where' => $where, 'with' => 'user', 'order' => 'id desc']; if (Yii::$app->request->post('flag') == 'EXPORT') { $filename = '招商分红明细-' . date('YmdHis').'_'.rand(10000,99999); $post = Yii::$app->request->post(); $post['condition'] = $condition; $post['mall_id'] = $this->mall_id; $res = CsvExportHelper::exportDownLoadCenter($this->mall_id, $filename, DownloadEnum::TYPE_HAND_BOUNS, BusinessBonusReward::class,'exportHandle', $post); if ($res === false) return $this->error('加入导出任务失败'.CsvExportHelper::getStaticError()); return $this->success('添加导出任务成功,任务完成后请在下载中心进行下载!'); } $page_data = BusinessBonusReward::listPage($condition, false, true); $page_data['list'] = is_array($page_data['list']) ? $page_data['list'] : []; $page_data['list'] = BusinessBonusReward::dealRewardList($page_data['list'], $this->mall_id, false); $page_data['export_list'] = BusinessBonusReward::fieldsList(); $this->success('获取成功', compact('page_data')); } else { return $this->render('index'); } } }