| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?phpnamespace 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 = model('wallet')->getwallet($this->auth->id);        $wallet['is_vip'] = $wallet['vip_endtime'] > time() ? 1 : 0;        $this->success('success',$wallet);    }    //我的余额日志    public function my_money_log(){        $type = input_post('type',0);        $map = [           'user_id' => $this->auth->id,        ];        if($type){            $map['log_type'] = $type;        }        $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);    }    //金币日志    public function my_gold_log(){        $type = input_post('type',0);        $map = [            'user_id' => $this->auth->id,        ];        if($type){            $map['log_type'] = $type;        }        $list = Db::name('user_gold_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');            foreach($list as $key => $val){                $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';            }        }        return $list;    }}
 |