Browse Source

编辑用户阶段信息

master
chuan 4 months ago
parent
commit
9249e0ff00
  1. 8
      app/admin/controller/User.php
  2. 7
      app/admin/route/app.php
  3. 66
      app/admin/service/UserService.php
  4. 2
      app/admin/validate/RechargeValidate.php
  5. 3
      app/admin/validate/UserValidate.php
  6. 18
      app/model/UserStageStateModel.php

8
app/admin/controller/User.php

@ -155,4 +155,12 @@ class User extends AdminBaseController
$result = $service->frozen($this->request->param(),$this->getAdminId()); $result = $service->frozen($this->request->param(),$this->getAdminId());
return json($result); return json($result);
} }
// 设置用户阶段信息
public function editUserStage()
{
$service = new UserService();
$result = $service->editUserStage($this->request->param(),$this->getAdminId());
return json($result);
}
} }

7
app/admin/route/app.php

@ -14,7 +14,7 @@ $header = [
//Route::get('/test', 'Test/index'); //Route::get('/test', 'Test/index');
Route::post('/test', 'Test/index'); Route::post('/test', 'Test/index');
Route::post('/test_upload', 'Upload/uploadVideo'); Route::post('/test_upload', 'Upload/uploadVideo');
Route::post('test_api', 'User/editUserBaseLabel'); Route::post('test_api', 'User/editUserStage');
Route::group('/', function () { Route::group('/', function () {
// 上传图片 // 上传图片
Route::post('/upload', 'Upload/upload'); Route::post('/upload', 'Upload/upload');
@ -195,8 +195,9 @@ Route::group('/', function () {
Route::post('/user/reg_email', 'User/reg_email')->middleware('admin_log'); Route::post('/user/reg_email', 'User/reg_email')->middleware('admin_log');
Route::post('/user/bank', 'User/bankDetail'); Route::post('/user/bank', 'User/bankDetail');
Route::post('/user/edit_bank', 'User/editBank')->middleware('admin_log'); Route::post('/user/edit_bank', 'User/editBank')->middleware('admin_log');
Route::post('/user/edit_password', 'User/editPassword')->middleware('admin_log'); Route::post('user/edit_password', 'User/editPassword')->middleware('admin_log');
Route::post('/user/frozen', 'User/frozen'); //用户充值、提款封禁与解封 Route::post('user/frozen', 'User/frozen'); //用户充值、提款封禁与解封
Route::post('user/edit_user_stage', 'User/editUserStage'); //编辑用户阶段信息
//送股 //送股
Route::post('/user/give_stock', 'setting.GiveStock/add')->middleware('admin_log'); Route::post('/user/give_stock', 'setting.GiveStock/add')->middleware('admin_log');

66
app/admin/service/UserService.php

@ -19,6 +19,7 @@ use app\model\UserDigitalModel;
use app\model\UserForexModel; use app\model\UserForexModel;
use app\model\UserLoginLog; use app\model\UserLoginLog;
use app\model\UserModel; use app\model\UserModel;
use app\model\UserStageStateModel;
use app\model\UserStockBrlModel; use app\model\UserStockBrlModel;
use app\model\UserStockEurModel; use app\model\UserStockEurModel;
use app\model\UserStockFurModel; use app\model\UserStockFurModel;
@ -124,10 +125,13 @@ class UserService extends AdminBaseService
} }
$userList = UserModel::where($where)->where($whereU)->page($param['page'], $param['limit'])->order('user_id', 'desc')->select(); $userList = UserModel::where($where)->where($whereU)->page($param['page'], $param['limit'])->order('user_id', 'desc')->select();
if (empty($userList)) {
return $this->toData('0', 'SUCCESS', ['total' => 0, 'list' => [], 'extent' => ['market_type_list' => StockMarketModel::STOCK_MARKET_TYPE, 'is_agent' => $IsAgent, 'agent_list' => $agentNameArr, 'market_rate' => $marketRate, 'market_tape_list' => $tapeList]]);
}
$total = UserModel::where($where)->where($whereU)->count(); $total = UserModel::where($where)->where($whereU)->count();
$rows = []; $rows = [];
if (!empty($userList)) {
$userIdArr = []; $userIdArr = [];
$parentIdArr = []; $parentIdArr = [];
foreach ($userList as $value) { foreach ($userList as $value) {
@ -224,6 +228,9 @@ class UserService extends AdminBaseService
$customerNames = AdminModel::where('id', 'in', $customerIds)->column('nick_name', 'id'); $customerNames = AdminModel::where('id', 'in', $customerIds)->column('nick_name', 'id');
} }
// 查询用户充值、提款冻结状态
$accountFrozenList = AccountFrozenModel::where('user_id', 'in', $userIdArr)->column('frozen_recharge,frozen_withdraw', 'user_id');
// 用户实名认证信息 // 用户实名认证信息
$realNameTranslation = UserVerifyLogModel::where('user_id', 'in', $userIdArr)->column('user_id,name,code,front_img,back_img,status,country', 'user_id'); $realNameTranslation = UserVerifyLogModel::where('user_id', 'in', $userIdArr)->column('user_id,name,code,front_img,back_img,status,country', 'user_id');
if ($realNameTranslation) { if ($realNameTranslation) {
@ -243,6 +250,9 @@ class UserService extends AdminBaseService
} }
} }
// 用户阶段信息
$userStageStateList = UserStageStateModel::where('user_id', 'in', $userIdArr)->column('first_stage,first_stage_state,second_stage,second_stage_state,third_stage,third_stage_state', 'user_id');
//最近登录IP、最近登录国家 //最近登录IP、最近登录国家
$subQuery = UserLoginLog::field('user_id,MAX(login_date) AS last_login_date') $subQuery = UserLoginLog::field('user_id,MAX(login_date) AS last_login_date')
->where('user_id', 'in', $userIdArr)->group('user_id')->buildSql(); ->where('user_id', 'in', $userIdArr)->group('user_id')->buildSql();
@ -272,6 +282,14 @@ class UserService extends AdminBaseService
'customer_id' => $itmCustomerId, 'customer_id' => $itmCustomerId,
'customer_name' => $itmCustomerName, 'customer_name' => $itmCustomerName,
'real_name_translation' => $realNameTranslation[$item['user_id']] ?? [], 'real_name_translation' => $realNameTranslation[$item['user_id']] ?? [],
'frozen_recharge' => $accountFrozenList[$item['user_id']]['frozen_recharge'] ?? 0,
'frozen_withdraw' => $accountFrozenList[$item['user_id']]['frozen_withdraw'] ?? 0,
'first_stage' => $userStageStateList[$item['user_id']]['first_stage'] ?? '',
'first_stage_state' => $userStageStateList[$item['user_id']]['first_stage_state'] ?? 0,
'second_stage' => $userStageStateList[$item['user_id']]['second_stage'] ?? '',
'second_stage_state' => $userStageStateList[$item['user_id']]['second_stage_state'] ?? 0,
'third_stage' => $userStageStateList[$item['user_id']]['third_stage'] ?? '',
'third_stage_state' => $userStageStateList[$item['user_id']]['third_stage_state'] ?? 0,
//余额 //余额
'digital' => $userDigitalList[$item['user_id']]['usable_num'] ?? '0', 'digital' => $userDigitalList[$item['user_id']]['usable_num'] ?? '0',
@ -330,7 +348,6 @@ class UserService extends AdminBaseService
'agent_name' => $item['agent_id'] > 0 ? $agentNameArr[$item['agent_id']] ?? '-' : '-', 'agent_name' => $item['agent_id'] > 0 ? $agentNameArr[$item['agent_id']] ?? '-' : '-',
]; ];
} }
}
return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, 'extent' => ['market_type_list' => StockMarketModel::STOCK_MARKET_TYPE, 'is_agent' => $IsAgent, 'agent_list' => $agentNameArr, 'market_rate' => $marketRate, 'market_tape_list' => $tapeList]]); return $this->toData('0', 'SUCCESS', ['total' => $total, 'list' => $rows, 'extent' => ['market_type_list' => StockMarketModel::STOCK_MARKET_TYPE, 'is_agent' => $IsAgent, 'agent_list' => $agentNameArr, 'market_rate' => $marketRate, 'market_tape_list' => $tapeList]]);
} catch (ValidateException $validateException) { } catch (ValidateException $validateException) {
@ -1166,6 +1183,51 @@ class UserService extends AdminBaseService
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
} }
} }
// 编辑用户阶段信息
public function editUserStage($param)
{
try {
if (empty($param['user_id'])) {
return $this->toData('400', '缺少参数');
}
// 检测用户数据
$user = UserModel::where('user_id', $param['user_id'])->findOrEmpty()->toArray();
if (empty($user)) {
return $this->toData('1', '用户不存在');
}
// 检测用户阶段数据
$userStageState = UserStageStateModel::where(['user_id'=>$user['user_id']])->find();
if (empty($userStageState)) {
UserStageStateModel::create([
'user_id' => $user['user_id'],
'first_stage' => $param['first_stage'] ?? '',
'first_stage_state' => $param['first_stage_state'] ?? 0,
'second_stage' => $param['second_stage'] ?? '',
'second_stage_state' => $param['second_stage_state'] ?? 0,
'third_stage' => $param['third_stage'] ?? '',
'third_stage_state' => $param['third_stage_state'] ?? 0,
]);
} else {
if (isset($param['first_stage'])) {
$userStageState->first_stage = $param['first_stage'];
$userStageState->first_stage_state = $param['first_stage_state'] ?? 0;
}
if (isset($param['second_stage'])) {
$userStageState->second_stage = $param['second_stage'];
$userStageState->second_stage_state = $param['second_stage_state'] ?? 0;
}
if (isset($param['third_stage'])) {
$userStageState->third_stage = $param['third_stage'];
$userStageState->third_stage_state = $param['third_stage_state'] ?? 0;
}
$userStageState->save();
}
return $this->toData('0', 'SUCCESS');
} catch (\Exception $exception) {
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]);
}
}
} }

