diff --git a/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java b/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java new file mode 100644 index 000000000..55d345ad0 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java @@ -0,0 +1,55 @@ +package com.simple.schedule; + +import com.simple.common.IdWorker; +import com.simple.domain.po.WxCouponOrder; +import com.simple.domain.po.WxDateAmountRecord; +import com.simple.domain.po.WxMall; +import com.simple.domain.po.WxMerchant; +import com.simple.enums.EnumDateAmtType; +import com.simple.mapper.*; +import com.simple.service.WxDateAmountRecordService; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +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.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +@Component +public class CouponExpiringSchedule { + + private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class); + + + @Autowired + private WxMallMapper wxMallMapper; + + @Autowired + private WxCouponChannelMapper wxCouponChannelMapper; + + @Autowired + private WxCouponMapper wxCouponMapper; + + + + @Scheduled(cron = "0 30 0 * * ?") // 每天凌晨 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + public void couponExpiringSchedule() { + + + + } + + @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + public void couponChannelExpiringSchedule() { + + wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(); + wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); + } +} \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java b/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java index 3f0aa43a9..9f7cbc007 100644 --- a/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxCouponOrderController.java @@ -7,6 +7,7 @@ import com.simple.common.ResultData; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxCouponOrder; import com.simple.domain.vo.WxCouponOrderCVo; +import com.simple.enums.EnumCouponOrderStatus; import com.simple.exception.MallinkException; import com.simple.service.WxCouponOrderService; import io.swagger.annotations.Api; @@ -72,7 +73,7 @@ public class WxCouponOrderController extends BaseController { wxCouponOrder.setCUserId(getUser().getId()); if (wxCouponOrder.getCouponOrderStatus() == null) wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); - else if (wxCouponOrder.getCouponOrderStatus() == 0) + else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()) wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); else wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java index 613e9dd7f..8e3cd641a 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java @@ -13,10 +13,10 @@ public interface WxCouponChannelMapper extends CommonMapper findVoList(WxCouponChannel wxCouponChannel); void updateStatusByCouponId(WxCouponChannel wxCouponChannel); - - - + void offExpiriedCouponChannelByEndTime(); + + void offExpiriedCouponChannelByValidDate(); } diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java index 1a3532e6e..d6a5b7cde 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java @@ -20,7 +20,7 @@ public interface WxCouponOrderMapper extends CommonMapper { WxCouponOrderCVo selectDetailOfUser(Map paramMap); List findListOfCUser(WxCouponOrder wxCouponOrder); - List findListOfAdmin(WxCouponOrder wxCouponOrder); + List findListOfAdmin(WxCouponOrder wxCouponOrder); //营销报表 券数据图表 List couponDataMap(HashMap params); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 85c3f401f..e5c7c516d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -147,7 +147,16 @@ + + update wx_coupon_channel SET status = 1, update_date = now() + where status = 0 and end_time < now() + + + + update wx_coupon_channel, wx_coupon c SET cc.status = 1, cc.update_date = now() + where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now(); + diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 2d48752ff..633ab599b 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -148,7 +148,7 @@ AND co.create_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.create_date < #{endDate,jdbcType=TIMESTAMP} AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') @@ -167,7 +167,7 @@ AND co.update_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.update_date < #{endDate,jdbcType=TIMESTAMP} AND co.coupon_order_status = '1' @@ -250,7 +250,7 @@ AND co.create_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.create_date < #{endDate,jdbcType=TIMESTAMP} AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') @@ -265,7 +265,7 @@ AND co.update_date > #{startDate,jdbcType=TIMESTAMP} - + AND co.update_date < #{endDate,jdbcType=TIMESTAMP} AND co.coupon_order_status = '1'