Userwallet.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $wallet['is_vip'] = $wallet['vip_endtime'] > time() ? 1 : 0;
  17. $this->success('success',$wallet);
  18. }
  19. //充值记录
  20. public function gold_recharge_log(){
  21. $map = [
  22. 'user_id' => $this->auth->id,
  23. 'log_type'=> 10,
  24. ];
  25. $list = Db::name('user_gold_log')->field('id,change_value,remain,createtime')->where($map)->order('id desc')->autopage()->select();
  26. $this->success('success',$list);
  27. }
  28. //我的余额日志
  29. public function my_money_log(){
  30. $type = input_post('type',0);
  31. $map = [
  32. 'user_id' => $this->auth->id,
  33. ];
  34. if($type){
  35. $map['log_type'] = $type;
  36. }
  37. $list = Db::name('user_money_log')
  38. ->field('id,log_type,before,change_value,remain,remark,createtime')
  39. ->where($map)->order('id desc')->autopage()->select();
  40. $list = $this->list_appen_logtext($list);
  41. $this->success('success',$list);
  42. }
  43. //金币日志
  44. public function my_gold_log(){
  45. $type = input_post('type',0);
  46. $map = [
  47. 'user_id' => $this->auth->id,
  48. ];
  49. if($type){
  50. $map['log_type'] = $type;
  51. }
  52. $list = Db::name('user_gold_log')
  53. ->field('id,log_type,before,change_value,remain,remark,createtime')
  54. ->where($map)->order('id desc')->autopage()->select();
  55. $list = $this->list_appen_logtext($list);
  56. $this->success('success',$list);
  57. }
  58. //追加log_text
  59. private function list_appen_logtext($list){
  60. if(!empty($list)){
  61. $conf = config('wallet.logtype');
  62. foreach($list as $key => $val){
  63. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  64. }
  65. }
  66. return $list;
  67. }
  68. }