From e78ca660a1a8d62e5230421f3dcc72b8d041c6fa Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 25 Sep 2019 10:03:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=87=91=E9=A2=9D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/iformall/service/impl/PosServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index 55278c83b..0f29ffa53 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -497,7 +497,7 @@ public class PosServiceImpl implements PosService { retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { - retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getSalePrice()); + retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getUsePrice()); String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), mydateFormat.format(couponOrderCVo.getExpiredTime())); @@ -557,7 +557,7 @@ public class PosServiceImpl implements PosService { retObj.put(WxPayConstant.PRICE, couponOrderCVo.getPrice()); retObj.put(WxPayConstant.SALE_PRICE, couponOrderCVo.getSalePrice()); if (couponType.equals(EnumCouponType.COUPON_MANJIAN)) { - retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getSalePrice()); + retObj.put(WxPayConstant.USE_PRICE, couponOrderCVo.getUsePrice()); String des = String.format("%s-满%s元可用,可抵%s元, 过期时间: %s", couponType.getMessage(), couponOrderCVo.getUsePriceStr(), couponOrderCVo.getPriceStr(), mydateFormat.format(couponOrderCVo.getExpiredTime())); From 13a50c6669242ae6434530f6fdcd391d5a08951e Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 25 Sep 2019 10:27:48 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:=E5=88=B8?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=90=8E=E4=BD=99=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/iformall/service/impl/PosServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index 0f29ffa53..ef686c31c 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -356,6 +356,7 @@ public class PosServiceImpl implements PosService { promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); // 券优惠总信息 promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); + promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); } // 构造支付信息 From 7b264a188c4a2507ed35eb2735e79d8c77dec811 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 25 Sep 2019 10:31:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[POS][=E4=BF=AE=E6=94=B9]:=E5=88=B8?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=90=8E=E4=BD=99=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/iformall/service/impl/PosServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java index ef686c31c..9592b569f 100644 --- a/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java +++ b/mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java @@ -241,6 +241,7 @@ public class PosServiceImpl implements PosService { promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); // 券优惠总信息 promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); + promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); } else if(sceneType.equals(EnumPosSceneType.PAY)) { JSONObject promotionCoupon = new JSONObject(); @@ -841,6 +842,7 @@ public class PosServiceImpl implements PosService { promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); // 券优惠总信息 promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); + promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); } else if(sceneType.equals(EnumPosSceneType.PAY)) { JSONObject promotionCoupon = new JSONObject(); @@ -923,6 +925,7 @@ public class PosServiceImpl implements PosService { promotionCoupon.put(WxPayConstant.COUPON_ORDER_LIST, couponList); // 券优惠总信息 promotionCoupon.put(WxPayConstant.COUPON_PROMOTION_AMOUNT, promotionCalc.getPromotionAmount()); + promotionCoupon.put(WxPayConstant.REMAIN_AMOUNT, promotionCalc.getAmountLeftAfterPay()); promotionInfo.put(WxPayConstant.COUPON, promotionCoupon); } // 构造支付信息 From e8b9093d77724898c09e4bbe2cca5db7b5a8e820 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 25 Sep 2019 14:10:34 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[=E4=BF=AE=E6=94=B9][=E5=8D=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8][=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/config/RedisConfig.java | 19 ++++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 19 ++++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 18 +++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 19 ++++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 18 +++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 18 +++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 19 ++++++++++++++++++ .../service/impl/WxCouponSendServiceImpl.java | 2 -- .../service/impl/WxCouponServiceImpl.java | 3 +++ .../java/com/iformall/config/RedisConfig.java | 19 ++++++++++++++++++ .../java/com/iformall/config/RedisConfig.java | 20 +++++++++++++++++++ 11 files changed, 172 insertions(+), 2 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java b/mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java index 7da08a3d9..90b93d911 100644 --- a/mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkAdmin/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -160,4 +162,21 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java b/mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java index 7e167a93e..29ceeaa55 100644 --- a/mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkBApi/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -122,4 +124,21 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java b/mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java index 39666265b..8af0c3b5c 100644 --- a/mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkCApi/src/main/java/com/iformall/config/RedisConfig.java @@ -1,10 +1,12 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; import com.iformall.domain.vo.WxCouponCVo; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -140,4 +142,20 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } } diff --git a/mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java b/mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java index 7da08a3d9..90b93d911 100644 --- a/mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkCallback/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -160,4 +162,21 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java b/mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java index 8f732eb31..91be4cbfe 100644 --- a/mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkMQConsumer/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -144,4 +146,20 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } } diff --git a/mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java b/mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java index 7e167a93e..59852710d 100644 --- a/mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkPosApi/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -122,4 +124,20 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } } diff --git a/mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java b/mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java index 9195744e4..6e35c905f 100644 --- a/mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkSchedule/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -145,4 +147,21 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java index 765ac0730..66bb348c7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -6,7 +6,6 @@ import com.github.pagehelper.PageInfo; import com.google.common.collect.Lists; import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; -import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.msg.AppUniformMsg; import com.iformall.domain.po.msg.MpAppMsg; @@ -26,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import java.text.SimpleDateFormat; import java.util.*; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index a013bba60..aa750c644 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -427,6 +427,9 @@ public class WxCouponServiceImpl implements WxCouponService { wxCouponMapper.updateByPrimaryKeySelective(record); } + + //清空缓存 + return new ResultData(record.getId()); } diff --git a/mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java b/mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java index 7da08a3d9..90b93d911 100644 --- a/mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkSysAdmin/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -160,4 +162,21 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + } diff --git a/mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java b/mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java index 8f732eb31..20259e822 100644 --- a/mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java +++ b/mallinkWebSocketServer/src/main/java/com/iformall/config/RedisConfig.java @@ -1,9 +1,11 @@ package com.iformall.config; +import com.github.pagehelper.PageInfo; import com.iformall.domain.po.PushLimit; import com.iformall.domain.po.WxCUser; import com.iformall.domain.po.WxMall; import com.iformall.domain.po.WxScoreRules; +import com.iformall.domain.vo.WxCouponChannelVo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.CacheManager; @@ -144,4 +146,22 @@ public class RedisConfig extends CachingConfigurerSupport { return template; } + @Bean("couponChannelRedisTemplate") + public RedisTemplate> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate> template = new RedisTemplate<>(); + + Jackson2JsonRedisSerializer j = new Jackson2JsonRedisSerializer(PageInfo.class); + // value值的序列化 + template.setValueSerializer(j); + template.setHashKeySerializer(j); + + // key的序列化 + template.setKeySerializer(new StringRedisSerializer()); + template.setHashKeySerializer(new StringRedisSerializer()); + + template.setConnectionFactory(connectionFactory); + return template; + } + + } From 1c1f7e07a47b4c4de2808e419d51a1e359171be5 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 25 Sep 2019 14:49:32 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[=E4=BF=AE=E6=94=B9][=E5=8D=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8][=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxCouponChannelServiceImpl.java | 50 +++++++++++++++++-- .../service/impl/WxCouponServiceImpl.java | 21 +++++++- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index 6fd63f643..57ba86e33 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -21,18 +21,22 @@ import com.iformall.service.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Service public class WxCouponChannelServiceImpl implements WxCouponChannelService { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - - @Autowired + + @Autowired WxCouponChannelMapper wxCouponChannelMapper; - @Autowired + @Autowired WxCouponService wxCouponService; @Autowired WxMerchantMapper wxMerchantMapper; @@ -46,6 +50,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { QrCodeService qrCodeService; @Autowired WxCardInfoMapper wxCardInfoMapper; + @Autowired + @Qualifier("couponChannelRedisTemplate") + RedisTemplate> cdRedisTemplate; /** * B端业务端 @@ -69,7 +76,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + record.setId(idWorker.nextId()); wxCouponChannelMapper.insertSelective(record); return new ResultData(record); } else { @@ -111,9 +118,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { record.setUpdateDate(new Date()); wxCouponChannelMapper.updateByPrimaryKeySelective(record); } + + //清除缓存 + clearCache(record.getTenantId()); return new ResultData(); } + /** + * 清除c端首页卷列表缓存 + * @param tenantId + */ + public void clearCache(String tenantId){ + for (int i = 1; i <=20 ; i++) { + String key = "couponChannelList_"+tenantId+"_" + i + ":"; + cdRedisTemplate.delete(key); + } + } + @Override public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { List errorList = new ArrayList<>(); @@ -228,7 +249,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) // 积分商城 - ){ + ){ // 默认投放结束时间为有效时间之后 beginTime = new Date(); endTime = wxCoupon.getValidEndDate(); @@ -284,6 +305,24 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { */ @Override public PageInfo listPageCVo(WxCouponChannel record, Integer pageIndex, Integer pageSize) { + PageInfo pageInfo; + //首页走缓存 + if(EnumTargetAd.LIST.getCode().equals(record.getTargetAd()) && new Integer(6).equals(pageSize) && pageIndex.intValue() <=20 ) { + logger.info("---------chache"); + String key = "couponChannelList_"+record.getTenantId()+"_" + pageIndex + ":"; + ValueOperations> operations = cdRedisTemplate.opsForValue(); + boolean hasKey = cdRedisTemplate.hasKey(key); + if (hasKey) { + pageInfo = operations.get(key); + logger.info("---------get:{}",pageInfo.getList().size()); + }else{ + pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); + } + //插入缓存 + operations.set(key, pageInfo, 3600, TimeUnit.SECONDS); + return pageInfo; + } + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponChannelMapper.findVoList(record)); } @@ -308,3 +347,4 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } } + diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index aa750c644..41027b3d5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -11,6 +11,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.dto.WxCouponMerchantDto; import com.iformall.domain.po.*; import com.iformall.domain.vo.WxCouponCVo; +import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.domain.vo.WxCouponStatisVo; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.*; @@ -22,6 +23,8 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -69,6 +72,10 @@ public class WxCouponServiceImpl implements WxCouponService { @Autowired WxCouponPasswordService couponPasswordService; + @Autowired + @Qualifier("couponChannelRedisTemplate") + RedisTemplate> cdRedisTemplate; + @Override public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { if (null == wxCoupon) wxCoupon = new WxCoupon(); @@ -429,10 +436,22 @@ public class WxCouponServiceImpl implements WxCouponService { } //清空缓存 - + clearCache(record.getTenantId()); return new ResultData(record.getId()); } + + /** + * 清除c端首页卷列表缓存 + * @param tenantId + */ + public void clearCache(String tenantId){ + for (int i = 1; i <=20 ; i++) { + String key = "couponChannelList_"+tenantId+"_" + i + ":"; + cdRedisTemplate.delete(key); + } + } + @Override public void deleteById(Long id) { wxCouponMapper.deleteByPrimaryKey(id);