|
@ -4,6 +4,7 @@ namespace app\admin\service; |
|
|
|
|
|
|
|
|
use app\admin\validate\UserValidate; |
|
|
use app\admin\validate\UserValidate; |
|
|
use app\home\service\BaseHomeService; |
|
|
use app\home\service\BaseHomeService; |
|
|
|
|
|
use app\model\AccountFrozenModel; |
|
|
use app\model\AdminModel; |
|
|
use app\model\AdminModel; |
|
|
use app\model\AwsS3Model; |
|
|
use app\model\AwsS3Model; |
|
|
use app\model\CountryModel; |
|
|
use app\model\CountryModel; |
|
@ -49,6 +50,11 @@ class UserService extends AdminBaseService |
|
|
validate(UserValidate::class)->scene('index')->check($param); |
|
|
validate(UserValidate::class)->scene('index')->check($param); |
|
|
|
|
|
|
|
|
$where = []; |
|
|
$where = []; |
|
|
|
|
|
// base_label过滤 |
|
|
|
|
|
if (!empty($param['base_label'])) { |
|
|
|
|
|
$where['base_label'] = trim($param['base_label']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 邮箱搜索 |
|
|
// 邮箱搜索 |
|
|
if (!empty($param['email']) && trim($param['email'])) { |
|
|
if (!empty($param['email']) && trim($param['email'])) { |
|
|
$where['email'] = $param['email']; |
|
|
$where['email'] = $param['email']; |
|
@ -218,6 +224,25 @@ class UserService extends AdminBaseService |
|
|
$customerNames = AdminModel::where('id', 'in', $customerIds)->column('nick_name', 'id'); |
|
|
$customerNames = AdminModel::where('id', 'in', $customerIds)->column('nick_name', 'id'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用户实名认证信息 |
|
|
|
|
|
$realNameTranslation = UserVerifyLogModel::where('user_id', 'in', $userIdArr) ->column('user_id,name,code,front_img,back_img,status,country', 'user_id'); |
|
|
|
|
|
if ($realNameTranslation) { |
|
|
|
|
|
// 获取s3图片 |
|
|
|
|
|
$frontImgIds = array_column($realNameTranslation, 'front_img'); |
|
|
|
|
|
$imgArr = AwsS3Model::where('id', 'in', $frontImgIds)->column('s3_url', 'id'); |
|
|
|
|
|
// 获取国家 |
|
|
|
|
|
$countryIds = array_column($realNameTranslation, 'country'); |
|
|
|
|
|
$countryArr = CountryModel::where('id', 'in', $countryIds)->column('name_cn', 'id'); |
|
|
|
|
|
foreach ($realNameTranslation as $k=>$v) { |
|
|
|
|
|
if (!empty($v['front_img'])) { |
|
|
|
|
|
$realNameTranslation[$k]['front_img'] = $imgArr[$v['front_img']] ?? ''; |
|
|
|
|
|
} |
|
|
|
|
|
if (!empty($v['country'])) { |
|
|
|
|
|
$realNameTranslation[$k]['country'] = $countryArr[$v['country']] ?? ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//最近登录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(); |
|
@ -243,8 +268,10 @@ class UserService extends AdminBaseService |
|
|
'mobile' => $item['country_code'] . '-' . $item['phone_number'], |
|
|
'mobile' => $item['country_code'] . '-' . $item['phone_number'], |
|
|
'customer_remark' => $item['customer_remark'], |
|
|
'customer_remark' => $item['customer_remark'], |
|
|
'label' => $item['label'], |
|
|
'label' => $item['label'], |
|
|
|
|
|
'base_label' => $item['base_label'], |
|
|
'customer_id' => $itmCustomerId, |
|
|
'customer_id' => $itmCustomerId, |
|
|
'customer_name' => $itmCustomerName, |
|
|
'customer_name' => $itmCustomerName, |
|
|
|
|
|
'real_name_translation' => $realNameTranslation[$item['user_id']] ?? [], |
|
|
|
|
|
|
|
|
//余额 |
|
|
//余额 |
|
|
'digital' => $userDigitalList[$item['user_id']]['usable_num'] ?? '0', |
|
|
'digital' => $userDigitalList[$item['user_id']]['usable_num'] ?? '0', |
|
@ -1024,7 +1051,7 @@ class UserService extends AdminBaseService |
|
|
Cache::store('redis')->set($key, $param['leverage_num']); |
|
|
Cache::store('redis')->set($key, $param['leverage_num']); |
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
return $this->toData('0', 'SUCCESS', []); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1032,21 +1059,18 @@ class UserService extends AdminBaseService |
|
|
public function editCustomerRemark($param) |
|
|
public function editCustomerRemark($param) |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id'])) { |
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id']) || empty($param['remark'])) { |
|
|
return $this->toData('1', 'Missing parameter user_id'); |
|
|
return $this->toData('400', 'Missing parameter user_id'); |
|
|
} |
|
|
|
|
|
if (empty($param['remark'])) { |
|
|
|
|
|
return $this->toData('1', 'Missing parameter remark'); |
|
|
|
|
|
} |
|
|
} |
|
|
$user = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
$user = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
if (empty($user)) { |
|
|
if (empty($user)) { |
|
|
return $this->toData('1', '操作的用户数据错误'); |
|
|
return $this->toData('500', '操作的用户数据错误'); |
|
|
} |
|
|
} |
|
|
$user->customer_remark = $param['remark']; |
|
|
$user->customer_remark = $param['remark']; |
|
|
$user->save(); |
|
|
$user->save(); |
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1054,15 +1078,12 @@ class UserService extends AdminBaseService |
|
|
public function editUserLabel($param) |
|
|
public function editUserLabel($param) |
|
|
{ |
|
|
{ |
|
|
try { |
|
|
try { |
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id'])) { |
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id']) || empty($param['label'])) { |
|
|
return $this->toData('1', 'Missing parameter user_id'); |
|
|
return $this->toData('400', 'Missing parameter user_id'); |
|
|
} |
|
|
|
|
|
if (empty($param['label'])) { |
|
|
|
|
|
return $this->toData('1', 'Missing parameter label'); |
|
|
|
|
|
} |
|
|
} |
|
|
$user = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
$user = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
if (empty($user)) { |
|
|
if (empty($user)) { |
|
|
return $this->toData('1', '操作的用户数据错误'); |
|
|
return $this->toData('500', '操作的用户数据错误'); |
|
|
} |
|
|
} |
|
|
$user->label = $param['label']; |
|
|
$user->label = $param['label']; |
|
|
$user->save(); |
|
|
$user->save(); |
|
@ -1083,7 +1104,66 @@ class UserService extends AdminBaseService |
|
|
} |
|
|
} |
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
} catch (\Exception $exception) { |
|
|
} catch (\Exception $exception) { |
|
|
return $this->toData('1', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); |
|
|
return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function editUserBaseLabel($param) |
|
|
|
|
|
{ |
|
|
|
|
|
try { |
|
|
|
|
|
if (empty($param['user_id']) || !is_numeric($param['user_id']) || empty($param['base_label'])) { |
|
|
|
|
|
return $this->toData('400', 'Missing parameter user_id'); |
|
|
|
|
|
} |
|
|
|
|
|
$user = UserModel::where(['user_id'=>$param['user_id']])->find(); |
|
|
|
|
|
if (empty($user)) { |
|
|
|
|
|
return $this->toData('500', '操作的用户数据错误'); |
|
|
|
|
|
} |
|
|
|
|
|
$user->base_label = $param['base_label']; |
|
|
|
|
|
$user->save(); |
|
|
|
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
|
|
|
} catch (\Exception $exception) { |
|
|
|
|
|
return $this->toData('500', 'The system is busy.', [$exception->getMessage(), $exception->getTrace()]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用户充值、提款封禁与解封 |
|
|
|
|
|
public function frozen($param, $adminId) |
|
|
|
|
|
{ |
|
|
|
|
|
try { |
|
|
|
|
|
// 参数校验 |
|
|
|
|
|
validate(UserValidate::class)->scene('frozen_state')->check($param); |
|
|
|
|
|
$userId = $param['id']; |
|
|
|
|
|
$user = UserModel::where('user_id', $userId)->find(); |
|
|
|
|
|
if (empty($user)) { |
|
|
|
|
|
return $this->toData('1', '用户不存在'); |
|
|
|
|
|
} |
|
|
|
|
|
$bool = $this->checkUserIdInAgent($adminId, $userId); |
|
|
|
|
|
if (!$bool) { |
|
|
|
|
|
return $this->toData('1', '无权操作'); |
|
|
|
|
|
} |
|
|
|
|
|
// 查询冻结记录表 |
|
|
|
|
|
$accountFrozen = AccountFrozenModel::where('user_id', $userId)->find(); |
|
|
|
|
|
if (empty($accountFrozen)) { |
|
|
|
|
|
if (isset($param['frozen_recharge'])) { |
|
|
|
|
|
AccountFrozenModel::create(['user_id'=>$userId, 'frozen_recharge' => $param['frozen_recharge']]); |
|
|
|
|
|
} |
|
|
|
|
|
if (isset($param['frozen_withdraw'])) { |
|
|
|
|
|
AccountFrozenModel::create(['user_id'=>$userId, 'frozen_withdraw' => $param['frozen_withdraw']]); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (isset($param['frozen_recharge'])) { |
|
|
|
|
|
AccountFrozenModel::update(['frozen_recharge' => $param['frozen_recharge']], ['user_id' => $userId]); |
|
|
|
|
|
} |
|
|
|
|
|
if (isset($param['frozen_withdraw'])) { |
|
|
|
|
|
AccountFrozenModel::update(['frozen_withdraw' => $param['frozen_withdraw']], ['user_id' => $userId]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return $this->toData('0', 'SUCCESS'); |
|
|
|
|
|
} catch (ValidateException $validateException) { |
|
|
|
|
|
$message = $validateException->getError(); |
|
|
|
|
|
return $this->toData('1', $message); |
|
|
|
|
|
} catch (\Exception $exception) { |
|
|
|
|
|
return $this->toData('1', '系统异常 请稍后重试', [$exception->getMessage(), $exception->getTrace()]); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|