Userwallet.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. $wallet['user_alipay'] = Db::name('user_alipay')->where(['user_id' => $this->auth->id])->find();
  17. $wallet['user_bank'] = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
  18. $wallet['user_wechat'] = Db::name('user_wechat')->where(['user_id' => $this->auth->id])->find();
  19. $this->success('success',$wallet);
  20. }
  21. //我的余额日志
  22. public function my_money_log(){
  23. $type = input('type',0);
  24. $map = [
  25. 'user_id' => $this->auth->id,
  26. ];
  27. if($type == 1){
  28. $map['change_value'] = ['gt',0];
  29. }
  30. if($type == 2){
  31. $map['change_value'] = ['lt',0];
  32. }
  33. $list = Db::name('user_money_log')
  34. ->field('id,log_type,before,change_value,remain,remark,createtime')
  35. ->where($map)->order('id desc')->autopage()->select();
  36. $list = $this->list_appen_logtext($list);
  37. $this->success('success',$list);
  38. }
  39. //追加log_text
  40. private function list_appen_logtext($list){
  41. if(!empty($list)){
  42. $conf = config('wallet.logtype');
  43. $conf_en = config('wallet.logtype_en');
  44. foreach($list as $key => $val){
  45. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  46. $list[$key]['log_text_en'] = isset($conf_en[$val['log_type']]) ? $conf_en[$val['log_type']] : '';
  47. }
  48. }
  49. return $list;
  50. }
  51. }