Merge branch 'cc_20250528_dataHandler' into 'master'
Cc 20250528 data handler See merge request hangzhou/java/custom_zxjp!104
This commit is contained in:
@@ -109,8 +109,7 @@ public class HyPartnerUserInfoDAO {
|
||||
}
|
||||
|
||||
public List<HyPartnerUserInfoDO> selectPasswordIsNull(){
|
||||
Example example = new Example(HyPartnerUserInfoDO.class);
|
||||
example.createCriteria().andIsNull("downstreamSystemPassword");
|
||||
return hyPartnerUserInfoMapper.selectByExample(example);
|
||||
|
||||
return hyPartnerUserInfoMapper.selectPasswordIsNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,4 +219,13 @@ public class LineInfoDAO {
|
||||
List<LineInfoDO> lineMobile = lineInfoMapper.getByLineIds(lineIds);
|
||||
return lineMobile.stream().filter(o->StringUtils.isNotBlank(o.getMobile())).collect(Collectors.toMap(LineInfoDO::getId, LineInfoDO::getUsername, (k1, k2)-> k1));
|
||||
}
|
||||
|
||||
public List<LineInfoDO> getListByPartnerIds(List<String> partnerIds){
|
||||
if(CollectionUtils.isEmpty(partnerIds)){
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Example example = new Example(LineInfoDO.class);
|
||||
example.createCriteria().andIn("partnerId",partnerIds);
|
||||
return lineInfoMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class QualificationsInfoDAO {
|
||||
}
|
||||
return qualificationsInfoMapper.getByLineId(lineId);
|
||||
}
|
||||
public List<QualificationsInfoDO> getByLineIds(@Param("lineIds") List<Long> lineIds){
|
||||
public List<QualificationsInfoDO> getByLineIds( List<Long> lineIds){
|
||||
if (lineIds==null|| lineIds.isEmpty()){
|
||||
return new java.util.ArrayList<>();
|
||||
}
|
||||
@@ -52,4 +52,13 @@ public class QualificationsInfoDAO {
|
||||
example.createCriteria().andIn("lineId", lineIds);
|
||||
return qualificationsInfoMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<QualificationsInfoDO> getByPartnerIds( List<String> partnerIds){
|
||||
if (partnerIds.isEmpty()){
|
||||
return new java.util.ArrayList<>();
|
||||
}
|
||||
Example example = new Example(QualificationsInfoDO.class);
|
||||
example.createCriteria().andIn("partnerId", partnerIds);
|
||||
return qualificationsInfoMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +141,29 @@ public class ShopAccountDAO {
|
||||
return shopAccountMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<ShopAccountDO> getPasswordIsNullByShopIds(List<Long> shopIds){
|
||||
if (CollectionUtils.isEmpty(shopIds)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Example example = new Example(ShopAccountDO.class);
|
||||
List<String> systemNameList = new ArrayList<>();
|
||||
systemNameList.add("火码POS");
|
||||
systemNameList.add("云流水");
|
||||
systemNameList.add("新掌柜");
|
||||
example.createCriteria().andIn("shopId", shopIds).andIsNull("password").andIn("systemName",systemNameList);
|
||||
return shopAccountMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Auther: wangshuo
|
||||
* @Date: 2025/4/28
|
||||
* @description: 数据处理专用只处理,盐值 密码 第二密码
|
||||
*/
|
||||
public Integer dateHandle(List<ShopAccountDO> list){
|
||||
if (CollectionUtils.isEmpty(list)){
|
||||
return CommonConstants.ZERO;
|
||||
}
|
||||
return shopAccountMapper.dateHandle(list);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -291,4 +291,10 @@ public class ShopInfoDAO {
|
||||
public List<FranchiseReportDTO> getShopFranchiseReportList(FranchiseReportRequest request){
|
||||
return shopInfoMapper.getShopFranchiseReportList(request);
|
||||
}
|
||||
|
||||
public List<ShopInfoDO> selectByPartnerIds(List<String> partnerIds){
|
||||
Example example = new Example(ShopInfoDO.class);
|
||||
example.createCriteria().andIn("partnerId", partnerIds).andEqualTo("deleted", false);
|
||||
return shopInfoMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,6 @@ public interface HyPartnerUserInfoMapper extends tk.mybatis.mapper.common.Mappe
|
||||
|
||||
Integer dataHandle(@Param("list") List<HyPartnerUserInfoDO> hyPartnerUserInfoDOList);
|
||||
|
||||
List<HyPartnerUserInfoDO> selectPasswordIsNull();
|
||||
|
||||
}
|
||||
@@ -56,6 +56,9 @@
|
||||
<select id="selectLastCrmCreateTime" resultType="java.lang.String">
|
||||
SELECT crm_create_time as crmCreateTime FROM xfsg_partner_user_info ORDER BY crm_create_time desc limit 1
|
||||
</select>
|
||||
<select id="selectPasswordIsNull" resultType="com.cool.store.entity.HyPartnerUserInfoDO">
|
||||
SELECT * FROM `xfsg_partner_user_info` a LEFT JOIN xfsg_qualifications_info b on a.partner_id=b.partner_id WHERE b.id is not null and a.downstream_system_password is null
|
||||
</select>
|
||||
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into xfsg_partner_user_info
|
||||
@@ -184,6 +187,8 @@
|
||||
<if test="item.downstreamSystemSecondaryPassword != null">
|
||||
downstream_system_secondary_password = #{item.downstreamSystemSecondaryPassword},
|
||||
</if>
|
||||
update_time = now()
|
||||
|
||||
</set>
|
||||
where id = #{item.id}
|
||||
|
||||
|
||||
@@ -176,6 +176,7 @@
|
||||
<if test="item.secondaryPassword != null">
|
||||
secondary_password = #{item.secondaryPassword},
|
||||
</if>
|
||||
remark = #{item.remark}
|
||||
</set>
|
||||
where id = #{item.id}
|
||||
|
||||
|
||||
@@ -428,9 +428,11 @@
|
||||
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<foreach collection="regionIds" item="item" index="index" open="and region_id in (" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<if test="regionIds!=null and regionIds.size >0">
|
||||
<foreach collection="regionIds" item="item" index="index" open="and region_id in (" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getShopIdBySuccessOpen" resultType="com.cool.store.entity.ShopInfoDO">
|
||||
select a.id as id, a.partner_id as partnerId
|
||||
|
||||
@@ -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
|
||||
@@ -55,6 +57,8 @@ public class ShopAccountServiceImpl implements ShopAccountService {
|
||||
OldShopDAO oldShopDAO;
|
||||
@Resource
|
||||
ThirdXinGuanJiaService thirdXinGuanJiaService;
|
||||
@Resource
|
||||
private LineInfoDAO lineInfoDAO;
|
||||
|
||||
@Override
|
||||
public List<ShopAccountDTO> getShopAccountByShopId(Long shopId) {
|
||||
@@ -362,13 +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());
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -85,6 +85,12 @@ public class ShopAccountController {
|
||||
return ResponseResult.success(accountService.handleAccountPassword());
|
||||
}
|
||||
|
||||
@ApiOperation("密码数据处理3.0")
|
||||
@GetMapping("/handleOldDataAccount")
|
||||
public ResponseResult<Boolean> handleOldDataAccount() {
|
||||
return ResponseResult.success(accountService.handleOldDataAccount());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user