Userset.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 用户设置,从user拿出来
  7. */
  8. class Userset extends Api
  9. {
  10. protected $noNeedLogin = ['chargeconfig'];
  11. protected $noNeedRight = '*';
  12. //用户详细资料
  13. public function userinfo(){
  14. $field = [
  15. 'id','mobile','wechat_openid','real_status','idcard_status','open_match_video','open_match_audio','chat_price','voice_price','video_price', 'is_hideaddress'
  16. ];
  17. $info = Db::name('user')->field($field)->where('id',$this->auth->id)->find();
  18. $rs = $info;
  19. $rs['mobile'] = $info['mobile'] ? 1 : 0; //手机号
  20. $rs['wechat_openid'] = $info['wechat_openid'] ? 1 : 0; //微信
  21. $rs['alipay'] = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 1])->count('id'); //支付宝绑定
  22. $rs['bank'] = Db::name('user_bank')->where(['user_id' => $this->auth->id, 'type' => 2])->count('id'); //银行卡绑定
  23. $rs['new_user_intro_gold'] = config('site.new_user_intro_gold') ? : 0; //邀请注册赠送金币
  24. $rs['intro_recharge_rebate_rate'] = $this->auth->is_agent == 1 ? $this->auth->h_intro_recharge_rebate_rate : config('site.intro_recharge_rebate_rate'); //邀请人充值返利比率
  25. $rs['intro_income_rebate_rate'] = $this->auth->is_agent == 1 ? $this->auth->h_intro_income_rebate_rate : config('site.intro_income_rebate_rate'); //邀请人收益返利比率
  26. $this->success('success',$rs);
  27. }
  28. /**
  29. * 修改会员状态信息 , APP验证过,没用到
  30. */
  31. /*public function set_status_switch()
  32. {
  33. if($this->auth->idcard_status != 1){
  34. $this->error('未通过实名认证');
  35. }
  36. if($this->auth->real_status != 1){
  37. $this->error('未通过真人认证');
  38. }
  39. //开始
  40. $field_array = ['open_match_video','open_match_audio','open_match_typing','free_video','free_audio','free_typing'];
  41. $data = [];
  42. $field = input_post('switch','default');
  43. $value = input_post('switch_value',0);
  44. if(!in_array($field,$field_array)){
  45. $this->error();
  46. }
  47. if(!empty($field)){
  48. $data[$field] = $value;
  49. }
  50. if(empty($data)){
  51. $this->error('没有任何改变');
  52. }
  53. Db::name('user')->where('id',$this->auth->id)->update($data);
  54. $this->success();
  55. }*/
  56. //文字语音视频收费配置
  57. public function chargeconfig() {
  58. $type = input('type', 0, 'intval'); //类型:0=文字,1=语音,2=视频
  59. if (!in_array($type, [0, 1, 2])) {
  60. $this->error('您的网络开小差啦~');
  61. }
  62. $where['type'] = $type;
  63. $list = Db::name('charge_config')->field('id, price, level')->where($where)->select();
  64. $this->success('success', $list);
  65. }
  66. //文字语音视频收费/隐藏所在位置设置
  67. public function chargeset() {
  68. $chat_id = input('chat_id', 0, 'intval'); //文字收费id
  69. $voice_id = input('voice_id', 0, 'intval'); //语音收费id
  70. $video_id = input('video_id', 0, 'intval'); //视频收费id
  71. $open_match_audio = input('open_match_audio', -1, 'intval'); //是否开启语音:1是 0否
  72. $open_match_video = input('open_match_video', -1, 'intval'); //是否开启视频:1是 0否
  73. $is_hideaddress = input('is_hideaddress', -1, 'intval'); //是否隐藏所在位置:0=否,1=是
  74. $data = [];
  75. //查询我的魅力等级
  76. /*$wallet_info = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
  77. $charm_level = Db::name('charm_level')->where(['value' => ['elt', $wallet_info['get_money']]])->order('id desc')->find();
  78. if ($charm_level) {
  79. $level = $charm_level['level'];
  80. } else {
  81. $level = 0;
  82. }*/
  83. if ($chat_id) {
  84. $charge_config = Db::name('charge_config')->where(['id' => $chat_id, 'type' => 0])->find();
  85. if (!$charge_config) {
  86. $this->error('您的网络开小差啦~');
  87. }
  88. /*if ($level < $charge_config['level']) {
  89. $this->error('您还未满足条件~');
  90. }*/
  91. $data['chat_price'] = $charge_config['price'];
  92. }
  93. if ($voice_id) {
  94. $charge_config = Db::name('charge_config')->where(['id' => $voice_id, 'type' => 1])->find();
  95. if (!$charge_config) {
  96. $this->error('您的网络开小差啦~');
  97. }
  98. /*if ($level < $charge_config['level']) {
  99. $this->error('您还未满足条件~');
  100. }*/
  101. $data['voice_price'] = $charge_config['price'];
  102. }
  103. if ($video_id) {
  104. $charge_config = Db::name('charge_config')->where(['id' => $video_id, 'type' => 2])->find();
  105. if (!$charge_config) {
  106. $this->error('您的网络开小差啦~');
  107. }
  108. /*if ($level < $charge_config['level']) {
  109. $this->error('您还未满足条件~');
  110. }*/
  111. $data['video_price'] = $charge_config['price'];
  112. }
  113. if (in_array($open_match_audio, [1, 0])) {
  114. $data['open_match_audio'] = $open_match_audio;
  115. }
  116. if (in_array($open_match_video, [1, 0])) {
  117. $data['open_match_video'] = $open_match_video;
  118. }
  119. if (in_array($is_hideaddress, [1, 0])) {
  120. $data['is_hideaddress'] = $is_hideaddress;
  121. }
  122. if (!$data) {
  123. $this->error('没有修改信息~');
  124. }
  125. $rs = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
  126. if ($rs === false) {
  127. $this->error('您的网络开小差啦~');
  128. }
  129. $this->success('设置成功');
  130. }
  131. }