2
app/admin/validate/RechargeValidate.php

@ -37,7 +37,7 @@ class RechargeValidate extends AdminBaseValidate
protected $scene = [ protected $scene = [
// 现货 // 现货
'index' => ['page','limit','order_id', 'user_no', 'start_time', 'end_time','is_online'], 'index' => ['page','limit','order_id', 'user_no', 'start_time', 'end_time'],
'info' => ['id'], 'info' => ['id'],
'check' => ['id','check_status'], 'check' => ['id','check_status'],
]; ];

3
app/admin/validate/UserValidate.php

@ -18,6 +18,8 @@ class UserValidate extends AdminBaseValidate
'password'=>'require', 'password'=>'require',
'id' =>'require|integer', 'id' =>'require|integer',
'is_test_user' => 'require|in:1,2', 'is_test_user' => 'require|in:1,2',
'frozen_recharge' => 'in:1,0',
'frozen_withdraw' => 'in:1,0',
]; ];
protected $message = [ protected $message = [
@ -51,5 +53,6 @@ class UserValidate extends AdminBaseValidate
'relation' => ['page','limit','user_no'], 'relation' => ['page','limit','user_no'],
'add_phone' =>['nation','phone','password'], 'add_phone' =>['nation','phone','password'],
'add_email' =>['email','password'], 'add_email' =>['email','password'],
'frozen_state' => ['id','frozen_recharge','frozen_withdraw'],
]; ];
} }

18
app/model/UserStageStateModel.php

@ -0,0 +1,18 @@
<?php
declare (strict_types = 1);
namespace app\model;
use think\Model;
/**
* @mixin \think\Model
*/
class UserStageStateModel extends Model
{
const FIRST_STAGE = 'first_stage';
const SECOND_STAGE = 'second_stage';
const THIRD_STAGE = 'third_stage';
protected $name = 'user_stage_state';
}
Loading…
Cancel
Save