From ebfdfcbea70a9092d2fd9cad33da07b270f2c775 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sat, 29 Aug 2026 09:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8B=BC=E5=9B=A2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hiver-admin/test-output/test-report.html | 16 ++--- .../controller/manage/UserController.java | 12 +++- .../service/impl/CampusServiceImpl.java | 59 +++++++++++++++++++ .../MallDeliveryOrderController.java | 14 +++-- .../mall/controller/ShopAreaController.java | 28 +++++++++ .../java/cc/hiver/mall/entity/ShopArea.java | 4 ++ .../service/impl/FishMarketServiceImpl.java | 45 +++++++++++++- .../ie/service/impl/IeChatServiceImpl.java | 50 ++++++++++++++++ .../serviceimpl/ShopTakeawayServiceImpl.java | 44 ++++++++++---- .../mybatis/MallAdPositionServiceImpl.java | 2 +- .../db/shop_area_delivery_enabled.sql | 2 + .../main/resources/mapper/ShopAreaMapper.xml | 19 ++++-- .../social/controller/WechatController.java | 41 +++++++------ .../serviceimpl/WechatPhoneService.java | 12 ++-- 14 files changed, 293 insertions(+), 55 deletions(-) create mode 100644 hiver-modules/hiver-mall/src/main/resources/db/shop_area_delivery_enabled.sql diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index b577a2c6..56db4bd9 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • -八月 24, 2026 11:57:28 +八月 26, 2026 18:43:14
  • @@ -84,7 +84,7 @@

    passTest

    -

    11:57:28 上午 / 0.022 secs

    +

    18:43:15 下午 / 0.04 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -08.24.2026 11:57:28 -08.24.2026 11:57:28 -0.022 secs +08.26.2026 18:43:15 +08.26.2026 18:43:15 +0.04 secs
    @@ -104,7 +104,7 @@ Pass - 11:57:28 + 18:43:15 Test passed @@ -128,13 +128,13 @@

    Started

    -

    八月 24, 2026 11:57:28

    +

    八月 26, 2026 18:43:14

    Ended

    -

    八月 24, 2026 11:57:28

    +

    八月 26, 2026 18:43:15

    diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java index 813e5636..705bb333 100644 --- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java +++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java @@ -672,13 +672,21 @@ public class UserController { User wechatUser = null; final Map resultMap = new HashMap<>(); if(StringUtils.isEmpty(wechatVo.getUserId())){ - wechatUser = userService.findByUnionid(unionid); + if (StringUtils.isNotEmpty(unionid)) { + wechatUser = userService.findByUnionid(unionid); + } + if (wechatUser == null) { + wechatUser = userService.findByMiniProgramOpenid(openId); + } }else{ wechatUser = userService.findById(wechatVo.getUserId()); - if (wechatUser == null) { + if (wechatUser == null && StringUtils.isNotEmpty(unionid)) { // 濡傛灉鏍规嵁userid娌℃煡鍒帮紝鍐嶆牴鎹畊nionid鏌ヨ涓閬 wechatUser = userService.findByUnionid(unionid); } + if (wechatUser == null) { + wechatUser = userService.findByMiniProgramOpenid(openId); + } } if (wechatUser == null) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/campus/service/impl/CampusServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/campus/service/impl/CampusServiceImpl.java index a5d9627b..7b02d068 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/campus/service/impl/CampusServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/campus/service/impl/CampusServiceImpl.java @@ -15,6 +15,7 @@ import cc.hiver.mall.ie.service.IeContentAuditLogService; import cc.hiver.mall.ie.service.IeSecurityAuditService; import cc.hiver.mall.ie.vo.IeAliyunModerationResult; import cc.hiver.mall.ie.vo.IeAuditResult; +import cc.hiver.mall.utils.WechatSendMessageUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -22,6 +23,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -31,8 +33,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionSynchronization; +import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionTemplate; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -45,6 +50,7 @@ public class CampusServiceImpl implements CampusService { private static final String IMAGE_AUDIT_REJECT_MESSAGE = "鍥剧墖瀹℃牳鏈氳繃锛岃鏇存崲鍚庨噸璇"; private static final String CHAT_UNREAD_KEY_PREFIX = "campus:unread:chat:"; private static final String COMMENT_UNREAD_KEY_PREFIX = "campus:unread:comment:"; + private static final String CAMPUS_COMMENT_WECHAT_TEMPLATE_ID = "X-lezVQyqm9EUsHCi6ja2cAnjdif5uyA21nhmg0RsuU"; private static final int STATUS_NORMAL = 1; private static final int STATUS_OFF_SHELF = 2; private static final int STATUS_DELETED = 3; @@ -84,6 +90,8 @@ public class CampusServiceImpl implements CampusService { private SimpMessagingTemplate messagingTemplate; @Autowired private PlatformTransactionManager transactionManager; + @Autowired + private WechatSendMessageUtil wechatSendMessageUtil; @Override public List listCategories(String regionId, String parentCode, String categoryType) { @@ -378,6 +386,11 @@ public class CampusServiceImpl implements CampusService { if (!user.getId().equals(post.getUserId())) { incrementUnread(commentUnreadKey(post.getUserId()), commentUnreadField(post.getId(), comment.getId())); } + if (StringUtils.isBlank(comment.getParentId()) + && Integer.valueOf(AUDIT_PASS).equals(comment.getAuditStatus()) + && !user.getId().equals(post.getUserId())) { + sendCampusCommentNotifyAfterCommit(comment, post); + } return comment; } @@ -1253,6 +1266,44 @@ public class CampusServiceImpl implements CampusService { messagingTemplate.convertAndSend("/topic/campus/session/" + message.getSessionId(), message); } + private void sendCampusCommentNotifyAfterCommit(CampusComment comment, CampusPost post) { + if (comment == null || post == null || StringUtils.isBlank(post.getUserId())) return; + if (TransactionSynchronizationManager.isSynchronizationActive()) { + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { + @Override + public void afterCommit() { + sendCampusCommentNotify(comment, post); + } + }); + return; + } + sendCampusCommentNotify(comment, post); + } + + private void sendCampusCommentNotify(CampusComment comment, CampusPost post) { + try { + User receiver = userService.findById(post.getUserId()); + if (receiver == null || StringUtils.isBlank(receiver.getOfficialAccountOpenid())) { + return; + } + List data = new ArrayList<>(); + Date createTime = comment.getCreateTime() == null ? new Date() : comment.getCreateTime(); + data.add(new WxMpTemplateData("time5", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime))); + data.add(new WxMpTemplateData("thing10", "鏍″洯鍦堟湁鏂扮殑璇勮鍟")); + data.add(new WxMpTemplateData("character_string6", limitCharacterStringValue(defaultString(comment.getId(), post.getId())))); + wechatSendMessageUtil.sendWechatTempMessage( + Collections.singletonList(receiver.getOfficialAccountOpenid()), + CAMPUS_COMMENT_WECHAT_TEMPLATE_ID, + data, + "pages/index/index" + ); + log.info("鏍″洯鍦堣瘎璁哄叕浼楀彿閫氱煡宸插彂閫侊紝commentId={}, receiverId={}", comment.getId(), post.getUserId()); + } catch (Exception e) { + log.warn("鏍″洯鍦堣瘎璁哄叕浼楀彿閫氱煡鍙戦佸け璐ワ紝commentId={}, receiverId={}, reason={}", + comment == null ? null : comment.getId(), post == null ? null : post.getUserId(), e.getMessage()); + } + } + private void incrementUnread(String key, String field) { if (stringRedisTemplate == null || StringUtils.isAnyBlank(key, field)) return; stringRedisTemplate.opsForHash().increment(key, field, 1L); @@ -1324,6 +1375,14 @@ public class CampusServiceImpl implements CampusService { return postId + ":" + commentId; } + private String limitCharacterStringValue(String value) { + String text = StringUtils.defaultString(value).replaceAll("[^A-Za-z0-9_-]", ""); + if (StringUtils.isBlank(text)) { + return "campus"; + } + return text.length() > 32 ? text.substring(0, 32) : text; + } + private CampusPageQuery normalizeQuery(CampusPageQuery query) { CampusPageQuery q = query == null ? new CampusPageQuery() : query; q.setPageNum(q.getPageNum() == null || q.getPageNum() < 1 ? 1 : q.getPageNum()); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallDeliveryOrderController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallDeliveryOrderController.java index 4698955d..257f8dd7 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallDeliveryOrderController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallDeliveryOrderController.java @@ -38,10 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 閰嶉佽鍗曟帴鍙 @@ -53,6 +50,7 @@ import java.util.Map; public class MallDeliveryOrderController { private static final int STATUS_WAIT = -1; + private static final String HOME_POPUP_POSITION = "home_popup"; @Autowired private MallDeliveryOrderService mallDeliveryOrderService; @@ -103,11 +101,14 @@ public class MallDeliveryOrderController { //棣栧厛浠庣紦瀛樹腑鏌ヨ Map cacheResult = waitOrderCacheUtil.getAll(q); List cathList = mallAdPositionService.getAdsByRegionId(q.getRegionId(),q.getPaths()); + MallAdPosition homePopupAd = getHomePopupAd(q.getRegionId()); if (cacheResult != null) { cacheResult.put("mallAds",cathList); + cacheResult.put("homePopupAd", homePopupAd); }else{ cacheResult = new HashMap<>(); cacheResult.put("mallAds",cathList); + cacheResult.put("homePopupAd", homePopupAd); if (q.getDeliveryType() == 4 && StrUtil.isNotBlank(q.getWorkerId())) { //鍏堟煡褰撳墠鐢ㄦ埛鎸囨淳鍗曟湭纭鎺ュ崟鏁伴噺 涓嶇敤鍒嗛〉 q.setHallOnly(false); @@ -163,6 +164,11 @@ public class MallDeliveryOrderController { return new ResultUtil().setData(cacheResult); } + private MallAdPosition getHomePopupAd(String regionId) { + List popupAds = mallAdPositionService.getAdsByRegionId(regionId, Collections.singletonList(HOME_POPUP_POSITION)); + return popupAds == null || popupAds.isEmpty() ? null : popupAds.get(0); + } + @PostMapping("/admin/page") @ApiOperation(value = "鍚庡彴绠$悊绔垎椤垫煡璇㈡姠鍗曞ぇ鍘呴厤閫佸崟", notes = "鐩存帴鏌ユ暟鎹簱锛屼笉璧扮敤鎴风缂撳瓨") public Result adminPage(@RequestBody MallDeliveryOrderPageQuery q) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java index 0ccfa304..2d68b2b3 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java @@ -181,6 +181,34 @@ public class ShopAreaController { return ResultUtil.success("缂栬緫鎴愬姛"); } + @RequestMapping(value = "/deliverySwitch/get", method = RequestMethod.GET) + @ApiOperation(value = "鏍规嵁鏍″尯ID鏌ヨ閰嶉佸紑鍏") + public Result getDeliverySwitch(@RequestParam String regionId) { + ShopArea shopArea = shopAreaService.get(regionId); + if (shopArea == null) { + return ResultUtil.error("鏍″尯涓嶅瓨鍦"); + } + Integer deliveryEnabled = shopArea.getDeliveryEnabled() == null ? 1 : shopArea.getDeliveryEnabled(); + return new ResultUtil().setData(deliveryEnabled); + } + + @RequestMapping(value = "/deliverySwitch/update", method = RequestMethod.POST) + @ApiOperation(value = "鏍规嵁鏍″尯ID鏇存柊閰嶉佸紑鍏") + public Result updateDeliverySwitch(@RequestParam String regionId, @RequestParam Integer deliveryEnabled) { + if (deliveryEnabled == null || (deliveryEnabled != 0 && deliveryEnabled != 1)) { + return ResultUtil.error("閰嶉佸紑鍏冲弬鏁伴敊璇"); + } + ShopArea shopArea = shopAreaService.get(regionId); + if (shopArea == null) { + return ResultUtil.error("鏍″尯涓嶅瓨鍦"); + } + shopArea.setDeliveryEnabled(deliveryEnabled); + ShopArea updated = shopAreaService.update(shopArea); + shopAreaService.refreshShopAreaCache(updated.getParentId(), updated.getId()); + redisTemplate.deleteByPattern("ShopArea:*"); + return ResultUtil.success("淇濆瓨鎴愬姛"); + } + @RequestMapping(value = "/delByIds", method = RequestMethod.POST) @ApiOperation(value = "鎵归噺閫氳繃id鍒犻櫎") public Result delByIds(@RequestParam String[] ids) { diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java index 830bba00..bd69cc40 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/entity/ShopArea.java @@ -51,6 +51,10 @@ public class ShopArea extends HiverBaseEntity { @ApiModelProperty(value = "鏄惁鍚敤 0鍚敤 -1绂佺敤") private Integer status = CommonConstant.STATUS_NORMAL; + @ApiModelProperty(value = "鏄惁寮鍚厤閫侊細1寮鍚紝0鍏抽棴") + @Column(nullable = false, columnDefinition = "int default 1") + private Integer deliveryEnabled = 1; + @Transient @TableField(exist = false) @ApiModelProperty(value = "鐖惰妭鐐瑰悕绉") diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/fishmarket/service/impl/FishMarketServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/fishmarket/service/impl/FishMarketServiceImpl.java index 1e99bdf7..39651e4f 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/fishmarket/service/impl/FishMarketServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/fishmarket/service/impl/FishMarketServiceImpl.java @@ -496,6 +496,11 @@ public class FishMarketServiceImpl implements FishMarketService { goods.setCommentCount(safeInt(goods.getCommentCount()) + 1); goodsMapper.updateById(goods); addCommentUnread(comment, goods, user.getId()); + if (StringUtils.isBlank(comment.getParentId()) + && Integer.valueOf(1).equals(comment.getAuditStatus()) + && !user.getId().equals(goods.getUserId())) { + sendWechatCommentNotifyAfterCommit(comment, goods); + } return comment; } @@ -1606,6 +1611,44 @@ public class FishMarketServiceImpl implements FishMarketService { sendWechatChatNotify(message, session, sender); } + private void sendWechatCommentNotifyAfterCommit(FishComment comment, FishGoods goods) { + if (comment == null || goods == null || StringUtils.isBlank(goods.getUserId())) return; + if (TransactionSynchronizationManager.isSynchronizationActive()) { + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { + @Override + public void afterCommit() { + sendWechatCommentNotify(comment, goods); + } + }); + return; + } + sendWechatCommentNotify(comment, goods); + } + + private void sendWechatCommentNotify(FishComment comment, FishGoods goods) { + try { + User receiver = userService.findById(goods.getUserId()); + if (receiver == null || StringUtils.isBlank(receiver.getOfficialAccountOpenid())) { + return; + } + List data = new ArrayList<>(); + Date createTime = comment.getCreateTime() == null ? new Date() : comment.getCreateTime(); + data.add(new WxMpTemplateData("time5", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime))); + data.add(new WxMpTemplateData("thing10", "鏍″洯浜屾墜鏈夋柊鐨勮瘎璁哄暒")); + data.add(new WxMpTemplateData("character_string6", limitCharacterStringValue(defaultString(comment.getId(), goods.getId())))); + wechatSendMessageUtil.sendWechatTempMessage( + Collections.singletonList(receiver.getOfficialAccountOpenid()), + FISH_CHAT_WECHAT_TEMPLATE_ID, + data, + "pages/index/index" + ); + log.info("鏍″洯浜屾墜璇勮鍏紬鍙烽氱煡宸插彂閫侊紝commentId={}, receiverId={}", comment.getId(), goods.getUserId()); + } catch (Exception e) { + log.warn("鏍″洯浜屾墜璇勮鍏紬鍙烽氱煡鍙戦佸け璐ワ紝commentId={}, receiverId={}, reason={}", + comment == null ? null : comment.getId(), goods == null ? null : goods.getUserId(), e.getMessage()); + } + } + private void sendWechatChatNotify(FishChatMessage message, FishChatSession session, User sender) { try { User receiver = userService.findById(message.getReceiverId()); @@ -1617,7 +1660,7 @@ public class FishMarketServiceImpl implements FishMarketService { List data = new ArrayList<>(); Date createTime = message.getCreateTime() == null ? new Date() : message.getCreateTime(); data.add(new WxMpTemplateData("time5", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime))); - data.add(new WxMpTemplateData("thing10", buildContactTemplateValue("鍗婂緞鍜ㄨ", itemTitle))); + data.add(new WxMpTemplateData("thing10", buildContactTemplateValue("浜屾墜鍜ㄨ", itemTitle))); data.add(new WxMpTemplateData("character_string6", limitCharacterStringValue(itemCode))); wechatSendMessageUtil.sendWechatTempMessage( Collections.singletonList(receiver.getOfficialAccountOpenid()), diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/ie/service/impl/IeChatServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/ie/service/impl/IeChatServiceImpl.java index 868d6cf9..1bbc72ba 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/ie/service/impl/IeChatServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/ie/service/impl/IeChatServiceImpl.java @@ -16,12 +16,14 @@ import cc.hiver.mall.ie.vo.IeAuditResult; import cc.hiver.mall.ie.vo.IeChatEvent; import cc.hiver.mall.ie.vo.IeMessageAckVO; import cc.hiver.mall.service.HomeReminderService; +import cc.hiver.mall.utils.WechatSendMessageUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.messaging.simp.SimpMessagingTemplate; @@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronizationManager; +import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; @@ -88,6 +91,9 @@ public class IeChatServiceImpl implements IeChatService { @Autowired private IeContentAuditLogService contentAuditLogService; + @Autowired + private WechatSendMessageUtil wechatSendMessageUtil; + private static final String STREAK_REWARD_KEY = "ie:streak:reward:"; private static final int STREAK_LOOKBACK_DAYS = 60; private static final int STREAK_REWARD_INTERVAL = 7; @@ -101,6 +107,7 @@ public class IeChatServiceImpl implements IeChatService { private static final long MEDIA_AUDIT_POLL_MILLIS = 10L * 1000; /** 鎻愪氦瀹℃牳澶辫触鍚庣殑寤惰繜閲嶈瘯闂撮殧 */ private static final long MEDIA_AUDIT_SUBMIT_RETRY_MILLIS = 15L * 1000; + private static final String IE_CHAT_WECHAT_TEMPLATE_ID = "X-lezVQyqm9EUsHCi6ja2cAnjdif5uyA21nhmg0RsuU"; @Override public IeRoom getRoom(Long roomId) { @@ -194,6 +201,7 @@ public class IeChatServiceImpl implements IeChatService { if (message.getIsBlocked() == 0 && !needMediaAudit) { deliverMessage(message, ack); homeReminderService.incrementIeUnread(receiverId); + sendIeChatNotifyAfterCommit(message); } else if (message.getIsBlocked() == 0) { afterCommitOrNow(() -> { chatEventProducer.sendMediaAudit(message.getId()); @@ -302,6 +310,47 @@ public class IeChatServiceImpl implements IeChatService { publishEvent(IeChatEventType.MESSAGE_DELIVERED, message.getRoomId(), message.getId(), message.getSenderId(), message.getReceiverId(), message.getRiskLevel(), JSONUtil.toJsonStr(ack)); } + private void sendIeChatNotifyAfterCommit(IeRoomMessage message) { + if (message == null || message.getReceiverId() == null + || !Integer.valueOf(IeConstants.AUDIT_PASS).equals(message.getAuditStatus()) + || !Integer.valueOf(0).equals(message.getIsBlocked())) { + return; + } + afterCommitOrNow(() -> sendIeChatNotify(message)); + } + + private void sendIeChatNotify(IeRoomMessage message) { + try { + User receiver = userDao.findById(String.valueOf(message.getReceiverId())).orElse(null); + if (receiver == null || CharSequenceUtil.isBlank(receiver.getOfficialAccountOpenid())) { + return; + } + List data = new ArrayList<>(); + Date createTime = message.getCreateTime() == null ? new Date() : message.getCreateTime(); + data.add(new WxMpTemplateData("time5", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime))); + data.add(new WxMpTemplateData("thing10", "ie鏈夋柊鐨勬紓娴佹秷鎭暒")); + data.add(new WxMpTemplateData("character_string6", limitCharacterStringValue(String.valueOf(message.getId())))); + wechatSendMessageUtil.sendWechatTempMessage( + Collections.singletonList(receiver.getOfficialAccountOpenid()), + IE_CHAT_WECHAT_TEMPLATE_ID, + data, + "pages/index/index" + ); + log.info("i/e鑱婂ぉ鍏紬鍙烽氱煡宸插彂閫侊紝messageId={}, receiverId={}", message.getId(), message.getReceiverId()); + } catch (Exception e) { + log.warn("i/e鑱婂ぉ鍏紬鍙烽氱煡鍙戦佸け璐ワ紝messageId={}, receiverId={}, reason={}", + message == null ? null : message.getId(), message == null ? null : message.getReceiverId(), e.getMessage()); + } + } + + private String limitCharacterStringValue(String value) { + String text = value == null ? "" : value.replaceAll("[^A-Za-z0-9_-]", ""); + if (CharSequenceUtil.isBlank(text)) { + return "ie"; + } + return text.length() > 32 ? text.substring(0, 32) : text; + } + private Boolean roomHasPeerReply(Long roomId) { IeRoom room = getRoom(roomId); return room != null && Boolean.TRUE.equals(room.getHasPeerReply()); @@ -710,6 +759,7 @@ public class IeChatServiceImpl implements IeChatService { IeMessageAckVO ack = buildAck(message, null, roomHasPeerReply(message.getRoomId())); deliverMessage(message, ack); homeReminderService.incrementIeUnread(message.getReceiverId()); + sendIeChatNotifyAfterCommit(message); messagingTemplate.convertAndSendToUser(String.valueOf(message.getSenderId()), "/queue/ie/ack", ack); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopTakeawayServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopTakeawayServiceImpl.java index f58b1c13..751e5d7c 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopTakeawayServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/ShopTakeawayServiceImpl.java @@ -20,6 +20,7 @@ import cc.hiver.mall.entity.Shop; import cc.hiver.mall.entity.ShopTakeaway; import cc.hiver.mall.service.ShopService; import cc.hiver.mall.service.ShopTakeawayService; +import cn.hutool.core.text.CharSequenceUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -71,22 +72,39 @@ public class ShopTakeawayServiceImpl extends ServiceImpl getAdsByRegionId(String regionId,List paths) { - if (StringUtils.isBlank(regionId)) { + if (StringUtils.isBlank(regionId) || paths == null || paths.isEmpty()) { return Collections.emptyList(); } diff --git a/hiver-modules/hiver-mall/src/main/resources/db/shop_area_delivery_enabled.sql b/hiver-modules/hiver-mall/src/main/resources/db/shop_area_delivery_enabled.sql new file mode 100644 index 00000000..163724b1 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/resources/db/shop_area_delivery_enabled.sql @@ -0,0 +1,2 @@ +ALTER TABLE `t_shop_area` + ADD COLUMN `delivery_enabled` int(11) NOT NULL DEFAULT 1 COMMENT '鏄惁寮鍚厤閫侊細1寮鍚紝0鍏抽棴'; diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/ShopAreaMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopAreaMapper.xml index 5392e657..d9d5d8d8 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/ShopAreaMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/ShopAreaMapper.xml @@ -14,10 +14,11 @@ + id, create_by, create_time, del_flag, update_by, update_time, is_parent, parent_id, - sort_order, status, title, isCanteen + sort_order, status, title, is_canteen, delivery_enabled