|
@@ -40,7 +40,7 @@ class User extends Api
|
|
|
$this->success('', ['welcome' => $this->auth->nickname]);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //h5注册
|
|
|
public function h5register()
|
|
|
{
|
|
|
$mobile = input('mobile');
|
|
@@ -209,119 +209,110 @@ class User extends Api
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
- * 运营商一键登录
|
|
|
+ * 微信注册来的,绑定手机号
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $mobile 手机号
|
|
|
+ * @param string $captcha 验证码
|
|
|
*/
|
|
|
- public function onLogin()
|
|
|
+ public function bindmobile()
|
|
|
{
|
|
|
- $accessToken = input('accessToken');// 运营商预取号获取到的token
|
|
|
- $token = input('tokenT');// 易盾返回的token
|
|
|
- if (!$accessToken || !$token) {
|
|
|
- $this->error("参数获取失败!");
|
|
|
- }
|
|
|
-
|
|
|
- $params = array(
|
|
|
- // 运营商预取号获取到的token
|
|
|
- "accessToken" => $accessToken,
|
|
|
- // 易盾返回的token
|
|
|
- "token" => $token
|
|
|
- );
|
|
|
-
|
|
|
- // 获取密钥配置
|
|
|
- $configInfo = config("onLogin");
|
|
|
- $onlogin = new onlogin($configInfo["secretid"], $configInfo["secretkey"], $configInfo["businessid"]);
|
|
|
-
|
|
|
- $onret = $onlogin->check($params);
|
|
|
-
|
|
|
-// $ret = [];
|
|
|
-// $ret["code"] = 200;
|
|
|
-// $ret["msg"] = "ok";
|
|
|
-// $ret["data"] = [
|
|
|
-// "phone" => "17574504021",
|
|
|
-// "resultCode" => 0
|
|
|
-// ];
|
|
|
-
|
|
|
- if ($onret["code"] == 200) {
|
|
|
- $mobile = $onret["data"]["phone"];
|
|
|
- if (empty($mobile)) {
|
|
|
- // 取号失败,建议进行二次验证,例如短信验证码
|
|
|
- $this->error("取号登录失败,请用验证码方式登录!");
|
|
|
- } else {
|
|
|
- // 取号成功, 执行登录等流程
|
|
|
- // 用户登录逻辑 === 开始
|
|
|
- $user = \app\common\model\User::getByMobile($mobile);
|
|
|
- if ($user) {
|
|
|
- if ($user->status == -1) {
|
|
|
- $this->error('账户已注销');
|
|
|
- }
|
|
|
- if ($user->status != 1) {
|
|
|
- $this->error(__('Account is locked'));
|
|
|
- }
|
|
|
- //如果已经有账号则直接登录
|
|
|
- $ret = $this->auth->direct($user->id);
|
|
|
- $is_register = 0;
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- $extend = [
|
|
|
- ];
|
|
|
- $ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
- $is_register = 1;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ $mobile = $this->request->param('mobile');
|
|
|
+ $captcha = $this->request->param('captcha');
|
|
|
+ $code = $this->request->param('code');
|
|
|
|
|
|
- if ($ret) {
|
|
|
- $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
|
|
|
- } else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
- }
|
|
|
- // 用户登录逻辑 === 结束
|
|
|
- }
|
|
|
- } else {
|
|
|
- $this->error("登录失败,请用验证码方式登录!");
|
|
|
+ if (!$mobile || !$captcha || !$code) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ $this->error(__('Mobile is incorrect'));
|
|
|
+ }
|
|
|
+ $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
+ if (!$result) {
|
|
|
+ $this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //苹果登录+预注册
|
|
|
- public function applelogin(){
|
|
|
- $iosUserId = $this->request->param('ios_user_id','');
|
|
|
- if(!$iosUserId){
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
+ $wechatCodeWhere['code'] = $code;
|
|
|
+ $wechatCode = Db::name('wechat_code')->where($wechatCodeWhere)->find();
|
|
|
+ if (empty($wechatCode)) {
|
|
|
+ $this->error('请先微信登录');
|
|
|
}
|
|
|
|
|
|
- //检查用户
|
|
|
- $user = Db::name('user')->where('ios_user_id',$iosUserId)->find();
|
|
|
+ //检查appid绑定的用户
|
|
|
+ $user = Db::name('user')->where('wechat_openid',$wechatCode['openid'])->find();
|
|
|
if ($user) {
|
|
|
if ($user['status'] == -1) {
|
|
|
- $this->error('账户已经注销');
|
|
|
+ $this->error('账户已注销');
|
|
|
}
|
|
|
if ($user['status'] != 1) {
|
|
|
$this->error(__('Account is locked'));
|
|
|
}
|
|
|
//如果已经有账号则直接登录
|
|
|
$ret = $this->auth->direct($user['id']);
|
|
|
+ $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
+ }
|
|
|
|
|
|
- if ($ret) {
|
|
|
- $userInfo = $this->auth->getUserinfo_simple();
|
|
|
- $userInfo['is_register'] = 0;
|
|
|
- $userInfo['ios_user_id'] = $iosUserId;
|
|
|
- $this->success(__('Logged in successful'), $userInfo);
|
|
|
+ //新的openid用户
|
|
|
+ $where = [];
|
|
|
+ $where['mobile'] = $mobile;
|
|
|
+ $userData = Db::name('user')->where($where)->find();//老用户
|
|
|
+ if (!empty($userData)) {
|
|
|
+ if (empty($userData['wechat_openid'])) {
|
|
|
+ Db::name('user')->where('id',$userData['id'])->update(['wechat_openid' => $wechatCode['openid']]);//老用户更新openid
|
|
|
} else {
|
|
|
- $this->error($this->auth->getError());
|
|
|
+ if ($userData['wechat_openid'] != $wechatCode['openid']) {
|
|
|
+ $this->error('该手机号已被其他用户绑定');
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ $ret = $this->auth->direct($userData['id']);
|
|
|
} else {
|
|
|
- //直接返回
|
|
|
- $userInfo = [];
|
|
|
- $userInfo['is_register'] = 1;
|
|
|
- $userInfo['ios_user_id'] = $iosUserId;
|
|
|
- $this->success('获取信息成功', $userInfo);
|
|
|
+ $extend = [
|
|
|
+ 'wechat_openid' => $wechatCode['openid'],
|
|
|
+ 'plat_unique_id' => input('plat_unique_id',''),
|
|
|
+ 'plat_from' => input('plat_from',''),
|
|
|
+ ];
|
|
|
+ $ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
+ }
|
|
|
+ if (!$ret) {
|
|
|
+ $this->error($this->auth->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 手机注册来的,绑定微信
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $wechat_openid
|
|
|
+ */
|
|
|
+ public function bindopenid()
|
|
|
+ {
|
|
|
+ $wechat_openid = input('wechat_openid');
|
|
|
+ if (!$wechat_openid) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($this->auth->wechat_openid)){
|
|
|
+ //$this->error('已经绑定了微信号');
|
|
|
+ }
|
|
|
+
|
|
|
+ $otherUserWhere['wechat_openid'] = $wechat_openid;
|
|
|
+ $otherUserWhere['id'] = ['neq',$this->auth->id];
|
|
|
+ if (\app\common\model\User::where($otherUserWhere)->find()) {
|
|
|
+ $this->error('该微信号已被其他用户绑定');
|
|
|
}
|
|
|
|
|
|
+ $user = $this->auth->getUser();
|
|
|
+ $user->wechat_openid = $wechat_openid;
|
|
|
+ $user->save();
|
|
|
+
|
|
|
+ $this->success('绑定成功',$this->auth->getUserinfo_simple());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//用户详细资料
|
|
|
public function userInfo($type = 1){
|
|
|
$info = $this->auth->getUserinfo();
|
|
@@ -737,87 +728,249 @@ class User extends Api
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 苹果注册来的,绑定手机号
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $mobile 手机号
|
|
|
- * @param string $captcha 验证码
|
|
|
- */
|
|
|
- public function applebindmobile()
|
|
|
- {
|
|
|
- $mobile = $this->request->param('mobile');
|
|
|
- $captcha = $this->request->param('captcha');
|
|
|
- $iosUserId = $this->request->param('ios_user_id','');
|
|
|
|
|
|
- if (!$mobile || !$captcha || !$iosUserId) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //假注销
|
|
|
+ public function cancleUser(){
|
|
|
+ $captcha = input('captcha','');
|
|
|
+
|
|
|
+ if (!$captcha) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
- if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
- $this->error(__('Mobile is incorrect'));
|
|
|
- }
|
|
|
- $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
- if (!$result) {
|
|
|
+
|
|
|
+ if (!Sms::check($this->auth->mobile, $captcha, 'mobilelogin')) {
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
|
|
|
+ Db::name('user')->where('id',$this->auth->id)->update(['status'=>-1]);
|
|
|
|
|
|
- //检查ios_user_id绑定的用户
|
|
|
- $user = Db::name('user')->where('ios_user_id',$iosUserId)->find();
|
|
|
- if ($user) {
|
|
|
- if ($user['status'] == -1) {
|
|
|
- $this->error('账户已经注销');
|
|
|
- }
|
|
|
- if ($user['status'] != 1) {
|
|
|
- $this->error(__('Account is locked'));
|
|
|
- }
|
|
|
- //如果已经有账号则直接登录
|
|
|
+ $this->auth->logout();
|
|
|
+ $this->success('注销成功');
|
|
|
+ }
|
|
|
|
|
|
- $ret = $this->auth->direct($user['id']);
|
|
|
- $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
- }
|
|
|
|
|
|
- //新的ios用户
|
|
|
- $where = [];
|
|
|
- $where['mobile'] = $mobile;
|
|
|
- $userData = Db::name('user')->where($where)->find();//老用户
|
|
|
- if (!empty($userData)) {
|
|
|
- if (empty($userData['ios_user_id'])) {
|
|
|
- Db::name('user')->where('id',$userData['id'])->update(['ios_user_id' => $iosUserId]);//老用户更新ios_user_id
|
|
|
- } else {
|
|
|
- if ($userData['ios_user_id'] != $iosUserId) {
|
|
|
- $this->error('该手机号已被其他用户绑定');
|
|
|
- }
|
|
|
- }
|
|
|
- $ret = $this->auth->direct($userData['id']);
|
|
|
- } else {
|
|
|
- $extend = [
|
|
|
- 'ios_user_id' => $iosUserId,
|
|
|
- ];
|
|
|
- $ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
- }
|
|
|
- if (!$ret) {
|
|
|
- $this->error($this->auth->getError());
|
|
|
+ //文字语音视频收费设置
|
|
|
+ public function chargeconfig() {
|
|
|
+ $type = input('type', 0, 'intval'); //类型:0=文字,1=语音,2=视频
|
|
|
+ if (!in_array($type, [0, 1, 2])) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
}
|
|
|
|
|
|
+ $where['type'] = $type;
|
|
|
+ $where['level'] = ['elt',$this->auth->charm_level];
|
|
|
|
|
|
- $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
+ $list = Db::name('charge_config')->field('id, price, level')->where($where)->order('price asc')->select();
|
|
|
|
|
|
+ $this->success('success', $list);
|
|
|
}
|
|
|
- /**
|
|
|
- * 微信注册来的,绑定手机号
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $mobile 手机号
|
|
|
- * @param string $captcha 验证码
|
|
|
- */
|
|
|
- public function bindmobile()
|
|
|
+
|
|
|
+ //文字语音视频收费/隐藏所在位置设置
|
|
|
+ public function chargeset() {
|
|
|
+
|
|
|
+ if($this->auth->gender == 1 && $this->auth->idcard_status != 1){
|
|
|
+ $this->error('请先完成实名认证');
|
|
|
+ }
|
|
|
+ if($this->auth->gender == 0 && $this->auth->real_status != 1){
|
|
|
+ $this->error('请先完成真人认证');
|
|
|
+ }
|
|
|
+
|
|
|
+ $chat_id = input('chat_id', 0, 'intval'); //文字收费id
|
|
|
+ $voice_id = input('voice_id', 0, 'intval'); //语音收费id
|
|
|
+ $video_id = input('video_id', 0, 'intval'); //视频收费id
|
|
|
+
|
|
|
+ $open_match_audio = input('open_match_audio', -1, 'intval'); //是否开启语音:1是 0否
|
|
|
+ $open_match_video = input('open_match_video', -1, 'intval'); //是否开启视频:1是 0否
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ //查询我的魅力等级
|
|
|
+ $level = $this->auth->charm_level;
|
|
|
+
|
|
|
+ if ($chat_id) {
|
|
|
+ $charge_config = Db::name('charge_config')->where(['id' => $chat_id, 'type' => 0])->find();
|
|
|
+ if (!$charge_config) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+ if ($level < $charge_config['level']) {
|
|
|
+ $this->error('您还未满足条件~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['match_typing_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('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+ if ($level < $charge_config['level']) {
|
|
|
+ $this->error('您还未满足条件~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['match_audio_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('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+ if ($level < $charge_config['level']) {
|
|
|
+ $this->error('您还未满足条件~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['match_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 (!$data) {
|
|
|
+ $this->error('没有修改信息~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
|
|
|
+ if ($rs === false) {
|
|
|
+ $this->error('您的网络开小差啦~');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('设置成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ //////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 运营商一键登录
|
|
|
+ */
|
|
|
+ public function onLogin()
|
|
|
{
|
|
|
- $mobile = $this->request->param('mobile');
|
|
|
- $captcha = $this->request->param('captcha');
|
|
|
- $code = $this->request->param('code');
|
|
|
+ $accessToken = input('accessToken');// 运营商预取号获取到的token
|
|
|
+ $token = input('tokenT');// 易盾返回的token
|
|
|
+ if (!$accessToken || !$token) {
|
|
|
+ $this->error("参数获取失败!");
|
|
|
+ }
|
|
|
|
|
|
- if (!$mobile || !$captcha || !$code) {
|
|
|
+ $params = array(
|
|
|
+ // 运营商预取号获取到的token
|
|
|
+ "accessToken" => $accessToken,
|
|
|
+ // 易盾返回的token
|
|
|
+ "token" => $token
|
|
|
+ );
|
|
|
+
|
|
|
+ // 获取密钥配置
|
|
|
+ $configInfo = config("onLogin");
|
|
|
+ $onlogin = new onlogin($configInfo["secretid"], $configInfo["secretkey"], $configInfo["businessid"]);
|
|
|
+
|
|
|
+ $onret = $onlogin->check($params);
|
|
|
+
|
|
|
+// $ret = [];
|
|
|
+// $ret["code"] = 200;
|
|
|
+// $ret["msg"] = "ok";
|
|
|
+// $ret["data"] = [
|
|
|
+// "phone" => "17574504021",
|
|
|
+// "resultCode" => 0
|
|
|
+// ];
|
|
|
+
|
|
|
+ if ($onret["code"] == 200) {
|
|
|
+ $mobile = $onret["data"]["phone"];
|
|
|
+ if (empty($mobile)) {
|
|
|
+ // 取号失败,建议进行二次验证,例如短信验证码
|
|
|
+ $this->error("取号登录失败,请用验证码方式登录!");
|
|
|
+ } else {
|
|
|
+ // 取号成功, 执行登录等流程
|
|
|
+ // 用户登录逻辑 === 开始
|
|
|
+ $user = \app\common\model\User::getByMobile($mobile);
|
|
|
+ if ($user) {
|
|
|
+ if ($user->status == -1) {
|
|
|
+ $this->error('账户已注销');
|
|
|
+ }
|
|
|
+ if ($user->status != 1) {
|
|
|
+ $this->error(__('Account is locked'));
|
|
|
+ }
|
|
|
+ //如果已经有账号则直接登录
|
|
|
+ $ret = $this->auth->direct($user->id);
|
|
|
+ $is_register = 0;
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $extend = [
|
|
|
+ ];
|
|
|
+ $ret = $this->auth->register('', '', '', $mobile, $extend);
|
|
|
+ $is_register = 1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($ret) {
|
|
|
+ $this->success(__('Logged in successful'), $this->auth->getUserinfo_simple());
|
|
|
+ } else {
|
|
|
+ $this->error($this->auth->getError());
|
|
|
+ }
|
|
|
+ // 用户登录逻辑 === 结束
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $this->error("登录失败,请用验证码方式登录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //苹果登录+预注册
|
|
|
+ public function applelogin(){
|
|
|
+ $iosUserId = $this->request->param('ios_user_id','');
|
|
|
+ if(!$iosUserId){
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查用户
|
|
|
+ $user = Db::name('user')->where('ios_user_id',$iosUserId)->find();
|
|
|
+ if ($user) {
|
|
|
+ if ($user['status'] == -1) {
|
|
|
+ $this->error('账户已经注销');
|
|
|
+ }
|
|
|
+ if ($user['status'] != 1) {
|
|
|
+ $this->error(__('Account is locked'));
|
|
|
+ }
|
|
|
+ //如果已经有账号则直接登录
|
|
|
+ $ret = $this->auth->direct($user['id']);
|
|
|
+
|
|
|
+ if ($ret) {
|
|
|
+ $userInfo = $this->auth->getUserinfo_simple();
|
|
|
+ $userInfo['is_register'] = 0;
|
|
|
+ $userInfo['ios_user_id'] = $iosUserId;
|
|
|
+ $this->success(__('Logged in successful'), $userInfo);
|
|
|
+ } else {
|
|
|
+ $this->error($this->auth->getError());
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //直接返回
|
|
|
+ $userInfo = [];
|
|
|
+ $userInfo['is_register'] = 1;
|
|
|
+ $userInfo['ios_user_id'] = $iosUserId;
|
|
|
+ $this->success('获取信息成功', $userInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 苹果注册来的,绑定手机号
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $mobile 手机号
|
|
|
+ * @param string $captcha 验证码
|
|
|
+ */
|
|
|
+ public function applebindmobile()
|
|
|
+ {
|
|
|
+ $mobile = $this->request->param('mobile');
|
|
|
+ $captcha = $this->request->param('captcha');
|
|
|
+ $iosUserId = $this->request->param('ios_user_id','');
|
|
|
+
|
|
|
+ if (!$mobile || !$captcha || !$iosUserId) {
|
|
|
$this->error(__('Invalid parameters'));
|
|
|
}
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
@@ -828,44 +981,38 @@ class User extends Api
|
|
|
$this->error(__('Captcha is incorrect'));
|
|
|
}
|
|
|
|
|
|
- $wechatCodeWhere['code'] = $code;
|
|
|
- $wechatCode = Db::name('wechat_code')->where($wechatCodeWhere)->find();
|
|
|
- if (empty($wechatCode)) {
|
|
|
- $this->error('请先微信登录');
|
|
|
- }
|
|
|
|
|
|
- //检查appid绑定的用户
|
|
|
- $user = Db::name('user')->where('wechat_openid',$wechatCode['openid'])->find();
|
|
|
+ //检查ios_user_id绑定的用户
|
|
|
+ $user = Db::name('user')->where('ios_user_id',$iosUserId)->find();
|
|
|
if ($user) {
|
|
|
if ($user['status'] == -1) {
|
|
|
- $this->error('账户已注销');
|
|
|
+ $this->error('账户已经注销');
|
|
|
}
|
|
|
if ($user['status'] != 1) {
|
|
|
$this->error(__('Account is locked'));
|
|
|
}
|
|
|
//如果已经有账号则直接登录
|
|
|
+
|
|
|
$ret = $this->auth->direct($user['id']);
|
|
|
$this->success('success',$this->auth->getUserinfo_simple());
|
|
|
}
|
|
|
|
|
|
- //新的openid用户
|
|
|
+ //新的ios用户
|
|
|
$where = [];
|
|
|
$where['mobile'] = $mobile;
|
|
|
$userData = Db::name('user')->where($where)->find();//老用户
|
|
|
if (!empty($userData)) {
|
|
|
- if (empty($userData['wechat_openid'])) {
|
|
|
- Db::name('user')->where('id',$userData['id'])->update(['wechat_openid' => $wechatCode['openid']]);//老用户更新openid
|
|
|
+ if (empty($userData['ios_user_id'])) {
|
|
|
+ Db::name('user')->where('id',$userData['id'])->update(['ios_user_id' => $iosUserId]);//老用户更新ios_user_id
|
|
|
} else {
|
|
|
- if ($userData['wechat_openid'] != $wechatCode['openid']) {
|
|
|
+ if ($userData['ios_user_id'] != $iosUserId) {
|
|
|
$this->error('该手机号已被其他用户绑定');
|
|
|
}
|
|
|
}
|
|
|
$ret = $this->auth->direct($userData['id']);
|
|
|
} else {
|
|
|
$extend = [
|
|
|
- 'wechat_openid' => $wechatCode['openid'],
|
|
|
- 'plat_unique_id' => input('plat_unique_id',''),
|
|
|
- 'plat_from' => input('plat_from',''),
|
|
|
+ 'ios_user_id' => $iosUserId,
|
|
|
];
|
|
|
$ret = $this->auth->register('', '','', $mobile, $extend);
|
|
|
}
|
|
@@ -873,41 +1020,11 @@ class User extends Api
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
|
|
|
- $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 手机注册来的,绑定微信
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $wechat_openid
|
|
|
- */
|
|
|
- public function bindopenid()
|
|
|
- {
|
|
|
- $wechat_openid = input('wechat_openid');
|
|
|
- if (!$wechat_openid) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- if(!empty($this->auth->wechat_openid)){
|
|
|
- //$this->error('已经绑定了微信号');
|
|
|
- }
|
|
|
-
|
|
|
- $otherUserWhere['wechat_openid'] = $wechat_openid;
|
|
|
- $otherUserWhere['id'] = ['neq',$this->auth->id];
|
|
|
- if (\app\common\model\User::where($otherUserWhere)->find()) {
|
|
|
- $this->error('该微信号已被其他用户绑定');
|
|
|
- }
|
|
|
-
|
|
|
- $user = $this->auth->getUser();
|
|
|
- $user->wechat_openid = $wechat_openid;
|
|
|
- $user->save();
|
|
|
+ $this->success('success',$this->auth->getUserinfo_simple());
|
|
|
|
|
|
- $this->success('绑定成功',$this->auth->getUserinfo_simple());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 重置密码
|
|
|
*
|
|
@@ -982,114 +1099,4 @@ class User extends Api
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //假注销
|
|
|
- public function cancleUser(){
|
|
|
- $captcha = input('captcha','');
|
|
|
-
|
|
|
- if (!$captcha) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
-
|
|
|
- if (!Sms::check($this->auth->mobile, $captcha, 'mobilelogin')) {
|
|
|
- $this->error(__('Captcha is incorrect'));
|
|
|
- }
|
|
|
-
|
|
|
- Db::name('user')->where('id',$this->auth->id)->update(['status'=>-1]);
|
|
|
-
|
|
|
- $this->auth->logout();
|
|
|
- $this->success('注销成功');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //文字语音视频收费设置
|
|
|
- public function chargeconfig() {
|
|
|
- $type = input('type', 0, 'intval'); //类型:0=文字,1=语音,2=视频
|
|
|
- if (!in_array($type, [0, 1, 2])) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
-
|
|
|
- $where['type'] = $type;
|
|
|
- $where['level'] = ['elt',$this->auth->charm_level];
|
|
|
-
|
|
|
- $list = Db::name('charge_config')->field('id, price, level')->where($where)->order('price asc')->select();
|
|
|
-
|
|
|
- $this->success('success', $list);
|
|
|
- }
|
|
|
-
|
|
|
- //文字语音视频收费/隐藏所在位置设置
|
|
|
- public function chargeset() {
|
|
|
-
|
|
|
- if($this->auth->gender == 1 && $this->auth->idcard_status != 1){
|
|
|
- $this->error('请先完成实名认证');
|
|
|
- }
|
|
|
- if($this->auth->gender == 0 && $this->auth->real_status != 1){
|
|
|
- $this->error('请先完成真人认证');
|
|
|
- }
|
|
|
-
|
|
|
- $chat_id = input('chat_id', 0, 'intval'); //文字收费id
|
|
|
- $voice_id = input('voice_id', 0, 'intval'); //语音收费id
|
|
|
- $video_id = input('video_id', 0, 'intval'); //视频收费id
|
|
|
-
|
|
|
- $open_match_audio = input('open_match_audio', -1, 'intval'); //是否开启语音:1是 0否
|
|
|
- $open_match_video = input('open_match_video', -1, 'intval'); //是否开启视频:1是 0否
|
|
|
-
|
|
|
- $data = [];
|
|
|
- //查询我的魅力等级
|
|
|
- $level = $this->auth->charm_level;
|
|
|
-
|
|
|
- if ($chat_id) {
|
|
|
- $charge_config = Db::name('charge_config')->where(['id' => $chat_id, 'type' => 0])->find();
|
|
|
- if (!$charge_config) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
- if ($level < $charge_config['level']) {
|
|
|
- $this->error('您还未满足条件~');
|
|
|
- }
|
|
|
-
|
|
|
- $data['match_typing_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('您的网络开小差啦~');
|
|
|
- }
|
|
|
- if ($level < $charge_config['level']) {
|
|
|
- $this->error('您还未满足条件~');
|
|
|
- }
|
|
|
-
|
|
|
- $data['match_audio_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('您的网络开小差啦~');
|
|
|
- }
|
|
|
- if ($level < $charge_config['level']) {
|
|
|
- $this->error('您还未满足条件~');
|
|
|
- }
|
|
|
-
|
|
|
- $data['match_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 (!$data) {
|
|
|
- $this->error('没有修改信息~');
|
|
|
- }
|
|
|
-
|
|
|
- $rs = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
|
|
|
- if ($rs === false) {
|
|
|
- $this->error('您的网络开小差啦~');
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('设置成功');
|
|
|
- }
|
|
|
-
|
|
|
}
|