From c422763f048e1658a38adfa16c8c51f27f4e59f5 Mon Sep 17 00:00:00 2001 From: liwei <1598061435@qq.com> Date: Wed, 12 Feb 2025 10:48:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/MemLeaveMessage.java | 7 ++++ .../impl/MemLeaveMessageServiceImpl.java | 41 +++++++++++++++---- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/rcisoft/business/memLeaveMessage/entity/MemLeaveMessage.java b/src/main/java/org/rcisoft/business/memLeaveMessage/entity/MemLeaveMessage.java index ef6427b..f2457f9 100644 --- a/src/main/java/org/rcisoft/business/memLeaveMessage/entity/MemLeaveMessage.java +++ b/src/main/java/org/rcisoft/business/memLeaveMessage/entity/MemLeaveMessage.java @@ -88,5 +88,12 @@ public class MemLeaveMessage extends CyIdIncreNotDataEntity<MemLeaveMessage> { */ @TableField(exist = false) private String isPay; + + /** + * 会员wxOpenid + */ + @TableField(exist = false) + private String wxOpenid; + } diff --git a/src/main/java/org/rcisoft/business/memLeaveMessage/service/impl/MemLeaveMessageServiceImpl.java b/src/main/java/org/rcisoft/business/memLeaveMessage/service/impl/MemLeaveMessageServiceImpl.java index f941e77..67a5c32 100644 --- a/src/main/java/org/rcisoft/business/memLeaveMessage/service/impl/MemLeaveMessageServiceImpl.java +++ b/src/main/java/org/rcisoft/business/memLeaveMessage/service/impl/MemLeaveMessageServiceImpl.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import lombok.extern.slf4j.Slf4j; import org.rcisoft.business.memInfo.bean.MemberInfoRedisBean; +import org.rcisoft.business.memInfo.dao.MemInfoRepository; +import org.rcisoft.business.memInfo.entity.MemInfo; import org.rcisoft.business.memLeaveMessage.bean.MemLeaveMessageRedisBean; import org.rcisoft.business.memLeaveMessage.dao.MemLeaveMessageRepository; import org.rcisoft.business.memLeaveMessage.entity.*; @@ -51,6 +53,8 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos @Autowired private CyRedisServiceImpl cyRedisServiceImpl; + @Autowired + private MemInfoRepository memInfoRepository; /** * 留言 * @param memLeaveMessage @@ -61,16 +65,30 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos public CyPersistModel leaveMessage(MemLeaveMessage memLeaveMessage) { String userId = CyUserUtil.getAuthenBusinessId(); //获å–留言æ¯å¤©é™åˆ¶æ¡æ•° - List<DictData> articleConfig = dictionaryService.selectByTypes("leave_message_config"); - DictData dictData = articleConfig.stream().filter(item -> item.getDictLabel().equals("leave_message_limit_count")).findFirst().orElse(null); - Integer leaveMessageLimitCount = Integer.valueOf(dictData.getDictValue()); - //判æ–留言次数是å¦å¤§äºŽç‰äºŽleaveMessageLimitCount + List<DictData> leaveMessageConfig = dictionaryService.selectByTypes("leave_message_config"); + DictData dictData1 = leaveMessageConfig.stream().filter(item -> item.getDictLabel().equals("leave_message_limit_count")).findFirst().orElse(null); + DictData dictData2 = leaveMessageConfig.stream().filter(item -> item.getDictLabel().equals("pay_leave_message_limit_count")).findFirst().orElse(null); + Integer leaveMessageLimitCount = Integer.valueOf(dictData1.getDictValue()); + Integer payLeaveMessageLimitCount = Integer.valueOf(dictData2.getDictValue()); + //判æ–redisä¸çš„留言次数是å¦å¤§äºŽç‰äºŽleaveMessageLimitCount Object redisLeaveMessageCount = cyRedisServiceImpl.hget(MemLeaveMessageRedisBean.USER_LEAVE_MESSAGE + userId, String.valueOf(memLeaveMessage.getTargetId())); - if (redisLeaveMessageCount != null && Integer.parseInt(redisLeaveMessageCount.toString()) >= leaveMessageLimitCount){ + //超出留言次数的æ¡ä»¶ï¼š + //1:redisä¸çš„å˜å‚¨æ•°é‡>=å—å…¸é™åˆ¶æ•°é‡ + //2:用户ä¸ç”¨é‡‘å¸è¿›è¡Œç•™è¨€ + //3:超出金å¸è¿›è¡Œç•™è¨€çš„é™åˆ¶æ•°é‡ + if (redisLeaveMessageCount != null && Integer.parseInt(redisLeaveMessageCount.toString()) >= leaveMessageLimitCount && memLeaveMessage.getIsPay().equals("0")){ //超出留言次数 - throw new CyServiceException("留言次数超出é™åˆ¶"); + if (Integer.parseInt(redisLeaveMessageCount.toString()) >= payLeaveMessageLimitCount){ + //超出金å¸è¿›è¡Œç•™è¨€çš„æ•°é‡é™åˆ¶ + throw new CyServiceException(1002,"今日留言次数超出é™åˆ¶"); + } else { + throw new CyServiceException(1001,"留言次数超出é™åˆ¶"); + } } else { - //未超出留言次数 + if (Integer.parseInt(redisLeaveMessageCount.toString()) >= payLeaveMessageLimitCount){ + //超出金å¸è¿›è¡Œç•™è¨€çš„æ•°é‡é™åˆ¶ + throw new CyServiceException(1002,"今日留言次数超出é™åˆ¶"); + } //å…ˆæ’入到留言表 memLeaveMessage.setCreateBy(Integer.valueOf(userId)); memLeaveMessage.setUpdateBy(Integer.valueOf(userId)); @@ -113,6 +131,15 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos cyRedisServiceImpl.hset(MemLeaveMessageRedisBean.USER_LEAVE_MESSAGE + userId, String.valueOf(memLeaveMessage.getTargetId()), 1L); } } + //金叿”¯ä»˜è¿›è¡Œç•™è¨€ + if (memLeaveMessage.getIsPay().equals("1")){ + //æ‰£é™¤è¯¥ç”¨æˆ·çš„é‡‘å¸æ•°é‡ + DictData dictData3 = leaveMessageConfig.stream().filter(item -> item.getDictLabel().equals("pay_count")).findFirst().orElse(null); + Integer payCount = Integer.valueOf(dictData3.getDictValue()); + MemInfo memInfo = memInfoRepository.selectByOpenId(memLeaveMessage.getWxOpenid()); + memInfo.setGoldCoinsCount(memInfo.getGoldCoinsCount() - payCount); + memInfoRepository.updateById(memInfo); + } return new CyPersistModel(line); } } -- 2.22.0