User.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\CoinRate;
  5. use app\common\library\Ems;
  6. use app\common\library\Sms;
  7. use app\common\model\Config;
  8. use think\Db;
  9. use function EasyWeChat\Payment\get_server_ip;
  10. use fast\Random;
  11. use think\Validate;
  12. /**
  13. * 会员接口
  14. */
  15. class User extends Api
  16. {
  17. protected $noNeedLogin = ['login', 'syslogin', 'register', 'findpwd', 'sendMsg', 'mobilelogin', 'resetpwd', 'changeemail', 'changemobile', 'third'];
  18. protected $noNeedRight = '*';
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. }
  23. function syslogin()
  24. {
  25. $id = input('uid');
  26. //直接登录会员
  27. $re = $this->auth->direct($id);
  28. if ($re) {
  29. echo ' <script language="javascript">
  30. window.location.href="/index/index/index";
  31. </script>';
  32. }
  33. }
  34. function sendMsg()
  35. {
  36. if ((time() - session('sendSmsTime')) < 30) {
  37. $this->error('30秒内不能重复发送');
  38. }
  39. $verify=input('verify');
  40. if(empty($verify))
  41. {
  42. $this->error('请输入验证码');
  43. }
  44. if(!captcha_check($verify)){
  45. // 验证失败
  46. $this->error('验证码输入有误');
  47. };
  48. $mobile = input('mobile');
  49. //生成验证码世界名河
  50. $code = randnumber(4);
  51. $content="【轻奢名品汇】你的短信验证码:".$code;
  52. $result=sendmsg($mobile,$content);
  53. if ($result['returnstatus'] == 'Success') {
  54. session('reg_verify', md5($code, $mobile));
  55. session('mobileVerify', $code);
  56. session('sendSmsTime', time());
  57. $this->success('短信已发送成功,请耐心等待~');
  58. } else {
  59. $this->error('发送失败!'.$result['message']);
  60. }
  61. }
  62. /**
  63. * 会员中心
  64. */
  65. public function index()
  66. {
  67. $this->success('', ['welcome' => $this->auth->nickname]);
  68. }
  69. /**
  70. * 会员登录
  71. *
  72. * @param string $account 账号
  73. * @param string $password 密码
  74. */
  75. public function login()
  76. {
  77. $account = $this->request->request('account');
  78. $password = $this->request->request('password');
  79. if (!$account || !$password) {
  80. $this->error(__('Invalid parameters'));
  81. }
  82. $ret = $this->auth->login($account, $password);
  83. if ($ret) {
  84. $data = ['userinfo' => $this->auth->getUserinfo()];
  85. $this->success(__('Logged in successful'), $data);
  86. } else {
  87. $this->error($this->auth->getError());
  88. }
  89. }
  90. /**
  91. * 手机验证码登录
  92. *
  93. * @param string $mobile 手机号
  94. * @param string $captcha 验证码
  95. */
  96. public function mobilelogin()
  97. {
  98. $mobile = $this->request->request('mobile');
  99. $captcha = $this->request->request('captcha');
  100. if (!$mobile || !$captcha) {
  101. $this->error(__('Invalid parameters'));
  102. }
  103. if (!Validate::regex($mobile, "^1\d{10}$")) {
  104. $this->error(__('Mobile is incorrect'));
  105. }
  106. if (!Sms::check($mobile, $captcha, 'mobilelogin')) {
  107. $this->error(__('Captcha is incorrect'));
  108. }
  109. $user = \app\common\model\User::getByMobile($mobile);
  110. if ($user) {
  111. if ($user->status != 1) {
  112. $this->error(__('Account is locked'));
  113. }
  114. //如果已经有账号则直接登录
  115. $ret = $this->auth->direct($user->id);
  116. } else {
  117. $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
  118. }
  119. if ($ret) {
  120. Sms::flush($mobile, 'mobilelogin');
  121. $data = ['userinfo' => $this->auth->getUserinfo()];
  122. $this->success(__('Logged in successful'), $data);
  123. } else {
  124. $this->error($this->auth->getError());
  125. }
  126. }
  127. /* 找回密码 */
  128. function findpwd()
  129. {
  130. $param = $this->request->post();
  131. if (empty($param['mobile'])) {
  132. $this->error(__('请填写手机号'));
  133. }
  134. // if (empty($param['verify'])) {
  135. // $this->error(__('请填写验证码'));
  136. // }
  137. // if($param['verify'] != config('site')['verify_code'])
  138. // {
  139. // if (md5($param['verify'], $param['mobile']) != session('reg_verify')) {
  140. // $this->error(__('验证码输入有误'));
  141. // }
  142. // if ($param['verify'] != session('mobileVerify')) {
  143. // $this->error(__('验证码输入有误'));
  144. // }
  145. // }
  146. $usernameinfo = db('user')->where([ 'mobile' => $param['mobile']])->find();
  147. if (empty($usernameinfo)) {
  148. $this->error(__('请输入的手机号未注册'));
  149. }
  150. $data['password'] = getEncryptPassword($param['password'], $usernameinfo['salt']);
  151. $res = db('user')->where('id', $usernameinfo['id'])->update($data);
  152. if ($res) {
  153. $this->success(__("修改成功"));
  154. } else {
  155. $this->error(__("修改失败"));
  156. }
  157. }
  158. /**
  159. * 注册会员
  160. *
  161. * @param string $username 用户名
  162. * @param string $password 密码
  163. * @param string $email 邮箱
  164. * @param string $mobile 手机号
  165. * @param string $code 验证码
  166. */
  167. function register()
  168. {
  169. $param = $this->request->post();
  170. if (empty($param['mobile'])) {
  171. $this->error(__('请填写手机号'));
  172. }else{
  173. $mob=db('user')->where(['mobile'=>$param['mobile']])->count();
  174. if($mob>0)
  175. {
  176. $this->error('手机号已注册,请更换');
  177. }
  178. }
  179. // if (empty($param['verify'])) {
  180. // $this->error(__('请填写验证码'));
  181. // }
  182. // if($param['verify'] != config('site')['verify_code'])
  183. // {
  184. // if (md5($param['verify'], $param['mobile']) != session('reg_verify')) {
  185. // $this->error(__('验证码输入有误'));
  186. // }
  187. // if ($param['verify'] != session('mobileVerify')) {
  188. // $this->error(__('验证码输入有误'));
  189. // }
  190. // }
  191. $param['username']=str_shuffle(substr(str_shuffle('abcdefghijklmnopqrstuvwxyz1234567890'),0,6));
  192. if (empty($param['username'])) {
  193. $this->error(__('请填写会员账号'));
  194. } else {
  195. $usernameinfo = db('user')->where('username', $param['username'])->find();
  196. if ($usernameinfo) {
  197. $this->error(__('此用户名已注册,请更换'));
  198. }
  199. $reg1='/^[A-Za-z0-9]+$/';
  200. if(!preg_match($reg1,$param['username']))
  201. {
  202. $this->error('账户只能由字母数字组成');
  203. }
  204. if(strlen($param['username'])>8)
  205. {
  206. $this->error('登录账户不能超过8个字符');
  207. }
  208. }
  209. if(empty($param['nickname'])){
  210. $this->error('请填写用户昵称');
  211. }
  212. if(strlen($param['nickname'])<2){
  213. $this->error('昵称至少2个字符');
  214. }
  215. $param['nickname']=$param['nickname']? $param['nickname'] : $param['mobile'];
  216. if (empty($param['password'])) {
  217. $this->error(__('请填写登录密码'));
  218. }
  219. if (empty($param['password2'])) {
  220. $this->error(__('请填写支付密码'));
  221. }
  222. $data = [
  223. 'username' => $param['username'],
  224. 'nickname' => $param['nickname'],
  225. 'email' => '',
  226. 'mobile' => $param['mobile'],
  227. 'level' => 0,
  228. 'salt' => Random::alnum(),
  229. 'createtime' => time(),
  230. 'joinip' => request()->ip(),
  231. 'status' => '1',
  232. ];
  233. $data['password'] = getEncryptPassword($param['password'], $data['salt']);
  234. $data['password2'] = getEncryptPassword($param['password2'], $data['salt']);
  235. $referee = db('user')->where(['username' => $param['referee'], 'status' => 1])->find();
  236. if ($referee) {
  237. $data['refereeid'] = $referee['id'];
  238. $data['referee_name'] = $referee['username'];
  239. $data['refereeids'] = $referee['refereeids']. $referee['id'] . ',' ;
  240. $data['tdeep'] = $referee['tdeep'] + 1;
  241. } else {
  242. $this->error(__('推荐人不可用或输入的推荐编号有误'));
  243. }
  244. $ids = db('user')->insertGetId($data);
  245. if ($ids) {
  246. db('user')->where('id', $data['refereeid'])->setInc('referee_number', 1);
  247. $this->success(__("注册成功"));
  248. } else {
  249. $this->error(__("注册失败"));
  250. }
  251. }
  252. /**
  253. * 注销登录
  254. */
  255. public function logout()
  256. {
  257. $this->auth->logout();
  258. $this->success(__('Logout successful'));
  259. }
  260. function getdetailed()
  261. {
  262. $type = $this->request->post('type');
  263. if ($type == 'all') {
  264. } elseif ($type == 'shop') {
  265. $map['type'] = ['in', '16,17,18'];
  266. } elseif ($type == 'jt') {
  267. $map['type'] = 19;
  268. }
  269. $group = $this->request->post('group');
  270. $map['userid'] = $this->auth->id;
  271. $p = $this->request->post('p');
  272. $data_list = db('detailed' . ucfirst($group))->where($map)->page($p, 15)->order("id desc")->select();
  273. foreach ($data_list as $k => $v) {
  274. $data_list[$k]['money'] = $v['money'] > 0 ? '+' . $v['money'] : $v['money'];
  275. $data_list[$k]['times'] = date("Y-m-d H:i:s", $v['create_time']);
  276. $data_list[$k]['type'] = __(get_detailed_type_text($v['type']));
  277. }
  278. if ($data_list) {
  279. $return['data'] = $data_list;
  280. } else {
  281. $return['data'] = null;
  282. }
  283. $count = db('detailed' . ucfirst($group))->where($map)->count();
  284. $return['total'] = ceil($count / 15);
  285. return $return;
  286. }
  287. function getdetailed2()
  288. {
  289. $type = $this->request->post('type');
  290. if ($type) {
  291. $map['type'] = $type;
  292. }
  293. $group = $this->request->post('group');
  294. $map['userid'] = $this->auth->id;
  295. $p = $this->request->post('p');
  296. $data_list = db('detailed' . ucfirst($group))->where($map)->page($p, 10)->order("id desc")->select();
  297. foreach ($data_list as $k => $v) {
  298. $data_list[$k]['money'] = $v['money'] > 0 ? '+' . $v['money'] : $v['money'];
  299. $data_list[$k]['times'] = date("Y-m-d H:i:s", $v['create_time']);
  300. $data_list[$k]['type'] = __(get_detailed_type_text($v['type']));
  301. }
  302. if ($data_list) {
  303. $return['data'] = $data_list;
  304. } else {
  305. $return['data'] = null;
  306. }
  307. $count = db('detailed' . ucfirst($group))->where($map)->count();
  308. $return['total'] = ceil($count / 10);
  309. return $return;
  310. }
  311. /* 记录 */
  312. function teamwithdrawdetaile()
  313. {
  314. $stuid=get_user_data($this->auth->id,'stuid');
  315. $map['a.stuid'] = $stuid;
  316. $p = $this->request->post('p');
  317. $map['a.money_type'] = $this->request->post('money_type');
  318. $data_list = db('withdrawals')->alias('a')
  319. ->join('user b','b.id=a.userid','left')
  320. ->where($map)
  321. ->where(function($query){
  322. $datetime = strtotime(date('Y-m-d'));
  323. $query->where("process_status=1 or (process_status in (2,3) and withdraw_date>={$datetime})");
  324. })
  325. ->field('a.*,b.mobile,b.nickname')
  326. ->page($p, 10)
  327. ->order("a.process_status asc,a.id desc")->select();
  328. foreach ($data_list as $k => $v) {
  329. $data_list[$k]['times'] = date("Y-m-d H:i", $v['withdraw_date']);
  330. $data_list[$k]['click'] = 'onclick="review(\'' . $v['remark'] . '\')"';
  331. $data_list[$k]['payment'] = $v['name'].' '.($v['prc']? '<img src="'.$v['prc'].'" style="width: 80px;height: 80px;">' : '');
  332. }
  333. if ($data_list) {
  334. $return['data'] = $data_list;
  335. } else {
  336. $return['data'] = null;
  337. }
  338. $count = db('withdrawals')->alias('a')
  339. ->join('user b','b.id=a.userid','left')
  340. ->where($map)->count();
  341. $return['total'] = ceil($count / 10);
  342. return $return;
  343. }
  344. function toviewwithdraw()
  345. {
  346. $ids = $this->request->post('id');
  347. $type=$this->request->post('type');
  348. $info=db('withdrawals')->where(['id'=>$ids,'process_status'=>1])->find();
  349. if(!$info)
  350. {
  351. $this->error("信息不存在,或已审核");
  352. }
  353. if($type == 1)
  354. {
  355. $res=db('withdrawals')->where(array('id'=>$ids))->update(['process_status'=>2,'confirm_date'=>time()]);
  356. if($res)
  357. {
  358. $this->success('审核完成');
  359. }else{
  360. $this->error('审核失败');
  361. }
  362. }else{
  363. db()->startTrans();
  364. $res1=$this->model->where('id',$ids)->update(['process_status'=>-1,'confirm_date'=>time()]);
  365. $changedata=[
  366. 'type'=>5,
  367. 'money'=>$info['amount'],
  368. 'userid'=>$info['userid'],
  369. 'relevant_userid'=>-1,
  370. 'remark'=>'拒绝提现返还',
  371. ];
  372. $res=caiwu($changedata, $info['money_type']);
  373. if($res && $res1)
  374. {
  375. db()->commit();
  376. $this->success('审核完成');
  377. }else{
  378. db()->rollback();
  379. $this->error('审核失败');
  380. }
  381. }
  382. }
  383. /* 提现记录 */
  384. function withdrawdetaile()
  385. {
  386. $map['userid'] = $this->auth->id;
  387. $p = $this->request->post('p');
  388. $map['money_type'] = $this->request->post('money_type');
  389. $data_list = db('withdrawals')->where($map)->page($p, 10)->order("id desc")->select();
  390. foreach ($data_list as $k => $v) {
  391. $data_list[$k]['times'] = date("Y-m-d H:i", $v['withdraw_date']);
  392. $data_list[$k]['click'] = 'onclick="review(\'' . $v['remark'] . '\')"';
  393. }
  394. if ($data_list) {
  395. $return['data'] = $data_list;
  396. } else {
  397. $return['data'] = null;
  398. }
  399. $count = db('withdrawals')->where($map)->count();
  400. $return['total'] = ceil($count / 10);
  401. return $return;
  402. }
  403. /* 释放记录 */
  404. function releaselog()
  405. {
  406. $map['a.userid'] = $this->auth->id;
  407. $p = $this->request->post('p');
  408. if($this->request->post('type')){
  409. $map['a.type'] = $this->request->post('type');
  410. }
  411. $config = Config::getConfigByGroup('trade');
  412. $releaseRate = isset($config['release_rate'])? floatval($config['release_rate']['value']) : 0;
  413. $speedRate = isset($config['speed_rate'])? floatval($config['speed_rate']['value']) : 0;
  414. $data_list = db('release_log')->alias('a')
  415. ->join('trade t','t.id=a.orderid','left')
  416. ->where($map)
  417. ->field('a.*,t.release_total_usdt')
  418. ->page($p, 10)
  419. ->order("a.id desc")
  420. ->select();
  421. foreach ($data_list as $k => $v) {
  422. $data_list[$k]['times'] = date("Y-m-d H:i", $v['create_time']);
  423. $data_list[$k]['click'] = 'onclick="review(\'' . $v['remark'] . '\')"';
  424. $data_list[$k]['release_rate'] = $releaseRate;
  425. $data_list[$k]['speed_rate'] = $speedRate;
  426. }
  427. if ($data_list) {
  428. $return['data'] = $data_list;
  429. } else {
  430. $return['data'] = null;
  431. }
  432. $count = db('release_log')->alias('a')->where($map)->count();
  433. $return['total'] = ceil($count / 10);
  434. return $return;
  435. }
  436. /**
  437. * 修改邮箱
  438. *
  439. * @param string $email 邮箱
  440. * @param string $captcha 验证码
  441. */
  442. public function changeemail()
  443. {
  444. $user = $this->auth->getUser();
  445. $email = $this->request->post('email');
  446. $captcha = $this->request->request('captcha');
  447. if (!$email || !$captcha) {
  448. $this->error(__('Invalid parameters'));
  449. }
  450. if (!Validate::is($email, "email")) {
  451. $this->error(__('Email is incorrect'));
  452. }
  453. if (\app\common\model\User::where('email', $email)->where('id', '<>', $user->id)->find()) {
  454. $this->error(__('Email already exists'));
  455. }
  456. $result = Ems::check($email, $captcha, 'changeemail');
  457. if (!$result) {
  458. $this->error(__('Captcha is incorrect'));
  459. }
  460. $verification = $user->verification;
  461. $verification->email = 1;
  462. $user->verification = $verification;
  463. $user->email = $email;
  464. $user->save();
  465. Ems::flush($email, 'changeemail');
  466. $this->success();
  467. }
  468. /**
  469. * 修改手机号
  470. *
  471. * @param string $email 手机号
  472. * @param string $captcha 验证码
  473. */
  474. public function changemobile()
  475. {
  476. $user = $this->auth->getUser();
  477. $mobile = $this->request->request('mobile');
  478. $captcha = $this->request->request('captcha');
  479. if (!$mobile || !$captcha) {
  480. $this->error(__('Invalid parameters'));
  481. }
  482. if (!Validate::regex($mobile, "^1\d{10}$")) {
  483. $this->error(__('Mobile is incorrect'));
  484. }
  485. if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
  486. $this->error(__('Mobile already exists'));
  487. }
  488. $result = Sms::check($mobile, $captcha, 'changemobile');
  489. if (!$result) {
  490. $this->error(__('Captcha is incorrect'));
  491. }
  492. $verification = $user->verification;
  493. $verification->mobile = 1;
  494. $user->verification = $verification;
  495. $user->mobile = $mobile;
  496. $user->save();
  497. Sms::flush($mobile, 'changemobile');
  498. $this->success();
  499. }
  500. /**
  501. * 第三方登录
  502. *
  503. * @param string $platform 平台名称
  504. * @param string $code Code码
  505. */
  506. public function third()
  507. {
  508. $url = url('user/index');
  509. $platform = $this->request->request("platform");
  510. $code = $this->request->request("code");
  511. $config = get_addon_config('third');
  512. if (!$config || !isset($config[$platform])) {
  513. $this->error(__('Invalid parameters'));
  514. }
  515. $app = new \addons\third\library\Application($config);
  516. //通过code换access_token和绑定会员
  517. $result = $app->{$platform}->getUserInfo(['code' => $code]);
  518. if ($result) {
  519. $loginret = \addons\third\library\Service::connect($platform, $result);
  520. if ($loginret) {
  521. $data = [
  522. 'userinfo' => $this->auth->getUserinfo(),
  523. 'thirdinfo' => $result
  524. ];
  525. $this->success(__('Logged in successful'), $data);
  526. }
  527. }
  528. $this->error(__('Operation failed'), $url);
  529. }
  530. /**
  531. * 重置密码
  532. *
  533. * @param string $mobile 手机号
  534. * @param string $newpassword 新密码
  535. * @param string $captcha 验证码
  536. */
  537. public function resetpwd()
  538. {
  539. $type = $this->request->request("type");
  540. $mobile = $this->request->request("mobile");
  541. $email = $this->request->request("email");
  542. $newpassword = $this->request->request("newpassword");
  543. $captcha = $this->request->request("captcha");
  544. if (!$newpassword || !$captcha) {
  545. $this->error(__('Invalid parameters'));
  546. }
  547. if ($type == 'mobile') {
  548. if (!Validate::regex($mobile, "^1\d{10}$")) {
  549. $this->error(__('Mobile is incorrect'));
  550. }
  551. $user = \app\common\model\User::getByMobile($mobile);
  552. if (!$user) {
  553. $this->error(__('User not found'));
  554. }
  555. $ret = Sms::check($mobile, $captcha, 'resetpwd');
  556. if (!$ret) {
  557. $this->error(__('Captcha is incorrect'));
  558. }
  559. Sms::flush($mobile, 'resetpwd');
  560. } else {
  561. if (!Validate::is($email, "email")) {
  562. $this->error(__('Email is incorrect'));
  563. }
  564. $user = \app\common\model\User::getByEmail($email);
  565. if (!$user) {
  566. $this->error(__('User not found'));
  567. }
  568. $ret = Ems::check($email, $captcha, 'resetpwd');
  569. if (!$ret) {
  570. $this->error(__('Captcha is incorrect'));
  571. }
  572. Ems::flush($email, 'resetpwd');
  573. }
  574. //模拟一次登录
  575. $this->auth->direct($user->id);
  576. $ret = $this->auth->changepwd($newpassword, '', true);
  577. if ($ret) {
  578. $this->success(__('Reset password successful'));
  579. } else {
  580. $this->error($this->auth->getError());
  581. }
  582. }
  583. /*充值 */
  584. function torecharge()
  585. {
  586. $param = $this->request->post();
  587. if (empty($param['money'])) {
  588. $this->error("请输入充值金额");
  589. }
  590. if (empty($param['icon'])) {
  591. $this->error("请上传打款凭证");
  592. }
  593. if (empty($param['paytype'])) {
  594. $this->error("请选择支付类型");
  595. }
  596. $user = db('user')->where('id', $param['userid'])->find();
  597. $param['username'] = $user['username'];
  598. $param['ctime'] = time();
  599. $ids = db('recharge')->insertGetId($param);
  600. if ($ids) {
  601. $this->success("申请成功,请耐心等待审核");
  602. } else {
  603. $this->error("申请失败");
  604. }
  605. }
  606. /* 充值记录 */
  607. function getrechargedata()
  608. {
  609. $map['userid'] = $this->auth->id;
  610. $p = $this->request->post('p');
  611. $data_list = db('recharge')->where($map)->page($p, 10)->select();
  612. foreach ($data_list as $k => $v) {
  613. $data_list[$k]['status'] = get_recharge_status($v['status']);
  614. $data_list[$k]['times'] = date("Y-m-d H:i:s", $v['ctime']);
  615. $data_list[$k]['moneytype'] = get_money_name_byident($v['money_type']);
  616. }
  617. if ($data_list) {
  618. $return['data'] = $data_list;
  619. } else {
  620. $return['data'] = null;
  621. }
  622. $count = db('recharge')->where($map)->count();
  623. $return['total'] = ceil($count / 10);
  624. return $return;
  625. }
  626. function getnotice()
  627. {
  628. $map['status'] = 1;
  629. $map['type'] = $this->request->langset();
  630. $p = $this->request->post('p');
  631. $data_list = db('article')->where($map)->page($p, 10)->select();
  632. foreach ($data_list as $k => $v) {
  633. $data_list[$k]['times'] = date("Y-m-d", $v['ctime']);
  634. $data_list[$k]['url'] = "'" . url('index/user/newdetail', ['id' => $v['id']]) . "'";
  635. }
  636. if ($data_list) {
  637. $return['data'] = $data_list;
  638. } else {
  639. $return['data'] = null;
  640. }
  641. $count = db('article')->where($map)->count();
  642. $return['total'] = ceil($count / 10);
  643. return $return;
  644. }
  645. function getbonus2()
  646. {
  647. $map['userid'] = $this->auth->id;
  648. $p = $this->request->post('p');
  649. $data_list = db('user_bonus2')->where($map)->page($p, 10)->select();
  650. foreach ($data_list as $k => $v) {
  651. $data_list[$k]['times'] = date("Y.m.d H:i", $v['ctime']);
  652. if ($v['status'] == 1) {
  653. $data_list[$k]['status_dec'] = '锁仓中';
  654. $data_list[$k]['flag'] = 0;
  655. } else {
  656. $data_list[$k]['status_dec'] = '已解锁';
  657. $data_list[$k]['flag'] = 1;
  658. }
  659. }
  660. if ($data_list) {
  661. $return['data'] = $data_list;
  662. } else {
  663. $return['data'] = null;
  664. }
  665. $count = db('user_bonus2')->where($map)->count();
  666. $return['total'] = ceil($count / 10);
  667. return $return;
  668. }
  669. function getchat()
  670. {
  671. $user = $this->auth->getUserinfo();
  672. $map['from_uid|to_uid'] = $user['id'];
  673. $p = $this->request->post('p');
  674. $myset = config('site');
  675. $data_list = db('user_message')->where($map)->page($p, 10)->order("id asc")->select();
  676. foreach ($data_list as $k => $v) {
  677. if ($v['from_uid'] == $user['id']) {
  678. $data_list[$k]['flag'] = 0;
  679. $data_list[$k]['from_avatar'] = $user['avatar'];
  680. } else {
  681. $data_list[$k]['flag'] = 1;
  682. $data_list[$k]['from_avatar'] = $myset['web_site_logo'];
  683. }
  684. }
  685. $count = db('user_message')->where($map)->count();
  686. $total = ceil($count / 10);
  687. $return['total'] = $total;
  688. if ($data_list) {
  689. if ($p == $total) {
  690. $return['data'] = $data_list;
  691. } else {
  692. rsort($data_list);
  693. $return['data'] = $data_list;
  694. }
  695. } else {
  696. $return['data'] = null;
  697. }
  698. return $return;
  699. }
  700. /*发送留言 */
  701. function tosendmsg()
  702. {
  703. $param = $this->request->post();
  704. if (empty($param['content'])) {
  705. $this->error(__("请输入留言"));
  706. }
  707. $param['from_uid'] = $this->auth->id;
  708. $param['to_uid'] = 0;
  709. $param['ctime'] = time();
  710. $param['userid'] = $this->auth->id;
  711. $ids = db('user_message')->insertGetId($param);
  712. if ($ids) {
  713. $this->success(__("留言成功"));
  714. } else {
  715. $this->error(__("留言失败"));
  716. }
  717. }
  718. /* 修改密码 */
  719. function updatepwd()
  720. {
  721. $param = $this->request->post();
  722. if (empty($param['newPwd'])) {
  723. $this->error(__("请输入新密码"));
  724. }
  725. $user = get_user_data($this->auth->id);
  726. if ($param['type'] == 1) {
  727. $data['updatetime'] = time();
  728. $data['password'] = getEncryptPassword($param['newPwd'], $user['salt']);
  729. $res = db('user')->where('id', $user['id'])->update($data);
  730. if ($res) {
  731. $this->success(__("修改成功"));
  732. } else {
  733. $this->error(__("修改失败"));
  734. }
  735. } else {
  736. $data['updatetime'] = time();
  737. $data['password2'] = getEncryptPassword($param['newPwd'], $user['salt']);
  738. $res = db('user')->where('id', $user['id'])->update($data);
  739. if ($res) {
  740. $this->success(__("修改成功"));
  741. } else {
  742. $this->error(__("修改失败"));
  743. }
  744. }
  745. }
  746. function withdraw()
  747. {
  748. $param = $this->request->post();
  749. $psdtwo = $param['psdtwo'];
  750. if (empty($psdtwo)) {
  751. $this->error(__('请输入支付密码'));
  752. }
  753. if (!check_psdtwo($psdtwo, $this->auth->id)) {
  754. $this->error(__('支付密码验证失败!'));
  755. }
  756. //$config = db('bonus_config')->where('id', 6)->find();
  757. $tradeConfig = Config::getConfigByGroup('trade');
  758. $config['withdraw_min'] = isset($tradeConfig['withdraw_min'])? $tradeConfig['withdraw_min']['value'] : 0;
  759. $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap'])? $tradeConfig['withdraw_cap']['value'] : 0;
  760. $config['withdraw_fee'] = isset($tradeConfig['withdraw_fee'])? $tradeConfig['withdraw_fee']['value'] : 0;
  761. if (empty($param['money'])) {
  762. $this->error(__('请输入提现金额!'));
  763. }
  764. if (!($param['money'] > 0)) {
  765. $this->error(__('提现金额有误'));
  766. }
  767. if (!is_numeric($param['money'])) {
  768. $this->error(__('提现金额有误'));
  769. }
  770. if ($param['money'] < $config['withdraw_min']) {
  771. $this->error(__('提现金额最低为'.$config['withdraw_min']));
  772. }
  773. if ($config['withdraw_cap'] && $param['money'] % $config['withdraw_cap'] != 0) {
  774. $this->error(__('提现金额应为'.$config['withdraw_cap'].'的倍数'));
  775. }
  776. if (empty($param['type'])) {
  777. $this->error(__('请选择提现方式'));
  778. }
  779. $user = get_user_data($this->auth->id);
  780. $JC = $param['money'] - $user['usdt'];
  781. if ($JC > 0) {
  782. $this->error("余额不足");
  783. }
  784. if($param['type'] == 1)
  785. {
  786. if(empty($user['alipayprc']))
  787. {
  788. $this->error('请完善支付宝收款信息');
  789. }
  790. $prc=$user['alipayprc'];
  791. $name='';
  792. $type="支付宝";
  793. }elseif($param['type'] == 2){
  794. if(empty($user['wxprc']))
  795. {
  796. $this->error('请完善微信收款信息');
  797. }
  798. $prc=$user['wxprc'];
  799. $name='';
  800. $type="微信";
  801. }else if($param['type'] == 3){
  802. if(!($user['bank'] && $user['bank_user_name'] && $user['bank_number']))
  803. {
  804. $this->error('请完善y银行卡收款信息');
  805. }
  806. $prc='';
  807. $name=$user['bank'].'-'.$user['bank_user_name'].'-'.$user['bank_number'];
  808. $type="银行卡";
  809. }else {
  810. if(empty($user['usdt_address']))
  811. {
  812. $this->error('请先完善USDT钱包地址信息');
  813. }
  814. $prc='';
  815. $name='';
  816. $type="USDT";
  817. }
  818. $studio=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  819. $fee=$param['money']*$config['withdraw_fee']*0.01;
  820. db()->startTrans();
  821. $res = db('user')->where("id",$this->auth->id)->update(['usdt'=> $user['usdt']-$param['money'],'updatetime'=>time()]);
  822. // 流水明细
  823. $changedata=[
  824. 'userid'=>$this->auth->id,
  825. 'type'=> 6,
  826. 'money'=> -$param['money'],
  827. 'balance'=> $user['usdt'],
  828. 'relevant_userid'=>$this->auth->id,
  829. 'status'=>1,
  830. 'create_time'=>time(),
  831. 'remark'=>'提现扣除',
  832. 'user_name'=>$user['username']? $user['username'] : '系统',
  833. 'relevant_name'=>$user['username']? $user['username'] : '系统',
  834. ];
  835. $res1 = Db::name('detailed_usdt')->insertGetId($changedata);
  836. $data = [
  837. 'withdraw_date' => time(),
  838. 'amount' => $param['money'],
  839. 'usdt_num' => $param['money'],
  840. 'fack_receive' => $param['money']-$fee,
  841. 'fee' => $fee,
  842. 'userid' => $this->auth->id,
  843. 'username' => $user['username'],
  844. 'prc' => $prc,
  845. 'usdt_address' => isset($user['usdt_address']) && $param['type'] == 4? $user['usdt_address'] : '',
  846. 'name'=>$name,
  847. 'process_status' => 1,
  848. 'money_type' => 'usdt',
  849. 'type'=>$type,
  850. 'stuid'=>$studio['id'],
  851. ];
  852. $ids = db('withdrawals')->insertGetId($data);
  853. if ($res && $res1 && $ids) {
  854. db()->commit();
  855. $this->success(__("提现成功"));
  856. } else {
  857. db()->rollback();
  858. $this->error(__("提现失败"));
  859. }
  860. }
  861. /**
  862. * 佣金提现
  863. * @throws \think\db\exception\DataNotFoundException
  864. * @throws \think\db\exception\ModelNotFoundException
  865. * @throws \think\exception\DbException
  866. * @throws \think\exception\PDOException
  867. */
  868. function withdraw1()
  869. {
  870. $param = $this->request->post();
  871. $psdtwo = $param['psdtwo'];
  872. if (empty($psdtwo)) {
  873. $this->error(__('请输入支付密码'));
  874. }
  875. if (!check_psdtwo($psdtwo, $this->auth->id)) {
  876. $this->error(__('支付密码验证失败!'));
  877. }
  878. //$config = db('bonus_config')->where('id', 6)->find();
  879. $tradeConfig = Config::getConfigByGroup('trade');
  880. $config['withdraw_min'] = isset($tradeConfig['withdraw_min'])? $tradeConfig['withdraw_min']['value'] : 0;
  881. $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap'])? $tradeConfig['withdraw_cap']['value'] : 0;
  882. $config['withdraw_fee'] = isset($tradeConfig['withdraw_bonus_fee'])? $tradeConfig['withdraw_bonus_fee']['value'] : 0;
  883. if (empty($param['money'])) {
  884. $this->error(__('请输入提现金额!'));
  885. }
  886. if (!($param['money'] > 0)) {
  887. $this->error(__('提现金额有误'));
  888. }
  889. if (!is_numeric($param['money'])) {
  890. $this->error(__('提现金额有误'));
  891. }
  892. if ($param['money'] < $config['withdraw_min']) {
  893. $this->error(__('提现金额最低为'.$config['withdraw_min']));
  894. }
  895. if ($config['withdraw_cap'] && $param['money'] % $config['withdraw_cap'] != 0) {
  896. $this->error(__('提现金额应为'.$config['withdraw_cap'].'的倍数'));
  897. }
  898. if (empty($param['type'])) {
  899. $this->error(__('请选择提现方式'));
  900. }
  901. $user = get_user_data($this->auth->id);
  902. $JC = $param['money'] - $user['bonus'];
  903. if ($JC > 0) {
  904. $this->error("佣金余额不足");
  905. }
  906. if($param['type'] == 1)
  907. {
  908. if(empty($user['alipayprc']))
  909. {
  910. $this->error('请完善支付宝收款信息');
  911. }
  912. $prc=$user['alipayprc'];
  913. $name= $user['alipay_name'].'-'.$user['alipayname'];
  914. $type="支付宝";
  915. }elseif($param['type'] == 2){
  916. if(empty($user['wxprc']))
  917. {
  918. $this->error('请完善微信收款信息');
  919. }
  920. $prc=$user['wxprc'];
  921. $name='';
  922. $type="微信";
  923. }else if($param['type'] == 3){
  924. if(!($user['bank'] && $user['bank_user_name'] && $user['bank_number']))
  925. {
  926. $this->error('请完善银行卡收款信息');
  927. }
  928. $prc='';
  929. $name=$user['bank'].'-'.$user['bank_user_name'].'-'.$user['bank_number'];
  930. $type="银行卡";
  931. }
  932. $studio=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  933. $fee=$param['money']*$config['withdraw_fee']*0.01;
  934. db()->startTrans();
  935. $changedata=[
  936. 'type'=>6,
  937. 'money'=>0-$param['money'],
  938. 'userid'=>$this->auth->id,
  939. 'relevant_userid'=>$this->auth->id,
  940. 'remark'=>'佣金提现扣除',
  941. ];
  942. $res=caiwu($changedata, 'bonus');
  943. $data = [
  944. 'withdraw_date' => time(),
  945. 'amount' => $param['money'],
  946. 'usdt_num' => $param['money'],
  947. 'fack_receive' => $param['money']-$fee,
  948. 'fee' => $fee,
  949. 'userid' => $this->auth->id,
  950. 'username' => $user['username'],
  951. 'prc' => $prc,
  952. 'name'=>$name,
  953. 'process_status' => 1,
  954. 'money_type' => 'bonus',
  955. 'type'=>$type,
  956. 'stuid'=>$studio['id'],
  957. ];
  958. $ids = db('withdrawals')->insertGetId($data);
  959. if ($res && $ids) {
  960. db()->commit();
  961. $this->success(__("提现成功"));
  962. } else {
  963. db()->rollback();
  964. $this->error(__("提现失败"));
  965. }
  966. }
  967. function toupdateuserinfo()
  968. {
  969. $param = $this->request->post();
  970. $userid = $this->auth->id;
  971. $res = db('user')->where("id", $userid)->update($param);
  972. if ($res) {
  973. $this->success(__("上传完成"));
  974. } else {
  975. $this->error(__("上传失败"));
  976. }
  977. }
  978. function getroselist1()
  979. {
  980. $map['pid'] = $this->auth->id;
  981. $p = $this->request->post('p');
  982. $type = $this->request->post('type');
  983. if($type)
  984. {
  985. $map['status']=$type;
  986. }
  987. $data_list = db('rose')->where($map)->page($p, 15)->select();
  988. foreach ($data_list as &$v) {
  989. $v['times'] = date("Y/m/d H:i:s", $v['ctime']);
  990. $v['phone']=substr($v['mobile'],0,3).'****'.substr($v['mobile'],-4);
  991. }
  992. if ($data_list) {
  993. $return['data'] = $data_list;
  994. } else {
  995. $return['data'] = null;
  996. }
  997. $count = db('rose')->where($map)->count();
  998. $return['total'] = ceil($count / 15);
  999. return $return;
  1000. }
  1001. function getroselist()
  1002. {
  1003. $map['pid'] = $this->auth->id;
  1004. $p = $this->request->post('p');
  1005. $type = $this->request->post('type');
  1006. if($type)
  1007. {
  1008. $map['status']=$type;
  1009. }
  1010. $data_list = db('rose')->where($map)->page($p, 10)->select();
  1011. foreach ($data_list as &$v) {
  1012. $v['times'] = date("Y/m/d H:i:s", $v['ctime']);
  1013. $v['phone']=substr($v['mobile'],0,3).'****'.substr($v['mobile'],-4);
  1014. }
  1015. if ($data_list) {
  1016. $return['data'] = $data_list;
  1017. } else {
  1018. $return['data'] = null;
  1019. }
  1020. $count = db('rose')->where($map)->count();
  1021. $return['total'] = ceil($count / 10);
  1022. return $return;
  1023. }
  1024. function updatename()
  1025. {
  1026. $param=$this->request->post();
  1027. $userid = $this->auth->id;
  1028. $res=db('user')->where("id",$userid)->update(['nickname'=>$param['nickname']]);
  1029. if($res)
  1030. {
  1031. $this->success(__("修改完成"));
  1032. }else{
  1033. $this->error(__("修改失败"));
  1034. }
  1035. }
  1036. function profile()
  1037. {
  1038. $param = $this->request->post();
  1039. $check = (($param['bank'] && $param['bank_user_name'] && $param['bank_number']) || ($param['alipayprc'] && $param['alipay_name'] && $param['alipayname']) || ($param['wxprc']) || ($param['usdt_address']) || ($param['thb_bank_user_name'] && $param['thb_bank'] && ($param['thb_bank_number'] || $param['thb_qrcode'])) || ($param['idr_bank_user_name'] && $param['idr_bank'] && ($param['idr_bank_number'] || $param['idr_qrcode'])));
  1040. if(!$check)
  1041. {
  1042. $this->error('请至少完整填写一项收款信息');
  1043. }
  1044. $intime=get_user_data($this->auth->id,'intime');
  1045. $userid = $this->auth->id;
  1046. $param['isuser']=1;
  1047. $param['updatetime']=time();
  1048. if($intime>0)
  1049. {
  1050. $param['intime']=time();
  1051. }
  1052. $res=db('user')->where("id",$userid)->update($param);
  1053. if($res)
  1054. {
  1055. $this->success(__("修改完成"));
  1056. }else{
  1057. $this->error(__("修改失败"));
  1058. }
  1059. }
  1060. function toreal()
  1061. {
  1062. $param = $this->request->post();
  1063. $user=db('user')->where(['id'=> $this->auth->id])->find();
  1064. if($user['isreal']>0)
  1065. {
  1066. $this->error('您已实名或者实名审核中,不可重复操作');
  1067. }
  1068. if(!($param['idcard'] && $param['realname'] && $param['idprc1'] && $param['idprc2']))
  1069. {
  1070. $this->error('请完善实名资料');
  1071. }
  1072. $idcardinfo=db('user')->where(['idcard'=>$param['idcard'],'id'=>['neq',$this->auth->id]])->find();
  1073. if($idcardinfo)
  1074. {
  1075. $this->error('一个身份号只能绑定一个账号');
  1076. }
  1077. $param['isreal']=1;
  1078. $userid = $this->auth->id;
  1079. $res=db('user')->where("id",$userid)->update($param);
  1080. if($res)
  1081. {
  1082. $this->success(__("认证完成"));
  1083. }else{
  1084. $this->error(__("认证失败"));
  1085. }
  1086. }
  1087. function totrans()
  1088. {
  1089. $param=$this->request->post();
  1090. $from_moneytyp='cash';
  1091. $to_moneytype='bonus';
  1092. $psdtwo = $param['psdtwo'];
  1093. if(empty($psdtwo))
  1094. {
  1095. $this->error(__('请输入支付密码!'));
  1096. }
  1097. if(!check_psdtwo($psdtwo,$this->auth->id)){
  1098. $this->error(__('支付密码验证失败!'));
  1099. }
  1100. if(empty($param['money']))
  1101. {
  1102. $this->error(__('请输入提取金额'));
  1103. }
  1104. if(!($param['money']>0))
  1105. {
  1106. $this->error(__('提取金额有误'));
  1107. }
  1108. if(!is_numeric($param['money']))
  1109. {
  1110. $this->error(__('提取金额有误'));
  1111. }
  1112. $user=get_user_data($this->auth->id);
  1113. $jc=$param['money']-$user[$from_moneytyp];
  1114. if($jc>0)
  1115. {
  1116. $this->error(get_money_name_byident($from_moneytyp).'不足');
  1117. }
  1118. db()->startTrans();
  1119. $changedata=[
  1120. 'type'=>10,
  1121. 'money'=>0-$param['money'],
  1122. 'userid'=>$this->auth->id,
  1123. 'relevant_userid'=>$this->auth->id,
  1124. 'remark'=>'提取扣除'.$param['money'],
  1125. ];
  1126. $res=caiwu($changedata, $from_moneytyp);
  1127. $changedata=[
  1128. 'type'=>10,
  1129. 'money'=>$param['money'],
  1130. 'userid'=>$this->auth->id,
  1131. 'relevant_userid'=>$this->auth->id,
  1132. 'remark'=>'提取增加'.$param['money'],
  1133. ];
  1134. $res1=caiwu($changedata,$to_moneytype);
  1135. if($res && $res1)
  1136. {
  1137. db()->commit();
  1138. $this->success(__("提取成功"));
  1139. }else{
  1140. db()->rollback();
  1141. $this->error(__("提取失败"));
  1142. }
  1143. }
  1144. /* 转账 */
  1145. function transfer()
  1146. {
  1147. $param=$this->request->post();
  1148. $psdtwo = $param['psdtwo'];
  1149. if(empty($psdtwo))
  1150. {
  1151. $this->error(__('请输入安全密码!'));
  1152. }
  1153. if(!check_psdtwo($psdtwo,$this->auth->id)){
  1154. $this->error(__('安全密码验证失败!'));
  1155. }
  1156. if(empty($param['money']))
  1157. {
  1158. $this->error(__('请输入转账数量'));
  1159. }
  1160. if(!($param['money']>0))
  1161. {
  1162. $this->error(__('转账数量有误'));
  1163. }
  1164. if(!is_numeric($param['money']))
  1165. {
  1166. $this->error(__('转账数量有误'));
  1167. }
  1168. $user=get_user_data($this->auth->id);
  1169. $jc=$param['money']-$user['bonus'];
  1170. if($jc>0)
  1171. {
  1172. $this->error(__('平台币不足'));
  1173. }
  1174. $touser=db('user')->where(['username|mobile'=>$param['touser'],'status'=>1])->find();
  1175. if(empty($touser))
  1176. {
  1177. $this->error(__("接收会员不存在"));
  1178. }
  1179. if(!in_array($this->auth->id,explode(',',$touser['refereeids'])) && !in_array($touser['id'],explode(',',$user['refereeids'])) )
  1180. {
  1181. $this->error(__("与目标用户存在推荐关系方可转出"));
  1182. }
  1183. db()->startTrans();
  1184. $changedata=[
  1185. 'type'=>8,
  1186. 'money'=>0-$param['money'],
  1187. 'userid'=>$this->auth->id,
  1188. 'relevant_userid'=>$touser['id'],
  1189. 'remark'=>'转账给'.$touser['username'],
  1190. ];
  1191. $res=caiwu($changedata, 'bonus');
  1192. $changedata=[
  1193. 'type'=>7,
  1194. 'money'=>$param['money'],
  1195. 'userid'=>$touser['id'],
  1196. 'relevant_userid'=>$this->auth->id,
  1197. 'remark'=>'接收'.$user['username'].'转账',
  1198. ];
  1199. $res1=caiwu($changedata, 'bonus');
  1200. if($res && $res1)
  1201. {
  1202. db()->commit();
  1203. $this->success(__("转账成功"));
  1204. }else{
  1205. db()->rollback();
  1206. $this->error(__("转账失败"));
  1207. }
  1208. }
  1209. function gettranscode()
  1210. {
  1211. $group = $this->request->post('money_type');
  1212. $map['userid'] = $this->auth->id;
  1213. $map['type']=8;
  1214. $p = $this->request->post('p');
  1215. $data_list = db('detailed' . ucfirst($group))->where($map)->page($p, 15)->order("id desc")->select();
  1216. foreach ($data_list as $k => $v) {
  1217. $data_list[$k]['money'] = $v['money'] > 0 ? '+' . $v['money'] : $v['money'];
  1218. $data_list[$k]['times'] = date("Y-m-d H:i:s", $v['create_time']);
  1219. $data_list[$k]['type'] = get_detailed_type_text($v['type']);
  1220. }
  1221. if ($data_list) {
  1222. $return['data'] = $data_list;
  1223. } else {
  1224. $return['data'] = null;
  1225. }
  1226. $count = db('detailed' . ucfirst($group))->where($map)->count();
  1227. $return['total'] = ceil($count / 15);
  1228. return $return;
  1229. }
  1230. }