|
@@ -509,6 +509,65 @@ class User extends Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 微信注册来的,绑定手机号
|
|
|
+ *
|
|
|
+ * @ApiMethod (POST)
|
|
|
+ * @param string $mobile 手机号
|
|
|
+ * @param string $captcha 验证码
|
|
|
+ */
|
|
|
+ public function bindmobile()
|
|
|
+ {
|
|
|
+ $user = $this->auth->getUser();
|
|
|
+ $mobile = $this->request->request('mobile');
|
|
|
+ $captcha = $this->request->request('captcha');
|
|
|
+
|
|
|
+ if(!empty($this->auth->mobile)){
|
|
|
+ $this->error('已经绑定了手机号');
|
|
|
+ }
|
|
|
+ if (!$mobile || !$captcha) {
|
|
|
+ $this->error(__('Invalid parameters'));
|
|
|
+ }
|
|
|
+ if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
+ $this->error(__('Mobile is incorrect'));
|
|
|
+ }
|
|
|
+ if (\app\common\model\User::where('mobile', $mobile)->find()) {
|
|
|
+ $this->error('该手机号已被其他用户绑定');
|
|
|
+ }
|
|
|
+ $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
+ if (!$result) {
|
|
|
+ $this->error(__('Captcha is incorrect'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $user->mobile = $mobile;
|
|
|
+ $user->save();
|
|
|
+
|
|
|
+ Sms::flush($mobile, 'changemobile');
|
|
|
+
|
|
|
+ //手机号奖励
|
|
|
+ $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,18);
|
|
|
+ if($task_rs === false){
|
|
|
+ Db::rollback();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $this->success('success',$this->userInfo('return'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //注销配置
|
|
|
+ public function cancleconfig(){
|
|
|
+ $rs = [
|
|
|
+ 'rule' => config('site.user_cancle_rules'),
|
|
|
+ 'reason' => [
|
|
|
+ '想换个新账号',
|
|
|
+ '没有聊得来的',
|
|
|
+ '不想玩了',
|
|
|
+ '其他原因',
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ $this->success(1,$rs);
|
|
|
+ }
|
|
|
+
|
|
|
//假注销
|
|
|
public function cancleUser(){
|
|
|
if (!$this->request->isPost()) {
|
|
@@ -1109,51 +1168,6 @@ class User extends Api
|
|
|
Sms::flush($mobile, 'changemobile');
|
|
|
$this->success();
|
|
|
}
|
|
|
- /**
|
|
|
- * 微信注册来的,绑定手机号
|
|
|
- *
|
|
|
- * @ApiMethod (POST)
|
|
|
- * @param string $mobile 手机号
|
|
|
- * @param string $captcha 验证码
|
|
|
- */
|
|
|
- /*public function bindmobile()
|
|
|
- {
|
|
|
- $user = $this->auth->getUser();
|
|
|
- $mobile = $this->request->request('mobile');
|
|
|
- $captcha = $this->request->request('captcha');
|
|
|
-
|
|
|
- if(!empty($this->auth->mobile)){
|
|
|
- $this->error('已经绑定了手机号');
|
|
|
- }
|
|
|
- if (!$mobile || !$captcha) {
|
|
|
- $this->error(__('Invalid parameters'));
|
|
|
- }
|
|
|
- if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
- $this->error(__('Mobile is incorrect'));
|
|
|
- }
|
|
|
- if (\app\common\model\User::where('mobile', $mobile)->find()) {
|
|
|
- $this->error('该手机号已被其他用户绑定');
|
|
|
- }
|
|
|
- $result = Sms::check($mobile, $captcha, 'changemobile');
|
|
|
- if (!$result) {
|
|
|
- $this->error(__('Captcha is incorrect'));
|
|
|
- }
|
|
|
- $verification = $user->verification;
|
|
|
- $verification->mobile = 1;
|
|
|
- $user->verification = $verification;
|
|
|
- $user->mobile = $mobile;
|
|
|
- $user->save();
|
|
|
-
|
|
|
- Sms::flush($mobile, 'changemobile');
|
|
|
-
|
|
|
- //手机号奖励
|
|
|
- $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,18);
|
|
|
- if($task_rs === false){
|
|
|
- Db::rollback();
|
|
|
- return false;
|
|
|
- }
|
|
|
- $this->success('success',$this->userInfo('return'));
|
|
|
- }*/
|
|
|
|
|
|
/**
|
|
|
* 手机号注册来的,绑定微信
|
|
@@ -1924,68 +1938,6 @@ class User extends Api
|
|
|
$this->success('用户', $id);
|
|
|
}
|
|
|
|
|
|
- //绑定支付宝账号信息
|
|
|
- public function bindalipayaccount() {
|
|
|
- $mt_user_bank = Db::name('user_bank');
|
|
|
- $count = $mt_user_bank->where(['user_id' => $this->auth->id, 'type' => 1])->count();
|
|
|
- if ($count) {
|
|
|
- $this->error('您已绑定支付宝啦');
|
|
|
- }
|
|
|
-
|
|
|
- $auth_code = input('auth_code', '', 'trim');
|
|
|
- if (!$auth_code) {
|
|
|
- $this->error('授权码缺失');
|
|
|
- }
|
|
|
- //获取支付宝用户信息
|
|
|
- $rs = getAlipayInfo($auth_code);
|
|
|
- if ($rs['status'] == 0) {
|
|
|
- $this->error($rs['info']);
|
|
|
- }
|
|
|
- $rs = $rs['data'];
|
|
|
- /*
|
|
|
- * Array(
|
|
|
- [alipay_user_info_share_response] => Array
|
|
|
- (
|
|
|
- [code] => 10000
|
|
|
- [msg] => Success
|
|
|
- [avatar] => https://tfs.alipayobjects.com/images/partner/T1BQJsXhhbXXXXXXXX 头像
|
|
|
- [city] => 临沂市 市名称。
|
|
|
- [gender] => m 【注意】只有is_certified为T的时候才有意义,否则不保证准确性. 性别(F:女性;M:男性)。
|
|
|
- [is_certified] => T 是否通过实名认证。T是通过 F是没有实名认证。
|
|
|
- [is_student_certified] => F 是否是学生 T是 F否
|
|
|
- [nick_name] => 风的追求 用户昵称
|
|
|
- [province] => 山东省 省份名称
|
|
|
- [user_id] => 2088902918001020 支付宝用户的userId
|
|
|
- [user_status] => T 用户状态(Q/T/B/W)。 Q代表快速注册用户 T代表已认证用户 B代表被冻结账户 W代表已注册,未激活的账户
|
|
|
- [user_type] => 2 用户类型(1/2) 1代表公司账户2代表个人账户
|
|
|
- )
|
|
|
- )
|
|
|
- */
|
|
|
-
|
|
|
- $data['banknumber'] = $rs['user_id']; //支付宝用户id
|
|
|
- if (!$data['banknumber']) {
|
|
|
- $this->error('获取用户信息失败');
|
|
|
- }
|
|
|
- $bank_number_count = $mt_user_bank->where(['banknumber' => $data['banknumber'], 'type' => 1])->count();
|
|
|
- if ($bank_number_count) {
|
|
|
- $this->error('该支付宝账号已经绑定用户, 请先解除绑定');
|
|
|
- }
|
|
|
-
|
|
|
- if (isset($rs['nick_name'])) {
|
|
|
- $data['realname'] = $rs['nick_name']; //支付宝用户昵称
|
|
|
- }
|
|
|
-
|
|
|
- $data['user_id'] = $this->auth->id;
|
|
|
- $data['createtime'] = time();
|
|
|
- $data['type'] = 1;
|
|
|
-
|
|
|
- $rt = $mt_user_bank->insertGetId($data);
|
|
|
- if (!$rt) {
|
|
|
- $this->error('绑定失败');
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('绑定成功');
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|