From 55642c818f14bf8cf52c98e6858014bd8dc3d3a7 Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期四, 16 四月 2026 20:10:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 170 insertions(+), 4 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 b46cb11..bf5a84a 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
@@ -16,18 +16,24 @@
import com.doumee.biz.system.SystemDictDataBiz;
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.ShopInfoMapper;
import com.doumee.dao.business.model.Areas;
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.ShopInfo;
import com.doumee.dao.dto.*;
import com.doumee.dao.system.SystemUserMapper;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.dao.vo.ShopDetailVO;
+import com.doumee.dao.vo.ShopCenterVO;
import com.doumee.dao.vo.ShopLoginVO;
import com.doumee.dao.vo.ShopNearbyVO;
import com.doumee.dao.vo.ShopWebDetailVO;
+import com.doumee.service.business.AreasService;
import com.doumee.service.business.ShopInfoService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -68,6 +74,15 @@
@Autowired
private RedisTemplate<String,Object> redisTemplate;
+
+ @Autowired
+ private PricingRuleMapper pricingRuleMapper;
+
+ @Autowired
+ private OrdersMapper ordersMapper;
+
+ @Autowired
+ private AreasService areasService;
@Override
public Integer create(ShopInfo shopInfo) {
shopInfoMapper.insert(shopInfo);
@@ -299,6 +314,7 @@
existing.setLegalPersonCard(request.getLegalPersonCard());
existing.setPassword(encryptedPassword);
existing.setSalt(salt);
+ existing.setAliAccount(request.getAliAccount());
existing.setAuditStatus(Constants.ZERO);
existing.setUpdateTime(now);
existing.setUpdateUser(memberId);
@@ -328,6 +344,7 @@
shopInfo.setLegalPersonCard(request.getLegalPersonCard());
shopInfo.setPassword(encryptedPassword);
shopInfo.setSalt(salt);
+ shopInfo.setAliAccount(request.getAliAccount());
shopInfo.setOpenid(member.getOpenid());
shopInfo.setAuditStatus(Constants.ZERO);
shopInfo.setStatus(Constants.ZERO);
@@ -407,6 +424,38 @@
shopInfo.setAuditRemark(auditDTO.getAuditRemark());
shopInfo.setAuditUserId(auditDTO.getAuditUser());
shopInfo.setUpdateTime(now);
+ // 瀹℃壒閫氳繃鏃讹紝鏍¢獙鍩庡競pricing_rule閰嶇疆锛岃鍙栨娂閲戦噾棰�
+ if (Constants.equalsInteger(newAuditStatus, Constants.ONE)) {
+ // 1. 瑙f瀽闂ㄥ簵鎵�鍦ㄥ煄甯�
+ Areas area = areasBiz.resolveArea(shopInfo.getAreaId());
+ if (area == null || area.getParentId() == null) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "闂ㄥ簵鍖哄垝淇℃伅寮傚父锛屾棤娉曠‘瀹氭墍鍦ㄥ煄甯�");
+ }
+ Integer cityId = area.getParentId();
+
+ // 2. 鏍¢獙 pricing_rule 閰嶇疆锛堝煄甯傚紑閫氬湪鎶奸噾鏀粯瀹屾垚鍚庡鐞嗭級
+ Areas cityArea = areasService.findById(cityId, Constants.ONE);
+ if (cityArea == null) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鍩庡競淇℃伅涓嶅瓨鍦�");
+ }
+ if (!Constants.equalsInteger(cityArea.getStatus(), Constants.ONE)) {
+ List<String> errors = validateCityPricingRules(cityId);
+ if (!errors.isEmpty()) {
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),
+ "鍩庡競[" + cityArea.getName() + "]灏氭湭寮�閫氾紝瀹氫环瑙勫垯鏈厤缃畬鏁达細" + String.join("锛�", errors));
+ }
+ }
+
+ // 3. 浠嶱ricingRule璇诲彇鎶奸噾閲戦
+ PricingRule pricingRule = pricingRuleMapper.selectOne(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.THREE)
+ .eq(PricingRule::getFieldA, String.valueOf(shopInfo.getCompanyType()))
+ .last("limit 1"));
+ if (pricingRule != null && StringUtils.isNotBlank(pricingRule.getFieldB())) {
+ shopInfo.setDepositAmount(Long.parseLong(pricingRule.getFieldB()));
+ }
+ }
shopInfoMapper.updateById(shopInfo);
}
@@ -612,7 +661,7 @@
// 鎷兼帴鍥剧墖鍓嶇紑
String imgPrefix = "";
try {
- imgPrefix = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
+ imgPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.SHOP_FILES).getCode();
} catch (Exception e) {
// 鏈厤缃椂蹇界暐
@@ -670,7 +719,7 @@
if (payMember != null && StringUtils.isNotBlank(payMember.getCoverImage())) {
String memberPrefix = "";
try {
- memberPrefix = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
+ memberPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.MEMBER_FILES).getCode();
} catch (Exception e) {
// 鏈厤缃椂蹇界暐
@@ -861,7 +910,7 @@
*/
private String getShopPrefix() {
try {
- return systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
+ return systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.SHOP_FILES).getCode();
} catch (Exception e) {
return "";
@@ -903,7 +952,37 @@
return urls;
}
-
+ @Override
+ public ShopCenterVO getShopCenterInfo(Integer shopId) {
+ ShopInfo shop = shopInfoMapper.selectById(shopId);
+ if (shop == null || Constants.equalsInteger(shop.getDeleted(), Constants.ONE)) {
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ ShopCenterVO vo = new ShopCenterVO();
+ vo.setShopName(shop.getName());
+ vo.setLinkName(shop.getLinkName());
+ vo.setCompanyType(shop.getCompanyType());
+ vo.setCoverImg(shop.getCoverImg());
+ if (StringUtils.isNotBlank(shop.getCoverImg())) {
+ String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.SHOP_FILES).getCode();
+ vo.setFullCoverImg(path + shop.getCoverImg());
+ }
+ vo.setHasMessage(false);
+ // 寰呮牳楠岃鍗曟暟閲忥紙瀛樹欢闂ㄥ簵锛宻tatus=1锛�
+ Long waitDepositCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDepositShopId, shopId)
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .eq(Orders::getStatus, Constants.OrderStatus.waitDeposit.getStatus()));
+ vo.setWaitDepositCount(waitDepositCount.intValue());
+ // 寰呮敹璐ц鍗曟暟閲忥紙鍙栦欢闂ㄥ簵锛宻tatus IN 4,5锛�
+ Long waitReceiveCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getTakeShopId, shopId)
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .in(Orders::getStatus, Constants.OrderStatus.delivering.getStatus(), Constants.OrderStatus.arrived.getStatus()));
+ vo.setWaitReceiveCount(waitReceiveCount.intValue());
+ return vo;
+ }
/**
* 鍟嗘埛璐﹀彿瀵嗙爜鐧诲綍
@@ -993,4 +1072,91 @@
return vo;
}
+ /**
+ * 鏍¢獙鍩庡競瀹氫环瑙勫垯閰嶇疆鏄惁瀹屾暣
+ * @param cityId 鍩庡競涓婚敭
+ * @return 閿欒淇℃伅鍒楄〃锛岀┖琛ㄧず鏍¢獙閫氳繃
+ */
+ private List<String> validateCityPricingRules(Integer cityId) {
+ List<String> errors = new ArrayList<>();
+
+ // type=0 灏卞湴瀛樺彇瑙勫垯锛氳嚦灏�1鏉★紝fieldB涓嶄负绌�
+ List<PricingRule> type0 = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.ZERO)
+ .eq(PricingRule::getCityId, cityId));
+ if (type0.isEmpty()) {
+ errors.add("缂哄皯灏卞湴瀛樺彇瑙勫垯");
+ } else if (type0.stream().allMatch(r -> StringUtils.isBlank(r.getFieldB()))) {
+ errors.add("灏卞湴瀛樺彇瑙勫垯鏈厤缃敹璐瑰崟浠�");
+ }
+
+ // type=1 寮傚湴瀵勯�佽鍒欙細鑷冲皯1鏉★紝fieldB/C/D/E涓嶄负绌�
+ List<PricingRule> type1 = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.ONE)
+ .eq(PricingRule::getCityId, cityId));
+ if (type1.isEmpty()) {
+ errors.add("缂哄皯寮傚湴瀵勯�佽鍒�");
+ } else if (type1.stream().allMatch(r -> StringUtils.isAnyBlank(r.getFieldB(), r.getFieldC(), r.getFieldD(), r.getFieldE()))) {
+ errors.add("寮傚湴瀵勯�佽鍒欓厤缃笉瀹屾暣");
+ }
+
+ // type=2 棰勮鏃舵晥锛歠ieldA=1(鏍囬�熻揪) 鍜� fieldA=2(鏋侀�熻揪) 鍚�1鏉�
+ List<PricingRule> type2 = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.TWO)
+ .eq(PricingRule::getCityId, cityId));
+ Map<String, PricingRule> type2Map = type2.stream()
+ .collect(Collectors.toMap(PricingRule::getFieldA, r -> r, (a, b) -> a));
+ if (!type2Map.containsKey("1")) {
+ errors.add("缂哄皯棰勮鏃舵晥-鏍囬�熻揪閰嶇疆");
+ } else if (StringUtils.isAnyBlank(type2Map.get("1").getFieldB(), type2Map.get("1").getFieldC(),
+ type2Map.get("1").getFieldD(), type2Map.get("1").getFieldE())) {
+ errors.add("棰勮鏃舵晥-鏍囬�熻揪閰嶇疆涓嶅畬鏁�");
+ }
+ if (!type2Map.containsKey("2")) {
+ errors.add("缂哄皯棰勮鏃舵晥-鏋侀�熻揪閰嶇疆");
+ } else if (StringUtils.isAnyBlank(type2Map.get("2").getFieldB(), type2Map.get("2").getFieldC(),
+ type2Map.get("2").getFieldD(), type2Map.get("2").getFieldE())) {
+ errors.add("棰勮鏃舵晥-鏋侀�熻揪閰嶇疆涓嶅畬鏁�");
+ }
+
+ // type=3 闂ㄥ簵娉ㄥ唽鎶奸噾锛歠ieldA=0(浼佷笟) 鍜� fieldA=1(涓汉) 鍚�1鏉★紝fieldB涓嶄负绌�
+ List<PricingRule> type3 = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.THREE)
+ .eq(PricingRule::getCityId, cityId));
+ Map<String, PricingRule> type3Map = type3.stream()
+ .collect(Collectors.toMap(PricingRule::getFieldA, r -> r, (a, b) -> a));
+ String[] depositNames = {"浼佷笟", "涓汉"};
+ for (int i = 0; i <= 1; i++) {
+ String key = String.valueOf(i);
+ if (!type3Map.containsKey(key)) {
+ errors.add("缂哄皯闂ㄥ簵娉ㄥ唽鎶奸噾-" + depositNames[i] + "閰嶇疆");
+ } else if (StringUtils.isBlank(type3Map.get(key).getFieldB())) {
+ errors.add("闂ㄥ簵娉ㄥ唽鎶奸噾-" + depositNames[i] + "鏈厤缃娂閲戦噾棰�");
+ }
+ }
+
+ // type=4 鍒嗘垚姣斾緥锛歠ieldA=0~4 鍏�5鏉★紝fieldB涓嶄负绌�
+ List<PricingRule> type4 = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+ .eq(PricingRule::getDeleted, Constants.ZERO)
+ .eq(PricingRule::getType, Constants.FOUR)
+ .eq(PricingRule::getCityId, cityId));
+ String[] shareNames = {"浼佷笟瀵�", "涓汉瀵�", "浼佷笟鍙�", "涓汉鍙�", "閰嶉�佸憳"};
+ Map<String, PricingRule> type4Map = type4.stream()
+ .collect(Collectors.toMap(PricingRule::getFieldA, r -> r, (a, b) -> a));
+ for (int i = 0; i <= 4; i++) {
+ String key = String.valueOf(i);
+ if (!type4Map.containsKey(key)) {
+ errors.add("缂哄皯鍒嗘垚姣斾緥-" + shareNames[i] + "閰嶇疆");
+ } else if (StringUtils.isBlank(type4Map.get(key).getFieldB())) {
+ errors.add("鍒嗘垚姣斾緥-" + shareNames[i] + "鏈厤缃垎鎴愭瘮渚�");
+ }
+ }
+
+ return errors;
+ }
+
}
--
Gitblit v1.9.3