123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- class Userset extends Api
- {
- protected $noNeedLogin = ['chargeconfig'];
- protected $noNeedRight = '*';
-
- public function userinfo(){
- $field = [
- 'id','mobile','wechat_openid','real_status','idcard_status','open_match_video','open_match_audio','chat_price','voice_price','video_price', 'is_hideaddress'
- ];
- $info = Db::name('user')->field($field)->where('id',$this->auth->id)->find();
- $rs = $info;
- $rs['mobile'] = $info['mobile'] ? 1 : 0;
- $rs['wechat_openid'] = $info['wechat_openid'] ? 1 : 0;
- $rs['alipay'] = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 1])->count('id');
- $rs['bank'] = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 2])->count('id');
- $rs['new_user_intro_gold'] = config('site.new_user_intro_gold') ? : 0;
- $rs['intro_recharge_rebate_rate'] = $this->auth->is_agent == 1 ? $this->auth->h_intro_recharge_rebate_rate : config('site.intro_recharge_rebate_rate');
- $rs['intro_income_rebate_rate'] = $this->auth->is_agent == 1 ? $this->auth->h_intro_income_rebate_rate : config('site.intro_income_rebate_rate');
- $this->success('success',$rs);
- }
-
-
-
- public function chargeconfig() {
- $type = input('type', 0, 'intval');
- if (!in_array($type, [0, 1, 2])) {
- $this->error('您的网络开小差啦~');
- }
- $where['type'] = $type;
- $list = Db::name('charge_config')->field('id, price, level')->where($where)->select();
- $this->success('success', $list);
- }
-
- public function chargeset() {
- $chat_id = input('chat_id', 0, 'intval');
- $voice_id = input('voice_id', 0, 'intval');
- $video_id = input('video_id', 0, 'intval');
- $open_match_audio = input('open_match_audio', -1, 'intval');
- $open_match_video = input('open_match_video', -1, 'intval');
- $is_hideaddress = input('is_hideaddress', -1, 'intval');
- $data = [];
-
-
- if ($chat_id) {
- $charge_config = Db::name('charge_config')->where(['id' => $chat_id, 'type' => 0])->find();
- if (!$charge_config) {
- $this->error('您的网络开小差啦~');
- }
-
- $data['chat_price'] = $charge_config['price'];
- }
- if ($voice_id) {
- $charge_config = Db::name('charge_config')->where(['id' => $voice_id, 'type' => 1])->find();
- if (!$charge_config) {
- $this->error('您的网络开小差啦~');
- }
-
- $data['voice_price'] = $charge_config['price'];
- }
- if ($video_id) {
- $charge_config = Db::name('charge_config')->where(['id' => $video_id, 'type' => 2])->find();
- if (!$charge_config) {
- $this->error('您的网络开小差啦~');
- }
-
- $data['video_price'] = $charge_config['price'];
- }
- if (in_array($open_match_audio, [1, 0])) {
- $data['open_match_audio'] = $open_match_audio;
- }
- if (in_array($open_match_video, [1, 0])) {
- $data['open_match_video'] = $open_match_video;
- }
- if (in_array($is_hideaddress, [1, 0])) {
- $data['is_hideaddress'] = $is_hideaddress;
- }
- if (!$data) {
- $this->error('没有修改信息~');
- }
- $rs = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
- if ($rs === false) {
- $this->error('您的网络开小差啦~');
- }
- $this->success('设置成功');
- }
- }
|