getUserPhoneNumber($params['code']); $phoneNumber = $response['phone_info']['purePhoneNumber'] ?? ''; if (empty($phoneNumber)) { throw new \Exception('获取手机号码失败'); } $user = User::where([ ['mobile', '=', $phoneNumber], ['id', '<>', $params['user_id']] ])->findOrEmpty(); if (!$user->isEmpty()) { throw new \Exception('手机号已被其他账号绑定'); } // 绑定手机号 User::update([ 'id' => $params['user_id'], 'mobile' => $phoneNumber ]); return true; } catch (\Exception $e) { self::setError($e->getMessage()); return false; } } public static function info($uid) { $data = User::with(['userShip'])->where('id',$uid) ->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money,total_recharge_amount,user_ship') ->find(); //判断是不是员工 if($data){ $data = $data->toArray(); $all =UserShip::field('id,title,limit')->select()->toArray(); $new = self::getNextArrayByID($all,$data['user_ship']); $data['next_level'] = ''; $data['next_limit'] = 0; if($new){ $data['next_level'] = $new['title']; $data['next_limit'] = $new['limit'] - $data['total_recharge_amount']; } $data['is_staff'] = 0; $data['store_id'] = 0; if(isset($data['mobile']) && $data['mobile']){ $check = SystemStore::where('phone',$data['mobile'])->find()??[]; if ($check){ $data['is_staff'] = 1; $data['store_id'] = $check['store_id']; } } }else{ $data = []; } return $data; } public static function recharge($param) { $param['order_id'] = getNewOrderId('rc'); $param['recharge_type'] = 'wechat'; return UserRecharge::create($param); } public static function getNextArrayByID($arr, $id) { // 遍历数组 foreach ($arr as $key => $value) { // 检查当前数组的id是否与传入的id匹配 if ($value['id'] == $id) { // 如果当前数组不是最后一个,则返回下一个数组 if ($key + 1 < count($arr)) { return $arr[$key + 1]; } // 如果当前数组是最后一个,则返回null或空数组 return null; } } // 如果没有找到匹配的id,则返回null或空数组 return null; } }