|
@@ -1,4 +1,4 @@
|
|
|
-package com.zhongzheng.modules.distribution.service.impl;
|
|
|
+package com.zhongzheng.framework.web.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
@@ -7,12 +7,11 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
+import com.zhongzheng.common.enums.UserStatus;
|
|
|
+import com.zhongzheng.common.exception.BaseException;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.type.EncryptHandler;
|
|
|
-import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
-import com.zhongzheng.common.utils.ServletUtils;
|
|
|
-import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
+import com.zhongzheng.common.utils.*;
|
|
|
import com.zhongzheng.modules.distribution.bo.*;
|
|
|
import com.zhongzheng.modules.distribution.domain.DistributionSeller;
|
|
|
import com.zhongzheng.modules.distribution.mapper.DistributionSellerMapper;
|
|
@@ -20,6 +19,8 @@ import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
|
|
|
import com.zhongzheng.modules.distribution.vo.DistributionSellerVo;
|
|
|
import com.zhongzheng.modules.user.bo.UserAppRegisterBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
+import com.zhongzheng.modules.user.entity.ClientLoginSeller;
|
|
|
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -28,10 +29,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -49,6 +48,9 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SellerTokenService sellerTokenService;
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean registerSeller(SellerAppRegisterBo bo) {
|
|
|
if(StringUtils.isBlank(bo.getIdcard())){
|
|
@@ -90,7 +92,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
inertData.setRealname(bo.getRealname());
|
|
|
inertData.setAvatar(Constants.DEFAULT_AVATAR);
|
|
|
inertData.setPassword(SecurityUtils.encryptPassword(bo.getPwd()));
|
|
|
- inertData.setCode(ServletUtils.getEncoded("YW"));
|
|
|
+ inertData.setUserAccount(ServletUtils.getEncoded("YW"));
|
|
|
inertData.setCreateTime(DateUtils.getNowTime());
|
|
|
inertData.setUpdateTime(DateUtils.getNowTime());
|
|
|
inertData.setShareCode(ToolsUtils.getRandomString(8));
|
|
@@ -184,7 +186,47 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> accountLogin(SellerAppAccountLoginBo bo) {
|
|
|
- return null;
|
|
|
+ if(Validator.isEmpty(bo.getAccount())){
|
|
|
+ throw new CustomException("账号不能为空");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<DistributionSeller> queryWrapper =new LambdaQueryWrapper<DistributionSeller>();
|
|
|
+ queryWrapper.and(wq -> wq
|
|
|
+ .eq(DistributionSeller::getTelphone,EncryptHandler.encrypt(bo.getAccount()))
|
|
|
+ .or()
|
|
|
+ .eq(DistributionSeller::getIdCard,EncryptHandler.encrypt(bo.getAccount())));
|
|
|
+ DistributionSeller seller = getOne(queryWrapper);
|
|
|
+ if(Validator.isEmpty(seller)){
|
|
|
+ throw new CustomException("登录信息错误");
|
|
|
+ }
|
|
|
+ else if (UserStatus.DISABLE.getCode().equals(seller.getStatus()))
|
|
|
+ {
|
|
|
+ throw new BaseException("对不起,您的账号:已停用");
|
|
|
+ }
|
|
|
+ String password = null;
|
|
|
+ if(bo.getPwd().length()>20){
|
|
|
+ String rsaPrivate = null;
|
|
|
+ try {
|
|
|
+ InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("config/pri.key");
|
|
|
+ rsaPrivate = AES.getStringByInputStream_1(certStream);
|
|
|
+ certStream.close();
|
|
|
+ password = AES.decrypt(bo.getPwd(),rsaPrivate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ password = bo.getPwd();
|
|
|
+ }
|
|
|
+ if (!SecurityUtils.matchesPassword(password,seller.getPassword()))
|
|
|
+ {
|
|
|
+ throw new BaseException("登录信息错误");
|
|
|
+ }
|
|
|
+ ClientLoginSeller loginSeller = new ClientLoginSeller();
|
|
|
+ loginSeller.setSeller(seller);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(Constants.TOKEN,sellerTokenService.createToken(loginSeller));
|
|
|
+ map.put("user_account",seller.getUserAccount());
|
|
|
+ map.put("full_info",Validator.isEmpty(seller.getIdCard())?false:true); //是否完善身份信息
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -202,7 +244,7 @@ public class DistributionSellerServiceImpl extends ServiceImpl<DistributionSelle
|
|
|
lqw.eq(bo.getStatus() != null, DistributionSeller::getStatus, bo.getStatus());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getAvatar()), DistributionSeller::getAvatar, bo.getAvatar());
|
|
|
lqw.eq(bo.getUserId() != null, DistributionSeller::getUserId, bo.getUserId());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCode()), DistributionSeller::getCode, bo.getCode());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getUserAccount()), DistributionSeller::getUserAccount, bo.getUserAccount());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getGzhOpenId()), DistributionSeller::getGzhOpenId, bo.getGzhOpenId());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getUnionId()), DistributionSeller::getUnionId, bo.getUnionId());
|
|
|
lqw.eq(StrUtil.isNotBlank(bo.getPassword()), DistributionSeller::getPassword, bo.getPassword());
|