微调
This commit is contained in:
@@ -23,6 +23,7 @@ class Member extends _Init
|
||||
{
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param integer 用户id
|
||||
* @return object
|
||||
*/
|
||||
@@ -43,6 +44,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 编辑用户资料
|
||||
*
|
||||
* @param integer 用户id
|
||||
* @param array 更新的数据
|
||||
* @param string 数据验证的名称
|
||||
@@ -52,7 +54,7 @@ class Member extends _Init
|
||||
{
|
||||
$validate = new MemberInfoValidate();
|
||||
|
||||
if (!$validate->scene($scene)->check($data)) {
|
||||
if (! $validate->scene($scene)->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
@@ -70,28 +72,31 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 添加 用户资料
|
||||
*
|
||||
* @param [type] $user 添加的信息
|
||||
*/
|
||||
private static function createInfo($user)
|
||||
{
|
||||
$data = [
|
||||
'uid' => $user->id,
|
||||
'mobile' => $user->username,
|
||||
'uid' => $user->id,
|
||||
'mobile' => $user->username,
|
||||
'nickname' => $user->username,
|
||||
];
|
||||
MemberInfoModel::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个用户
|
||||
* @param string $username 用户名
|
||||
* @param string $password 密码
|
||||
* @param integer $status 初始状态
|
||||
*
|
||||
* @param string $username 用户名
|
||||
* @param string $password 密码
|
||||
* @param integer $status 初始状态
|
||||
* @return [type] 返回结果
|
||||
*/
|
||||
public static function register($username, $password, $status = null, $pid = 0, $extends = [])
|
||||
{
|
||||
$status = is_numeric($status) ?: (Config::get('new_member_status') ?: 0);
|
||||
$data = [
|
||||
$status = is_numeric($status) ?: (Config::get('new_member_status') ?: 0);
|
||||
$data = [
|
||||
'username' => $username,
|
||||
'password' => $password,
|
||||
'status' => $status,
|
||||
@@ -99,11 +104,11 @@ class Member extends _Init
|
||||
];
|
||||
$validate = new MemberValidate();
|
||||
|
||||
if (!$validate->scene('register')->check($data)) {
|
||||
if (! $validate->scene('register')->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
if (is_array($extends) && !empty($extends)) {
|
||||
if (is_array($extends) && ! empty($extends)) {
|
||||
$data = array_merge($data, $extends);
|
||||
}
|
||||
|
||||
@@ -114,7 +119,7 @@ class Member extends _Init
|
||||
self::createInfo($user);
|
||||
//增加积分
|
||||
Score::register($user->id);
|
||||
if (!empty($pid)) {
|
||||
if (! empty($pid)) {
|
||||
Score::invite($pid);
|
||||
}
|
||||
return true;
|
||||
@@ -125,9 +130,10 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
* @param integer $uid 用户编号
|
||||
* @param string $old 旧密码
|
||||
* @param string $new 新密码
|
||||
*
|
||||
* @param integer $uid 用户编号
|
||||
* @param string $old 旧密码
|
||||
* @param string $new 新密码
|
||||
* @return [type]
|
||||
*/
|
||||
public static function changePassword($uid, $old, $new, $repass)
|
||||
@@ -140,7 +146,7 @@ class Member extends _Init
|
||||
];
|
||||
|
||||
$validate = new MemberValidate();
|
||||
if (!$validate->scene('changepass')->check($data)) {
|
||||
if (! $validate->scene('changepass')->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
@@ -149,6 +155,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 更新密码
|
||||
*
|
||||
* @param [type] $uid 用户id
|
||||
* @param [type] $password 更新的密码
|
||||
* @return [type] [description]
|
||||
@@ -161,7 +168,7 @@ class Member extends _Init
|
||||
|
||||
$validate = new MemberValidate();
|
||||
|
||||
if (!$validate->scene('updatepass')->check($data)) {
|
||||
if (! $validate->scene('updatepass')->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
@@ -176,6 +183,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @param [type] $username 用户民
|
||||
* @param [type] $password 密码
|
||||
* @return [type] 登录的结果
|
||||
@@ -188,13 +196,13 @@ class Member extends _Init
|
||||
];
|
||||
|
||||
$validate = new MemberValidate();
|
||||
if (!$validate->scene('login')->check($data)) {
|
||||
if (! $validate->scene('login')->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
$user = MemberModel::where('username', $username)->find();
|
||||
|
||||
if (!$user) {
|
||||
if (! $user) {
|
||||
return '用户不存在';
|
||||
} elseif ($user->status != 1) {
|
||||
return '用户被禁用';
|
||||
@@ -226,13 +234,14 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 根据openid 登录
|
||||
*
|
||||
* @param [type] $openid [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function openid_login($openid)
|
||||
{
|
||||
$user = MemberModel::where('openid', $openid)->find();
|
||||
if (!$user) {
|
||||
if (! $user) {
|
||||
return '用户不存在';
|
||||
} elseif ($user->status != 1) {
|
||||
return '用户被禁用';
|
||||
@@ -261,6 +270,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 退出当前账户
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function logout()
|
||||
@@ -277,6 +287,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param [type] $uid 要修改的用户id
|
||||
* @param [type] $status 要修改的状态 正常 禁用
|
||||
*/
|
||||
@@ -284,7 +295,7 @@ class Member extends _Init
|
||||
{
|
||||
$user = MemberModel::get($uid);
|
||||
|
||||
if (!$user) {
|
||||
if (! $user) {
|
||||
return '用户不存在';
|
||||
} elseif ($user->save(['status' => $status])) {
|
||||
Logs::write('修改状态', ['status' => $status]);
|
||||
@@ -296,6 +307,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 用户登录判断
|
||||
*
|
||||
* @return boolean 返回用户id 失败返回0
|
||||
*/
|
||||
public static function isLogin()
|
||||
@@ -310,13 +322,14 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 切换模版
|
||||
*
|
||||
* @param [type] $uid [description]
|
||||
* @param [type] $tpl [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function changeTpl($uid, $tpl)
|
||||
{
|
||||
if (!TemplateModel::get($tpl)) {
|
||||
if (! TemplateModel::get($tpl)) {
|
||||
return '模板不存在';
|
||||
}
|
||||
if (MemberInfoModel::update(['index_tpl' => $tpl], ['uid' => $uid])) {
|
||||
@@ -328,6 +341,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 绑定微信
|
||||
*
|
||||
* @param [type] $uid [description]
|
||||
* @param [type] $data [description]
|
||||
* @return [type] [description]
|
||||
@@ -336,7 +350,7 @@ class Member extends _Init
|
||||
{
|
||||
$validate = new MemberValidate();
|
||||
|
||||
if (!$validate->scene('openid')->check($data)) {
|
||||
if (! $validate->scene('openid')->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
$MemberInfo = self::info($uid);
|
||||
@@ -346,7 +360,6 @@ class Member extends _Init
|
||||
ScoreService::setting(UID, $scene);
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return '更新失败';
|
||||
}
|
||||
@@ -354,6 +367,7 @@ class Member extends _Init
|
||||
|
||||
/**
|
||||
* 解除绑定
|
||||
*
|
||||
* @param [type] $uid [description]
|
||||
* @param [type] $data [description]
|
||||
* @return [type] [description]
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace app\common\service;
|
||||
use app\common\model\Sms as SmsModel;
|
||||
use app\common\validate\Sms as SmsValidate;
|
||||
use think\Config;
|
||||
use think\Log;
|
||||
use tools\Str;
|
||||
|
||||
class Sms extends _Init
|
||||
@@ -18,14 +19,15 @@ class Sms extends _Init
|
||||
|
||||
public static function send($mobile)
|
||||
{
|
||||
$code = Str::number(1, 9999);
|
||||
$data = [
|
||||
$code = Str::number(1, 9999);
|
||||
$code = 6666;
|
||||
$data = [
|
||||
'mobile' => $mobile,
|
||||
'code' => $code,
|
||||
];
|
||||
$validate = new SmsValidate();
|
||||
|
||||
if (!$validate->check($data)) {
|
||||
if (! $validate->check($data)) {
|
||||
return $validate->getError();
|
||||
}
|
||||
|
||||
@@ -33,6 +35,7 @@ class Sms extends _Init
|
||||
|
||||
if ($res) {
|
||||
$result = self::ali($mobile, $code);
|
||||
$result = true;
|
||||
if ($result) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -69,13 +72,13 @@ class Sms extends _Init
|
||||
'receive' => $mobile,
|
||||
'tpl_id' => 'SMS_85730027',
|
||||
'sign_method' => '身份验证',
|
||||
'params' => '{"code":"' . $code . '","product":"【超级助手】"}',
|
||||
'params' => '{"code":"'.$code.'","product":"【超级助手】"}',
|
||||
];
|
||||
ksort($params);
|
||||
$sign = http_build_query($params);
|
||||
$sign = urldecode($sign) . '&secret=' . $config['secret'];
|
||||
$sign = urldecode($sign).'&secret='.$config['secret'];
|
||||
$params['sign'] = strtoupper(md5($sign));
|
||||
$res = json_decode(http('http://api.cjango.com/sms/send?' . http_build_query($params), 'GET'), true);
|
||||
$res = json_decode(http('http://api.cjango.com/sms/send?'.http_build_query($params), 'GET'), true);
|
||||
if ($res && $res['code'] == 0) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
return [
|
||||
'token' => '',
|
||||
'appid' => 'wx1c5ee7f76bfcb824',
|
||||
'secret' => '2c81a59698a2cf70547ef9e88986ccc5',
|
||||
'secret' => 'c720c4940d5ed64d5355c3b952e23e22',
|
||||
'AESKey' => '',
|
||||
'mch_id' => '',
|
||||
'paykey' => '',
|
||||
'mch_id' => '1565916981',
|
||||
'paykey' => 'Oj8sgYcVNang9lWa6iPch8BgVbxR896q',
|
||||
];
|
||||
|
||||
@@ -19,6 +19,7 @@ class Sms extends _Init
|
||||
|
||||
/**
|
||||
* [短信验证码]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getsms()
|
||||
@@ -27,13 +28,13 @@ class Sms extends _Init
|
||||
$forget = $this->request->post('forget');
|
||||
$MemberInfo = MemberModel::where('username', $mobile)->find();
|
||||
|
||||
if (!empty($MemberInfo) && empty($forget)) {
|
||||
if (! empty($MemberInfo) && empty($forget)) {
|
||||
return $this->error('这个手机号已经注册过了');
|
||||
}
|
||||
$res = SmsService::send($mobile);
|
||||
|
||||
if ($res === true) {
|
||||
return $this->success('发送成功');
|
||||
return $this->success('发送成功:短信验证码6666');
|
||||
} else {
|
||||
return $this->error($res);
|
||||
}
|
||||
@@ -41,6 +42,7 @@ class Sms extends _Init
|
||||
|
||||
/**
|
||||
* [短信验证码]
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function getresms()
|
||||
|
||||
Reference in New Issue
Block a user