Userwallet.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 钱包,积分
  7. */
  8. class Userwallet extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = ['*'];
  12. public function my_wallet(){
  13. $wallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
  14. $this->success(1,$wallet);
  15. }
  16. //积分日志
  17. public function score_log(){
  18. $type = input('type',1);
  19. $where = [
  20. 'user_id' => $this->auth->id
  21. ];
  22. if($type == 1){
  23. $where['change_value'] = ['egt',0];
  24. }else{
  25. $where['change_value'] = ['lt',0];
  26. }
  27. $list = Db::name('user_score_log')->field('id,before,change_value,remain,remark,remark_en,createtime')
  28. ->where($where)->autopage()->order('id desc')->select();
  29. if(!empty($list)){
  30. foreach($list as $key => &$val){
  31. $val['createtime'] = $this->datetime_lang($val['createtime']);
  32. $val = $this->info_lang($val,['remark']);
  33. }
  34. }
  35. $this->success(1,$list);
  36. }
  37. }