From c74a6f59490cfb9a0ee37f70427739b74e7fbd58 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 20 五月 2026 08:50:29 +0800
Subject: [PATCH] 代码生成
---
server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java | 323 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 312 insertions(+), 11 deletions(-)
diff --git a/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
index 149dd06..e302df5 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java
@@ -15,16 +15,20 @@
import com.doumee.biz.system.AreasBiz;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.utils.aliyun.AliSmsService;
+import com.doumee.dao.business.CategoryMapper;
import com.doumee.dao.business.MemberMapper;
import com.doumee.dao.business.MultifileMapper;
import com.doumee.dao.business.OrdersMapper;
import com.doumee.dao.business.PricingRuleMapper;
+import com.doumee.dao.business.RevenueMapper;
import com.doumee.dao.business.ShopInfoMapper;
import com.doumee.dao.business.model.Areas;
+import com.doumee.dao.business.model.Category;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.business.model.Multifile;
import com.doumee.dao.business.model.Orders;
import com.doumee.dao.business.model.PricingRule;
+import com.doumee.dao.business.model.Revenue;
import com.doumee.dao.business.model.ShopInfo;
import com.doumee.config.xyy.XyyConfig;
import com.doumee.config.xyy.dto.AddPrinterRequest;
@@ -36,13 +40,17 @@
import com.doumee.dao.system.model.SystemDictData;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.model.SystemUser;
+import com.doumee.dao.vo.LuggageTypeItem;
import com.doumee.dao.vo.ShopDetailVO;
import com.doumee.dao.vo.ShopCenterVO;
+import com.doumee.dao.vo.ShopKpiVO;
import com.doumee.dao.vo.ShopLoginVO;
+import com.doumee.dao.vo.LocationTagShopCountVO;
import com.doumee.dao.vo.ShopNearbyVO;
import com.doumee.dao.vo.ShopSalesStatsVO;
import com.doumee.dao.vo.ShopWebDetailVO;
import com.doumee.service.business.AreasService;
+import com.doumee.service.business.DataBoardService;
import com.doumee.service.business.ShopInfoService;
import com.doumee.dao.business.SmsrecordMapper;
import com.doumee.dao.business.model.Smsrecord;
@@ -105,6 +113,16 @@
@Autowired
private XyyConfig xyyConfig;
+
+ @Autowired
+ private DataBoardService dataBoardService;
+
+ @Autowired
+ private RevenueMapper revenueMapper;
+
+ @Autowired
+ private CategoryMapper categoryMapper;
+
@Override
public Integer create(ShopInfo shopInfo) {
shopInfoMapper.insert(shopInfo);
@@ -193,6 +211,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()));
@@ -307,9 +328,6 @@
// 鏈�鏂板彉鏇寸増鏈凡鏀粯鎶奸噾(status=3)锛氱敓鎴愭柊鐨勫彉鏇寸増鏈�
Integer relationShopId = changeVersion.getRelationShopId();
- // 鏍¢獙鎵嬫満鍙峰敮涓�鎬э紙鎺掗櫎姝e紡鐗堟湰鍜屽彉鏇寸増鏈級
- checkTelephoneUnique(request.getTelephone(), relationShopId);
-
String rawPassword = generateDefaultPassword(request.getTelephone());
String salt = RandomStringUtils.randomAlphabetic(6);
String encryptedPassword = Utils.Secure.encryptPassword(rawPassword, salt);
@@ -329,13 +347,17 @@
// 淇濆瓨鏂板彉鏇寸増鏈檮浠�
saveShopAttachments(newChange.getId(), request, now);
+ // 鏍囪鍘嗗彶鐨勫彉鏇寸増鏈负鍒犻櫎
+ shopInfoMapper.update(null, new UpdateWrapper<ShopInfo>().lambda()
+ .eq(ShopInfo::getRegionMemberId, member.getId())
+ .eq(ShopInfo::getVersionType, Constants.ONE)
+ .eq(ShopInfo::getDeleted, Constants.ZERO)
+ .ne(ShopInfo::getId, newChange.getId())
+ .set(ShopInfo::getDeleted, Constants.ONE)
+ .set(ShopInfo::getUpdateTime, 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);
@@ -479,6 +501,19 @@
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠鐘舵�佷笉鍏佽瀹℃壒");
}
+ // 瀹℃壒閫氳繃鏃讹紝鏀剁泭姣斾緥閰嶇疆蹇呭~
+ String revenueShareConfig = null;
+ if (Constants.equalsInteger(auditDTO.getAuditStatus(), Constants.ZERO)) {
+ if (auditDTO.getLocalDeposit() == null || auditDTO.getRemoteDeposit() == null || auditDTO.getRemoteTake() == null) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀹℃壒閫氳繃鏃舵敹鐩婃瘮渚嬮厤缃笉鑳戒负绌�");
+ }
+ JSONObject json = new JSONObject();
+ json.put("localDeposit", auditDTO.getLocalDeposit());
+ json.put("remoteDeposit", auditDTO.getRemoteDeposit());
+ json.put("remoteTake", auditDTO.getRemoteTake());
+ revenueShareConfig = json.toJSONString();
+ }
+
Date now = new Date();
// auditDTO.auditStatus: 0=閫氳繃 鈫� 1, 1=椹冲洖 鈫� 2
Integer newAuditStatus = Constants.equalsInteger(auditDTO.getAuditStatus(), Constants.ZERO) ? Constants.ONE : Constants.TWO;
@@ -498,6 +533,7 @@
changeVersion.setUpdateTime(now);
if (Constants.equalsInteger(newAuditStatus, Constants.ONE)) {
+ changeVersion.setRevenueShareConfig(revenueShareConfig);
validateCityAndSetDeposit(changeVersion);
}
shopInfoMapper.updateById(changeVersion);
@@ -511,6 +547,7 @@
official.setUpdateTime(now);
if (Constants.equalsInteger(newAuditStatus, Constants.ONE)) {
official.setDepositAmount(changeVersion.getDepositAmount());
+ official.setRevenueShareConfig(revenueShareConfig);
}
shopInfoMapper.updateById(official);
}
@@ -525,8 +562,19 @@
changeVersion.setAuditTime(now);
changeVersion.setAuditRemark(auditDTO.getAuditRemark());
changeVersion.setAuditUserId(auditDTO.getAuditUser());
+ changeVersion.setRevenueShareConfig(revenueShareConfig);
changeVersion.setUpdateTime(now);
shopInfoMapper.updateById(changeVersion);
+
+ // 鏍囪鍘嗗彶鐨勫彉鏇寸増鏈负鍒犻櫎
+ shopInfoMapper.update(null, new UpdateWrapper<ShopInfo>().lambda()
+ .eq(ShopInfo::getRegionMemberId, changeVersion.getRegionMemberId())
+ .eq(ShopInfo::getVersionType, Constants.ONE)
+ .eq(ShopInfo::getDeleted, Constants.ZERO)
+ .ne(ShopInfo::getId, changeVersion.getId())
+ .ne(ShopInfo::getId, officialId)
+ .set(ShopInfo::getDeleted, Constants.ONE)
+ .set(ShopInfo::getUpdateTime, now));
// 鍚屾鍙樻洿鐗堟湰鏁版嵁鍒版寮忕増鏈�
syncChangeToOfficial(changeVersion, official, now);
@@ -730,6 +778,7 @@
shopInfo.setAliAccount(request.getAliAccount());
shopInfo.setAliName(request.getAliName());
shopInfo.setRevenueShareConfig(buildRevenueShareConfig(request.getLocalDeposit(), request.getRemoteDeposit(), request.getRemoteTake()));
+ shopInfo.setLocationTagIds(request.getLocationTagIds());
shopInfo.setUpdateTime(now);
shopInfoMapper.updateById(shopInfo);
@@ -802,12 +851,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);
@@ -914,6 +969,19 @@
vo.setDeliveryRange(shopInfo.getDeliveryArea());
vo.setVersionType(shopInfo.getVersionType());
vo.setRelationShopId(shopInfo.getRelationShopId());
+ vo.setLocationTagIds(shopInfo.getLocationTagIds());
+
+ // 浣嶇疆鏍囩鍚嶇О
+ if (StringUtils.isNotBlank(shopInfo.getLocationTagIds())) {
+ List<String> tagNames = new ArrayList<>();
+ for (String tagId : shopInfo.getLocationTagIds().split(",")) {
+ Category tag = categoryMapper.selectById(Integer.valueOf(tagId.trim()));
+ if (tag != null) {
+ tagNames.add(tag.getName());
+ }
+ }
+ vo.setLocationTagNames(String.join(",", tagNames));
+ }
// 瑙f瀽鏀剁泭姣斾緥閰嶇疆
if (StringUtils.isNotBlank(shopInfo.getRevenueShareConfig())) {
try {
@@ -944,6 +1012,13 @@
vo.setIdcardImgBackUrl(StringUtils.isNotBlank(shopInfo.getIdcardImgBack()) ? imgPrefix + shopInfo.getIdcardImgBack() : null);
vo.setBusinessImg(shopInfo.getBusinessImg());
vo.setBusinessImgUrl(StringUtils.isNotBlank(shopInfo.getBusinessImg()) ? imgPrefix + shopInfo.getBusinessImg() : null);
+ vo.setCoverImg(shopInfo.getCoverImg());
+ vo.setCoverImgUrl(StringUtils.isNotBlank(shopInfo.getCoverImg()) ? imgPrefix + shopInfo.getCoverImg() : null);
+ vo.setContent(shopInfo.getContent());
+ vo.setDepositTypes(shopInfo.getDepositTypes());
+ vo.setFeeStandard(shopInfo.getFeeStandard());
+ vo.setShopHours(shopInfo.getShopHours());
+ vo.setBusinessType(shopInfo.getBusinessType());
// 鏌ヨ闄勪欢
QueryWrapper<Multifile> fileQw = new QueryWrapper<>();
@@ -1045,6 +1120,11 @@
"SELECT id FROM areas WHERE parent_id = " + dto.getCityId() + " AND isdeleted = 0");
}
+ // 浣嶇疆鏍囩绛涢��
+ if (dto.getLocationTagId() != null) {
+ qw.apply("FIND_IN_SET({0}, LOCATION_TAG_IDS) > 0", dto.getLocationTagId());
+ }
+
// 璺濈绛涢�夛紙鍗曚綅锛氱背 鈫� 杞崲涓簁m姣旇緝锛�
if (distanceMeter != null && distanceMeter > 0) {
double maxKm = distanceMeter / 1000.0;
@@ -1081,6 +1161,8 @@
vo.setLongitude(shop.getLongitude());
// 闂ㄥご鐓х涓�寮�
vo.setCoverImg(getFirstImage(shop.getId(), Constants.FileType.STORE_FRONT.getKey(), imgPrefix));
+ // 浣嶇疆鏍囩鍚嶇О
+ vo.setLocationTagNames(resolveLocationTagNames(shop.getLocationTagIds()));
// 璺濈
if (longitude != null && latitude != null && shop.getLongitude() != null && shop.getLatitude() != null) {
double distKm = haversine(latitude, longitude, shop.getLatitude(), shop.getLongitude());
@@ -1095,6 +1177,53 @@
pageData.setPage(result.getCurrent());
pageData.setCapacity(result.getSize());
return pageData;
+ }
+
+ @Override
+ public List<LocationTagShopCountVO> countShopsByLocationTag(Integer cityId) {
+ // 鏌ヨ鎵�鏈変綅缃爣绛�
+ List<Category> tags = categoryMapper.selectList(new QueryWrapper<Category>().lambda()
+ .eq(Category::getDeleted, Constants.ZERO)
+ .eq(Category::getStatus, Constants.ZERO)
+ .eq(Category::getType, Constants.FIVE)
+ .orderByAsc(Category::getSortnum));
+ if (tags.isEmpty()) {
+ return new ArrayList<>();
+ }
+
+ // 鏋勫缓闂ㄥ簵鍩虹鏌ヨ鏉′欢
+ QueryWrapper<ShopInfo> baseQw = new QueryWrapper<>();
+ baseQw.lambda()
+ .eq(ShopInfo::getDeleted, Constants.ZERO)
+ .eq(ShopInfo::getStatus, Constants.ZERO)
+ .eq(ShopInfo::getVersionType, Constants.ZERO)
+ .eq(ShopInfo::getAuditStatus, Constants.THREE);
+ if (cityId != null) {
+ baseQw.inSql("AREA_ID",
+ "SELECT id FROM areas WHERE parent_id = " + cityId + " AND isdeleted = 0");
+ }
+
+ // 鎸夋爣绛剧粺璁�
+ List<LocationTagShopCountVO> result = new ArrayList<>();
+ for (Category tag : tags) {
+ QueryWrapper<ShopInfo> qw = baseQw.clone();
+ qw.apply("FIND_IN_SET({0}, LOCATION_TAG_IDS) > 0", tag.getId());
+ Long count = shopInfoMapper.selectCount(qw);
+ LocationTagShopCountVO vo = new LocationTagShopCountVO();
+ vo.setTagId(tag.getId());
+ vo.setTagName(tag.getName());
+ vo.setShopCount(count != null ? count.intValue() : 0);
+ result.add(vo);
+ }
+
+ // 鎬绘暟鏀惧湪鍒楄〃绗竴涓�
+ Long totalCount = shopInfoMapper.selectCount(baseQw);
+ LocationTagShopCountVO totalVo = new LocationTagShopCountVO();
+ totalVo.setTagId(null);
+ totalVo.setTagName("瀵勫瓨鐐规�绘暟");
+ totalVo.setShopCount(totalCount != null ? totalCount.intValue() : 0);
+ result.add(0, totalVo);
+ return result;
}
@Override
@@ -1114,6 +1243,7 @@
vo.setLatitude(shop.getLatitude());
vo.setLongitude(shop.getLongitude());
vo.setLinkPhone(shop.getLinkPhone());
+ vo.setLocationTagNames(resolveLocationTagNames(shop.getLocationTagIds()));
// 闂ㄥご鐓� + 鍐呴儴鐓� 鍏ㄨ矾寰勯泦鍚�
String imgPrefix = getShopPrefix();
@@ -1203,6 +1333,18 @@
/**
* 鑾峰彇闂ㄥ簵鍥剧墖鍓嶇紑
*/
+ private String resolveLocationTagNames(String locationTagIds) {
+ if (StringUtils.isBlank(locationTagIds)) return null;
+ List<String> tagNames = new ArrayList<>();
+ for (String tagId : locationTagIds.split(",")) {
+ Category tag = categoryMapper.selectById(Integer.valueOf(tagId.trim()));
+ if (tag != null) {
+ tagNames.add(tag.getName());
+ }
+ }
+ return tagNames.isEmpty() ? null : String.join(",", tagNames);
+ }
+
private String getShopPrefix() {
try {
return systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
@@ -1386,6 +1528,128 @@
.eq(Orders::getTakeShopId, shopId)
.eq(Orders::getStatus, Constants.OrderStatus.arrived.getStatus()));
vo.setStorageCount(localStorageCount.intValue() + remoteStorageCount.intValue() + takeStorageCount.intValue());
+
+ return vo;
+ }
+
+ @Override
+ public List<LuggageTypeItem> shopLuggageTypeList(Integer shopId, ShopRevenueQueryDTO query) {
+ QueryWrapper<Orders> qw = new QueryWrapper<>();
+ qw.lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .in(Orders::getStatus,
+ Constants.OrderStatus.waitDeposit.getKey(),
+ Constants.OrderStatus.deposited.getKey(),
+ Constants.OrderStatus.accepted.getKey(),
+ Constants.OrderStatus.delivering.getKey(),
+ Constants.OrderStatus.arrived.getKey(),
+ Constants.OrderStatus.finished.getKey())
+ .and(w -> w.eq(Orders::getDepositShopId, shopId).or().eq(Orders::getTakeShopId, shopId));
+ if (query.getStartDate() != null) {
+ qw.lambda().ge(Orders::getCreateTime, query.getStartDate());
+ }
+ if (query.getEndDate() != null) {
+ qw.lambda().le(Orders::getCreateTime, Utils.Date.getEnd(query.getEndDate()));
+ }
+ List<Orders> orders = ordersMapper.selectList(qw);
+ List<Integer> orderIds = orders.stream().map(Orders::getId).collect(Collectors.toList());
+ return dataBoardService.buildLuggageTypeList(orderIds);
+ }
+
+ @Override
+ public ShopKpiVO getShopKpi(Integer shopId, ShopRevenueQueryDTO query) {
+ // 鏌ヨ闂ㄥ簵鍙備笌鐨勮鍗曪紙鐘舵��1-7锛屾棩鏈熻寖鍥达級
+ QueryWrapper<Orders> qw = new QueryWrapper<>();
+ qw.lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .in(Orders::getStatus,
+ Constants.OrderStatus.waitDeposit.getKey(),
+ Constants.OrderStatus.deposited.getKey(),
+ Constants.OrderStatus.accepted.getKey(),
+ Constants.OrderStatus.delivering.getKey(),
+ Constants.OrderStatus.arrived.getKey(),
+ Constants.OrderStatus.finished.getKey())
+ .and(w -> w.eq(Orders::getDepositShopId, shopId).or().eq(Orders::getTakeShopId, shopId));
+ if (query.getStartDate() != null) {
+ qw.lambda().ge(Orders::getCreateTime, query.getStartDate());
+ }
+ if (query.getEndDate() != null) {
+ qw.lambda().le(Orders::getCreateTime, Utils.Date.getEnd(query.getEndDate()));
+ }
+ List<Orders> orders = ordersMapper.selectList(qw);
+
+ ShopKpiVO vo = new ShopKpiVO();
+
+ // 瀵勫瓨璁㈠崟閲忥紙灏卞湴锛�
+ long localCount = orders.stream().filter(o -> Constants.equalsInteger(o.getType(), Constants.ZERO)).count();
+ vo.setLocalOrderCount((int) localCount);
+
+ // 瀵勯�佽鍗曢噺锛堝紓鍦帮級
+ long remoteCount = orders.stream().filter(o -> Constants.equalsInteger(o.getType(), Constants.ONE)).count();
+ vo.setRemoteOrderCount((int) remoteCount);
+
+ // 鎬昏鍗曢噺
+ vo.setTotalOrderCount(orders.size());
+
+ // 鎬诲畬鎴愯鍗曢噺
+ long finishedCount = orders.stream()
+ .filter(o -> Constants.equalsInteger(o.getStatus(), Constants.OrderStatus.finished.getStatus()))
+ .count();
+ vo.setFinishedOrderCount((int) finishedCount);
+
+ // 鎬昏惀鏀堕噾棰� = sum(totalAmount - refundAmount)
+ long totalRevenue = orders.stream()
+ .mapToLong(o -> {
+ long total = o.getTotalAmount() != null ? o.getTotalAmount() : 0L;
+ long refund = o.getRefundAmount() != null ? o.getRefundAmount() : 0L;
+ return total - refund;
+ }).sum();
+ vo.setTotalRevenue(totalRevenue);
+
+ // 闂ㄥ簵鍒嗘垚閲戦
+ long shopFee = 0L;
+ for (Orders o : orders) {
+ if (Constants.equalsInteger(o.getType(), Constants.ZERO)) {
+ // 灏卞湴瀵勫瓨锛氬彇瀛樹欢闂ㄥ簵鍒嗘垚
+ if (Constants.equalsInteger(o.getDepositShopId(), shopId)) {
+ shopFee += o.getDepositShopFee() != null ? o.getDepositShopFee() : 0L;
+ }
+ } else if (Constants.equalsInteger(o.getType(), Constants.ONE)) {
+ // 寮傚湴锛氫綔涓哄瓨浠堕棬搴楀彇depositShopFee锛屼綔涓哄彇浠堕棬搴楀彇takeShopFee
+ if (Constants.equalsInteger(o.getDepositShopId(), shopId)) {
+ shopFee += o.getDepositShopFee() != null ? o.getDepositShopFee() : 0L;
+ }
+ if (Constants.equalsInteger(o.getTakeShopId(), shopId)) {
+ shopFee += o.getTakeShopFee() != null ? o.getTakeShopFee() : 0L;
+ }
+ }
+ }
+ vo.setShopFeeTotal(shopFee);
+
+ // 閫�娆惧崟鏁�
+ long refundCount = orders.stream()
+ .filter(o -> o.getRefundAmount() != null && o.getRefundAmount() > 0)
+ .count();
+ vo.setRefundOrderCount((int) refundCount);
+
+ // 璐d换鎵f鎬婚锛歊evenue memberId=shopId, memberType=2, type=4
+ QueryWrapper<Revenue> revQw = new QueryWrapper<>();
+ revQw.lambda()
+ .eq(Revenue::getMemberId, shopId)
+ .eq(Revenue::getMemberType, Constants.TWO)
+ .eq(Revenue::getType, Constants.FOUR)
+ .eq(Revenue::getDeleted, Constants.ZERO);
+ if (query.getStartDate() != null) {
+ revQw.lambda().ge(Revenue::getCreateTime, query.getStartDate());
+ }
+ if (query.getEndDate() != null) {
+ revQw.lambda().le(Revenue::getCreateTime, Utils.Date.getEnd(query.getEndDate()));
+ }
+ List<Revenue> deductRecords = revenueMapper.selectList(revQw);
+ long deductTotal = deductRecords.stream()
+ .mapToLong(r -> r.getAmount() != null ? r.getAmount() : 0L)
+ .sum();
+ vo.setDeductTotal(deductTotal);
return vo;
}
@@ -1582,7 +1846,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 +1990,41 @@
log.info("瑙g粦鎴愬姛锛歿}", 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. 鏌ヨ鎵�鏈夋病鏈夊彉鏇寸増鏈殑姝e紡鐗堟湰闂ㄥ簵
+ 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;
+ }
+
}
--
Gitblit v1.9.3