// +---------------------------------------------------------------------- namespace App\Models; use App\Services\Common\MemberService; use App\Services\Common\UserRoleService; use App\Services\UsdtWalletService; /** * 会员管理-模型 * @author laravel开发员 * @since 2020/11/10 * Class AdminModel * @package App\Models */ class UserModel extends BaseModel { // 设置数据表 protected $table = 'user'; /** * 获取数据信息 * @param int $id 用户ID * @return array|string * @author laravel开发员 * @since 2020/11/10 */ public function getInfo($id) { $info = $this->getOne([['id'=> $id]]); // TODO: Change the autogenerated stub if ($info) { // 头像 if ($info['avatar']) { $info['avatar'] = get_image_url($info['avatar']); } // 头像 if ($info['create_time']) { $info['create_time'] = datetime($info['create_time']); } // 性别 if ($info['gender']) { $info['gender_name'] = config('admin.gender_list')[$info['gender']]; } // 交易员承兑商账户和钱包地址 $userId = isset($info['user_id'])? $info['user_id'] : 0; $userType = isset($info['user_type'])? $info['user_type'] : 0; if($userType == 2){ $memberInfo = $userId? MemberService::make()->getInfo($userId) : []; $info['usdt_num'] = isset($memberInfo['usdt_num'])? floatval($memberInfo['usdt_num']) : '0.00'; $info['trc_address'] = isset($memberInfo['trc_address'])? trim($memberInfo['trc_address']) : ''; $info['erc_hexaddress'] = isset($memberInfo['erc_hexaddress'])? trim($memberInfo['erc_hexaddress']) : ''; $info['credit'] = isset($memberInfo['credit'])? intval($memberInfo['credit']) : 0; $info['exception_num'] = isset($memberInfo['exception_num'])? intval($memberInfo['exception_num']) : 0; // 钱包余额 $info['trc_num'] = '0.00'; $info['trc_usdt_num'] = '0.00'; $info['erc_num'] = '0.00'; $info['erc_usdt_num'] = '0.00'; if($memberInfo){ $trcNum = UsdtWalletService::make()->getTrxBalance($memberInfo['trc_address']); $info['trc_num'] = floatval($trcNum); $trcUsdtNum = UsdtWalletService::make()->getTrc20Usdt($memberInfo['trc_address']); $info['trc_usdt_num'] = floatval($trcUsdtNum); $ercNum = UsdtWalletService::make()->getErcBalance($memberInfo['erc_hexaddress']); $info['erc_num'] = floatval($ercNum); $ercUsdtNum = UsdtWalletService::make()->getErc20Usdt($memberInfo['erc_hexaddress']); $info['erc_usdt_num'] = floatval($ercUsdtNum); } } // 获取用户角色列表 $userRoleService = new UserRoleService(); $roleList = $userRoleService->getUserRoleList($id); $info['roles'] = $roleList; } return $info; } }