request; if ($request->isAjax) { // 提交等级内容 if ($request->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params, [ [['page','user_id','user_name','mobile','date_start','date_end','from_type'], 'safe'], ]); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $user_ids = []; $user_name_ids = []; $is_search = false; if(!empty($params['user_id'])) $where[] = ['=','user_id',$params['user_id']]; if(!empty($params['mobile'])) { $user_ids[] = User::find()->select("id")->where(['mall_id' => $this->mall_id,'mobile' => $params['mobile']])->scalar(); $is_search = true; } if(!empty($params['user_name'])) { $user_where[] = ['like','nickname',$params['user_name'] . '%', false]; $select = 'id,nickname'; $user_list = User::lists(['where' =>$user_where,'select' => $select],true); $user_name_ids = array_column($user_list,'id'); $is_search = true; } if($is_search){ $all_user_ids = array_merge($user_ids,$user_name_ids); if(!$all_user_ids){ $all_user_ids = [-1]; } $where[] = ['in','user_id',$all_user_ids]; } if(!empty($params['from_type'])) $where[] = ['=','from_type',$params['from_type']]; if($params['date_start'] && $params['date_end']) $where[] = ['between', 'created_at', strtotime($params['date_start']),strtotime($params['date_end'])]; $where[] = ['=','mall_id',$this->mall_id]; $where[] = ['>=','status',StatusEnum::DISABLED]; $order = 'id desc'; $list = RedpackWalletLog::listPage(['where' => $where,'order' => $order,'with' => ['user']],false); $list['from_type'] = RedpackEnum::getFromType('', $this->mall_id); $list['redpack_type'] = RedpackEnum::getRedpackText('', $this->mall_id); $list['redpack_name'] = Yii::$app->services->setting->addons->get($this->mall_id, RedpackEnum::ADDONS_NAME, 'basic.redpack_name') ?? '红包'; return $this->success('操作成功',$list); } } } catch (\Exception $e) { return $this->error($e->getMessage(), []); } return $this->render($this->action->id); } }