rk
17 小时以前 3e210fac9492b90e21ca9bf76c1d9a8fda1f4388
server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
@@ -194,6 +194,9 @@
        if (pageWrap.getModel().getUpdateUser() != null) {
            queryWrapper.lambda().eq(ShopInfo::getUpdateUser, pageWrap.getModel().getUpdateUser());
        }
        if (pageWrap.getModel().getVersionType() != null) {
            queryWrapper.lambda().eq(ShopInfo::getVersionType, pageWrap.getModel().getVersionType());
        }
        if (pageWrap.getModel().getUpdateTime() != null) {
            queryWrapper.lambda().ge(ShopInfo::getUpdateTime, Utils.Date.getStart(pageWrap.getModel().getUpdateTime()));
            queryWrapper.lambda().le(ShopInfo::getUpdateTime, Utils.Date.getEnd(pageWrap.getModel().getUpdateTime()));
@@ -307,9 +310,6 @@
            // 最新变更版本已支付押金(status=3):生成新的变更版本
            Integer relationShopId = changeVersion.getRelationShopId();
            // 校验手机号唯一性(排除正式版本和变更版本)
            checkTelephoneUnique(request.getTelephone(), relationShopId);
            String rawPassword = generateDefaultPassword(request.getTelephone());
            String salt = RandomStringUtils.randomAlphabetic(6);
            String encryptedPassword = Utils.Secure.encryptPassword(rawPassword, salt);
@@ -331,11 +331,6 @@
            saveShopAttachments(newChange.getId(), request, now);
        } else {
            // 最新变更版本 status=0(待审批) 或 2(被驳回):直接更新
            Integer relationShopId = changeVersion.getRelationShopId();
            // 校验手机号唯一性
            checkTelephoneUnique(request.getTelephone(), relationShopId);
            String rawPassword = generateDefaultPassword(request.getTelephone());
            String salt = RandomStringUtils.randomAlphabetic(6);
            String encryptedPassword = Utils.Secure.encryptPassword(rawPassword, salt);
@@ -802,12 +797,18 @@
        changeShop.setAliName(origin.getAliName());
        changeShop.setDepositAmount(origin.getDepositAmount());
        changeShop.setRevenueShareConfig(origin.getRevenueShareConfig());
        changeShop.setDeliveryArea(origin.getDeliveryArea());
        changeShop.setScore(origin.getScore());
        changeShop.setBalance(origin.getBalance());
        changeShop.setTotalBalance(origin.getTotalBalance());
        changeShop.setPayStatus(origin.getPayStatus());
        changeShop.setVersionType(Constants.ONE);
        changeShop.setRelationShopId(originShopId);
        changeShop.setAuditStatus(origin.getAuditStatus());
        changeShop.setRegionMemberId(origin.getRegionMemberId());
        changeShop.setOpenid(origin.getOpenid());
        changeShop.setStatus(Constants.ZERO);
        changeShop.setDeleted(Constants.ZERO);
        changeShop.setStatus(origin.getStatus());
        changeShop.setDeleted(origin.getDeleted());
        changeShop.setCreateTime(now);
        changeShop.setUpdateTime(now);
        shopInfoMapper.insert(changeShop);
@@ -1582,7 +1583,7 @@
        if (shopInfo.getCompanyType() == null) {
            return;
        }
        Areas areas = areasService.findById(shopInfo.getAreaId());
        Areas areas = areasService.getById(shopInfo.getAreaId());
        PricingRule pricingRule = pricingRuleMapper.selectOne(new QueryWrapper<PricingRule>().lambda()
                .eq(PricingRule::getDeleted, Constants.ZERO)
                .eq(PricingRule::getType, Constants.THREE)
@@ -1726,4 +1727,41 @@
        log.info("解绑成功:{}", sn);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int initChangeVersions() {
        Date now = new Date();
        // 1. 补全 version_type 为 NULL 的记录
        shopInfoMapper.update(new UpdateWrapper<ShopInfo>().lambda()
                .set(ShopInfo::getVersionType, Constants.ZERO)
                .isNull(ShopInfo::getVersionType));
        // 2. 查询所有已有变更版本的 relationShopId
        List<ShopInfo> changeVersions = shopInfoMapper.selectList(new QueryWrapper<ShopInfo>().lambda()
                .eq(ShopInfo::getVersionType, Constants.ONE)
                .eq(ShopInfo::getDeleted, Constants.ZERO)
                .select(ShopInfo::getRelationShopId)
                .isNotNull(ShopInfo::getRelationShopId));
        Set<Integer> existingRelationIds = changeVersions.stream()
                .map(ShopInfo::getRelationShopId)
                .collect(Collectors.toSet());
        // 3. 查询所有没有变更版本的正式版本门店
        QueryWrapper<ShopInfo> qw = new QueryWrapper<>();
        qw.lambda()
                .eq(ShopInfo::getVersionType, Constants.ZERO)
                .eq(ShopInfo::getDeleted, Constants.ZERO);
        List<ShopInfo> officialList = shopInfoMapper.selectList(qw);
        int count = 0;
        for (ShopInfo official : officialList) {
            if (existingRelationIds.contains(official.getId())) {
                continue;
            }
            createChangeVersion(official, official.getId(), now);
            count++;
        }
        return count;
    }
}