|
|
|
@ -8,8 +8,10 @@ use app\model\AdminDownScoresRecords; |
|
|
|
use app\model\AdminUpScoresRecords; |
|
|
|
use app\model\AgentRechargeRecords; |
|
|
|
use app\model\AgentUser; |
|
|
|
use app\model\RechargeRecords; |
|
|
|
use app\model\User; |
|
|
|
use app\model\User as UserModel; |
|
|
|
use app\model\WithdrawalRecords; |
|
|
|
use think\facade\Db; |
|
|
|
use think\facade\Request; |
|
|
|
use think\facade\Session; |
|
|
|
@ -92,6 +94,90 @@ class AdminTeam extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户上分 |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public function upScores() |
|
|
|
{ |
|
|
|
$request = Request::param(); |
|
|
|
|
|
|
|
$connection = Db::connect(); |
|
|
|
try { |
|
|
|
$adminUser = Session::get('login_admin_user_data'); |
|
|
|
|
|
|
|
validate(Admin::class)->scene('scoresUser')->check($request); |
|
|
|
|
|
|
|
$user_id = $request['user_id']; # 用户id |
|
|
|
$quota = $request['quota']; # 额度 |
|
|
|
|
|
|
|
# 开启事务 |
|
|
|
$connection->startTrans(); |
|
|
|
|
|
|
|
# 用户上分 |
|
|
|
$userBalance = User::incrBalance($user_id,$quota); |
|
|
|
|
|
|
|
# 管理用户上分记录 |
|
|
|
AdminUpScoresRecords::createRecords($user_id,$adminUser['id'],$quota,$userBalance); |
|
|
|
|
|
|
|
# 用户充值记录-上分 |
|
|
|
RechargeRecords::createRecords($user_id,$quota,$userBalance,1,2); |
|
|
|
|
|
|
|
$connection->commit(); |
|
|
|
return $this->renderSuccess('上分成功'); |
|
|
|
} catch (ValidateException $e) { |
|
|
|
return $this->renderError($e->getMessage()); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
$connection->rollback(); |
|
|
|
return $this->renderError($exception->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户下分 |
|
|
|
* @return array|void |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
*/ |
|
|
|
public function downScores() |
|
|
|
{ |
|
|
|
$request = Request::param(); |
|
|
|
|
|
|
|
$connection = Db::connect(); |
|
|
|
try { |
|
|
|
$adminUser = Session::get('login_admin_user_data'); |
|
|
|
validate(Admin::class)->scene('scoresUser')->check($request); |
|
|
|
|
|
|
|
$user_id = $request['user_id']; # 用户id |
|
|
|
$quota = $request['quota']; # 额度 |
|
|
|
|
|
|
|
# 检测用户余额是否足够 |
|
|
|
$inspectRes = User::inspectUserBalance($user_id,$quota); |
|
|
|
if (!$inspectRes['status']) throw new ValidateException($inspectRes['msg']); |
|
|
|
|
|
|
|
# 开启事务 |
|
|
|
$connection->startTrans(); |
|
|
|
|
|
|
|
# 用户下分 |
|
|
|
$userBalance = User::decrWithdrawalBalance($user_id,$quota); |
|
|
|
|
|
|
|
# 管理给用户下分记录 |
|
|
|
AdminDownScoresRecords::createRecords($user_id,$adminUser['id'],$quota,$userBalance); |
|
|
|
|
|
|
|
# 用户提现记录-下分 |
|
|
|
WithdrawalRecords::createRecords($user_id,$quota,$userBalance,1,2); |
|
|
|
|
|
|
|
$connection->commit(); |
|
|
|
return $this->renderSuccess('下分成功'); |
|
|
|
} catch (ValidateException $e) { |
|
|
|
return $this->renderError($e->getMessage()); |
|
|
|
} catch (\Exception $exception) { |
|
|
|
$connection->rollback(); |
|
|
|
return $this->renderError($exception->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 代理列表 |
|
|
|
* @return array |
|
|
|
|