Userwallet.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_bank'] = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
  17. $wallet['take_cash'] = [
  18. 'min' => config('site.min_takecash_money'),
  19. 'max' => config('site.max_takecash_money'),
  20. 'takecash_plat_bili' => config('site.takecash_plat_bili'),
  21. 'take_cash_rule' => config('site.take_cash_rule'),
  22. ];
  23. $this->success('success',$wallet);
  24. }
  25. //我的余额日志
  26. public function my_money_log(){
  27. $type = input('type',0);
  28. $map = [
  29. 'user_id' => $this->auth->id,
  30. ];
  31. if($type == 1){
  32. $map['change_value'] = ['gt',0];
  33. }
  34. if($type == 2){
  35. $map['change_value'] = ['lt',0];
  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. //追加log_text
  44. private function list_appen_logtext($list){
  45. if(!empty($list)){
  46. $conf = config('wallet.logtype');
  47. foreach($list as $key => $val){
  48. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  49. }
  50. }
  51. return $list;
  52. }
  53. }