zhangwei #5
|
@ -12,26 +12,57 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['status'],
|
'=' => ['status','age','gender'],
|
||||||
'%like%' => ['nick_name','phone'],
|
'%like%' => ['nick_name','real_name','phone'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户列表
|
// 获取用户列表
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$field = "id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,status,create_time";
|
$params = $this->params;
|
||||||
return User::field($field)->where($this->searchWhere)->where('status','<>',2)
|
$field = "u.id,phone,avatar,nick_name,real_name,id_card,gender,age,total_balance,total_integral,CONCAT(province_name,city_name,area_name,street_name,village_name,brigade_name,address) as address,status,create_time";
|
||||||
|
return User::alias('u')->field($field)
|
||||||
|
->leftJoin('geo_province p','u.province = p.province_code')
|
||||||
|
->leftJoin('geo_city c','u.city = c.city_code')
|
||||||
|
->leftJoin('geo_area a','u.area = a.area_code')
|
||||||
|
->leftJoin('geo_street s','u.street = s.street_code')
|
||||||
|
->leftJoin('geo_village v','u.village = v.village_code')
|
||||||
|
->leftJoin('geo_brigade b','u.brigade = b.id')
|
||||||
|
->where('status','<>',2)
|
||||||
|
->where($this->searchWhere)
|
||||||
|
->where(function($query) use ($params){
|
||||||
|
if(isset($params['address'])){
|
||||||
|
$query->where('CONCAT(province_name,city_name,area_name,street_name,village_name,brigade_name,address) LIKE "%'.$params['address'].'%"');
|
||||||
|
}
|
||||||
|
})
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order('id desc')->select()->each(function($item){
|
->order('u.id desc')
|
||||||
$item['status_text'] = $item->status_text;
|
->select()->each(function($item){
|
||||||
$item['gender_text'] = $item->gender_text;
|
$item['gender_text'] = $item->gender_text;
|
||||||
|
$item['status_text'] = $item->status_text;
|
||||||
})->toArray();
|
})->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取数量
|
// 获取数量
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
return User::field('id')->where($this->searchWhere)->where('status','<>',2)->count();
|
$params = $this->params;
|
||||||
|
$field = "u.id,CONCAT(province_name,city_name,area_name,street_name,village_name,brigade_name,address) as address,status,create_time";
|
||||||
|
return User::alias('u')->field($field)
|
||||||
|
->leftJoin('geo_province p','u.province = p.province_code')
|
||||||
|
->leftJoin('geo_city c','u.city = c.city_code')
|
||||||
|
->leftJoin('geo_area a','u.area = a.area_code')
|
||||||
|
->leftJoin('geo_street s','u.street = s.street_code')
|
||||||
|
->leftJoin('geo_village v','u.village = v.village_code')
|
||||||
|
->leftJoin('geo_brigade b','u.brigade = b.id')
|
||||||
|
->where('status','<>',2)
|
||||||
|
->where($this->searchWhere)
|
||||||
|
->where(function($query) use ($params){
|
||||||
|
if(isset($params['address'])){
|
||||||
|
$query->where('CONCAT(province_name,city_name,area_name,street_name,village_name,brigade_name,address) LIKE "%'.$params['address'].'%"');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
return [
|
return [
|
||||||
'middleware' => [
|
'middleware' => [
|
||||||
app\api\http\middleware\InitMiddleware::class, // 初始化
|
app\api\http\middleware\InitMiddleware::class, // 初始化
|
||||||
// app\api\http\middleware\VerifySignMiddleware::class, // 签名验证
|
app\api\http\middleware\VerifySignMiddleware::class, // 签名验证
|
||||||
app\api\http\middleware\LoginMiddleware::class, // 登录验证
|
app\api\http\middleware\LoginMiddleware::class, // 登录验证
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -32,7 +32,7 @@ class IndexController extends BaseApiController
|
||||||
return $this->fail('短信场景错误');
|
return $this->fail('短信场景错误');
|
||||||
}
|
}
|
||||||
//验证手机号
|
//验证手机号
|
||||||
$user = User::field('user_phone')->where('user_phone',$params['phone'])->findOrEmpty();
|
$user = User::field('phone')->where('phone',$params['phone'])->findOrEmpty();
|
||||||
if($user->isEmpty()){
|
if($user->isEmpty()){
|
||||||
return $this->fail('手机号码错误');
|
return $this->fail('手机号码错误');
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@ class UserLogic extends BaseLogic
|
||||||
public static function resetPassword(array $params): bool
|
public static function resetPassword(array $params): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
//验证手机号码
|
||||||
|
$user = User::field('id')->where('phone',$params['phone'])->findOrEmpty();
|
||||||
|
if($user->isEmpty()){
|
||||||
|
throw new \Exception('该手机号未注册');
|
||||||
|
}
|
||||||
// 校验验证码
|
// 校验验证码
|
||||||
$smsDriver = new SmsDriver();
|
$smsDriver = new SmsDriver();
|
||||||
if (!$smsDriver->verify($params['phone'], $params['code'], NoticeEnum::FIND_LOGIN_PASSWORD_CAPTCHA)) {
|
if (!$smsDriver->verify($params['phone'], $params['code'], NoticeEnum::FIND_LOGIN_PASSWORD_CAPTCHA)) {
|
||||||
|
@ -24,7 +29,8 @@ class UserLogic extends BaseLogic
|
||||||
$passwordSalt = Config::get('project.unique_identification');
|
$passwordSalt = Config::get('project.unique_identification');
|
||||||
$password = create_password($params['password'], $passwordSalt);
|
$password = create_password($params['password'], $passwordSalt);
|
||||||
// 更新
|
// 更新
|
||||||
User::where('phone', $params['phone'])->update(['password' => $password]);
|
$user->password = $password;
|
||||||
|
$user->save();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
|
|
|
@ -16,7 +16,7 @@ class PasswordValidate extends BaseValidate
|
||||||
'phone' => 'require|mobile',
|
'phone' => 'require|mobile',
|
||||||
'code' => 'require',
|
'code' => 'require',
|
||||||
'old_password' => 'require',
|
'old_password' => 'require',
|
||||||
'password' => 'require|length:6,20',
|
'password' => 'require|length:6,20|different:old_password',
|
||||||
'password_confirm' => 'require|confirm',
|
'password_confirm' => 'require|confirm',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ class PasswordValidate extends BaseValidate
|
||||||
'code.require' => '请填写验证码',
|
'code.require' => '请填写验证码',
|
||||||
'password.require' => '请输入新密码',
|
'password.require' => '请输入新密码',
|
||||||
'password.length' => '密码须在6-25位之间',
|
'password.length' => '密码须在6-25位之间',
|
||||||
|
'password.different' => '新密码不能和原密码一样',
|
||||||
'password_confirm.require' => '请确认密码',
|
'password_confirm.require' => '请确认密码',
|
||||||
'password_confirm.confirm' => '确认密码和新密码不一致',
|
'password_confirm.confirm' => '确认密码和新密码不一致',
|
||||||
'old_password.require' => '请输入原密码',
|
'old_password.require' => '请输入原密码',
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SystemValidate extends BaseValidate
|
||||||
|
|
||||||
public function sceneEdit(): SystemValidate
|
public function sceneEdit(): SystemValidate
|
||||||
{
|
{
|
||||||
return $this->only(['id','_name','url','status']);
|
return $this->only(['id','name','url','status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sceneDetail(): SystemValidate
|
public function sceneDetail(): SystemValidate
|
||||||
|
|
Loading…
Reference in New Issue