Userwallet.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. use app\admin\model\shopro\user\WalletLog as UserWalletLogModel;
  6. //use app\common\model\wallet;
  7. /**
  8. * 用户钱包
  9. */
  10. class Userwallet extends Api
  11. {
  12. protected $noNeedLogin = [];
  13. protected $noNeedRight = ['*'];
  14. //我的钱包余额
  15. public function my_wallet(){
  16. $wallet['money'] = $this->auth->money;
  17. $this->success('success',$wallet);
  18. }
  19. //我的余额日志
  20. public function my_money_log()
  21. {
  22. $tab = $this->request->param('type', 'all');
  23. $where = [
  24. 'user_id' => $this->auth->id,
  25. ];
  26. if($tab == 1){
  27. $where['change_value'] = ['>', 0];
  28. }
  29. if($tab == 2){
  30. $where['change_value'] = ['<', 0];
  31. }
  32. $logs = Db::name('user_money_log')
  33. ->field('id,log_type,before,change_value,remain,remark,createtime')
  34. ->where($where)
  35. ->order('id desc')
  36. ->autopage()->select();
  37. $this->success(1, $logs);
  38. }
  39. //善豆明细
  40. public function my_bean_log(){
  41. $type = input('type',0);
  42. $map = [
  43. 'user_id' => $this->auth->id,
  44. ];
  45. if($type){
  46. $map['log_type'] = $type;
  47. }
  48. $list = Db::name('user_bean_log')
  49. ->field('id,log_type,before,change_value,remain,remark,createtime')
  50. ->where($map)
  51. ->order('id desc')
  52. ->autopage()->select();
  53. // $list = $this->list_appen_logtext($list);
  54. $this->success(1,$list);
  55. }
  56. //追加log_text
  57. private function list_appen_logtext($list){
  58. if(!empty($list)){
  59. $conf = config('wallet.logtype');
  60. foreach($list as $key => $val){
  61. $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
  62. }
  63. }
  64. return $list;
  65. }
  66. }