From 6b6243ffa7ec658ad87fe3d1466d17b2d9e46c8f Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 28 Mar 2022 17:09:15 +0800 Subject: [PATCH] //add order --- .../java/com/iformall/mq/MqBaseConsumer.java | 11 ++-- .../schedule/CouponExpiringSchedule.java | 54 +++++++++++++++-- .../domain/po/msg/FmInsideProductPushMsg.java | 3 +- .../java/com/iformall/enums/EnumPushType.java | 38 ++++++++++++ .../mapper/WxCouponChannelMapper.java | 17 +++++- .../service/WxCouponChannelService.java | 2 + .../com/iformall/service/WxCouponService.java | 5 +- .../impl/WxCouponChannelServiceImpl.java | 60 ++++++++++++++++--- .../service/impl/WxCouponSendServiceImpl.java | 5 +- .../service/impl/WxCouponServiceImpl.java | 50 ++++++++++++++-- .../service/impl/WxOrderServiceImpl.java | 4 +- .../FmInsideProductPushMsgServiceImpl.java | 37 ++++++++++++ .../mapper/WxCouponChannelMapper.xml | 30 +++++++++- 13 files changed, 283 insertions(+), 33 deletions(-) create mode 100644 mallinkService/src/main/java/com/iformall/enums/EnumPushType.java create mode 100644 mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java diff --git a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java index 6e21e4f46..d89f7a805 100644 --- a/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java +++ b/mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java @@ -52,6 +52,9 @@ public class MqBaseConsumer { @Autowired private FmInsideCashOutMsgServiceImpl fmInsideCashOutMsgService; + + @Autowired + private FmInsideProductPushMsgServiceImpl fmInsideProductPushMsgServiceImpl; @@ -131,10 +134,10 @@ public class MqBaseConsumer { //baseMsg.setMsgStatus(EnumMsgRecordStatus.CONSUME_SUCC.getCode()); //wxMsgRecordMapper.updateByBaseMsg(baseMsg); - else if(EnumMsgRecordType.CASH_OUT.getCode().equals(baseMsg.getMsgType())) { - // 内部消息 - 商户提现通知 - FmInsideCashOutMsg msg = (FmInsideCashOutMsg)JsonUtil.readValue(message,FmInsideCashOutMsg.class); - fmInsideCashOutMsgService.send(msg); + else if(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode().equals(baseMsg.getMsgType())) { + // 内部消息 - 同步POI + FmInsideProductPushMsg msg = (FmInsideProductPushMsg)JsonUtil.readValue(message,FmInsideProductPushMsg.class); + fmInsideProductPushMsgServiceImpl.send(msg); } }catch (Throwable e){ diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java index 4b6e6778c..10c4bd5eb 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java @@ -12,6 +12,7 @@ import com.iformall.enums.EnumCouponChannelStatus; import com.iformall.enums.EnumCouponChannelType; import com.iformall.enums.EnumGameStatus; import com.iformall.mapper.*; +import com.iformall.service.WxCouponChannelService; import com.iformall.utils.Constant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,12 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.List; -import java.util.Objects; -import java.util.concurrent.TimeUnit; @Component public class CouponExpiringSchedule { @@ -37,6 +35,9 @@ public class CouponExpiringSchedule { @Autowired private WxCouponChannelMapper wxCouponChannelMapper; + @Autowired + private WxCouponChannelService wxCouponChannelService; + @Autowired private WxCouponSendMapper wxCouponSendMapper; @@ -64,9 +65,21 @@ public class CouponExpiringSchedule { try { wxCouponMapper.offExpiriedCouponByValidDate(mall.getTenantId()); wxCouponMapper.offExpiriedCouponByMerchantStatus(mall.getTenantId(),wxCouponMapper.getValidMerchantProductIds(mall.getTenantId())); - + wxCouponSendMapper.offExpiriedCouponSendByCouponStatus(mall.getTenantId()); + + List ids = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId()); wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId()); + //同步poi + if(ids != null && ids.size() > 0){ + for (Long id: ids) { + try{ + wxCouponChannelService.spuStatusSync(mall,id); + }catch(Exception e){ + logger.error("send spuStatusSync error: " + e.getMessage()); + } + } + } }catch(Exception e) { logger.error("couponExpiringSchedule error.mall:"+mall.getTenantId(),e); } @@ -94,9 +107,40 @@ public class CouponExpiringSchedule { List malls = getMalls(); for (WxMall mall : malls) { try { + List ids = new ArrayList<>(); + + List id1s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByEndTime(mall.getTenantId()); + if(id1s != null && id1s.size() > 0){ + ids.removeAll(id1s); + ids.addAll(id1s); + } wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(mall.getTenantId()); + + List id2s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByValidDate(mall.getTenantId()); + if(id2s != null && id2s.size() > 0){ + ids.removeAll(id2s); + ids.addAll(id2s); + } wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(mall.getTenantId()); + + List id3s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId()); + if(id3s != null && id3s.size() > 0){ + ids.removeAll(id3s); + ids.addAll(id3s); + } wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId()); + + //同步poi + if(ids != null && ids.size() > 0){ + for (Long id: ids) { + try{ + wxCouponChannelService.spuStatusSync(mall,id); + }catch(Exception e){ + logger.error("send spuStatusSync error: " + e.getMessage()); + } + } + } + }catch(Exception e) { logger.error("couponChannelExpiringSchedule error.mall:"+mall.getTenantId(),e); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java index 959fa04df..36941991c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java @@ -1,5 +1,6 @@ package com.iformall.domain.po.msg; +import com.iformall.enums.EnumPushType; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -13,6 +14,6 @@ public class FmInsideProductPushMsg extends BaseMsg{ private Long couponChannelId; @io.swagger.annotations.ApiModelProperty(value = "同步类型", name = "syncType") - private Integer syncType; + private EnumPushType syncType; } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumPushType.java b/mallinkService/src/main/java/com/iformall/enums/EnumPushType.java new file mode 100644 index 000000000..9989176bf --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumPushType.java @@ -0,0 +1,38 @@ +package com.iformall.enums; + +/** + * Created by Stormeye on 2018/08/09. + */ +public enum EnumPushType { + + // 1-B端, 2-C端, 3-服务号, 4-订阅号 + + SPU_STATUS_SYNC(1, "同步状态"), + SPU_STOCK_SYNC(2, "同步库存"), + ; + + public static EnumPushType getEnum(Integer code) { + for (EnumPushType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumPushType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index c4572e110..edfe49916 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -2,10 +2,7 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; -import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.WxTopic; -import com.iformall.domain.vo.WxCouponCVo; -import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.domain.po.WxCouponChannel; import org.apache.ibatis.annotations.Param; @@ -27,10 +24,13 @@ public interface WxCouponChannelMapper extends CommonMapper getExpiriedCouponChannelIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByEndTime(@Param("tenantId")String tenantId); + List getExpiriedCouponChannelIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByValidDate(@Param("tenantId")String tenantId); + List getExpiriedCouponChannelIdsByCouponStatus(@Param("tenantId")String tenantId);//同步poi状态 void offExpiriedCouponChannelByCouponStatus(@Param("tenantId")String tenantId); void offExpiriedCouponChannel2ByEndTime(@Param("tenantId")String tenantId); @@ -47,4 +47,15 @@ public interface WxCouponChannelMapper extends CommonMapper newfindCList(WxCouponChannel wxCouponChannel); + + /** + * 查询已同步的上架卷的Id + * @param tenantId + * @param id + * @return + */ + List getPoiProductIdList(@Param("tenantId")String tenantId, @Param("couponId")Long couponId); + + + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index 6b17651cf..ae70ded22 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -43,6 +43,8 @@ public interface WxCouponChannelService { */ ResultData saveOrUpdate(WxCouponChannel record); + void spuStatusSync(TenantEntity tenantEntity,Long id); + /** * 创建二维码 */ diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index 5968764e4..ce9f5cb7f 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -8,7 +8,6 @@ import javax.servlet.http.HttpServletResponse; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.po.WxCoupon; -import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponStatisVo; @@ -234,7 +233,7 @@ public interface WxCouponService { * @param number 减少数量 * @param remainInventory 当前库存 */ - void reduceRemainInventory(Long id,String tenantId, Integer number); + void reduceRemainInventory(TenantEntity tenantEntity,Long id, Integer number); /** * 库存退回 @@ -243,7 +242,7 @@ public interface WxCouponService { * @param number 回退数量 * @param remainInventory 当前库存 */ - void backRemainInventory(Long id,String tenantId, Integer number, Integer remainInventory); + void backRemainInventory(TenantEntity tenantEntity,Long id, Integer number, Integer remainInventory); /** * 卡延期 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 434bf04e3..3f8c7ea12 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -6,37 +6,32 @@ import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; import com.iformall.common.Result; import com.iformall.common.ResultData; -import com.iformall.domain.po.WxMerchant; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxMall; +import com.iformall.domain.po.msg.FmInsideProductPushMsg; import com.iformall.domain.vo.WxCouponCVo; import com.iformall.domain.vo.WxCouponChannelAddVo; import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.domain.vo.WxMerchantVo; import com.iformall.enums.*; import com.iformall.mapper.*; +import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.Constant; -import com.iformall.utils.JsonUtil; -import com.iformall.utils.RedisCacheUtils; -import com.iformall.utils.RedisUtils; import org.apache.commons.beanutils.BeanUtils; -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.context.annotation.Lazy; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; import java.lang.reflect.InvocationTargetException; import java.util.*; -import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @Service @@ -87,6 +82,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { @Lazy @Autowired WxMerchantService wxMerchantService; + + @Autowired + private MqBaseProducer mqBaseProducer; /** * B端业务端 @@ -157,6 +155,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } record.setUpdateDate(new Date()); wxCouponChannelMapper.updateById(record); + + if(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode().equals(record.getStatus())){ + try{ + spuStatusSync(record,record.getId()); + }catch(Exception e){ + logger.error("send spuStatusSync error: " + e.getMessage()); + } + } + } //清除缓存 @@ -164,6 +171,19 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return new ResultData(); } + @Override + public void spuStatusSync(TenantEntity tenantEntity, Long id) { + FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); + productPush.setDelayTimeLevel(3); + productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); + productPush.updateTenantInfo(tenantEntity); + productPush.setCouponChannelId(id); + productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC); + logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); + mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); + } + + @Override public void updateQrCode(TenantEntity tenantEntity, Long couponChannelId, Integer couponType) { WxCouponChannel couponChannel = new WxCouponChannel(); @@ -267,6 +287,32 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setCouponId(couponId); wxCouponChannel.setUpdateDate(new Date()); wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel); + + if(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode().equals(status)){ + try{ + spuStatusSyncByCoupon(tenantEntity,couponId); + }catch(Exception e){ + logger.error("send spuStockSync error: " + e.getMessage()); + } + } + } + + private void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId){ + + List couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),couponId); + if(couponChannelIds != null && couponChannelIds.size() > 0){ + for (Long couponChannelId:couponChannelIds) { + FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); + productPush.setDelayTimeLevel(3); + productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); + productPush.updateTenantInfo(tenantEntity); + productPush.setCouponChannelId(couponChannelId); + productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC); + logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); + mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); + } + } + } @Override 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 642562e7d..e00a99d75 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -37,7 +37,6 @@ import org.springframework.transaction.annotation.Transactional; import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.*; -import java.util.stream.Collectors; @Service public class WxCouponSendServiceImpl implements WxCouponSendService { @@ -340,7 +339,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { } //更新库存 - wxCouponService.reduceRemainInventory(wxCouponOfDb.getId(),wxCouponOfDb.getTenantId(), merchantLnventory); + wxCouponService.reduceRemainInventory(wxCouponOfDb,wxCouponOfDb.getId(), merchantLnventory); } @Override @@ -370,7 +369,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { } //退回coupon库存 if(merchantRemain != 0) { - wxCouponService.backRemainInventory(queryById.getId(),wxCouponOfDb.getTenantId(), merchantRemain, wxCouponOfDb.getRemainInventory()); + wxCouponService.backRemainInventory(wxCouponOfDb,queryById.getId(), merchantRemain, wxCouponOfDb.getRemainInventory()); } } wxCouponSendMapper.updateById(record); 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 e6b0c31d9..61855951c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -14,6 +14,7 @@ import com.iformall.domain.dto.WxCouponMerchantDto; import com.iformall.domain.po.*; import com.iformall.domain.po.base.BaseEntity; import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.po.msg.FmInsideProductPushMsg; import com.iformall.domain.vo.*; import com.iformall.domain.vo.excel.WxCardData; import com.iformall.domain.vo.excel.WxCouponData; @@ -21,6 +22,7 @@ import com.iformall.domain.vo.excel.WxPressData; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; +import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.service.excel.WxCardDataExporter; import com.iformall.service.excel.WxCouponDataExporter; @@ -119,6 +121,9 @@ public class WxCouponServiceImpl implements WxCouponService { @Autowired WxProfitSharingReceiverMapper wxProfitSharingReceiverMapper; + @Autowired + private MqBaseProducer mqBaseProducer; + @Override public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { if (null == wxCoupon) wxCoupon = new WxCoupon(); @@ -927,20 +932,57 @@ public class WxCouponServiceImpl implements WxCouponService { @Override @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) - public void reduceRemainInventory(Long id,String tenantId, Integer number) { - int num = wxCouponMapper.reduceInventory(id,tenantId, number); + public void reduceRemainInventory(TenantEntity tenantEntity,Long id, Integer number) { + int num = wxCouponMapper.reduceInventory(id,tenantEntity.getTenantId(), number); if (num == 0) { throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); } + try{ + spuStockSync(tenantEntity,id); + }catch(Exception e){ + logger.error("send spuStockSync error: " + e.getMessage()); + } } @Override @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) - public void backRemainInventory(Long id,String tenantId, Integer number, Integer remainInventory) { - int num = wxCouponMapper.backInventory(id,tenantId, number, remainInventory); + public void backRemainInventory(TenantEntity tenantEntity,Long id, Integer number, Integer remainInventory) { + int num = wxCouponMapper.backInventory(id,tenantEntity.getTenantId(), number, remainInventory); if (num == 0) { throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL); } + try{ + spuStockSync(tenantEntity,id); + }catch(Exception e){ + logger.error("send spuStockSync error: " + e.getMessage()); + } + } + + private void spuStockSync(TenantEntity tenantEntity,Long id){ + new Thread(() -> { + //1秒之后同步poi + try { + Thread.currentThread().sleep(1000); + } catch (Exception e) { + logger.error("sleep error: " + e.getMessage()); + } + + List couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),id); + if(couponChannelIds != null && couponChannelIds.size() > 0){ + for (Long couponChannelId:couponChannelIds) { + FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); + productPush.setDelayTimeLevel(3); + productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); + productPush.updateTenantInfo(tenantEntity); + productPush.setCouponChannelId(couponChannelId); + productPush.setSyncType(EnumPushType.SPU_STOCK_SYNC); + logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); + mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); + } + } + + }).start(); + } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 05aa336fe..818210197 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -935,7 +935,7 @@ public class WxOrderServiceImpl implements WxOrderService { try { //减库存, - wxCouponService.reduceRemainInventory(coupon.getId(),coupon.getTenantId(), number); + wxCouponService.reduceRemainInventory(coupon,coupon.getId(),number); long stock = redisLock.decrease(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), number); if (stock < 0 ) { @@ -1072,7 +1072,7 @@ public class WxOrderServiceImpl implements WxOrderService { } try { - wxCouponService.backRemainInventory(coupon.getId(),coupon.getTenantId(), updateOrder.getCouponNumber(), coupon.getRemainInventory()); + wxCouponService.backRemainInventory(coupon,coupon.getId(), updateOrder.getCouponNumber(), coupon.getRemainInventory()); redisLock.increase(EnumCacheKey.COUPON_STOCK.getMessage()+coupon.getId(), updateOrder.getCouponNumber()); } catch (Exception e) { logger.error("数据库更新失败,库存+1失败, e:" + e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java new file mode 100644 index 000000000..ceecd8398 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java @@ -0,0 +1,37 @@ +package com.iformall.service.msg.impl; + +import com.iformall.domain.po.msg.BaseMsg; +import com.iformall.domain.po.msg.FmInsideProductPushMsg; +import com.iformall.enums.EnumPushType; +import com.iformall.service.TtMerchantPoiService; +import com.iformall.service.msg.MsgSendService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * + * @author Stormeye Wu + * @date 2019/5/10 + */ +@Service +public class FmInsideProductPushMsgServiceImpl implements MsgSendService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private TtMerchantPoiService poiService; + + @Override + public void send(BaseMsg baseMsg) throws Exception{ + FmInsideProductPushMsg msg = (FmInsideProductPushMsg)baseMsg; + + if(EnumPushType.SPU_STATUS_SYNC.equals(msg.getSyncType())){ + poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponChannelId()); + }else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){ + poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponChannelId()); + } + + } +} diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 168c936d5..eb85c4db3 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -188,16 +188,36 @@ - + + + update wx_coupon_channel SET status = 1, update_date = now() where status = 0 and tenant_id = #{tenantId} and end_time < now() + + update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() + + update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now() where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.status = 1 @@ -307,4 +327,12 @@ order by ${sortColumns} + + + +