Browse Source

//add order

release_toaliyun_real
xhxu 4 years ago
parent
commit
6b6243ffa7
13 changed files with 283 additions and 33 deletions
  1. +7
    -4
      mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java
  2. +49
    -5
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java
  3. +2
    -1
      mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java
  4. +38
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumPushType.java
  5. +14
    -3
      mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java
  6. +2
    -0
      mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java
  7. +2
    -3
      mallinkService/src/main/java/com/iformall/service/WxCouponService.java
  8. +53
    -7
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  9. +2
    -3
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java
  10. +46
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  11. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  12. +37
    -0
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java
  13. +29
    -1
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml

+ 7
- 4
mallinkMQConsumer/src/main/java/com/iformall/mq/MqBaseConsumer.java View File

@@ -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){


+ 49
- 5
mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java View File

@@ -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<Long> 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<WxMall> malls = getMalls();
for (WxMall mall : malls) {
try {
List<Long> ids = new ArrayList<>();

List<Long> id1s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByEndTime(mall.getTenantId());
if(id1s != null && id1s.size() > 0){
ids.removeAll(id1s);
ids.addAll(id1s);
}
wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(mall.getTenantId());

List<Long> id2s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByValidDate(mall.getTenantId());
if(id2s != null && id2s.size() > 0){
ids.removeAll(id2s);
ids.addAll(id2s);
}
wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(mall.getTenantId());

List<Long> 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);
}


+ 2
- 1
mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java View File

@@ -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;

}

+ 38
- 0
mallinkService/src/main/java/com/iformall/enums/EnumPushType.java View File

@@ -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;
}
}

+ 14
- 3
mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java View File

@@ -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<WxCouponChannel, Str

int updateEndTimeByCouponId(WxCouponChannel wxCouponChannel);

List<Long> getExpiriedCouponChannelIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态
void offExpiriedCouponChannelByEndTime(@Param("tenantId")String tenantId);

List<Long> getExpiriedCouponChannelIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态
void offExpiriedCouponChannelByValidDate(@Param("tenantId")String tenantId);

List<Long> 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<WxCouponChannel, Str
* @return
*/
List<WxCouponChannel> newfindCList(WxCouponChannel wxCouponChannel);

/**
* 查询已同步的上架卷的Id
* @param tenantId
* @param id
* @return
*/
List<Long> getPoiProductIdList(@Param("tenantId")String tenantId, @Param("couponId")Long couponId);



}

+ 2
- 0
mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java View File

@@ -43,6 +43,8 @@ public interface WxCouponChannelService {
*/
ResultData saveOrUpdate(WxCouponChannel record);

void spuStatusSync(TenantEntity tenantEntity,Long id);

/**
* 创建二维码
*/


+ 2
- 3
mallinkService/src/main/java/com/iformall/service/WxCouponService.java View File

@@ -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);
/**
* 卡延期


+ 53
- 7
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java View File

@@ -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<Long> 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


+ 2
- 3
mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java View File

@@ -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);


+ 46
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java View File

@@ -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<Long> 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


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java View File

@@ -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());


+ 37
- 0
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java View File

@@ -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());
}

}
}

+ 29
- 1
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml View File

@@ -188,16 +188,36 @@
<include refid="dynamicWhereConditions" />
</select>

<update id="offExpiriedCouponChannelByEndTime" parameterType="String">
<select id="getExpiriedCouponChannelIdsByEndTime" resultType="Long">
select id from wx_coupon_channel
where status = 0 and tenant_id = #{tenantId} and end_time &lt; now()
and `tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByEndTime">
update wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and tenant_id = #{tenantId} and end_time &lt; now()
</update>

<select id="getExpiriedCouponChannelIdsByValidDate" resultType="Long">
select cc.id from wx_coupon_channel cc, wx_coupon c
where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
and cc.status = 0 and cc.tenant_id = #{tenantId}
and cc.`tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByValidDate">
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 &lt; now()
</update>

<select id="getExpiriedCouponChannelIdsByCouponStatus" resultType="Long">
select cc.id from wx_coupon_channel cc, wx_coupon c
where cc.coupon_id = c.id and c.status = 1
and cc.status = 0 and cc.tenant_id = #{tenantId}
and cc.`tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByCouponStatus">
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 @@
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select>


<select id="getPoiProductIdList" parameterType="java.util.HashMap" resultType="Long">
select id from wx_coupon_channel
where `tenant_id` = #{tenantId}
and `tt_spu_id` is not null
</select>

</mapper>

Loading…
Cancel
Save