Userwallet.php 24 KB

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