From ea0ba0c03cf082be286f2dc551ae7aeffbb6e38e Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Fri, 9 Jun 2023 16:10:25 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=B1=87=E4=BB=98=E4=BC=9A=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/CacheConstants.java | 4 ++- .../pile/service/AdapayMemberInfoService.java | 2 ++ .../service/IPileMerchantInfoService.java | 2 ++ .../impl/AdapayMemberInfoServiceImpl.java | 30 ++++++++++++++++++- .../impl/PileStationInfoServiceImpl.java | 2 +- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java index 251bf3c89..4dfeb5114 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java +++ b/jsowell-common/src/main/java/com/jsowell/common/constant/CacheConstants.java @@ -23,7 +23,9 @@ public class CacheConstants { public static final int cache_expire_time_1d = 60 * 60 * 24; - public static final String PILE_PROGRAM_VERSION = "pile_program_version"; + public static final String ADAPAY_MEMBER_INFO = "adapay_member_info:"; + + public static final String PILE_PROGRAM_VERSION = "pile_program_version_"; public static final String QUERY_ORDER_CALLBACK = "query_order_callback:"; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/AdapayMemberInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/AdapayMemberInfoService.java index ba9ddae51..8eeac5c36 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/AdapayMemberInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/AdapayMemberInfoService.java @@ -16,4 +16,6 @@ public interface AdapayMemberInfoService { int updateByPrimaryKey(AdapayMemberInfo record); AdapayMemberInfo selectByMerchantId(String merchantId); + + AdapayMemberInfo selectByStationId(String stationId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java index d7c80aa95..f1ee27a32 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java @@ -70,4 +70,6 @@ public interface IPileMerchantInfoService { * @return */ List queryByMerchantDeptIds(List merchantDeptIds); + + } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/AdapayMemberInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/AdapayMemberInfoServiceImpl.java index 761d9f619..de703bcd1 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/AdapayMemberInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/AdapayMemberInfoServiceImpl.java @@ -1,8 +1,13 @@ package com.jsowell.pile.service.impl; +import com.jsowell.common.constant.CacheConstants; +import com.jsowell.common.core.redis.RedisCache; import com.jsowell.pile.domain.AdapayMemberInfo; +import com.jsowell.pile.domain.PileStationInfo; import com.jsowell.pile.mapper.AdapayMemberInfoMapper; import com.jsowell.pile.service.AdapayMemberInfoService; +import com.jsowell.pile.service.IPileStationInfoService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -12,6 +17,12 @@ public class AdapayMemberInfoServiceImpl implements AdapayMemberInfoService { @Resource private AdapayMemberInfoMapper adapayMemberInfoMapper; + @Autowired + private RedisCache redisCache; + + @Autowired + private IPileStationInfoService pileStationInfoService; + @Override public int deleteByPrimaryKey(Integer id) { return adapayMemberInfoMapper.deleteByPrimaryKey(id); @@ -44,7 +55,24 @@ public class AdapayMemberInfoServiceImpl implements AdapayMemberInfoService { @Override public AdapayMemberInfo selectByMerchantId(String merchantId) { - return adapayMemberInfoMapper.selectByMerchantId(merchantId); + String redisKey = CacheConstants.ADAPAY_MEMBER_INFO + merchantId; + AdapayMemberInfo adapayMemberInfo = redisCache.getCacheObject(redisKey); + if (adapayMemberInfo == null) { + adapayMemberInfo = adapayMemberInfoMapper.selectByMerchantId(merchantId); + if (adapayMemberInfo != null) { + redisCache.setCacheObject(redisKey, adapayMemberInfo, CacheConstants.cache_expire_time_1d); + } + } + return adapayMemberInfo; + } + + @Override + public AdapayMemberInfo selectByStationId(String stationId) { + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(Long.parseLong(stationId)); + if (pileStationInfo != null) { + return selectByMerchantId(pileStationInfo.getMerchantId() + ""); + } + return null; } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index e7c4d3e9e..d14aadf6e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -87,7 +87,7 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService { if (pileStationInfo == null) { // 查数据库 pileStationInfo = pileStationInfoMapper.selectPileStationInfoById(id); - redisCache.setCacheObject(redisKey, pileStationInfo, 5, TimeUnit.MINUTES); + redisCache.setCacheObject(redisKey, pileStationInfo, 15, TimeUnit.MINUTES); } return pileStationInfo; }