Userwallet.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
  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 == 1){
  25. $map['change_value'] = ['gt',0];
  26. }
  27. if($type == 2){
  28. $map['change_value'] = ['lt',0];
  29. }
  30. $list = Db::name('user_money_log')
  31. ->field('id,log_type,before,change_value,remain,remark,createtime')
  32. ->where($map)->order('id desc')->autopage()->select();
  33. // $list = $this->list_appen_logtext($list);
  34. $this->success('success',$list);
  35. }
  36. //我的核销余额日志
  37. public function my_hexiaomoney_log(){
  38. $type = input('type',0);
  39. $map = [
  40. 'user_id' => $this->auth->id,
  41. ];
  42. if($type == 1){
  43. $map['change_value'] = ['gt',0];
  44. }
  45. if($type == 2){
  46. $map['change_value'] = ['lt',0];
  47. }
  48. $list = Db::name('user_hexiaomoney_log')
  49. ->field('id,log_type,before,change_value,remain,remark,createtime')
  50. ->where($map)->order('id desc')->autopage()->select();
  51. // $list = $this->list_appen_logtext($list);
  52. $this->success('success',$list);
  53. }
  54. //我的分销余额日志
  55. public function my_intromoney_log(){
  56. $type = input('type',0);
  57. $map = [
  58. 'user_id' => $this->auth->id,
  59. ];
  60. if($type == 1){
  61. $map['change_value'] = ['gt',0];
  62. }
  63. if($type == 2){
  64. $map['change_value'] = ['lt',0];
  65. }
  66. $list = Db::name('user_intromoney_log')
  67. ->field('id,log_type,before,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. //追加log_text
  73. private function list_appen_logtext($list){
  74. if(!empty($list)){
  75. $conf = config('wallet.logtype');
  76. foreach($list as $key => $val){
  77. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  78. }
  79. }
  80. return $list;
  81. }
  82. }