Userwallet.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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,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. }
  33. }
  34. $this->success(1,$list);
  35. }
  36. }