Userset.php 6.1 KB

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