|
@@ -4,6 +4,7 @@ import cn.dev33.satoken.spring.SpringMVCUtil;
|
|
|
import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.crypto.digest.DigestUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -14,6 +15,7 @@ import com.pj.api.client.level_two_server.LevelTwoServerInterface;
|
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
|
import com.pj.api.dto.*;
|
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
+import com.pj.common.core.utils.StringUtils;
|
|
|
import com.pj.current.config.SystemObject;
|
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
@@ -615,6 +617,12 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
public void createUser(AppUserCreateDTO createDTO) {
|
|
|
log.info("创建APP账号:{}", JSONUtil.toJsonStr(createDTO));
|
|
|
String phone = createDTO.getPhone().trim();
|
|
|
+ boolean phoneStatus = true;
|
|
|
+ if (StringUtils.isEmpty(phone)) {
|
|
|
+ phoneStatus = false;
|
|
|
+ log.info("创建APP账号失败: 手机号不能为空");
|
|
|
+ phone = RandomUtil.randomNumbers(11);
|
|
|
+ }
|
|
|
AppUser appUser = this.findByPhone(phone);
|
|
|
if (appUser != null) {
|
|
|
log.info("创建APP账号失败:当前账号的手机号码已存在!!!");
|
|
@@ -629,14 +637,17 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
.setUserType(Integer.parseInt(createDTO.getUserType()))
|
|
|
.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
|
|
|
.setCreateTime(new Date());
|
|
|
- boolean save = this.save(appUser);
|
|
|
- String content = "您好,您的app账号已生成。账号:" + phone + ", 初始密码:" + phone + "。可前往app进行修改";
|
|
|
- // todo 发送短信
|
|
|
- SystemObject.smsFactory.handler().sendSMS(phone, content);
|
|
|
+ if (phoneStatus) {
|
|
|
+ boolean save = this.save(appUser);
|
|
|
+ String content = "您好,您的app账号已生成。账号:" + phone + ", 初始密码:" + phone + "。可前往app进行修改";
|
|
|
+ // todo 发送短信
|
|
|
+ SystemObject.smsFactory.handler().sendSMS(phone, content);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void authFace(Long loginId, MultipartFile file,Integer type) {
|
|
|
+ public void authFace(Long loginId, MultipartFile file, Integer type) {
|
|
|
String img;
|
|
|
try (InputStream is = file.getInputStream()) {
|
|
|
img = Base64.encode(is);
|
|
@@ -644,20 +655,20 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
} catch (IOException e) {
|
|
|
throw new AjaxError("识别失败");
|
|
|
}
|
|
|
- if (type==2){
|
|
|
+ if (type == 2) {
|
|
|
List<String> faceId = faceFactory.handler().faceSearch(img);
|
|
|
if (faceId.isEmpty()) {
|
|
|
- throw new AjaxError("人脸不匹配");
|
|
|
+ throw new AjaxError("人脸不匹配");
|
|
|
}
|
|
|
- AppUser appUser =null;
|
|
|
+ AppUser appUser = null;
|
|
|
for (String id : faceId) {
|
|
|
- AppUser checkUser = findByFaceId(id);
|
|
|
- if (checkUser!=null){
|
|
|
- appUser=checkUser;
|
|
|
+ AppUser checkUser = findByFaceId(id);
|
|
|
+ if (checkUser != null) {
|
|
|
+ appUser = checkUser;
|
|
|
}
|
|
|
}
|
|
|
if (appUser == null) {
|
|
|
- throw new AjaxError("人员信息未找到");
|
|
|
+ throw new AjaxError("人员信息未找到");
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -689,7 +700,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
img = Base64.encode(is);
|
|
|
boolean isLive = faceFactory.handler().checkIsLive(img);
|
|
|
if (!isLive) {
|
|
|
- // throw new AjaxError("非活体人脸");
|
|
|
+ // throw new AjaxError("非活体人脸");
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
throw new AjaxError("识别失败");
|
|
@@ -760,9 +771,37 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
}
|
|
|
|
|
|
public void changeBindShopStatus(BindShopDTO bindShopDTO) {
|
|
|
- log.info("修改绑定状态:{}", JSONUtil.toJsonStr(bindShopDTO));
|
|
|
+ log.info("修改商铺绑定状态:{}", JSONUtil.toJsonStr(bindShopDTO));
|
|
|
StrUtil.split(bindShopDTO.getIds(), ",").forEach(id -> {
|
|
|
appUserMapper.changeBindShopStatus(id, bindShopDTO.getBindShop());
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ public AppUserDto findUserByPhone(String phone) {
|
|
|
+ AppUser appUser = findByPhone(phone);
|
|
|
+ if (appUser == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ AppUserDto appUserDto = new AppUserDto();
|
|
|
+ BeanUtils.copyProperties(appUser, appUserDto);
|
|
|
+ return appUserDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改手机并且修改密码
|
|
|
+ * @param updateAccountDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int updateAccount(UpdateAccountDTO updateAccountDTO) {
|
|
|
+ Long id = updateAccountDTO.getId();
|
|
|
+ AppUser appUser = this.getById(id);
|
|
|
+ if (appUser==null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ String phone=updateAccountDTO.getPhone();
|
|
|
+ appUser.setId(id);
|
|
|
+ appUser.setUpdateTime(new Date()).setPhone(phone);
|
|
|
+ appUser.setPassword(passwordEncoder.encode(phone));
|
|
|
+ return updateById(appUser)?1:0;
|
|
|
+ }
|
|
|
}
|