request->isAjax && Yii::$app->request->isGet) { $get = Yii::$app->request->get(); // 检查提交的参数 $res = Yii::$app->services->validate->validate($get,[ [['user_id','level','mobile','settlement_type', 'from_user_id'], 'integer'], [['start_at','end_at','tab_type','order_no','capital_type'], 'string'], [['month'],'safe'] ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); // 获取等级 $level_arr = DoubleCopyLevel::getLevelMap($this->mall_id, 2); $capital_type_arr = DoubleCopyEnum::getCapitalMap($this->mall_id); $where = $list = []; $where[] = ['=', 'mall_id', $this->mall_id]; !empty($get['user_id']) && $where[] = ['=', 'user_id', $get['user_id']]; !empty($get['order_no']) && $where[] = ['=', 'order_no', $get['order_no']]; // tab切换 if (empty($get['capital_type'])) { if ($get['tab_type'] == 'commission') {// 佣金明细 $where[] = ['in', 'capital_type', DoubleCopyEnum::getCommissionMap()]; }elseif($get['tab_type'] == 'frozen-fund-clear'){ // 基金明细 $where[] = ['in', 'capital_type', DoubleCopyEnum::FREEZE_FUND]; $where[] = ['<', 'money', 0]; $where[] = ['=', 'buy_uid', 0]; } else if ($get['tab_type'] === 'frozen-fund-transfer-parent') { $where[] = ['=', 'operation_type', DoubleCopyEnum::OPERATION_TYPE_FREEZE_FUND_MONTHLY_LIMITED_FROM_CHILD]; !empty($get['from_user_id']) && $where[] = ['=', 'operation_id', $get['from_user_id']]; } else { // 冻结基金 $where[] = ['=', 'capital_type', DoubleCopyEnum::FREEZE_FUND]; } } else { !empty($get['capital_type']) && $where[] = ['=', 'capital_type', $get['capital_type']]; } isset($get['settlement_type']) && $where[] = ['=', 'settlement_type', $get['settlement_type']]; // 根据等级获取用户 if (!empty($get['level'])) { $user_ids = DoubleCopyUser::find()->select('user_id')->where(['level' => $get['level']])->column(); if (empty($user_ids)) return $this->success('获取成功', compact('list','level_arr', 'capital_type_arr')); } if (!empty($get['start_at']) && !empty($get['end_at'])) { $where[] = ['between', 'created_at', strtotime($get['start_at']), strtotime($get['end_at'])]; } if (!empty($get['month'])) { $where[] = ['>=', 'created_at', strtotime($get['month'])]; } $where[] = ['=', 'status', StatusEnum::ENABLED]; // 根据搜索手机号查询用户id if (!empty($get['mobile'])) { $user_id = User::find()->select("id")->where(['mall_id' => $this->mall_id,'mobile' => $get['mobile']])->asArray()->column(); if (empty($user_id)) $this->success('获取成功', compact('list','level_arr', 'capital_type_arr')); $where[] = ['in', 'user_id', $user_id]; } $with = ['user','lduser','buyuser']; $order = 'created_at desc'; $params = array('where' => $where, 'order'=>$order, 'with' => $with, 'limit' => $get['limit']); $list = DoubleCopyCommission::listPage($params, false, true); if ($get['tab_type'] === 'frozen-fund-transfer-parent') { $from_users = User::lists([ 'where' => [ [ 'id' => array_column($list['list'], 'operation_id'), 'status' => StatusEnum::ENABLED, 'mall_id' => $this->mall_id ] ], 'select' => 'id, nickname, mobile, avatar_url', 'index' => 'id' ]); } foreach($list['list'] as &$v){ $v['time_txt'] = date('Y年m月',$v['created_at']); if ($get['tab_type'] === 'frozen-fund-transfer-parent') { $v['from_user'] = $from_users[$v['operation_id']] ?? []; } } $this->success('获取成功', compact('list','level_arr','capital_type_arr')); } return $this->render('index'); } }