Userwallet.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. //use app\common\model\wallet;
  6. /**
  7. * 用户钱包
  8. */
  9. class Userwallet extends Api
  10. {
  11. protected $noNeedLogin = [];
  12. protected $noNeedRight = ['*'];
  13. //我的钱包余额
  14. public function my_wallet(){
  15. $wallet = model('wallet')->getwallet($this->auth->id);
  16. $this->success('success',$wallet);
  17. }
  18. //充值记录
  19. public function gold_recharge_log(){
  20. $map = [
  21. 'user_id' => $this->auth->id,
  22. 'log_type'=> 10,
  23. ];
  24. $list = Db::name('user_gold_log')->field('id,change_value,remain,createtime')->where($map)->order('id desc')->autopage()->select();
  25. $this->success('success',$list);
  26. }
  27. //我的收益,三个数据
  28. public function my_income_count(){
  29. //累计收益,不计来源
  30. $map = [
  31. 'user_id' => $this->auth->id,
  32. //'log_type'=> ['IN',[21,22,23]],
  33. ];
  34. $income_sum = Db::name('user_money_log')->where($map)->sum('change_value');
  35. //可提现总收益
  36. $money_remain = model('wallet')->getwallet($this->auth->id,'money');
  37. //今日收益
  38. $start = strtotime(date('Y-m-d'));
  39. $end = $start + 86399;
  40. $map['createtime'] = ['between',[$start,$end]];
  41. $today_income_sum = Db::name('user_money_log')->where($map)->sum('change_value');
  42. $result = [
  43. 'income_sum' => $income_sum,
  44. 'money_remain' => $money_remain,
  45. 'today_income_sum' => $today_income_sum,
  46. ];
  47. $this->success('success',$result);
  48. }
  49. //追加log_text
  50. private function list_appen_logtext($list){
  51. if(!empty($list)){
  52. $conf = config('wallet.logtype');
  53. foreach($list as $key => $val){
  54. $list[$key]['createtime'] = date('Y.m.d H:i');
  55. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  56. }
  57. }
  58. return $list;
  59. }
  60. //互动收益,打视频,语音,文字聊天,聊天送礼物
  61. public function hudong_money(){
  62. $map = [
  63. 'user_id' => $this->auth->id,
  64. 'log_type'=> ['IN',[21,22,23,54]],
  65. ];
  66. $list = Db::name('user_money_log')
  67. ->field('id,log_type,change_value,remain,remark,createtime')
  68. ->where($map)->order('id desc')->autopage()->select();
  69. $list = $this->list_appen_logtext($list);
  70. $this->success('success',$list);
  71. }
  72. //音聊收益,语聊间礼物
  73. public function party_money(){
  74. $map = [
  75. 'user_id' => $this->auth->id,
  76. 'log_type'=> 52,
  77. ];
  78. $list = Db::name('user_money_log')
  79. ->field('id,log_type,change_value,remain,remark,createtime')
  80. ->where($map)->order('id desc')->autopage()->select();
  81. $list = $this->list_appen_logtext($list);
  82. $this->success('success',$list);
  83. }
  84. //直播收益,直播间礼物
  85. public function livebc_money(){
  86. $map = [
  87. 'user_id' => $this->auth->id,
  88. 'log_type'=> 56,
  89. ];
  90. $list = Db::name('user_money_log')
  91. ->field('id,log_type,change_value,remain,remark,createtime')
  92. ->where($map)->order('id desc')->autopage()->select();
  93. $list = $this->list_appen_logtext($list);
  94. $this->success('success',$list);
  95. }
  96. //我的余额日志
  97. public function my_money_log(){
  98. $type = input_post('type',0);
  99. $map = [
  100. 'user_id' => $this->auth->id,
  101. ];
  102. // if($type){
  103. // $map['log_type'] = $type;
  104. // }
  105. $list = Db::name('user_money_log')
  106. ->field('id,log_type,change_value,remain,remark,createtime, remark log_text')
  107. ->where($map)->order('id desc')->autopage()->select();
  108. // $list = $this->list_appen_logtext($list);
  109. if(!empty($list)){
  110. foreach($list as $key => $val){
  111. $list[$key]['createtime'] = date('Y.m.d H:i', $val['createtime']);
  112. }
  113. }
  114. $this->success('success',$list);
  115. }
  116. //金币日志
  117. public function my_gold_log(){
  118. $type = input_post('type',0);
  119. $map = [
  120. 'user_id' => $this->auth->id,
  121. ];
  122. if($type == 19){
  123. $map['log_type'] = $type;
  124. }
  125. $list = Db::name('user_gold_log')->field('id,log_type,change_value,remain,createtime, remark log_text')->where($map)->order('id desc')->autopage()->select();
  126. // $list = $this->list_appen_logtext($list);
  127. if(!empty($list)){
  128. foreach($list as $key => $val){
  129. $list[$key]['createtime'] = date('Y.m.d H:i', $val['createtime']);
  130. }
  131. }
  132. $this->success('success',$list);
  133. }
  134. //提现配置
  135. public function take_cash_config(){
  136. $data = [
  137. 'money' => model('wallet')->getwallet($this->auth->id,'money'),
  138. 'alipay_account' => '',
  139. 'min' => 1,
  140. 'max' => 1000,
  141. ];
  142. $this->success('success',$data);
  143. }
  144. //提现
  145. public function take_cash(){
  146. $money = floatval(input_post('money',0));
  147. if(empty($money)){
  148. $this->error();
  149. }
  150. if(empty($this->auth->idcard_status)){
  151. $this->error('请先完成实名认证');
  152. }
  153. $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
  154. if($check){
  155. $this->error('您已经申请了提现,请等待审核');
  156. }
  157. $user_money = model('wallet')->getwallet($this->auth->id,'money');
  158. if($money > $user_money){
  159. $this->error('提现金额不能大于可提现余额');
  160. }
  161. $data = [
  162. 'user_id' => $this->auth->id,
  163. 'number' => $money,
  164. 'status' => 0,
  165. 'createtime' => time(),
  166. 'updatetime' => time(),
  167. ];
  168. Db::name('take_cash')->insertGetId($data);
  169. //审核时候再扣,或者这里先扣,等需求方确认
  170. $this->success('申请成功请等待审核');
  171. }
  172. //提现记录
  173. public function take_cash_log(){
  174. $list = Db::name('take_cash')->field('id, number, status, createtime')->where(['user_id'=>$this->auth->id])->autopage()->order('id desc')->select();
  175. if ($list) {
  176. foreach ($list as &$v) {
  177. $v['title'] = '余额提现';
  178. $v['number'] = '-' . $v['number'];
  179. $v['createtime'] = date('Y.m.d H:i', $v['createtime']);
  180. }
  181. }
  182. $this->success('success',$list);
  183. }
  184. //提现金额配置
  185. public function withdrawal_config() {
  186. $show = config('site.withdrawal_show');
  187. $list = Db::name('withdrawal_config')->where('is_show',1)->order('weight asc,id asc')->select();
  188. if ($list) {
  189. $arr = [
  190. 'id' => -1,
  191. 'money' => 0,
  192. 'real_money' => 0,
  193. 'type' => 0,
  194. 'is_show' => 1,
  195. 'weight' => 1
  196. ];
  197. array_push($list, $arr);
  198. }
  199. $return_data['show'] = $show;
  200. $return_data['withdrawal_rate'] = config('site.withdrawal_rate') > 0 ? config('site.withdrawal_rate') : 10;
  201. $return_data['list'] = $list;
  202. $this->success('success',$return_data);
  203. }
  204. //提现(废弃)
  205. public function withdrawal_feiqi() {
  206. if ($this->auth->idcard_status != 1) {
  207. $this->error('请先完成实名认证~');
  208. }
  209. $id = input('id', 0, 'intval');
  210. $type = input('type', 0, 'intval'); //账户类型:1=微信,2=支付宝
  211. if (!$id) {
  212. $this->error('您的网络开小差啦~');
  213. }
  214. $withdrawal_config = Db::name('withdrawal_config')->find($id);
  215. if (!$withdrawal_config) {
  216. $this->error('提现金额不存在~');
  217. }
  218. if ($withdrawal_config['is_show'] != 1) {
  219. $this->error('提现金额暂未开放~');
  220. }
  221. if ($withdrawal_config['money'] <= 0 || $withdrawal_config['real_money'] <= 0 || $withdrawal_config['money'] < $withdrawal_config['real_money']) {
  222. $this->error('提现金额异常~');
  223. }
  224. if (!in_array($type, [1, 2])) {
  225. $this->error('请选择提现账户~');
  226. }
  227. if ($type != 2) {
  228. $this->error('提现方式请选择支付宝');
  229. }
  230. //扣除金额
  231. $money = floatval($withdrawal_config['money']);
  232. $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
  233. if($check){
  234. $this->error('您已经申请了提现,请等待审核');
  235. }
  236. $time = strtotime(date('Y-m-d'));
  237. $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id, 'wallet_id'=>$id, 'createtime' => ['egt', $time]])->find();
  238. if($check){
  239. $this->error('您今日已经提现过该额度');
  240. }
  241. $user_money = model('wallet')->getwallet($this->auth->id,'money');
  242. if($money > $user_money){
  243. $this->error('可提现余额不足');
  244. }
  245. if ($type == 1) { //微信
  246. $alipay_account = '';
  247. } else { //支付宝
  248. $user_bank_info = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 1])->find();
  249. if (!$user_bank_info) {
  250. $this->error('请先绑定支付宝');
  251. }
  252. $alipay_account = $user_bank_info['banknumber'];
  253. $realname = $user_bank_info['realname'];
  254. }
  255. $data = [
  256. 'user_id' => $this->auth->id,
  257. 'wallet_id' => $id,
  258. 'number' => $money,
  259. 'money' => $withdrawal_config['real_money'],
  260. 'alipay_account' => $alipay_account,
  261. 'status' => 0,
  262. 'createtime' => time(),
  263. 'updatetime' => time(),
  264. 'type' => $type,
  265. 'realname' => $realname
  266. ];
  267. //计算上级可获得金额
  268. if ($this->auth->intro_uid) {
  269. $data['intro_uid'] = $this->auth->intro_uid;
  270. //获取返利比率
  271. $intro_withdrawal_rebate_rate = (int)config('site.intro_withdrawal_rebate_rate');
  272. if ($intro_withdrawal_rebate_rate > 0 && $intro_withdrawal_rebate_rate <= 100) {
  273. //上级获得金额数量
  274. $intro_uid_money = number_format($money * $intro_withdrawal_rebate_rate / 100, 2, '.', '');
  275. if ($intro_uid_money > 0) {
  276. $data['intro_money'] = $intro_uid_money;
  277. }
  278. }
  279. }
  280. $msg = '申请成功请等待审核';
  281. //开启事务
  282. Db::startTrans();
  283. $log_id = Db::name('take_cash')->insertGetId($data);
  284. if (!$log_id) {
  285. Db::rollback();
  286. $this->error('您的网络开小差啦~');
  287. }
  288. if ($withdrawal_config['type'] == 1) { //秒到账,无需审核
  289. $info = Db::name('take_cash')->find($log_id);
  290. //扣钱
  291. $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],0,'money',-$info['number'],15,'提现:'.$info['number'],'take_cash',$info['id']);
  292. if($wallet_rs['status'] === false){
  293. Db::rollback();
  294. $this->error($wallet_rs['msg']);
  295. }
  296. //上级返利
  297. if ($info['intro_uid'] && $info['intro_money'] > 0) {
  298. $wallet_rs = model('wallet')->lockChangeAccountRemain($info['intro_uid'],$info['user_id'],'money',$info['intro_money'],66,'邀请人提现奖励:'.$info['number'],'take_cash',$info['id']);
  299. if($wallet_rs['status'] === false){
  300. Db::rollback();
  301. $this->error($wallet_rs['msg']);
  302. }
  303. }
  304. //自动打款
  305. if ($info['type'] == 1) { //微信
  306. } elseif ($info['type'] == 2) { //支付宝
  307. $dakuanrs = $this->withdraw($info);
  308. if (!$dakuanrs) {
  309. Db::rollback();
  310. $this->error('打款失败');
  311. }
  312. }
  313. //修改提现记录状态
  314. $take_cash_result = Db::name('take_cash')->where(['id' => $log_id, 'status' => 0])->setField('status', 1);
  315. if (!$take_cash_result) {
  316. Db::rollback();
  317. $this->error('打款失败');
  318. }
  319. //系统消息
  320. $msg_id = \app\common\model\Message::addMessage($info['user_id'],'提现','您的提现已经到账');
  321. $msg = '提现成功';
  322. }
  323. Db::commit();
  324. //审核时候再扣,或者这里先扣,等需求方确认
  325. $this->success($msg);
  326. }
  327. //提现
  328. public function withdrawal() {
  329. if ($this->auth->idcard_status != 1) {
  330. $this->error('请先完成实名认证~');
  331. }
  332. $id = input('id', 0, 'intval');
  333. $type = input('type', 0, 'intval'); //账户类型:1=支付宝,2=银行卡
  334. $freemoney = input_post('freemoney', 0, 'intval'); //自定义金额
  335. if (!$id && !$freemoney) {
  336. $this->error('请选择或填写提现金额');
  337. }
  338. if ($id > 0) {
  339. $withdrawal_config = Db::name('withdrawal_config')->find($id);
  340. if (!$withdrawal_config) {
  341. $this->error('提现金额不存在~');
  342. }
  343. if ($withdrawal_config['is_show'] != 1) {
  344. $this->error('提现金额暂未开放~');
  345. }
  346. if ($withdrawal_config['money'] <= 0 || $withdrawal_config['real_money'] <= 0 || $withdrawal_config['money'] < $withdrawal_config['real_money']) {
  347. $this->error('提现金额异常~');
  348. }
  349. //扣除金额
  350. $money = floatval($withdrawal_config['money']);
  351. //实际获得金额
  352. $real_money = $withdrawal_config['real_money'];
  353. }
  354. if ($freemoney > 0) {
  355. //扣除金额
  356. $money = $freemoney;
  357. //实际获得金额
  358. $bili = config('site.withdrawal_rate') >= 0 ? config('site.withdrawal_rate') : 10;
  359. $real_money = number_format($money * (100 - $bili) / 100, 2, '.', '');
  360. }
  361. if ($money <= 0) {
  362. $this->error('提现金额异常');
  363. }
  364. if (!in_array($type, [1, 2])) {
  365. $this->error('请选择提现账户~');
  366. }
  367. $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
  368. if($check){
  369. $this->error('您有一笔提现在审核中,待审核通过后再申请提现。');
  370. }
  371. $time = strtotime(date('Y-m-d'));
  372. $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id, 'wallet_id'=>$id, 'createtime' => ['egt', $time]])->find();
  373. if($check){
  374. $this->error('您今日已经提现过该额度');
  375. }
  376. $user_money = model('wallet')->getwallet($this->auth->id,'money');
  377. if($money > $user_money){
  378. $this->error('可提现余额不足');
  379. }
  380. $user_bank_info = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => $type])->find();
  381. if (!$user_bank_info) {
  382. $this->error('请先添加提现方式');
  383. }
  384. $alipay_account = $user_bank_info['banknumber'];
  385. $realname = $user_bank_info['realname'];
  386. $data = [
  387. 'user_id' => $this->auth->id,
  388. 'wallet_id' => $freemoney > 0 ? 0 : $id,
  389. 'number' => $money,
  390. 'money' => $real_money,
  391. 'alipay_account' => $alipay_account,
  392. 'status' => 0,
  393. 'createtime' => time(),
  394. 'updatetime' => time(),
  395. 'type' => $type,
  396. 'realname' => $realname
  397. ];
  398. //计算上级可获得金额
  399. /*if ($this->auth->intro_uid) {
  400. $data['intro_uid'] = $this->auth->intro_uid;
  401. //获取返利比率
  402. $intro_withdrawal_rebate_rate = (int)config('site.intro_withdrawal_rebate_rate');
  403. if ($intro_withdrawal_rebate_rate > 0 && $intro_withdrawal_rebate_rate <= 100) {
  404. //上级获得金额数量
  405. $intro_uid_money = number_format($money * $intro_withdrawal_rebate_rate / 100, 2, '.', '');
  406. if ($intro_uid_money > 0) {
  407. $data['intro_money'] = $intro_uid_money;
  408. }
  409. }
  410. }*/
  411. $msg = '申请成功请等待审核';
  412. //开启事务
  413. Db::startTrans();
  414. $log_id = Db::name('take_cash')->insertGetId($data);
  415. if (!$log_id) {
  416. Db::rollback();
  417. $this->error('您的网络开小差啦~');
  418. }
  419. Db::commit();
  420. //审核时候再扣,或者这里先扣,等需求方确认
  421. $this->success($msg);
  422. }
  423. //提现转账(新版2020-01-01)
  424. public function withdraw($info) {
  425. $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000); //商户订单号
  426. $data['trans_amount'] = $info['money']; //订单总金额,单位为元,精确到小数点后两位
  427. $data['product_code'] = 'TRANS_ACCOUNT_NO_PWD';//业务产品码,收发现金红包固定为:STD_RED_PACKET;单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;单笔无密转账到银行卡固定为:TRANS_BANKCARD_NO_PWD
  428. $data['biz_scene'] = 'DIRECT_TRANSFER'; //描述特定的业务场景,可传的参数如下:PERSONAL_COLLECTION:C2C现金红包-领红包;DIRECT_TRANSFER:B2C现金红包、单笔无密转账到支付宝/银行卡
  429. $data['order_title'] = '知音佣金发放'; //转账业务的标题,用于在支付宝用户的账单里显示
  430. $data['payee_info']['identity'] = $info['alipay_account'];//收款方支付宝id或支付宝账户
  431. /*if ($info['alipay_type'] == 1) { //支付宝账户
  432. $data['payee_info']['identity_type'] = 'ALIPAY_LOGON_ID';
  433. //收款支付宝账号真实姓名, 不为空时支付宝会验证
  434. $data['payee_info']['name'] = $info['name'];
  435. } else { //支付宝id
  436. $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
  437. $data['payee_info']['name'] = '';
  438. }*/
  439. //支付宝id
  440. $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
  441. $data['payee_info']['name'] = '';
  442. //转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空。收款方可见,会展示在收款用户的收支详情中。
  443. $data['remark'] = '知音佣金发放';
  444. require_once("../extend/AliPay/AliPay.php");
  445. $alipay =new \AliPay();
  446. $result =$alipay->AliPayWithdraw($data);
  447. return $result;
  448. }
  449. //每日数据
  450. public function todayincome() {
  451. $start = input('time', 0, 'strtotime'); //时间: 2022-09-30
  452. if (!$start) {
  453. $start = strtotime(date('Y-m-d')); //默认今日
  454. }
  455. $end = $start + 86399;
  456. //收益type
  457. $profit_type = [21,22,23,54,58,60,67];
  458. //今日收益
  459. $today_map = [
  460. 'log_type' => ['IN',$profit_type],
  461. 'user_id' => $this->auth->id,
  462. 'createtime' => ['between',[$start,$end]],
  463. ];
  464. $today_profit = Db::name('user_money_log')->where($today_map)->sum('change_value');
  465. //今日视频时长/收益/人数
  466. $map = [
  467. 'to_user_id' => $this->auth->id,
  468. 'createtime' => ['between',[$start,$end]],
  469. ];
  470. $today_video_min = Db::name('user_match_video_log')->where($map)->sum('call_minutes');
  471. $today_video_income = Db::name('user_match_video_log')->where($map)->sum('money');
  472. $today_video_income = $today_video_income ? : 0;
  473. $today_video_user = Db::name('user_match_video_log')->where($map)->column('user_id');
  474. $today_video_user = array_unique($today_video_user);
  475. $today_video_user_num = count($today_video_user);
  476. //今日语音时长/收益/人数
  477. $today_audio_min = Db::name('user_match_audio_log')->where($map)->sum('call_minutes');
  478. $today_audio_income = Db::name('user_match_audio_log')->where($map)->sum('money');
  479. $today_audio_income = $today_audio_income ? : 0;
  480. $today_audio_user = Db::name('user_match_audio_log')->where($map)->column('user_id');
  481. $today_audio_user = array_unique($today_audio_user);
  482. $today_audio_user_num = count($today_audio_user);
  483. //今日时长/收益/人数
  484. $today_time = $today_video_min + $today_audio_min;
  485. $today_time_income = number_format($today_video_income + $today_audio_income, 2, '.', '');
  486. $today_user_num = $today_video_user_num + $today_audio_user_num;
  487. //礼物收益
  488. $gitft_map = [
  489. 'log_type' => ['IN',[54, 58, 60]],
  490. 'user_id' => $this->auth->id,
  491. 'createtime' => ['between',[$start,$end]],
  492. ];
  493. $today_gift_income = Db::name('user_money_log')->where($gitft_map)->sum('change_value');
  494. //私聊时长/收益/人数
  495. $today_chat_min = Db::name('user_match_typing_log')->where($map)->count('id');
  496. $today_chat_income = Db::name('user_match_typing_log')->where($map)->sum('money');
  497. $today_chat_income = $today_chat_income ? : 0;
  498. $today_chat_user = Db::name('user_match_typing_log')->where($map)->column('user_id');
  499. $today_chat_user = array_unique($today_chat_user);
  500. $today_chat_user_num = count($today_chat_user);
  501. //任务收益 客户要求由money改为gold
  502. $today_task_income = Db::name('user_gold_log')->where(['user_id' => $this->auth->id, 'log_type' => 67, 'createtime' => ['between',[$start,$end]]])->sum('change_value');
  503. $today_task_income = $today_task_income ? : 0;
  504. $result = [
  505. 'today_profit' => $today_profit,
  506. 'today_time_income' => $today_time_income,
  507. 'today_gift_income' => $today_gift_income,
  508. 'today_chat_income' => $today_chat_income,
  509. 'today_task_income' => $today_task_income,
  510. 'today_time' => $today_time,
  511. 'today_user_num' => $today_user_num,
  512. 'today_chat_min' => $today_chat_min,
  513. 'today_chat_user_num' => $today_chat_user_num
  514. ];
  515. $this->success('success',$result);
  516. }
  517. //每日数据礼物列表
  518. public function todaygiftlist() {
  519. $start = input('time', 0, 'strtotime'); //时间: 09-30
  520. if (!$start) {
  521. $start = strtotime(date('Y-m-d')); //默认今日
  522. }
  523. $end = $start + 86399;
  524. //今日收益
  525. $today_map = [
  526. 'log_type' => ['IN', [54,/*58,*/60]],
  527. 'user_id' => $this->auth->id,
  528. 'createtime' => ['between',[$start,$end]],
  529. ];
  530. $list = Db::name('user_money_log')->where($today_map)->autopage()->order('id desc')->select();
  531. if (!$list) {
  532. $this->success('success', $list);
  533. }
  534. $mt_gift_user_typing = Db::name('gift_user_typing'); //54
  535. // $mt_gift_user_greet = Db::name('gift_user_greet'); //58
  536. $mt_gift_user_dongtai = Db::name('gift_user_dongtai'); //60
  537. foreach ($list as &$v) {
  538. if ($v['log_type'] == 54) {
  539. $table = $mt_gift_user_typing;
  540. }/* elseif ($v['log_type'] == 58) {
  541. $table = $mt_gift_user_greet;
  542. } */else {
  543. $table = $mt_gift_user_dongtai;
  544. }
  545. $info = $table->where(['id' => $v['table_id']])->find();
  546. $v['gift_name'] = $info['gift_name'];
  547. $v['number'] = $info['number'];
  548. }
  549. $this->success('success', $list);
  550. }
  551. }