From c51de64d5ee334d914c90f5e4f82a13f159492ca Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期四, 23 四月 2026 20:08:15 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
server/services/src/main/java/com/doumee/service/business/impl/ShopInfoServiceImpl.java | 402 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 380 insertions(+), 22 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..14b7636 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
@@ -14,21 +14,32 @@
import com.doumee.core.utils.Utils;
import com.doumee.biz.system.AreasBiz;
import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.utils.aliyun.AliSmsService;
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.ShopSalesStatsVO;
import com.doumee.dao.vo.ShopWebDetailVO;
+import com.doumee.service.business.AreasService;
import com.doumee.service.business.ShopInfoService;
+import com.doumee.dao.business.SmsrecordMapper;
+import com.doumee.dao.business.model.Smsrecord;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.RandomStringUtils;
@@ -45,6 +56,7 @@
* @author rk
* @date 2026/04/08
*/
+@Slf4j
@Service
public class ShopInfoServiceImpl implements ShopInfoService {
@@ -68,6 +80,18 @@
@Autowired
private RedisTemplate<String,Object> redisTemplate;
+
+ @Autowired
+ private PricingRuleMapper pricingRuleMapper;
+
+ @Autowired
+ private OrdersMapper ordersMapper;
+
+ @Autowired
+ private AreasService areasService;
+
+ @Autowired
+ private SmsrecordMapper smsrecordMapper;
@Override
public Integer create(ShopInfo shopInfo) {
shopInfoMapper.insert(shopInfo);
@@ -182,6 +206,9 @@
if (pageWrap.getModel().getAreaId() != null) {
queryWrapper.lambda().eq(ShopInfo::getAreaId, pageWrap.getModel().getAreaId());
}
+ if (pageWrap.getModel().getAddress() != null) {
+ queryWrapper.lambda().like(ShopInfo::getAddress, pageWrap.getModel().getAddress());
+ }
if (pageWrap.getModel().getAuditStatus() != null) {
queryWrapper.lambda().eq(ShopInfo::getAuditStatus, pageWrap.getModel().getAuditStatus());
}
@@ -221,11 +248,9 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public void applyShop(ShopApplyDTO request, Member member) {
- Integer memberId = member.getId();
+ public void applyShop(ShopApplyDTO request) {
+ Member member = memberMapper.selectById(request.getMemberId());
- // 1. 鏍¢獙闂ㄥ簵鎵嬫満鍙峰敮涓�鎬э紙shop_info.telephone锛�
- checkTelephoneUnique(request.getTelephone(), null);
// 2. 鏍规嵁绫诲瀷鏍¢獙闄勪欢
if (Constants.equalsInteger(request.getCompanyType(), Constants.ZERO)) {
@@ -260,7 +285,7 @@
// 3. 鏌ヨ璇ヤ細鍛樻槸鍚﹀凡鏈夐棬搴楄褰�
QueryWrapper<ShopInfo> existQw = new QueryWrapper<>();
existQw.lambda()
- .eq(ShopInfo::getRegionMemberId, memberId)
+ .eq(ShopInfo::getRegionMemberId, member.getId())
.eq(ShopInfo::getDeleted, Constants.ZERO)
.last("limit 1");
ShopInfo existing = shopInfoMapper.selectOne(existQw);
@@ -299,15 +324,20 @@
existing.setLegalPersonCard(request.getLegalPersonCard());
existing.setPassword(encryptedPassword);
existing.setSalt(salt);
- existing.setAuditStatus(Constants.ZERO);
+ existing.setAliAccount(request.getAliAccount());
+ existing.setAliName(request.getAliName());
existing.setUpdateTime(now);
- existing.setUpdateUser(memberId);
existing.setAuditRemark(null);
existing.setAuditTime(null);
existing.setAuditUserId(null);
+ existing.setAuditStatus(Constants.ZERO);
+ // 璇诲彇鎶奸噾閲戦
+ setDepositAmountFromPricingRule(existing);
shopInfoMapper.updateById(existing);
shopId = existing.getId();
} else {
+ // 1. 鏍¢獙闂ㄥ簵鎵嬫満鍙峰敮涓�鎬э紙shop_info.telephone锛�
+ checkTelephoneUnique(request.getTelephone(), null);
// 鏂板缓
ShopInfo shopInfo = new ShopInfo();
shopInfo.setCompanyType(request.getCompanyType());
@@ -328,14 +358,15 @@
shopInfo.setLegalPersonCard(request.getLegalPersonCard());
shopInfo.setPassword(encryptedPassword);
shopInfo.setSalt(salt);
- shopInfo.setOpenid(member.getOpenid());
- shopInfo.setAuditStatus(Constants.ZERO);
+ shopInfo.setAliAccount(request.getAliAccount());
+ shopInfo.setAliName(request.getAliName());
shopInfo.setStatus(Constants.ZERO);
shopInfo.setDeleted(Constants.ZERO);
shopInfo.setCreateTime(now);
shopInfo.setUpdateTime(now);
- shopInfo.setCreateUser(memberId);
- shopInfo.setRegionMemberId(memberId);
+ shopInfo.setRegionMemberId(member.getId());
+ // 璇诲彇鎶奸噾閲戦
+ setDepositAmountFromPricingRule(shopInfo);
shopInfoMapper.insert(shopInfo);
shopId = shopInfo.getId();
}
@@ -407,7 +438,49 @@
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璇诲彇鎶奸噾閲戦锛堝鎵规椂鏇存柊锛�
+ setDepositAmountFromPricingRule(shopInfo);
+ }
shopInfoMapper.updateById(shopInfo);
+
+ // 鐭俊閫氱煡
+ if (Constants.equalsInteger(newAuditStatus, Constants.ONE)) {
+ // 瀹℃牳閫氳繃 鈫� 閫氱煡缂寸撼鎶奸噾
+ String depositMoney = shopInfo.getDepositAmount() != null
+ ? String.valueOf(shopInfo.getDepositAmount() / 100.0) : "0";
+ sendSmsNotify(shopInfo.getTelephone(),
+ Constants.SmsNotify.SHOP_AUTH_APPROVED_DEPOSIT,
+ "storeName", shopInfo.getName(),
+ "money", depositMoney);
+ } else if (Constants.equalsInteger(newAuditStatus, Constants.TWO)) {
+ // 瀹℃牳椹冲洖
+ sendSmsNotify(shopInfo.getTelephone(),
+ Constants.SmsNotify.SHOP_AUTH_REJECTED,
+ "storeName", shopInfo.getName(),
+ "reason", auditDTO.getAuditRemark() != null ? auditDTO.getAuditRemark() : "");
+ }
}
@Override
@@ -505,6 +578,8 @@
shopInfo.setLegalPersonName(request.getLegalPersonName());
shopInfo.setLegalPersonPhone(request.getLegalPersonPhone());
shopInfo.setLegalPersonCard(request.getLegalPersonCard());
+ shopInfo.setAliAccount(request.getAliAccount());
+ shopInfo.setAliName(request.getAliName());
shopInfo.setUpdateTime(now);
shopInfoMapper.updateById(shopInfo);
@@ -608,12 +683,15 @@
vo.setPayStatus(shopInfo.getPayStatus());
vo.setScore(shopInfo.getScore());
vo.setCreateTime(shopInfo.getCreateTime());
+ vo.setAliAccount(shopInfo.getAliAccount());
+ vo.setAliName(shopInfo.getAliName());
+ vo.setDepositAmount(shopInfo.getDepositAmount());
// 鎷兼帴鍥剧墖鍓嶇紑
String imgPrefix = "";
try {
- imgPrefix = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.SHOP_FILES).getCode();
+ imgPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILES).getCode();
} catch (Exception e) {
// 鏈厤缃椂蹇界暐
}
@@ -670,8 +748,8 @@
if (payMember != null && StringUtils.isNotBlank(payMember.getCoverImage())) {
String memberPrefix = "";
try {
- memberPrefix = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.MEMBER_FILES).getCode();
+ memberPrefix = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.MEMBER_FILES).getCode();
} catch (Exception e) {
// 鏈厤缃椂蹇界暐
}
@@ -712,6 +790,12 @@
qw.lambda().like(ShopInfo::getName, dto.getName());
}
+ // 鍩庡競绛涢�夛紙areaId鏄尯鍘匡紝闇�鍖归厤鍏秔arentId绛変簬鍩庡競ID锛�
+ if (dto.getCityId() != null) {
+ qw.inSql("AREA_ID",
+ "SELECT id FROM areas WHERE parent_id = " + dto.getCityId() + " AND isdeleted = 0");
+ }
+
// 璺濈绛涢�夛紙鍗曚綅锛氱背 鈫� 杞崲涓簁m姣旇緝锛�
if (distanceMeter != null && distanceMeter > 0) {
double maxKm = distanceMeter / 1000.0;
@@ -744,6 +828,8 @@
vo.setShopHours(shop.getShopHours());
vo.setAddress(shop.getAddress());
vo.setScore(shop.getScore());
+ vo.setLatitude(shop.getLatitude());
+ vo.setLongitude(shop.getLongitude());
// 闂ㄥご鐓х涓�寮�
vo.setCoverImg(getFirstImage(shop.getId(), Constants.FileType.STORE_FRONT.getKey(), imgPrefix));
// 璺濈
@@ -774,6 +860,10 @@
vo.setName(shop.getName());
vo.setAddress(shop.getAddress());
vo.setContent(shop.getContent());
+ vo.setDepositTypes(shop.getDepositTypes());
+ vo.setFeeStandard(shop.getFeeStandard());
+ vo.setLatitude(shop.getLatitude());
+ vo.setLongitude(shop.getLongitude());
// 闂ㄥご鐓� + 鍐呴儴鐓� 鍏ㄨ矾寰勯泦鍚�
String imgPrefix = getShopPrefix();
@@ -861,8 +951,8 @@
*/
private String getShopPrefix() {
try {
- return systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.SHOP_FILES).getCode();
+ return systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILES).getCode();
} catch (Exception e) {
return "";
}
@@ -903,7 +993,137 @@
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.OSS, 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());
+ // 鏀粯瀹濇彁鐜拌处鍙�
+ vo.setAliAccount(shop.getAliAccount());
+ vo.setAliName(shop.getAliName());
+ return vo;
+ }
+ @Override
+ public ShopSalesStatsVO getShopSalesStats(Integer shopId, Integer period) {
+ // 璁$畻鏃堕棿鑼冨洿 0=浠婃棩 1=鏈湀 2=涓婃湀
+ Calendar cal = Calendar.getInstance();
+ Date startTime;
+ Date endTime;
+
+ if (Constants.equalsInteger(period, 2)) {
+ // 涓婃湀锛氫笂鏈�1鍙�00:00:00 ~ 鏈湀1鍙�00:00:00
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ endTime = cal.getTime();
+ cal.add(Calendar.MONTH, -1);
+ startTime = cal.getTime();
+ } else if (Constants.equalsInteger(period, 1)) {
+ // 鏈湀锛氭湰鏈�1鍙�00:00:00 ~ 涓嬫湀1鍙�00:00:00
+ cal.set(Calendar.DAY_OF_MONTH, 1);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ startTime = cal.getTime();
+ cal.add(Calendar.MONTH, 1);
+ endTime = cal.getTime();
+ } else {
+ // 浠婃棩锛氫粖澶�00:00:00 ~ 鏄庡ぉ00:00:00
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ startTime = cal.getTime();
+ cal.add(Calendar.DAY_OF_MONTH, 1);
+ endTime = cal.getTime();
+ }
+
+ ShopSalesStatsVO vo = new ShopSalesStatsVO();
+
+ // 1. 閿�鍞 + 璁㈠崟鏁帮細鎸夎鍗曞垱寤烘椂闂达紝瀛樹欢闂ㄥ簵鎴栧彇浠堕棬搴楁槸鏈棬搴�
+ // 瀛樹欢闂ㄥ簵
+ List<Orders> depositSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .ge(Orders::getCreateTime, startTime)
+ .lt(Orders::getCreateTime, endTime)
+ .eq(Orders::getDepositShopId, shopId));
+ // 鍙栦欢闂ㄥ簵
+ List<Orders> takeSalesOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .ge(Orders::getCreateTime, startTime)
+ .lt(Orders::getCreateTime, endTime)
+ .eq(Orders::getTakeShopId, shopId));
+ long salesAmount = depositSalesOrders.stream().mapToLong(o -> o.getTotalAmount() != null ? o.getTotalAmount() : 0L).sum()
+ + takeSalesOrders.stream().mapToLong(o -> o.getTotalAmount() != null ? o.getTotalAmount() : 0L).sum();
+ vo.setSalesAmount(salesAmount);
+ vo.setOrderCount(depositSalesOrders.size() + takeSalesOrders.size());
+
+ // 2. 缁撶畻鍒╂鼎锛氭寜缁撶畻鏃堕棿锛屾牴鎹棬搴楄鑹插彇depositShopFee鎴杢akeShopFee
+ // 瀛樹欢闂ㄥ簵 = 鏈棬搴� 鐨勮鍗曪紝鍙� depositShopFee
+ List<Orders> depositSettleOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .eq(Orders::getSettlementStatus, Constants.ONE)
+ .ge(Orders::getSettlementTime, startTime)
+ .lt(Orders::getSettlementTime, endTime)
+ .eq(Orders::getDepositShopId, shopId));
+ // 鍙栦欢闂ㄥ簵 = 鏈棬搴� 鐨勮鍗曪紝鍙� takeShopFee
+ List<Orders> takeSettleOrders = ordersMapper.selectList(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .eq(Orders::getSettlementStatus, Constants.ONE)
+ .ge(Orders::getSettlementTime, startTime)
+ .lt(Orders::getSettlementTime, endTime)
+ .eq(Orders::getTakeShopId, shopId));
+ long depositFee = depositSettleOrders.stream()
+ .mapToLong(o -> o.getDepositShopFee() != null ? o.getDepositShopFee() : 0L).sum();
+ long takeFee = takeSettleOrders.stream()
+ .mapToLong(o -> o.getTakeShopFee() != null ? o.getTakeShopFee() : 0L).sum();
+ vo.setSettlementProfit(depositFee + takeFee);
+
+ // 3. 鍦ㄥ簱璁㈠崟鏁�
+ // 3.1 瀛樹欢闂ㄥ簵=鏈棬搴楋紝status in (2宸插瘎瀛�, 5寰呭彇浠�)
+ Long depositStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .eq(Orders::getDepositShopId, shopId)
+ .in(Orders::getStatus,
+ Constants.OrderStatus.deposited.getStatus(),
+ Constants.OrderStatus.arrived.getStatus()));
+ // 3.2 鍙栦欢闂ㄥ簵=鏈棬搴楋紝status = 5寰呭彇浠�
+ Long takeStorageCount = ordersMapper.selectCount(new QueryWrapper<Orders>().lambda()
+ .eq(Orders::getDeleted, Constants.ZERO)
+ .eq(Orders::getTakeShopId, shopId)
+ .eq(Orders::getStatus, Constants.OrderStatus.arrived.getStatus()));
+ vo.setStorageCount(depositStorageCount.intValue() + takeStorageCount.intValue());
+
+ return vo;
+ }
/**
* 鍟嗘埛璐﹀彿瀵嗙爜鐧诲綍
@@ -965,18 +1185,18 @@
}
@Override
- public ShopLoginVO shopSilentLogin(String openid) {
- if (StringUtils.isBlank(openid)) {
- throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "openid涓嶈兘涓虹┖");
+ public ShopLoginVO shopSilentLogin(Integer memberId) {
+ Member member = memberMapper.selectById(memberId);
+ if(Objects.isNull(member)||StringUtils.isBlank(member.getOpenid())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "褰撳墠鐧诲綍浼氬憳韬唤寮傚父,璇疯仈绯荤鐞嗗憳!");
}
ShopInfo shop = shopInfoMapper.selectOne(new QueryWrapper<ShopInfo>().lambda()
- .eq(ShopInfo::getOpenid, openid)
+ .eq(ShopInfo::getOpenid, member.getOpenid())
.eq(ShopInfo::getDeleted, Constants.ZERO)
.last("limit 1"));
if (shop == null) {
return null;
}
-
// 鍒涘缓token锛坓enerateTokenForRedis 宸茶嚜鍔ㄦ竻闄よ鐢ㄦ埛鏃oken锛屼繚璇佸敮涓�鏈夋晥锛�
String token = JwtTokenUtil.generateTokenForRedis(shop.getId(), Constants.TWO, JSONObject.toJSONString(shop), redisTemplate);
@@ -993,4 +1213,142 @@
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;
+ }
+
+ /**
+ * 浠嶱ricingRule璇诲彇鎶奸噾閲戦骞惰祴鍊煎埌闂ㄥ簵璁板綍
+ */
+ private void setDepositAmountFromPricingRule(ShopInfo shopInfo) {
+ if (shopInfo.getCompanyType() == null) {
+ return;
+ }
+ 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()));
+ }
+ }
+
+ /**
+ * 鍙戦�佺煭淇¢�氱煡锛堝け璐ヤ笉褰卞搷涓讳笟鍔★級
+ */
+ private void sendSmsNotify(String phone, Constants.SmsNotify smsNotify, String... paramPairs) {
+ if (StringUtils.isBlank(phone)) {
+ return;
+ }
+ String content = smsNotify.format(paramPairs);
+ try {
+ JSONObject templateParam = new JSONObject();
+ for (int i = 0; i < paramPairs.length - 1; i += 2) {
+ templateParam.put(paramPairs[i], paramPairs[i + 1]);
+ }
+ boolean result = AliSmsService.sendSms(phone, smsNotify.getTemplateCode(),
+ templateParam.toJSONString());
+ if (result) {
+ log.info("鐭俊鍙戦�佹垚鍔�: phone={}, template={}", phone, smsNotify.name());
+ } else {
+ log.warn("鐭俊鍙戦�佸け璐�: phone={}, template={}", phone, smsNotify.name());
+ }
+ // 瀛樺偍鐭俊璁板綍
+ Smsrecord smsRecord = new Smsrecord();
+ smsRecord.setPhone(phone);
+ smsRecord.setContent(content);
+ smsRecord.setType(Constants.ONE);
+ smsRecord.setStatus(result ? Constants.ONE : Constants.ZERO);
+ smsRecord.setCreateTime(new Date());
+ smsRecord.setDeleted(Constants.ZERO);
+ smsrecordMapper.insert(smsRecord);
+ } catch (Exception e) {
+ log.error("鐭俊鍙戦�佸紓甯�: phone={}, template={}, error={}", phone, smsNotify.name(), e.getMessage());
+ }
+ }
+
}
--
Gitblit v1.9.3