Userwallet.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 my_money_log(){
  20. $type = input('type',0);
  21. $map = [
  22. 'user_id' => $this->auth->id,
  23. ];
  24. if($type){
  25. $map['type'] = $type;
  26. }
  27. $list = Db::name('user_money_log')
  28. ->where($map)->order('id desc')->autopage()->select();
  29. $list = $this->list_appen_logtext($list);
  30. $this->success('success',$list);
  31. }
  32. //金币日志
  33. public function my_jewel_log(){
  34. $type = input('type',0);
  35. $map = [
  36. 'user_id' => $this->auth->id,
  37. ];
  38. if($type){
  39. $map['type'] = $type;
  40. }
  41. $list = Db::name('user_jewel_log')
  42. ->where($map)->order('id desc')->autopage()->select();
  43. $list = $this->list_appen_logtext($list);
  44. $this->success('success',$list);
  45. }
  46. //追加log_text
  47. private function list_appen_logtext($list){
  48. if(!empty($list)){
  49. $conf = config('wallet.logtype');
  50. foreach($list as $key => $val){
  51. $list[$key]['type_text'] = isset($conf[$val['type']]) ? $conf[$val['type']] : '';
  52. }
  53. }
  54. return $list;
  55. }
  56. }