From fff84506d177213fdb7a13637a97f8dbaa8ac862 Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 26 Sep 2019 16:18:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E4=BF=AE=E6=94=B9][=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=BC=93=E5=AD=98][=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/WxMerchantController.java | 2 +- .../service/impl/WxFlowServiceImpl.java | 24 +++++++++++++++++-- .../main/resources/mapper/WxCouponMapper.xml | 6 ++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java index d412b944f..8087f87f7 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/basic/WxMerchantController.java @@ -25,7 +25,7 @@ import javax.servlet.http.HttpServletResponse; import java.util.List; import java.util.Map; -/**w +/** * @author gongbiao */ @RestController diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index 6b1e9be95..e6b2db820 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -13,6 +13,7 @@ import com.iformall.domain.po.msg.WxMsgRecord; import com.iformall.domain.vo.FlowUserVo; import com.iformall.domain.vo.UserTaskVo; import com.iformall.domain.vo.WxBillAll; +import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.enums.*; import com.iformall.mapper.*; import com.iformall.mq.MqBaseProducer; @@ -38,6 +39,8 @@ import org.flowable.task.api.TaskQuery; 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.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -90,6 +93,9 @@ public class WxFlowServiceImpl implements WxFlowService { private WxBillSettleMapper wxBillSettleMapper; @Autowired private WxBillSettleService wxBillSettleService; + @Autowired + @Qualifier("couponChannelRedisTemplate") + RedisTemplate> cdRedisTemplate; /** * 获取流程key @@ -250,8 +256,7 @@ public class WxFlowServiceImpl implements WxFlowService { || EnumFlowKey.NEW_CARD_UPLINE.getCode().equals(flowType) || EnumFlowKey.NEW_GROUP_UPLINE.getCode().equals(flowType) || EnumFlowKey.NEW_PRESS_UPLINE.getCode().equals(flowType)) { - WxCoupon wxCoupon = new WxCoupon(); - wxCoupon.setId(businessId); + WxCoupon wxCoupon = wxCouponMapper.selectByPrimaryKey(businessId); wxCoupon.setUpdateDate(new Date()); if(EnumCouponAppType.PUT.getCode().equals(operateType)){ @@ -286,7 +291,11 @@ public class WxFlowServiceImpl implements WxFlowService { wxCoupon.setRemainInventory(remainInventory); wxCoupon.setType(type); wxCoupon.setValidType(validType); + wxCoupon.setTenantId(wxCoupon.getTenantId()); wxCouponService.updateCouponStockAndEndTime(wxCoupon); + + //清除缓存 + clearCache(wxCoupon.getTenantId()); } }else if(EnumCouponAppType.CANCLE.getCode().equals(operateType)){ wxCoupon.setCancleApplyStatus(applyStatus); @@ -324,6 +333,17 @@ public class WxFlowServiceImpl implements WxFlowService { } } + /** + * 清除c端首页卷列表缓存 + * @param tenantId + */ + public void clearCache(String tenantId){ + for (int i = 1; i <=5 ; i++) { + String key = EnumCacheKey.C_INDEX_PAGE_LIST.getMessage()+tenantId+"_" + i + ":"; + cdRedisTemplate.delete(key); + } + } + public Map mallUserInfoToMap(MallUserInfo userInfo){ try { Map map = new HashMap<>(); diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 2a192f5f6..505fa69c4 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -271,7 +271,11 @@ SET `remain_inventory` = #{remainInventory}, `inventory` = #{inventory}, `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays} - WHERE `tenant_id` = #{tenantId} and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} + WHERE 1=1 + + and `tenant_id` = #{tenantId} + + and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} From 8c37c019eed525abc22073e4d073656c0d352d5e Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 26 Sep 2019 16:19:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E4=BF=AE=E6=94=B9][=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=BC=93=E5=AD=98][=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iformall/service/impl/WxFlowServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java index e6b2db820..fe9ee7adf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxFlowServiceImpl.java @@ -293,9 +293,6 @@ public class WxFlowServiceImpl implements WxFlowService { wxCoupon.setValidType(validType); wxCoupon.setTenantId(wxCoupon.getTenantId()); wxCouponService.updateCouponStockAndEndTime(wxCoupon); - - //清除缓存 - clearCache(wxCoupon.getTenantId()); } }else if(EnumCouponAppType.CANCLE.getCode().equals(operateType)){ wxCoupon.setCancleApplyStatus(applyStatus); @@ -307,6 +304,9 @@ public class WxFlowServiceImpl implements WxFlowService { } wxCoupon.setApprovalType(operateType); wxCouponMapper.updateByPrimaryKeySelective(wxCoupon); + + //清除缓存 + clearCache(wxCoupon.getTenantId()); }else if(EnumFlowKey.SETTLE.getCode().equals(flowType)){ WxBillSettle wxBillSettle = new WxBillSettle(); wxBillSettle.setId(businessId);