123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- //use app\common\model\wallet;
- /**
- * 用户钱包
- */
- class Userwallet extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- //我的钱包余额
- public function my_wallet(){
- $wallet = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
- $wallet['user_alipay'] = Db::name('user_alipay')->where(['user_id' => $this->auth->id])->find();
- $wallet['user_bank'] = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
- $wallet['user_wechat'] = Db::name('user_wechat')->where(['user_id' => $this->auth->id])->find();
- $this->success('success',$wallet);
- }
- //我的余额日志
- public function my_money_log(){
- $type = input('type',0);
- $map = [
- 'user_id' => $this->auth->id,
- ];
- if($type == 1){
- $map['change_value'] = ['gt',0];
- }
- if($type == 2){
- $map['change_value'] = ['lt',0];
- }
- $list = Db::name('user_money_log')
- ->field('id,log_type,before,change_value,remain,remark,createtime')
- ->where($map)->order('id desc')->autopage()->select();
- $list = $this->list_appen_logtext($list);
- $this->success('success',$list);
- }
- //追加log_text
- private function list_appen_logtext($list){
- if(!empty($list)){
- $conf = config('wallet.logtype');
- $conf_en = config('wallet.logtype_en');
- foreach($list as $key => $val){
- $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
- $list[$key]['log_text_en'] = isset($conf_en[$val['log_type']]) ? $conf_en[$val['log_type']] : '';
- }
- }
- return $list;
- }
- }
|