|
@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
|
import com.pj.api.client.level_two_server.LevelTwoServerInterface;
|
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
|
+import com.pj.api.consts.FeignFactory;
|
|
|
import com.pj.api.dto.*;
|
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
import com.pj.common.core.utils.StringUtils;
|
|
@@ -22,6 +23,7 @@ import com.pj.current.satoken.StpAPPUserUtil;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.enummj.DeleteStatus;
|
|
|
import com.pj.enummj.IsLock;
|
|
|
+import com.pj.enummj.UserType;
|
|
|
import com.pj.face.factory.FaceFactory;
|
|
|
import com.pj.project.app_user.dto.*;
|
|
|
import com.pj.project.app_user.vo.AppUserVo;
|
|
@@ -48,6 +50,7 @@ import java.io.InputStream;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -482,13 +485,10 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
/**
|
|
|
* 退出登录
|
|
|
*
|
|
|
- * @param appUserId appUser表主键
|
|
|
* @return
|
|
|
*/
|
|
|
- public String logout(Object appUserId) {
|
|
|
- if (appUserId == null || appUserId.toString().trim().equals(""))
|
|
|
- throw new ServiceException("退出信息异常!");
|
|
|
- StpAPPUserUtil.logout(appUserId);
|
|
|
+ public String logout() {
|
|
|
+ StpAPPUserUtil.logout();
|
|
|
return "退出登录成功!";
|
|
|
}
|
|
|
|
|
@@ -800,4 +800,44 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
appUser.setPassword(passwordEncoder.encode(phone));
|
|
|
return updateById(appUser) ? 1 : 0;
|
|
|
}
|
|
|
+
|
|
|
+ public AjaxJson purchaserLogin(LoginDto dto) {
|
|
|
+ String phone= Aes.aesDecrypt(dto.getPhone());
|
|
|
+ if (StrUtil.isEmpty(phone)) {
|
|
|
+ return AjaxJson.getError("手机号不正确");
|
|
|
+ }
|
|
|
+ String pwd= Aes.aesDecrypt(dto.getPassword());
|
|
|
+ if (StrUtil.isEmpty(pwd)) {
|
|
|
+ return AjaxJson.getError("请输入密码");
|
|
|
+ }
|
|
|
+ AppUser appUser = findByPhone(phone);
|
|
|
+ if (appUser == null|| !Objects.equals(appUser.getUserType(),UserType.USER_TYPE_PURCHASER.getCode())) {
|
|
|
+ return AjaxJson.getError("账号不存在");
|
|
|
+ }
|
|
|
+ if (!passwordEncoder.matches(pwd, appUser.getPassword())) {
|
|
|
+ return AjaxJson.getError("密码不正确");
|
|
|
+ }
|
|
|
+ if (appUser.getStatus().equals("0")) {
|
|
|
+ return AjaxJson.getError("该账户 " + appUser.getPhone() + " 已停用!");
|
|
|
+ }
|
|
|
+ PurchaserDto purchaserDto= FeignFactory.levelTwoServerInterface.getByPurchaserId(appUser.getFkId());
|
|
|
+ if (purchaserDto==null){
|
|
|
+ return AjaxJson.getError("商户不存在");
|
|
|
+ }
|
|
|
+ //开始执行登录
|
|
|
+ StpAPPUserUtil.login(appUser.getId());
|
|
|
+ APPLoginUserInfo info = new APPLoginUserInfo();
|
|
|
+ info.setLoginId(appUser.getId());
|
|
|
+ info.setLoginName(appUser.getName());
|
|
|
+ info.setFk(appUser.getFkId());
|
|
|
+ info.setUserType(appUser.getUserType());
|
|
|
+ StpAPPUserUtil.cacheAPPLoginInfo(info);
|
|
|
+ SoMap map = new SoMap();
|
|
|
+ map.put("tokenInfo", StpAPPUserUtil.getTokenInfo());
|
|
|
+ SoMap companyInfo = new SoMap();
|
|
|
+ companyInfo.put("companyId", purchaserDto.getId());
|
|
|
+ companyInfo.put("companyName", purchaserDto.getName());
|
|
|
+ map.put("companyInfo", companyInfo);
|
|
|
+ return AjaxJson.getSuccessData(map);
|
|
|
+ }
|
|
|
}
|