UserServices.php 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. <?php
  2. namespace app\api\services;
  3. use AlibabaCloud\SDK\Cloudauth\V20190307\Models\CompareFacesResponseBody\data;
  4. use app\common\model\MachineListModel;
  5. use app\common\model\MoneyLogModel;
  6. use app\common\model\UserDataModel;
  7. use app\common\model\UserModel;
  8. use app\common\model\UserScoreModel as UserScore;
  9. use app\common\model\MemberModel;
  10. use app\common\model\NumRecordModel;
  11. use app\common\model\WithdrawAccountModel;
  12. use app\common\model\WithDrawLogModel;
  13. use app\common\service\SystemConfigService;
  14. use app\common\service\WithdrawService;
  15. use data\service\RequestUtilService;
  16. use http\Params;
  17. use jobs\UserJobs;
  18. use sms\Verify;
  19. use think\db\Where;
  20. use think\Exception;
  21. use think\facade\Db;
  22. use utils\Json;
  23. use utils\Queue;
  24. class UserServices extends BaseServices
  25. {
  26. public function __construct()
  27. {
  28. $this->model = new UserModel();
  29. }
  30. /**
  31. * 用户注册
  32. */
  33. public function userRegister(array $param)
  34. {
  35. $model = $this->model->where('mobile', $param['mobile'])->value('mobile');
  36. if ($model) {
  37. throw new Exception('该手机号已被绑定,请切换');
  38. }
  39. if (Db::name('user')->where('user_name', $param['user_name'])->find()){
  40. throw new Exception('该用户名已注册,请更换');
  41. }
  42. $has_inviter = false;
  43. if (isset($param['invite_code'])){
  44. if ($param['invite_code']) {
  45. $inviter = $this->model->where('code', $param['invite_code'])->find();
  46. if ($inviter) {
  47. $has_inviter = true;
  48. }
  49. }
  50. }
  51. if ($param['code'] != '123321' && !UserServices::checkSmsCode($param['code'], 'register', $param['mobile'])) {
  52. throw new Exception('验证码错误或过期');
  53. }
  54. $insert['mobile'] = $param['mobile'];
  55. $insert['password'] = md5(AESjiami($param['password']));
  56. $insert['pass_enable'] = $param['password'];
  57. $insert['user_name'] = $param['user_name'];
  58. $insert['reg_ip'] = get_client_ip();
  59. $insert['nickname'] = createUserNickname();
  60. $insert['path'] = '';
  61. $insert['avatar'] = 'static/img/user/default_avatar.jpg';
  62. $insert['code'] = create_invite_code();
  63. $insert['px_code'] = create_invite_code();
  64. $this->model->save($insert);
  65. $uid = $this->model->id;
  66. $user_data = new UserDataModel();
  67. $rz_money = 1.8 + rand(1, 30) / 100;
  68. $user_data->save(['uid' => $uid, 'rz_money' => $rz_money, 'device' => '']); // 保存用户关联信息
  69. if ($has_inviter){
  70. $this->bindRelation($param['invite_code'], $uid); // 绑定关系
  71. }
  72. return $uid;
  73. }
  74. /**
  75. * code| 注册的邀请码 uid 当前用户的uid
  76. * @param string $code
  77. * @param int $uid
  78. * @throws Exception
  79. * @throws \think\db\exception\DataNotFoundException
  80. * @throws \think\db\exception\DbException
  81. * @throws \think\db\exception\ModelNotFoundException
  82. */
  83. public function bindRelation (string $code, int $uid)
  84. {
  85. if (empty($code)){
  86. $code = '032842787';
  87. }
  88. $data = [];
  89. $data['px_pid'] = $data['pid'] = $data['is_px'] = $data['reg_pid'] = 0;
  90. $is_px = false;
  91. if (($up_user = $this->model->where('code', $code)->field('id,path')->lock(true)->find()) !== false && !empty($up_user)) {
  92. // 直推吗
  93. $data['pid'] = $up_user['id']; // pid
  94. $path = '';
  95. if (empty($up_user['path'])){
  96. $path = $up_user['id'];
  97. }else{
  98. $path = $up_user['path'].','.$up_user['id'];
  99. }
  100. // sr_log('path'.$path);
  101. $data['path'] = $path;
  102. $data['reg_pid'] = $up_user['id'];
  103. } elseif (($up_user = $this->model->where('px_code', $code)->field('id,path,px_id')->lock(true)->find()) !== false && !empty($up_user)) {
  104. // 排线码
  105. // $last_user = $this->model->where(['px_id'=>$up_user['id']])->field('id,px_pid,path')->order('id desc')->find(); // 排线最后一位
  106. // throw new Exception(json_encode($up_user));
  107. $is_px = true;
  108. if (empty($up_user['path'])){
  109. // 在顶层注册
  110. $count = $this->model->where(['px_id'=>$up_user['id']])->count();
  111. if ($count > 0){
  112. // 当前id有排线
  113. $max_user = $this->model->where(['px_id'=>$up_user['id']])->max('id');
  114. $max_user = $this->model->where(['id'=>$max_user])->field('id, path, px_id')->find();
  115. $data['path'] = $max_user['path'] .(empty($max_user['path'])?'':','). $max_user['id'];
  116. $data['px_id'] = $max_user['px_id'];
  117. $data['pid'] = $max_user['id'];
  118. }else {
  119. // 当前id 没有排线
  120. // 当前排线没人
  121. $data['path'] = $up_user['path'].(empty($up_user['path'])?'':',').$up_user['id'];
  122. $data['px_id'] = $up_user['id'];
  123. $data['pid'] = $up_user['id'];
  124. // throw new Exception($data['path']);
  125. }
  126. }else {
  127. $count = $this->model->where(['px_id'=>$up_user['id']])->count();
  128. if ($count == 0){
  129. // 当前没有排线
  130. // $max_user = $this->model->where(['px_id'=>$dc_user['id']])->max('id');
  131. // $max_user = $this->model->where(['id'=>$max_user])->field('id, path, px_id')->find();
  132. $data['path'] = $up_user['path'].(empty($up_user['path'])?'':',').$up_user['id'];
  133. $data['px_id'] = $up_user['id'];
  134. $data['pid'] = $up_user['id'];
  135. }else{
  136. // 当前有排线
  137. $max_user = $this->model->where(['px_id'=>$up_user['id']])->max('id');
  138. $max_user = $this->model->where(['id'=>$max_user])->field('id, path, px_id')->find();
  139. $data['path'] = $max_user['path'] .(empty($max_user['path'])?'':','). $max_user['id'];
  140. $data['px_id'] = $up_user['id'];
  141. $data['pid'] = $max_user['id'];
  142. }
  143. // 不在顶层注册
  144. }
  145. $data['px_pid'] = $up_user['id']; // 排线pid
  146. $data['reg_pid'] = $up_user['id'];
  147. $data['is_px'] = 1; // 标记排线
  148. }
  149. // $data['path'] = trim_string($data['path']);
  150. // $data['nickname'] = 'yju' . $uid;
  151. $data['total_number'] = 0;
  152. // $data['market_uid'] = $up_user['market_uid'];
  153. // $data['firstcode_uid'] = $up_user['firstcode_uid'];
  154. if ($is_px){
  155. if (!isset($data['path']) || empty($data['path'])){
  156. throw new Exception('注册失败');
  157. }
  158. }
  159. $this->model->where('id', $uid)->save($data);
  160. incTeamStatic($uid, 1, $data['path']);
  161. }
  162. public function userLogin(array $param)
  163. {
  164. $user_name = $param['user_name'];
  165. $f_user = Db::name('user')->where('mobile|user_name', $user_name)->find();
  166. if (!$f_user){
  167. sr_throw('请核对登录账号信息');
  168. }
  169. $user = $this->model->getUserDetailByUid($f_user['id']);
  170. if ($user['status'] == 0 ){
  171. $msg = '账号被禁用'.(empty($user['deny_reason'])?"":(',原因:'. $user['deny_reason']));
  172. throw new Exception($msg);
  173. }
  174. if ($user['status'] != 1){
  175. sr_throw('用户状态错误,登录失败');
  176. }
  177. $login_type = 'pass';
  178. if ($user){
  179. if ($login_type === 'pass'){
  180. $param['password'] = AESjiemi($param['password']);
  181. if (md5(AESjiami($param['password'])) == $user['password']){
  182. // 验证是否需要验证码登录
  183. if (checkUserNeedsSecuritLogin($f_user['id'])){
  184. throw new Exception('请使用验证码登录', 1148);
  185. }else{
  186. }
  187. }else{
  188. throw new Exception('账号密码错误,请检查', 500);
  189. }
  190. }elseif ($login_type === 'security'){
  191. // 验证短信验证码
  192. if (!UserServices::checkSmsCode($param['code'], 'loingcheck', $param['mobile'])) {
  193. throw new Exception('验证码错误或过期', 500);
  194. }
  195. // 验证滑动验证
  196. $ali_verify = json_decode(html_entity_decode($param['ali_verify']), true);
  197. /** @var Verify $verify */
  198. $verify = new Verify();
  199. $result = $verify->ali_verify($ali_verify['appkey'], $ali_verify['scene'], $ali_verify['csessionid'], $ali_verify['nc_token'], $ali_verify['sig']);
  200. if (!$result){
  201. throw new Exception('登录失败请重新滑动验证', 500);
  202. }
  203. }
  204. }else {
  205. throw new Exception('用户名或者密码错误,请检查');
  206. }
  207. $this->model->updateUserLoginInfo($user['id']);
  208. unset($user['password']);
  209. $user['login_count'] = $user['login_count']+1;
  210. $user['token'] = $this->createToken($user['id'], $user);
  211. unset($user['status']);
  212. unset($user['login_count']);
  213. unset($user['login_ip']);
  214. unset($user['login_time']);
  215. return ['msg'=>'登录成功', 'data'=>$user];
  216. }
  217. // // 老的排线
  218. // protected function bindRelation(string $code, int $uid)
  219. // {
  220. // $data['px_pid'] = $data['pid'] = $data['is_px'] = 0;
  221. // if (($up_user = $this->model->where('code', $code)->field('id')->lock(true)->find()) !== false && !empty($up_user)) { // 直推码
  222. // $data['pid'] = $up_user['id']; // pid
  223. // $relation = $this->model->where('id', $up_user['id'])->value('path');
  224. // $data['path'] = $relation . ',' . $up_user['id'];
  225. // } elseif (($up_user = $this->model->where('px_code', $code)->field('id')->lock(true)->find()) !== false && !empty($up_user)) { // 排线码
  226. // $last_user = $this->model->where('id', $up_user['id'])->field('id,px_pid,path')->order('id desc')->find(); // 排线最后一位
  227. // if (!empty($last_user)) { // 如果有则在该用户下继续排线
  228. // $data['pid'] = $last_user['id']; // 上级id
  229. // $data['path'] = $last_user['path'] . ',' . $last_user['id'];
  230. // } else { // 没有就开启新的排线
  231. // $relation = $this->model->where('id', $up_user['id'])->value('path');
  232. // $data['pid'] = $up_user['id']; // pid
  233. // $data['path'] = $relation . ',' . $up_user['id'];
  234. // }
  235. // $data['px_pid'] = $up_user['id']; // 排线pid
  236. // $data['is_px'] = 1; // 标记排线
  237. // }
  238. // $data['path'] = trim_string($data['path']);
  239. // $data['nickname'] = '会员_' . $uid;
  240. //// $data['market_uid'] = $up_user['market_uid'];
  241. //// $data['firstcode_uid'] = $up_user['firstcode_uid'];
  242. // if (!isset($data['path']) || empty($data['path']))
  243. // throw new Exception('注册失败');
  244. // $this->model->where('id', $uid)->save($data);
  245. // $data['path'] .= ',' . $uid;
  246. // $data['path'] = trim_string($data['path']);
  247. // $this->model->where('id', 'in', $data['path'])->save(['total_number' => ['inc', 1]]);
  248. // }
  249. public function checkSmsCode($code, $type, $phone = 0) : bool
  250. {
  251. // sr_log(env('APP.CUR_SYS_PARAMS'));
  252. // sr_log(intval($code));
  253. if (in_array(env('APP.CUR_SYS_PARAMS'), [1, 2])){
  254. if (intval($code) == 111111){
  255. return true;
  256. }
  257. }else{
  258. // if (intval($code) == 931256){
  259. // sr_log('统一验证码使用,手机号:'.$phone.',type:'.$type);
  260. // return true;
  261. // }
  262. }
  263. // // 测试手机号
  264. // if ($phone == '18280066008'){
  265. // return true;
  266. // }
  267. $m = new NumRecordModel();
  268. $data = [
  269. 'type'=>$type,
  270. 'content'=>$code,
  271. 'is_use'=>0,
  272. 'phone'=>$phone
  273. ];
  274. if ($info = $m->where($data)->find()){
  275. // $info = $m->getQuery($data, '*', 'create_time asc');
  276. //
  277. // $old_time = $info[0]['create_time'];
  278. // if ((time()-$old_time) > 900){
  279. // return false;
  280. // }else {
  281. $m->where(['id'=>$info['id']])->save(['is_use'=>1]);
  282. return true;
  283. // }
  284. }else {
  285. return false;
  286. }
  287. }
  288. public function userAuth($request)
  289. {
  290. $param = $request->param();
  291. if (Db::name('user')->where(['id'=>$request->uid, 'is_auth'=>1])->find()){
  292. throw new Exception('已经实名啦');
  293. }
  294. // if (Db::name('user_data')->where(['idcard'=>$param['id_card']])->find()){
  295. // throw new Exception('该身份证已经实名');
  296. // }
  297. Db::startTrans();
  298. try {
  299. $ser_request = new \app\services\RequestUtilService();
  300. $result = $ser_request->requestJUHEidCardAuth($param['id_name'], $param['id_card']);
  301. // {
  302. // "data": {
  303. // "reason": "成功",
  304. // "result": {
  305. // "res": 1,
  306. // "realname": "王红力",
  307. // "idcard": "513023199202066138",
  308. // "orderid": "J2022010412272517923w7rV9"
  309. // },
  310. // "error_code": 0
  311. // }
  312. //}
  313. // {
  314. // "reason": "参数错误:姓名或身份证格式错误",
  315. // "result": {
  316. // "orderid": "J202201041221481052DNYXe4"
  317. // },
  318. // "error_code": 210304
  319. //}
  320. if ($result->error_code == 0){
  321. if ($result->result->res == 1){
  322. // 更新用户表的数据
  323. $m = new UserDataModel();
  324. $m->where(['uid'=>$request->uid])->save([
  325. 'idcard'=>$param['id_card'],
  326. 'idname'=>$param['id_name'],
  327. 'real_name'=>$param['id_name'],
  328. ]);
  329. Db::name('user')->where(['id'=>$request->uid])->save(['is_auth'=>1]);
  330. // $m->save(['true_name'=>$true_name, 'id_card'=>$id_card], ['uid'=>$this->uid]);
  331. // return $this->outMessage($title, []);
  332. // 赠送用户100积分
  333. Db::name('user')->where(['id'=>$request->uid])->inc('score', 100)->update();
  334. UserScore::change(['before_score' => $request->user_info->score, 'score' => 100, 'type' => 6, 'uid' => $request->uid, 'state' => 1]);
  335. Queue::instance()->log('实名人数执行成功')->do('userRelationAuth')->job(UserJobs::class)->push([$request->user_info->code, $request->uid]); // 绑定用户关系和添加用户静态数据
  336. } else {
  337. throw new Exception('输入信息不匹配');
  338. }
  339. }else{
  340. throw new Exception($result->reason);
  341. }
  342. Db::commit();
  343. return api_succ_return('实名认证成功');
  344. }catch (\Exception $e){
  345. Db::rollback();
  346. throw new Exception($e->getMessage());
  347. }
  348. }
  349. /**
  350. * 设置用户信息
  351. * @param $uid
  352. * @param $param
  353. * @return string
  354. */
  355. public function setUserInfo ($uid, $param)
  356. {
  357. $user = $this->model->findOrEmpty($uid);
  358. if (empty($user))
  359. throw new Exception('用户信息设置失败');
  360. // if (array_key_exists('pay_pass', $param)) { // 设置安全密码
  361. // if ($user->pay_pass) {
  362. // throw new Exception('不允许设置');
  363. // } else {
  364. // if ($param['pay_pass'] != $param['c_paypass'])
  365. // throw new Exception('两次输入的密码不一致');
  366. // else
  367. // $param['pay_pass'] = md5(AES::encrypt($param['pay_pass']));
  368. // }
  369. // }
  370. $config = ['avatar' => 'user', 'pay_pass' => 'user', 'sex' => 'user_data', 'email' => 'user_data', 'intro' => 'user_data', 'birthday' => 'user_data', 'qq' => 'user_data', 'wx' => 'user_data', 'nickname' => 'user', 'area_code_ids' => 'user_data', 'area_text' => 'user_data']; // 允许修改的字段
  371. foreach ($param as $key => $value) {
  372. $map = [];
  373. if (isset($config[$key]) && ($model_name = $config[$key]) !== false) {
  374. if ($model_name == 'user')
  375. $map['id'] = $uid;
  376. else
  377. $map['uid'] = $uid;
  378. Db::name($model_name)->where($map)->save([$key => $value]);
  379. }
  380. }
  381. // 如果有设置昵称跟头像要刷新消息聊天记录的信息
  382. if (isset($param['nickname'])){
  383. Db::name('chat_message')->where('uid', $uid)->save(['nick_name'=>$param['nickname']]);
  384. }
  385. if (isset($param['avatar'])){
  386. Db::name('chat_message')->where('uid', $uid)->save(['avatar'=>(getWebUrl().'/'.$param['avatar'])]);
  387. }
  388. return '用户信息设置成功';
  389. }
  390. public function setSellerPayWay ($uid, $param)
  391. {
  392. $user = $this->model->findOrEmpty($uid);
  393. if (empty($user))
  394. throw new Exception('用户信息设置失败');
  395. // if (array_key_exists('pay_pass', $param)) { // 设置安全密码
  396. // if ($user->pay_pass) {
  397. // throw new Exception('不允许设置');
  398. // } else {
  399. // if ($param['pay_pass'] != $param['c_paypass'])
  400. // throw new Exception('两次输入的密码不一致');
  401. // else
  402. // $param['pay_pass'] = md5(AES::encrypt($param['pay_pass']));
  403. // }
  404. // }
  405. $config = [
  406. 'wx_img' => 'user_data',
  407. 'wx_pay' => 'user_data',
  408. 'wx_pay_name' => 'user_data',
  409. 'ali_img' => 'user_data',
  410. 'ali_pay' => 'user_data',
  411. 'ali_pay_name' => 'user_data',
  412. 'bank_no' => 'user_data',
  413. 'bank_subname' => 'user_data'
  414. ]; // 允许修改的字段
  415. foreach ($param as $key => $value) {
  416. $map = [];
  417. if (isset($config[$key]) && ($model_name = $config[$key]) !== false) {
  418. if ($model_name == 'user')
  419. $map['id'] = $uid;
  420. else
  421. $map['uid'] = $uid;
  422. Db::name($model_name)->where($map)->save([$key => $value]);
  423. }
  424. }
  425. return '配置成功';
  426. }
  427. // 用户升星
  428. public function upgradeStar($param)
  429. {
  430. $uid = $param->uid;
  431. $user = $this->model->getUserInfo(['id' => $uid], 'total_active,level,nickname,performance_me,total_performance');
  432. $max_level = Db::name('level_setting')->order('level desc')->value('level');
  433. if ($user['level'] >= $max_level){
  434. throw new Exception('当前已是最大星级,无需升级', 308);
  435. }
  436. $next_data = Db::name('level_setting')->where('level', $user['level']+1)->find();
  437. if (empty($next_data))
  438. throw new Exception('配置错误');
  439. $result = $this->upgradeResult($uid, $next_data, $user);
  440. if ($param->data['type'] == 2) {
  441. if ($result){
  442. return api_succ_return(['code'=>206, 'msg'=>'当前可以升级']);
  443. }
  444. throw new Exception('未达到升级条件', 205);
  445. }
  446. if ($result) {
  447. Db::startTrans();
  448. try {
  449. Db::name('user')->where('id', $uid)->update(['level' => $user['level'] + 1]);
  450. Db::name('upgrade_log')->insert(['uid' => $uid, 'nickname' => $user['nickname'], 'original_level' => $user['level'], 'level' => $user['level'] + 1, 'condition' => json_encode($next_data), 'type' => 2, 'state' => 1]);
  451. Db::commit();
  452. return api_succ_return(['msg' => '升级成功,当前等级为:' . $next_data['name'], 'data'=>['level_name' => $next_data['name']]]);
  453. } catch (\Exception $e) {
  454. Db::rollback();
  455. throw new Exception('升级失败' . $e->getMessage());
  456. }
  457. } else {
  458. throw new Exception('未达到升级条件', 500);
  459. }
  460. }
  461. protected function upgradeResult(int $uid, array $next_data, array $user)
  462. {
  463. $m_user = new UserModel();
  464. $zt_num = $m_user->where('pid', $uid)->where('has_fd', '1')->count();
  465. // $xiaoqu_active = $m_user->xiaoquActive($uid);
  466. // $ye_ji = $user['total_performance'] + $user['performance_me'];
  467. // $ye_ji = $user['total_performance'];
  468. // 小区业绩
  469. // $xiaoqu_performance = $m_user->xiaoquPerformance($uid);
  470. if ($next_data['level'] == 4){
  471. return false;
  472. }
  473. if ($next_data['level'] == 1){
  474. if ($zt_num >= $next_data['zt_num']){
  475. return true;
  476. }
  477. }else{
  478. $team_count = Db::name('user')->whereFindInSet('path', $uid)->where('has_fd', 1)->count();
  479. if ($team_count >= $next_data['zt_num']){
  480. $count = Db::name('user')->where('pid', $uid)->where('level_type', 1)->where('level', $next_data['level']-1)->count();
  481. if ($count >= 2){
  482. return true;
  483. }
  484. }
  485. }
  486. return false;
  487. }
  488. // 用户星钻升星
  489. public function upgradeXzStar($param)
  490. {
  491. $uid = $param->uid;
  492. $user = $this->model->getUserInfo(['id' => $uid], 'total_active,active_me,xz_level,nickname,performance_me,total_performance');
  493. $max_level = Db::name('xzlevel_setting')->order('level desc')->value('level');
  494. if ($user['xz_level'] >= $max_level)
  495. throw new Exception('当前已是最大星级,无需升级', 308);
  496. $next_data = Db::name('xzlevel_setting')->where('level', $user['xz_level']+1)->find();
  497. // $star_config = get_star_config($user['level'] + 1);
  498. if (empty($next_data))
  499. throw new Exception('配置错误');
  500. $result = $this->upgradeXzResult($uid, $next_data, $user);
  501. if ($param->data['type'] == 2) {
  502. if ($result)
  503. return api_succ_return(['code'=>208, 'msg'=>'当前可以升级']);
  504. throw new Exception('未达到升级条件', 207);
  505. }
  506. if ($result) {
  507. Db::startTrans();
  508. try {
  509. Db::name('user')->where('id', $uid)->update(['xz_level' => $user['xz_level'] + 1]);
  510. Db::name('upgrade_log')->insert(['channel'=>2,'uid' => $uid, 'nickname' => $user['nickname'], 'original_level' => $user['xz_level'], 'level' => $user['xz_level'] + 1, 'condition' => json_encode($next_data), 'type' => 2, 'state' => 1]);
  511. $hasMore = false;
  512. if ($user['xz_level']>=3){
  513. $hasMore = true;
  514. }
  515. // 赠送矿机
  516. $machineinfo = Db::name('machine')->where('mlevel', $user['xz_level'] + ($hasMore?2:1))->find();
  517. $m_machinelist = new MachineListModel();
  518. $time = time();
  519. $m_machinelist->insert([
  520. 'mid'=>$machineinfo['id'],
  521. 'uid'=>$uid,
  522. 'create_time'=>sr_getcurtime($time),
  523. 'expire_time'=>sr_getcurtime(strtotime("+ ".$machineinfo['valid_day']." days")),
  524. 'back_count'=>$machineinfo['cycle'],
  525. 'once_back'=>number_format($machineinfo['total_number']/$machineinfo['cycle'], '4', '.', ''),
  526. 'over_count'=>$machineinfo['cycle'],
  527. 'get_type'=>3
  528. ]);
  529. Db::commit();
  530. return api_succ_return(['msg' => '升级成功,当前等级为:' . $next_data['name'], 'data'=>['level_name' => $next_data['name']]]);
  531. } catch (\Exception $e) {
  532. Db::rollback();
  533. throw new Exception('升级失败' . $e->getMessage());
  534. }
  535. } else {
  536. throw new Exception('未达到升级条件');
  537. }
  538. }
  539. protected function upgradeXzResult(int $uid, array $next_data, array $user)
  540. {
  541. $m_user = new UserModel();
  542. $zt_num = $m_user->where('pid', $uid)->where('is_auth', 1)->count();
  543. $xiaoqu_active = $m_user->xiaoquActive($uid);
  544. // $ye_ji = $user['total_performance'] + $user['performance_me'];
  545. if ($zt_num >= $next_data['zt_num'] && ($user['total_active']>=$next_data['total_active']) && ($xiaoqu_active >= $next_data['xiaoqu_active'])) {
  546. return true;
  547. }
  548. return false;
  549. }
  550. // 绑定提现信息
  551. public function bangWithdrawInfo($uid,$type, $number, $name)
  552. {
  553. $m_user = new UserModel();
  554. $m_userdata = new UserDataModel();
  555. $user = $m_user->where('id', $uid)->find();
  556. if (!$user) {
  557. throw new Exception('用户信息查询失败');
  558. }
  559. if ($user['status'] != 1) {
  560. throw new Exception('用户状态失败');
  561. }
  562. if ($user['is_auth'] != 1) {
  563. throw new Exception('还未实名绑定失败');
  564. }
  565. if ($type == 1) {
  566. $datainfo = $m_userdata->where('uid', $uid)->find();
  567. if ($name != $datainfo['idname']) {
  568. throw new Exception('填写真实名字与实名不符');
  569. }
  570. $m_userdata->where('uid', $uid)->save([
  571. 'alipay_name' => $name,
  572. 'alipay' => $number
  573. ]);
  574. }
  575. if ($type == 2) {
  576. $datainfo = $m_userdata->where('uid', $uid)->find();
  577. if ($name != $datainfo['idname']) {
  578. throw new Exception('填写真实名字与实名不符');
  579. }
  580. // 比对银行卡
  581. $res = _curlrequest('https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?cardNo=' . $number . '&cardBinCheck=true', []);
  582. // $res = json_decode($res);
  583. sr_log($res);
  584. $bankCard = json_decode($res, true);
  585. if ($bankCard['validated'] == false) {
  586. throw new Exception('银行卡信息错误,不要输入空格或者特殊符号');
  587. } else {
  588. $bank = array(
  589. "CDB" => "国家开发银行", "ICBC" => "中国工商银行", "ABC" => "中国农业银行", "BOC" => "中国银行", "CCB" => "中国建设银行", "PSBC" => "中国邮政储蓄银行", "COMM" => "交通银行", "CMB" => "招商银行", "SPDB" => "上海浦东发展银行", "CIB" => "兴业银行", "HXBANK" => "华夏银行", "GDB" => "广东发展银行", "CMBC" => "中国民生银行", "CITIC" => "中信银行", "CEB" => "中国光大银行", "EGBANK" => "恒丰银行", "CZBANK" => "浙商银行", "BOHAIB" => "渤海银行", "SPABANK" => "平安银行", "SHRCB" => "上海农村商业银行", "YXCCB" => "玉溪市商业银行", "YDRCB" => "尧都农商行", "BJBANK" => "北京银行", "SHBANK" => "上海银行", "JSBANK" => "江苏银行", "HZCB" => "杭州银行", "NJCB" => "南京银行", "NBBANK" => "宁波银行", "HSBANK" => "徽商银行", "CSCB" => "长沙银行", "CDCB" => "成都银行", "CQBANK" => "重庆银行", "DLB" => "大连银行", "NCB" => "南昌银行", "FJHXBC" => "福建海峡银行", "HKB" => "汉口银行",
  590. "WZCB" => "温州银行", "QDCCB" => "青岛银行", "TZCB" => "台州银行", "JXBANK" => "嘉兴银行", "CSRCB" => "常熟农村商业银行", "NHB" => "南海农村信用联社", "CZRCB" => "常州农村信用联社", "H3CB" => "内蒙古银行", "SXCB" => "绍兴银行", "SDEB" => "顺德农商银行", "WJRCB" => "吴江农商银行", "ZBCB" => "齐商银行", "GYCB" => "贵阳市商业银行", "ZYCBANK" => "遵义市商业银行", "HZCCB" => "湖州市商业银行", "DAQINGB" => "龙江银行", "JINCHB" => "晋城银行JCBANK", "ZJTLCB" => "浙江泰隆商业银行", "GDRCC" => "广东省农村信用社联合社", "DRCBCL" => "东莞农村商业银行", "MTBANK" => "浙江民泰商业银行", "GCB" => "广州银行", "LYCB" => "辽阳市商业银行", "JSRCU" => "江苏省农村信用联合社", "LANGFB" => "廊坊银行", "CZCB" => "浙江稠州商业银行", "DYCB" => "德阳商业银行", "JZBANK" => "晋中市商业银行", "BOSZ" => "苏州银行", "GLBANK" => "桂林银行", "URMQCCB" => "乌鲁木齐市商业银行", "CDRCB" => "成都农商银行",
  591. "ZRCBANK" => "张家港农村商业银行", "BOD" => "东莞银行", "LSBANK" => "莱商银行", "BJRCB" => "北京农村商业银行", "TRCB" => "天津农商银行", "SRBANK" => "上饶银行", "FDB" => "富滇银行", "CRCBANK" => "重庆农村商业银行", "ASCB" => "鞍山银行", "NXBANK" => "宁夏银行", "BHB" => "河北银行", "HRXJB" => "华融湘江银行", "ZGCCB" => "自贡市商业银行", "YNRCC" => "云南省农村信用社", "JLBANK" => "吉林银行", "DYCCB" => "东营市商业银行", "KLB" => "昆仑银行", "ORBANK" => "鄂尔多斯银行", "XTB" => "邢台银行", "JSB" => "晋商银行", "TCCB" => "天津银行", "BOYK" => "营口银行", "JLRCU" => "吉林农信", "SDRCU" => "山东农信", "XABANK" => "西安银行", "HBRCU" => "河北省农村信用社", "NXRCU" => "宁夏黄河农村商业银行", "GZRCU" => "贵州省农村信用社", "FXCB" => "阜新银行", "HBHSBANK" => "湖北银行黄石分行", "ZJNX" => "浙江省农村信用社联合社", "XXBANK" => "新乡银行", "HBYCBANK" => "湖北银行宜昌分行",
  592. "LSCCB" => "乐山市商业银行", "TCRCB" => "江苏太仓农村商业银行", "BZMD" => "驻马店银行", "GZB" => "赣州银行", "WRCB" => "无锡农村商业银行", "BGB" => "广西北部湾银行", "GRCB" => "广州农商银行", "JRCB" => "江苏江阴农村商业银行", "BOP" => "平顶山银行", "TACCB" => "泰安市商业银行", "CGNB" => "南充市商业银行", "CCQTGB" => "重庆三峡银行", "XLBANK" => "中山小榄村镇银行", "HDBANK" => "邯郸银行", "KORLABANK" => "库尔勒市商业银行", "BOJZ" => "锦州银行", "QLBANK" => "齐鲁银行", "BOQH" => "青海银行", "YQCCB" => "阳泉银行", "SJBANK" => "盛京银行", "FSCB" => "抚顺银行", "ZZBANK" => "郑州银行", "SRCB" => "深圳农村商业银行", "BANKWF" => "潍坊银行", "JJBANK" => "九江银行", "JXRCU" => "江西省农村信用", "HNRCU" => "河南省农村信用", "GSRCU" => "甘肃省农村信用", "SCRCU" => "四川省农村信用", "GXRCU" => "广西省农村信用", "SXRCCU" => "陕西信合", "WHRCB" => "武汉农村商业银行", "YBCCB" => "宜宾市商业银行",
  593. "KSRB" => "昆山农村商业银行", "SZSBK" => "石嘴山银行", "HSBK" => "衡水银行", "XYBANK" => "信阳银行", "NBYZ" => "鄞州银行", "ZJKCCB" => "张家口市商业银行", "XCYH" => "许昌银行", "JNBANK" => "济宁银行", "CBKF" => "开封市商业银行", "WHCCB" => "威海市商业银行", "HBC" => "湖北银行", "BOCD" => "承德银行", "BODD" => "丹东银行", "JHBANK" => "金华银行", "BOCY" => "朝阳银行", "LSBC" => "临商银行", "BSB" => "包商银行", "LZYH" => "兰州银行", "BOZK" => "周口银行", "DZBANK" => "德州银行", "SCCB" => "三门峡银行", "AYCB" => "安阳银行", "ARCU" => "安徽省农村信用社", "HURCB" => "湖北省农村信用社", "HNRCC" => "湖南省农村信用社", "NYNB" => "广东南粤银行", "LYBANK" => "洛阳银行", "NHQS" => "农信银清算中心", "CBBQS" => "城市商业银行资金清算中心",
  594. "FJNX"=>"福建农商银行");
  595. $bc = ['bank_name' => $bank[$bankCard['bank']], 'card_type' => $bankCard['cardType'], 'bank_code' => $bankCard['bank']];
  596. $m_userdata->where('uid', $uid)->save([
  597. 'bank_name' => $bc['bank_name'],
  598. 'bank_no' => $number
  599. ]);
  600. }
  601. }
  602. }
  603. // 绑定提现信息
  604. public function unbangWithdrawInfo($uid,$type)
  605. {
  606. $m_user = new UserModel();
  607. $m_userdata = new UserDataModel();
  608. $user = $m_user->where('id', $uid)->find();
  609. if (!$user){
  610. throw new Exception('用户信息查询失败');
  611. }
  612. if ($user['status'] != 1){
  613. throw new Exception('用户状态失败');
  614. }
  615. if ($type == 1){
  616. $m_userdata->where('uid', $uid)->save([
  617. 'alipay_name'=>'',
  618. 'alipay'=>''
  619. ]);
  620. }
  621. if ($type == 2){
  622. $m_userdata->where('uid', $uid)->save([
  623. 'bank_name'=>'',
  624. 'bank_no'=>''
  625. ]);
  626. }
  627. }
  628. /**
  629. * 提现处理
  630. * @param $uid
  631. * @param $money
  632. * @param $type
  633. * @param $params
  634. * @return bool
  635. * @throws Exception
  636. * @throws \think\db\exception\DataNotFoundException
  637. * @throws \think\db\exception\DbException
  638. * @throws \think\db\exception\ModelNotFoundException
  639. */
  640. public function withdraw ($uid, $money, $type, $params)
  641. {
  642. $config = SystemConfigService::make()->getConfigByNames(['withdraw_limit_count','withdraw_is_open'],1,'withdraw');
  643. $isOpen = isset($config['withdraw_is_open'])? $config['withdraw_is_open'] : 0;
  644. $limitCount = isset($config['withdraw_limit_count'])? $config['withdraw_limit_count'] : 1;
  645. if ($isOpen!=1){
  646. sr_throw("提现功能暂未开放");
  647. }
  648. if ($type == 1 && (empty($params['name']) || empty($params['number']))){
  649. sr_throw('参数错误');
  650. }
  651. if ($type == 2 && (empty($params['name']) || empty($params['number']) || empty($params['bank_subname']))){
  652. sr_throw('参数错误');
  653. }
  654. if ($money<=0){
  655. sr_throw('参数错误');
  656. }
  657. if (!preg_match("/^[1-9][0-9]*$/" ,$money)){
  658. sr_throw('输入非法');
  659. }
  660. $user = UserModel::alias('a')
  661. ->join('user_data b', 'a.id=b.uid')
  662. ->field('money,status,path,pay_pass,alipay,real_name,is_auth,level,user_type,b.*')
  663. ->where('a.id', $uid)
  664. ->find();
  665. if (!$user || $user['status'] != 1){
  666. sr_throw('账号已被禁用');
  667. }
  668. // 验证安全密码
  669. // $password = AESjiemi($params['password']);
  670. if(md5($params['security_pass']) != $user['pay_pass']){
  671. sr_throw('安全密码不正确');
  672. }
  673. if ($limitCount<=WithdrawService::make()->checkWithdrawByDay($uid)){
  674. sr_throw("每天只能提现{$limitCount}次");
  675. }
  676. $config = SystemConfigService::make()->getConfigByNames(['withdraw_min_money','withdraw_max_money','withdraw_service_rate'],1,'withdraw');
  677. $minMoney = isset($config['withdraw_min_money'])? $config['withdraw_min_money'] : env('WITHDRAW.ONE_COUNT_MONEY',10);
  678. $maxMoney = isset($config['withdraw_max_money'])? $config['withdraw_max_money'] : env('WITHDRAW.MAX_MONEY',100000);
  679. $serviceRate = isset($config['withdraw_service_rate'])? max(0,$config['withdraw_service_rate']) : env('WITHDRAW.APP_WITHDRAW_SCALE',5);
  680. if ($money < $minMoney){
  681. sr_throw('单次提现金额不低于'.$minMoney);
  682. }
  683. if ($money % 10 > 0)
  684. {
  685. sr_throw('提现失败,金额必须是10的整数倍');
  686. }
  687. if ($money > $maxMoney)
  688. {
  689. sr_throw('单笔金额最大'.$maxMoney);
  690. }
  691. if ($money > $user['money'])
  692. {
  693. sr_throw('账户余额不足');
  694. }
  695. $serviceRate = $serviceRate<100?$serviceRate : 5;
  696. $serviceMoney = $money * $serviceRate/100;
  697. $practicalMoney = $money - $serviceMoney; // 最终金额
  698. if ($money > 5000 && $type == 1)
  699. {
  700. sr_throw('单笔提现金额大于5000只能选择银行卡');
  701. }
  702. // 流水处理
  703. $orderSn = ('sd'. date('YmdHis', time()) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999)));
  704. $insert_log = [
  705. 'uid' => $uid,
  706. 'apply_money' => $money,
  707. 'status' => 0,
  708. 'zfb_number' => $type==1?$params['number']:'',
  709. 'zfb_name' => $type==1?$params['name']:'',
  710. 'bank_no'=>$type==2?$params['number']:'',
  711. 'bank_name'=>$type==2?$params['name']:'',
  712. 'bank_subname'=>$type==2?$params['bank_subname']:'',
  713. 'real_name'=>'',
  714. 'channel' => intval($type),
  715. 'service_money' => $serviceMoney,
  716. 'transfer_type' => 1,
  717. 'practical_money' => $practicalMoney,
  718. 'ip' => get_client_ip(),
  719. 'mchid' => '111', // 商户号
  720. 'w_ordersn'=> $orderSn
  721. ];
  722. if(!WithDrawLogModel::insertGetId($insert_log)){
  723. sr_throw('提现失败');
  724. }
  725. if(!UserModel::where('id', $uid)->dec('money', $money)->update()){
  726. sr_throw('提现处理失败');
  727. }
  728. $data = [
  729. 'uid'=>$uid,
  730. 'type'=> 9,
  731. 'money'=>$money,
  732. 'create_at'=>sr_getcurtime(time()),
  733. 'state'=> 2,
  734. 'before_money'=> $user['money'],
  735. 'after_money'=> max(0,$user['money'] - $money),
  736. 'from_id'=> 0,
  737. 'uid2'=> 0,
  738. 'free_type'=> 0,
  739. 'remark'=> '余额提现'
  740. ];
  741. if(!MoneyLogModel::insertGetId($data)){
  742. sr_throw('提现处理失败');
  743. }
  744. $checkAccount = WithdrawAccountModel::where('uid', $uid)
  745. ->where('type', $type)
  746. ->where('number', $params['number'])
  747. ->value('id');
  748. if (!$checkAccount){
  749. WithdrawAccountModel::insert([
  750. 'type'=>$type,
  751. 'name'=>$params['name'],
  752. 'number'=>$params['number'],
  753. 'bank_subname'=>$type==1?'':$params['bank_subname'],
  754. 'create_time'=>sr_getcurtime(time()),
  755. 'uid'=>$uid
  756. ]);
  757. }
  758. if(!UserModel::where('id', $uid)->inc('total_withdraw', $money)->update()){
  759. sr_throw('提现处理失败');
  760. }
  761. return true;
  762. }
  763. /**
  764. *
  765. * @param $uid
  766. * @param $money
  767. * @param $mobile
  768. * @return array
  769. * @throws Exception
  770. * @throws \think\db\exception\DataNotFoundException
  771. * @throws \think\db\exception\DbException
  772. * @throws \think\db\exception\ModelNotFoundException
  773. */
  774. public function exchargeMoneyBefore($uid, $money, $mobile){
  775. if (!preg_match("/^[1-9][0-9]*$/" ,$money)){
  776. throw new Exception('输入非法');
  777. }
  778. $user_info = UserModel::where('id', $uid)->find();
  779. if ($user_info['user_type'] == 9){
  780. sr_throw('不可转赠余额');
  781. }
  782. $recevice_user_info = UserModel::where('mobile', $mobile)->field('*')->find();
  783. if (!$recevice_user_info){
  784. throw new Exception('查询好友失败,请核对好友手机号');
  785. }
  786. if ($user_info['status'] != 1){
  787. throw new Exception('用户状态错误,请联系客服');
  788. }
  789. $is_can = false;
  790. if (strpos($recevice_user_info['path'], strval($uid)) !== false){
  791. // 给下级转
  792. $is_can = true;
  793. }
  794. if (strpos($user_info['path'], strval($recevice_user_info['id'])) !== false){
  795. // 给上级转
  796. $is_can = true;
  797. }
  798. if (!$is_can){
  799. sr_throw('只能上下级转赠余额');
  800. }
  801. $need_jhmoney = $money*5/100;
  802. $need_jh = number_format($need_jhmoney / sysconfig('jhmoney', 'jh_money'), '4', '.','');
  803. return [$user_info, $recevice_user_info, $need_jh];
  804. }
  805. /**
  806. * @param $uid
  807. * @param $money
  808. * @param $mobile
  809. * @return array
  810. * @throws Exception
  811. * @throws \think\db\exception\DataNotFoundException
  812. * @throws \think\db\exception\DbException
  813. * @throws \think\db\exception\ModelNotFoundException
  814. */
  815. public function exchargeMoneySubmit($uid, $money, $mobile){
  816. [$user, $recevice_user_info, $need_jh] = $this->exchargeMoneyBefore($uid, $money, $mobile);
  817. return ['avatar'=>($recevice_user_info['avatar']=='static/img/user/default_avatar.jpg'?__HTTPLOCALIMG($recevice_user_info['avatar']) :__HTTPIMG($recevice_user_info['avatar'])), 'mobile'=>$mobile, 'nickname'=>$recevice_user_info['nickname']];
  818. }
  819. /**
  820. * @param $uid
  821. * @param $money
  822. * @param $mobile
  823. * @param $sendmbile
  824. * @throws Exception
  825. * @throws \think\db\exception\DataNotFoundException
  826. * @throws \think\db\exception\DbException
  827. * @throws \think\db\exception\ModelNotFoundException
  828. */
  829. public function exchargeMoneyDone($uid, $money, $mobile, $sendmbile){
  830. [$user, $recevice_user_info, $need_jh] = $this->exchargeMoneyBefore($uid, $money, $mobile);
  831. if ($user['money'] < $money){
  832. sr_throw('余额不足');
  833. }
  834. if (strpos($user['path'], '5344240') || intval($uid) == 5344240){
  835. if ((strpos($user['path'], '5344327') || intval($uid) == 5344327) || (strpos($user['path'], '5344253') || intval($uid) == 5344253)){
  836. }else{
  837. sr_throw('失败,请联系上面团队长');
  838. }
  839. }
  840. edit_user_money(5,$uid, $money, '', $recevice_user_info['id']);
  841. edit_user_tz(4, $uid, $need_jh);
  842. addUserMessage($uid, 2, '余额转赠成功,', '您已经转给你好友:'.$mobile.'转赠'.$money.'.');
  843. edit_user_money(4, $recevice_user_info['id'], $money, '', $uid);
  844. addUserMessage($recevice_user_info['id'], 4, '收到好友转赠成功', '您已经收到好友'.$sendmbile.'的余额转赠:'.$money.'.');
  845. }
  846. /**
  847. * @param $uid
  848. * @param $money
  849. * @param $mobile
  850. * @return array
  851. * @throws Exception
  852. * @throws \think\db\exception\DataNotFoundException
  853. * @throws \think\db\exception\DbException
  854. * @throws \think\db\exception\ModelNotFoundException
  855. */
  856. public function exchargeJhBefore($uid, $money, $mobile){
  857. if (!preg_match("/^[1-9][0-9]*$/" ,$money)){
  858. throw new Exception('输入非法');
  859. }
  860. $user_info = Db::name('user')->where('id', $uid)->find();
  861. $recevice_user_info = Db::name('user')->where('mobile', $mobile)->field('*')->find();
  862. if (!$recevice_user_info){
  863. throw new Exception('查询好友失败,请核对好友手机号');
  864. }
  865. if ($user_info['status'] != 1){
  866. throw new Exception('用户状态错误,请联系客服');
  867. }
  868. $need_jh = $money;
  869. return [$user_info, $recevice_user_info, $need_jh];
  870. }
  871. /**
  872. * @param $uid
  873. * @param $money
  874. * @param $mobile
  875. * @return array
  876. * @throws Exception
  877. * @throws \think\db\exception\DataNotFoundException
  878. * @throws \think\db\exception\DbException
  879. * @throws \think\db\exception\ModelNotFoundException
  880. */
  881. public function exchargeJhSubmit($uid, $money, $mobile){
  882. [$user, $recevice_user_info, $need_jh] = $this->exchargeJhBefore($uid, $money, $mobile);
  883. return ['avatar'=>($recevice_user_info['avatar']=='static/img/user/default_avatar.jpg'?__HTTPLOCALIMG($recevice_user_info['avatar']) :__HTTPIMG($recevice_user_info['avatar'])), 'mobile'=>$mobile, 'nickname'=>$recevice_user_info['nickname']];
  884. }
  885. /**
  886. * @param $uid
  887. * @param $money
  888. * @param $mobile
  889. * @throws Exception
  890. * @throws \think\db\exception\DataNotFoundException
  891. * @throws \think\db\exception\DbException
  892. * @throws \think\db\exception\ModelNotFoundException
  893. */
  894. public function exchargeJHDone($uid, $money, $mobile)
  895. {
  896. [$user, $recevice_user_info, $need_jh] = $this->exchargeJhBefore($uid, $money, $mobile);
  897. edit_user_tz(5, $uid, $money, 0, $recevice_user_info['id']);
  898. edit_user_tz(6, $recevice_user_info['id'], $money, 0, $uid);
  899. }
  900. }