数据处理
This commit is contained in:
@@ -17,6 +17,7 @@ import com.cool.store.response.MiniShopsResponse;
|
||||
import com.cool.store.service.*;
|
||||
import com.cool.store.utils.PasswordUtil;
|
||||
import com.cool.store.utils.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -31,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2025/4/7 15:51
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
@Resource
|
||||
@@ -364,17 +366,77 @@ public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean handleOldDataAccount() {
|
||||
List<HyPartnerUserInfoDO> hyPartnerUserInfoDOS = hyPartnerUserInfoDAO.selectPasswordIsNull();
|
||||
if (CollectionUtils.isEmpty(hyPartnerUserInfoDOS)){
|
||||
return true;
|
||||
}
|
||||
List<String> partnerIds = hyPartnerUserInfoDOS.stream().map(HyPartnerUserInfoDO::getPartnerId).collect(Collectors.toList());
|
||||
List<LineInfoDO> lineInfoDOList = lineInfoDAO.getListByPartnerIds(partnerIds);
|
||||
List<Long> lineIds = lineInfoDOList.stream().map(LineInfoDO::getId).collect(Collectors.toList());
|
||||
// shopInfoDAO.selectByLines();
|
||||
|
||||
return null;
|
||||
List<QualificationsInfoDO> qualificationsInfoDOList = qualificationsInfoDAO.getByPartnerIds(partnerIds);
|
||||
Map<String, QualificationsInfoDO> qualificationsInfoDOMap = qualificationsInfoDOList.stream().collect(Collectors.toMap(QualificationsInfoDO::getPartnerId, Function.identity()));
|
||||
|
||||
List<ShopInfoDO> shopInfoDOS = shopInfoDAO.selectByPartnerIds(partnerIds);
|
||||
Map<String,List<Long>> shopIdByPartnerIdMap = shopInfoDOS.stream().collect(Collectors.groupingBy(ShopInfoDO::getPartnerId,Collectors.mapping(ShopInfoDO::getId,Collectors.toList())));
|
||||
List<Long> shopIds = shopInfoDOS.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
|
||||
// 获取密码为空的门店账户新管家,yls,pos
|
||||
List<ShopAccountDO> passwordIsNullByShopIds = shopAccountDAO.getPasswordIsNullByShopIds(shopIds);
|
||||
Map<Long, List<ShopAccountDO>> shopAccountDOMap = passwordIsNullByShopIds.stream().collect(Collectors.groupingBy(ShopAccountDO::getShopId));
|
||||
for (HyPartnerUserInfoDO hyPartnerUserInfoDO : hyPartnerUserInfoDOS){
|
||||
QualificationsInfoDO qualificationsInfoDO = qualificationsInfoDOMap.get(hyPartnerUserInfoDO.getPartnerId());
|
||||
if (qualificationsInfoDO == null ){
|
||||
log.info("获取证件信息失败,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
String substring = qualificationsInfoDO.getIdCardNo().substring(qualificationsInfoDO.getIdCardNo().length() - 6);
|
||||
if (StringUtil.isBlank(substring)){
|
||||
log.info("身份证截取失败,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
//生成密码和盐值
|
||||
byte[] saltBytes = PasswordUtil.generateSalt();
|
||||
String salt = PasswordUtil.bytesToHex(saltBytes);
|
||||
if (StringUtil.isBlank(salt)){
|
||||
log.info("盐值生成失败,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
String password = PasswordUtil.encryptPassword(substring, salt);
|
||||
if (StringUtil.isBlank(password)){
|
||||
log.info("密码生成失败,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
GetPasswordDTO getPasswordDTO = new GetPasswordDTO();
|
||||
getPasswordDTO.setPassword(substring);
|
||||
String downstreamSystemSecondaryPassword = thirdXinGuanJiaService.getPassword(getPasswordDTO);
|
||||
if (StringUtil.isBlank(downstreamSystemSecondaryPassword)){
|
||||
log.info("第二密码密码生成失败,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
hyPartnerUserInfoDO.setDownstreamSystemPassword(password);
|
||||
hyPartnerUserInfoDO.setDownstreamSystemSalting(salt);
|
||||
hyPartnerUserInfoDO.setDownstreamSystemSecondaryPassword(downstreamSystemSecondaryPassword);
|
||||
List<Long> shopIdList = shopIdByPartnerIdMap.get(hyPartnerUserInfoDO.getPartnerId());
|
||||
if (CollectionUtils.isEmpty(shopIdList)){
|
||||
log.info("没有门店,手机号:{}",hyPartnerUserInfoDO.getMobile());
|
||||
continue;
|
||||
}
|
||||
for (Long shopId : shopIdList){
|
||||
if (shopAccountDOMap.containsKey(shopId)){
|
||||
List<ShopAccountDO> shopAccountDOList = shopAccountDOMap.get(shopId);
|
||||
if (CollectionUtils.isNotEmpty(shopAccountDOList)){
|
||||
for (ShopAccountDO shopAccountDO : shopAccountDOList) {
|
||||
shopAccountDO.setPassword(password);
|
||||
shopAccountDO.setPasswordSalt(salt);
|
||||
shopAccountDO.setSecondaryPassword(downstreamSystemSecondaryPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hyPartnerUserInfoDAO.dataHandle(hyPartnerUserInfoDOS);
|
||||
shopAccountDAO.dateHandle(passwordIsNullByShopIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user