first commit
This commit is contained in:
141
app/adminapi/logic/user/UserGroupLogic.php
Normal file
141
app/adminapi/logic/user/UserGroupLogic.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\{User,UserGroup,UserGroupRecord};
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 用户分组逻辑
|
||||
* Class UserGroupLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserGroupLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加用户分组
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:04
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserGroup::create([
|
||||
'name' => $params['name']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑用户分组
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:04
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserGroup::where('id', $params['id'])->update([
|
||||
'name' => $params['name']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除用户分组
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:04
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserGroup::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户分组详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:04
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserGroup::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 用户分组
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/03/19 02:29
|
||||
*/
|
||||
public static function setUserGroup(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$user = User::where(['id' => $params['user_id']])->findOrEmpty();
|
||||
|
||||
if ($user->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
$group = UserGroup::where(['id' => $params['group_id']])->findOrEmpty();
|
||||
if ($group->isEmpty() && $params['group_id'] != 0) {
|
||||
throw new \Exception('分组不存在');
|
||||
}
|
||||
$data = [
|
||||
'user_id' => $params['user_id'],
|
||||
'group_id' => $params['group_id'],
|
||||
];
|
||||
|
||||
//查询用户分组
|
||||
$record = UserGroupRecord::where(['user_id' => $params['user_id']])->findOrEmpty();
|
||||
if($params['group_id'] != 0){
|
||||
|
||||
if ($record->isEmpty()) {
|
||||
UserGroupRecord::create($data);
|
||||
}else{
|
||||
$data['id'] = $record['id'];
|
||||
UserGroupRecord::update($data);
|
||||
}
|
||||
}else{
|
||||
UserGroupRecord::destroy($record['id']);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
app/adminapi/logic/user/UserGroupRuleLogic.php
Normal file
107
app/adminapi/logic/user/UserGroupRuleLogic.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserGroupRule;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 分组规则逻辑
|
||||
* Class UserGroupRuleLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserGroupRuleLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加分组规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:30
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserGroupRule::create([
|
||||
'group_id' => $params['group_id'],
|
||||
'num' => $params['num'],
|
||||
'money_type' => $params['money_type'],
|
||||
'money' => $params['money'],
|
||||
'money_percentage' => $params['money_percentage'],
|
||||
'commission_type' => $params['commission_type'],
|
||||
'commission' => $params['commission'],
|
||||
'commission_percentage' => $params['commission_percentage']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分组规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:30
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserGroupRule::where('id', $params['id'])->update([
|
||||
'group_id' => $params['group_id'],
|
||||
'num' => $params['num'],
|
||||
'money_type' => $params['money_type'],
|
||||
'money' => $params['money'],
|
||||
'money_percentage' => $params['money_percentage'],
|
||||
'commission_type' => $params['commission_type'],
|
||||
'commission' => $params['commission'],
|
||||
'commission_percentage' => $params['commission_percentage']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除分组规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:30
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserGroupRule::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组规则详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/04/25 01:30
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserGroupRule::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
||||
85
app/adminapi/logic/user/UserInfoLogic.php
Normal file
85
app/adminapi/logic/user/UserInfoLogic.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserInfo;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息逻辑
|
||||
* Class UserInfoLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserInfoLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 同意实名
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/06/08 17:51
|
||||
*/
|
||||
public static function agree(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$record = UserInfo::find($params['id']);
|
||||
if ($record->isEmpty()) {
|
||||
throw new \Exception('记录不存在');
|
||||
}
|
||||
if ($record['auth_card']!=2) {
|
||||
throw new \Exception('状态异常');
|
||||
}
|
||||
UserInfo::update([
|
||||
'id' => $params['id'],
|
||||
'auth_card' => 1
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 拒绝实名
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/06/08 17:51
|
||||
*/
|
||||
public static function refuse(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$record = UserInfo::find($params['id']);
|
||||
if ($record->isEmpty()) {
|
||||
throw new \Exception('记录不存在');
|
||||
}
|
||||
if ($record['auth_card']!=2) {
|
||||
throw new \Exception('状态异常');
|
||||
}
|
||||
UserInfo::update([
|
||||
'id' => $params['id'],
|
||||
'auth_card' => 3,
|
||||
'card_remark' => $params['remark']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
99
app/adminapi/logic/user/UserKadanLogic.php
Normal file
99
app/adminapi/logic/user/UserKadanLogic.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserKadan;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 卡单规则逻辑
|
||||
* Class UserKadanLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserKadanLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加卡单规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/24 17:00
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserKadan::create([
|
||||
'user_id' => $params['user_id'],
|
||||
'sn' => generate_sn(UserKadan::class, 'sn'),
|
||||
'num' => $params['num'],
|
||||
'money' => $params['money'],
|
||||
'commission' => $params['commission']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑卡单规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/24 17:00
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserKadan::where('id', $params['id'])->update([
|
||||
'num' => $params['num'],
|
||||
'money' => $params['money'],
|
||||
'commission' => $params['commission']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除卡单规则
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/04/24 17:00
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserKadan::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取卡单规则详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/04/24 17:00
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserKadan::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
||||
601
app/adminapi/logic/user/UserLogic.php
Normal file
601
app/adminapi/logic/user/UserLogic.php
Normal file
@@ -0,0 +1,601 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\user\{User,UserInfo,UserNotice,UserRelation,UserRelationAgent};
|
||||
use app\common\model\decorate\DecorateHint;
|
||||
use app\common\model\finance\RechargeRecord;
|
||||
use app\common\model\setting\RechargeMethod;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\article\Article;
|
||||
|
||||
use app\common\utils\Common;
|
||||
use app\common\service\{
|
||||
ConfigService,UtilsService
|
||||
};
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\model\user\UserSession;
|
||||
|
||||
use think\facade\{Db, Config};
|
||||
|
||||
/**
|
||||
* 用户逻辑层
|
||||
* Class UserLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加用户
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function add(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
|
||||
try {
|
||||
$userSn = User::createUserSn();
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
|
||||
$password_pay_ = ConfigService::get('login', 'password_pay');
|
||||
$password_pay = create_password($password_pay_, $passwordSalt);
|
||||
$avatar = ConfigService::get('default_image', 'user_avatar');
|
||||
|
||||
|
||||
//判断上级
|
||||
//邀请码
|
||||
$top_sn = $params['invite_code'];
|
||||
$top_User = User::where(['sn' => $top_sn,'is_sn' => 1])->findOrEmpty();
|
||||
|
||||
if(isset($params['invite_code']) && $params['invite_code'] != ''){
|
||||
if ($top_User->isEmpty()) {
|
||||
throw new \Exception('邀请码不存在,请重新输入');
|
||||
}
|
||||
}
|
||||
|
||||
$mobile = $params['account'];
|
||||
if($params['login_way'] == 1){
|
||||
$mobile = $params['country_code'] . ' ' .$params['account'];
|
||||
}
|
||||
|
||||
$is_transfer = 0;
|
||||
$trade = ConfigService::get('website', 'trade');
|
||||
if($trade['is_transfer'] != 0) $is_transfer = 1;
|
||||
|
||||
$user = User::create([
|
||||
'sn' => $userSn,
|
||||
'avatar' => $avatar,
|
||||
'nickname' => '' . $userSn,
|
||||
'account' => $params['account'],
|
||||
'mobile' => $mobile,
|
||||
'country_code' => $params['country_code'],
|
||||
'password' => $password,
|
||||
'password_pay' => $password_pay,
|
||||
'channel' => $params['channel'],
|
||||
'is_transfer' => $is_transfer,
|
||||
'act_time' => time()
|
||||
]);
|
||||
|
||||
//创建用户关系
|
||||
if (!$top_User->isEmpty()) {
|
||||
UtilsService::create_user_relation($user['id'],$top_User['id'],UtilsService::get_distribute_level());
|
||||
}
|
||||
|
||||
//创建系统消息记录
|
||||
UtilsService::create_user_notice($user['id']);
|
||||
|
||||
//创建初始会员等级
|
||||
UtilsService::set_user_member($user['id']);
|
||||
|
||||
//创建用户信息
|
||||
UserInfo::create(['user_id' => $user['id']]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 调整用户余额
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2023/2/23 14:25
|
||||
*/
|
||||
public static function adjustUserMoney(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$user = User::find($params['user_id']);
|
||||
$action = $params['action'];//1增加余额2扣减余额3手动充值
|
||||
|
||||
$finance_action = 1;//1增加2减少
|
||||
$change_type = 0;//变动类型
|
||||
|
||||
$params['num'] = floatval($params['num']);
|
||||
|
||||
if (1 == $action) {
|
||||
//调整可用余额
|
||||
$user->save();
|
||||
$finance_action = 1;
|
||||
$change_type = 5;
|
||||
}elseif (2 == $action) {
|
||||
//调整可用余额
|
||||
$user->save();
|
||||
$finance_action = 2;
|
||||
$change_type = 6;
|
||||
}elseif (3 == $action){
|
||||
$user->save();
|
||||
$finance_action = 1;
|
||||
$change_type = 1;
|
||||
}
|
||||
|
||||
//记录日志
|
||||
UtilsService::user_finance_add(
|
||||
$user['id'],
|
||||
$change_type,
|
||||
$finance_action,
|
||||
$params['num'],
|
||||
'',
|
||||
$params['remark'],
|
||||
1 //冻结
|
||||
);
|
||||
|
||||
//用户资金修改
|
||||
UtilsService::user_money_change($params['user_id'], $finance_action, $params['num'],'user_money');
|
||||
|
||||
//手动充值
|
||||
if($action == 3){
|
||||
$method = RechargeMethod::where(['id' => $params['method_id']])->findOrEmpty();
|
||||
if($method->isEmpty()){
|
||||
throw new \Exception('充值方式不存在');
|
||||
}
|
||||
|
||||
$order_amount_act = round($params['num'] * $method['rate'] , $method['precision']);
|
||||
//判断充值金额
|
||||
$config = ConfigService::get('website', 'trade');
|
||||
|
||||
if ($params['num'] < $config['recharge_min']) {
|
||||
throw new \Exception('该充值方式最小充值金额:' . $config['recharge_min']);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sn' => generate_sn(RechargeRecord::class, 'sn'),
|
||||
'user_id' => $user['id'],
|
||||
'method_id' => $params['method_id'],
|
||||
'amount' => $params['num'],
|
||||
'amount_act' => $order_amount_act,
|
||||
'account' => $method['account'],
|
||||
'rate' => $method['rate'],
|
||||
'symbol' => $method['symbol'],
|
||||
'status' => 1,
|
||||
];
|
||||
|
||||
$record = RechargeRecord::create($data);
|
||||
|
||||
//充值金额增加
|
||||
UtilsService::user_money_change($params['user_id'], $finance_action, $params['num'],'total_recharge');
|
||||
|
||||
//充值活动奖励
|
||||
UtilsService::activity_reward_add($params['user_id'],$params['num']);
|
||||
|
||||
//更新充值记录用户余额
|
||||
$user = User::where(['id' => $record['user_id']])->findOrEmpty();
|
||||
if (!$user->isEmpty()) {
|
||||
RechargeRecord::update([
|
||||
'id' => $record['id'],
|
||||
'user_money' => $user['user_money']
|
||||
]);
|
||||
|
||||
//充值次数+1
|
||||
User::update([
|
||||
'id' => $user['id'],
|
||||
'recharge_num' => $user['recharge_num'] + 1
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改密码
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function changePwd(array $params)
|
||||
{
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['pwd'], $passwordSalt);
|
||||
|
||||
return User::update([
|
||||
'id' => $params['id'],
|
||||
'password' => $password
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 重置支付密码
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function resetPayPwd(array $params)
|
||||
{
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
|
||||
$password_pay_ = ConfigService::get('login', 'password_pay');
|
||||
$password_pay = create_password($password_pay_, $passwordSalt);
|
||||
|
||||
return User::update([
|
||||
'id' => $params['id'],
|
||||
'password_pay' => $password_pay
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改邮箱
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function changeEmail(array $params)
|
||||
{
|
||||
$userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty();
|
||||
|
||||
return UserInfo::update([
|
||||
'id' => $userInfo['id'],
|
||||
'email' => $params['email'],
|
||||
'auth_email' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 重置邮箱验证
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function resetEmail(array $params)
|
||||
{
|
||||
$userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty();
|
||||
|
||||
return UserInfo::update([
|
||||
'id' => $userInfo['id'],
|
||||
'email' => "",
|
||||
'auth_email' => 0
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 重置谷歌验证
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function resetGoogle(array $params)
|
||||
{
|
||||
$userInfo = UserInfo::where(['user_id' => $params['id']])->findOrEmpty();
|
||||
|
||||
return UserInfo::update([
|
||||
'id' => $userInfo['id'],
|
||||
'google_key' => "",
|
||||
'google_qrcode' => "",
|
||||
'auth_google' => 0
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateMemberStatus(array $params)
|
||||
{
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'auto_member' => $params['auto_member']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateLhStatus(array $params)
|
||||
{
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'is_lh' => $params['is_lh']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateTransferStatus(array $params)
|
||||
{
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'is_transfer' => $params['is_transfer']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateSnStatus(array $params)
|
||||
{
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'is_sn' => $params['is_sn']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateOpenStatus(array $params)
|
||||
{
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'is_open' => $params['is_open']
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更改状态
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function updateAgentStatus(array $params)
|
||||
{
|
||||
try {
|
||||
if($params['is_agent'] == 1){
|
||||
$top_relation = UserRelation::where(['user_id' => $params['id']])->order('level desc')->findOrEmpty();
|
||||
if (!$top_relation->isEmpty()) {
|
||||
throw new \Exception('顶级用户才可设置为代理');
|
||||
}
|
||||
}
|
||||
|
||||
$user = User::where(['id' => $params['id']])->findOrEmpty();
|
||||
|
||||
if($user['agent_id'] == 0){
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($user['sn'].mt_rand(10, 100), $passwordSalt);
|
||||
|
||||
$admin = Admin::create([
|
||||
'name' => 'agent_'.$user['sn'],
|
||||
'account' => 'agent_'.$user['sn'],
|
||||
'password' => $password,
|
||||
'is_agent' => 1,
|
||||
'multipoint_login' => 1,
|
||||
]);
|
||||
|
||||
AdminRole::create([
|
||||
'admin_id' => $admin['id'],
|
||||
'role_id' => 6,
|
||||
]);
|
||||
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'agent_id' => $admin['id']
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'is_agent' => $params['is_agent']
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修改代理名称
|
||||
* @param array $params
|
||||
* @return User
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function changeAgentName(array $params)
|
||||
{
|
||||
try {
|
||||
$user = User::where(['id' => $params['id']])->findOrEmpty();
|
||||
|
||||
if($user['is_agent'] != 1){
|
||||
throw new \Exception('代理才可设置代理名称');
|
||||
}
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'agent_name' => $params['name']
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 发送站内信
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function sendNotice(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$article= Article::where(['id' => $params['article_id']])->findOrEmpty();
|
||||
if ($article->isEmpty()) {
|
||||
throw new \Exception('发送内容不存在');
|
||||
}
|
||||
|
||||
$accounts = $substr = explode(",", $params['accounts']);
|
||||
foreach ($accounts as $account) {
|
||||
$user = User::where(['account' => $account])->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
UserNotice::create([
|
||||
'user_id' => $user['id'],
|
||||
'article_id' => $article['id'],
|
||||
'title' => $article['title'],
|
||||
'content' => $article['content'],
|
||||
'langs' => $article['langs'],
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 彩金赠送
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2023/9/22 16:38
|
||||
*/
|
||||
public static function caijin(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$accounts = $substr = explode(",", $params['accounts']);
|
||||
$money = $params['money'];
|
||||
if($money <= 0){
|
||||
throw new \Exception('请输入正确的金额');
|
||||
}
|
||||
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$user = User::where(['account' => $account])->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
//记录日志
|
||||
UtilsService::user_finance_add(
|
||||
$user['id'],
|
||||
4,
|
||||
1,
|
||||
$money,
|
||||
'',
|
||||
$params['remark'],
|
||||
1 //冻结
|
||||
);
|
||||
|
||||
//用户资金修改
|
||||
UtilsService::user_money_change($user['id'], 1, $money,'user_money');
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 备注
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author bd
|
||||
* @date 2024/01/31 14:07
|
||||
*/
|
||||
public static function remark(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$record = User::find($params['id']);
|
||||
if ($record->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
//代理操作需查询是否有权限
|
||||
$user = User::where(['agent_id' => $params['admin_id']])->findOrEmpty();
|
||||
if (!$user->isEmpty()) {
|
||||
$userRelation = UserRelationAgent::where(['user_id' => $record['id'],'parent_id' => $user['id']])->findOrEmpty();
|
||||
if ($userRelation->isEmpty()) {
|
||||
throw new \Exception('参数异常');
|
||||
}
|
||||
}
|
||||
|
||||
User::update([
|
||||
'id' => $params['id'],
|
||||
'remark2' => $params['content']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
93
app/adminapi/logic/user/UserMineRecordLogic.php
Normal file
93
app/adminapi/logic/user/UserMineRecordLogic.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserMineRecord;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 挖矿记录逻辑
|
||||
* Class UserMineRecordLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserMineRecordLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加挖矿记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2025/01/01 15:47
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserMineRecord::create([
|
||||
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑挖矿记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2025/01/01 15:47
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserMineRecord::where('id', $params['id'])->update([
|
||||
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除挖矿记录
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2025/01/01 15:47
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserMineRecord::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取挖矿记录详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2025/01/01 15:47
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserMineRecord::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
||||
96
app/adminapi/logic/user/UserNoticeLogic.php
Normal file
96
app/adminapi/logic/user/UserNoticeLogic.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserNotice;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 用户消息逻辑
|
||||
* Class UserNoticeLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserNoticeLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加用户消息
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserNotice::create([
|
||||
'user_id' => $params['user_id'],
|
||||
'title' => $params['title'],
|
||||
'content' => $params['content'],
|
||||
'notice_type' => $params['notice_type']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑用户消息
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserNotice::where('id', $params['id'])->update([
|
||||
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除用户消息
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserNotice::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户消息详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/05/26 00:36
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserNotice::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
||||
30
app/adminapi/logic/user/UserRelationLogic.php
Normal file
30
app/adminapi/logic/user/UserRelationLogic.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserRelation;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 用户关系逻辑
|
||||
* Class UserRelationLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserRelationLogic extends BaseLogic
|
||||
{
|
||||
}
|
||||
273
app/adminapi/logic/user/UserTronLogic.php
Normal file
273
app/adminapi/logic/user/UserTronLogic.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
namespace app\adminapi\logic\user;
|
||||
|
||||
|
||||
use app\common\model\user\UserTron;
|
||||
use app\common\service\{UtilsService};
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 波场钱包逻辑
|
||||
* Class UserTronLogic
|
||||
* @package app\adminapi\logic\user
|
||||
*/
|
||||
class UserTronLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加波场钱包
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function add(): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
//创建地址
|
||||
$tronData = [
|
||||
'action' => 'reg'
|
||||
];
|
||||
|
||||
$response = UtilsService::usdt_request($tronData, 'POST');
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if($response['code'] == 200){
|
||||
$data['type'] = 2;
|
||||
$data['address'] = $response['data']['addr'];
|
||||
$data['qrcode'] = UtilsService::get_qrcode($data['address']);
|
||||
$data['key'] = $response['data']['key'];
|
||||
UserTron::create($data);
|
||||
}else{
|
||||
throw new \Exception('创建失败');
|
||||
}
|
||||
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑波场钱包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
UserTron::where('id', $params['id'])->update([
|
||||
'address' => $params['address'],
|
||||
'key' => $params['key'],
|
||||
'qrcode' => $params['qrcode'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除波场钱包
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return UserTron::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取波场钱包详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return UserTron::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新状态
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function updateSort(array $params)
|
||||
{
|
||||
return UserTron::update([
|
||||
'id' => $params['id'],
|
||||
'sort' => $params['sort']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新金额
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function updateMoney(array $params)
|
||||
{
|
||||
$record = UserTron::find($params['id']);
|
||||
if ($record->isEmpty()) {
|
||||
throw new \Exception('记录不存在');
|
||||
}
|
||||
//查询余额
|
||||
$data = [
|
||||
'action' => 'info',
|
||||
'addr' => $record['address']
|
||||
];
|
||||
|
||||
$response = UtilsService::usdt_request($data, 'POST');
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if($response['code'] == 200){
|
||||
return UserTron::update([
|
||||
'id' => $params['id'],
|
||||
'money_trx' => $response['data']['trx'],
|
||||
'money_usdt' => $response['data']['usdt'],
|
||||
]);
|
||||
}else{
|
||||
throw new \Exception('更新失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 转账
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function tran(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$userTron = UserTron::find($params['id']);
|
||||
//发起转账
|
||||
$data = [
|
||||
'action' => 'pay',
|
||||
'out_addr' => $userTron['address'],
|
||||
'out_key' => $userTron['key'],
|
||||
'out_money' => $params['num'],
|
||||
'in_addr' => $params['in_addr'],
|
||||
'type' => 'usdt',//usdt trx
|
||||
];
|
||||
|
||||
$response = UtilsService::usdt_request($data, 'POST');
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if($response['code'] == 200){
|
||||
UserTron::update([
|
||||
'id' => $params['id'],
|
||||
'money_usdt' => $userTron['money_usdt'] - $params['num'],
|
||||
]);
|
||||
|
||||
$inUserTron = UserTron::where(['address' => $params['in_addr']])->findOrEmpty();
|
||||
|
||||
if(!$inUserTron->isEmpty()){
|
||||
UserTron::update([
|
||||
'id' => $inUserTron['id'],
|
||||
'money_usdt' => $inUserTron['money_usdt'] + $params['num'],
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
throw new \Exception('转账失败');
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 归集
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author BD
|
||||
* @date 2024/05/04 23:38
|
||||
*/
|
||||
public static function tranAll(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$min_money = $params['min_money'];
|
||||
|
||||
$userTrons = UserTron::where("money_usdt >= $min_money")
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($userTrons as &$userTron) {
|
||||
$out_money = $userTron['money_usdt'] - $params['rem_money'];
|
||||
if($out_money <= 0) continue;
|
||||
|
||||
//发起转账
|
||||
$data = [
|
||||
'action' => 'pay',
|
||||
'out_addr' => $userTron['address'],
|
||||
'out_key' => $userTron['key'],
|
||||
'out_money' => $out_money,
|
||||
'in_addr' => $params['in_addr'],
|
||||
'type' => 'usdt',//usdt trx
|
||||
];
|
||||
$response = UtilsService::usdt_request($data, 'POST');
|
||||
|
||||
$response = json_decode($response, true);
|
||||
|
||||
if($response['code'] == 200){
|
||||
UserTron::update([
|
||||
'id' => $userTron['id'],
|
||||
'money_usdt' => $params['rem_money'],
|
||||
]);
|
||||
|
||||
$inUserTron = UserTron::where(['address' => $params['in_addr']])->findOrEmpty();
|
||||
if(!$inUserTron->isEmpty()){
|
||||
UserTron::update([
|
||||
'id' => $inUserTron['id'],
|
||||
'money_usdt' => $inUserTron['money_usdt'] + $out_money,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user