diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java index bbf87cc2b..ddd1742ed 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxCouponChannelController.java @@ -51,7 +51,7 @@ public class WxCouponChannelController extends BaseController { } wxCouponChannel.setTenantId(getUser().getTenantId()); wxCouponChannel.setSortColumns(WxCouponChannel.Field.Id_DESC); - final PageInfo page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); + final PageInfo page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize ,false); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java b/mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java index a0af0f569..eb7c2d078 100644 --- a/mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java +++ b/mallinkAdmin/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java @@ -14,17 +14,19 @@ public class CouponExpiringSchedule { private final Logger logger = LoggerFactory.getLogger(this.getClass()); + @Autowired + private WxCouponMapper wxCouponMapper; @Autowired private WxCouponChannelMapper wxCouponChannelMapper; + + @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public void couponExpiringSchedule() { - - - + wxCouponMapper.offExpiriedCouponByValidDate(); } @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 @@ -35,4 +37,10 @@ public class CouponExpiringSchedule { wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(); } + + @Scheduled(cron = "0 0 0/1 * * ?") // 每小时(整点)执行//限时抢购 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + public void couponChannel2ExpiringSchedule() { + wxCouponChannelMapper.offExpiriedCouponChannel2ByEndTime(); + } } \ No newline at end of file diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java index 735f1b948..921759ce3 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java @@ -2,6 +2,7 @@ package com.iformall.controller; import com.iformall.domain.vo.WxCouponChannelVo; import com.iformall.enums.EnumCouponChannelStatus; +import com.iformall.enums.EnumCouponChannelType; import io.swagger.annotations.Api; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +39,12 @@ public class WxCouponChannelController extends BaseController { wxCouponChannel.setTenantId(getTenantId()); wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); wxCouponChannel.setSortColumns(WxCouponChannel.Field.CreateDate_DESC); - final PageInfo page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize); + PageInfo page; + if (wxCouponChannel.getTargetAd() != null + && wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) + page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize,true); + else + page = wxCouponChannelService.listPageCAPI(wxCouponChannel, pageNum, pageSize,false); return new ResultData(page); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 1244a6739..45bfdeca6 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -10,6 +10,7 @@ public interface WxCouponChannelMapper extends CommonMapper findList(WxCouponChannel wxCouponChannel); List findVoList(WxCouponChannel wxCouponChannel); + List findVoListForCouponChannel2(WxCouponChannel wxCouponChannel); void updateStatusByCouponId(WxCouponChannel wxCouponChannel); @@ -18,6 +19,7 @@ public interface WxCouponChannelMapper extends CommonMapper { WxCouponCVo selectDetailForCUser(WxCouponChannel wxCouponChannel); void reduceInventory(@Param("id")Long id,@Param("number")Integer number); - + + void offExpiriedCouponByValidDate(); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java index ccfdaee5e..37d3d3d3b 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java @@ -28,7 +28,7 @@ public interface WxCouponChannelService { * @param pageSize * @return */ - PageInfo listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize); + PageInfo listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize, boolean couponChannel2); /** * 根据实体查询Vo分页列表 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 8791ec8e7..702644e75 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -192,10 +192,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { * @return */ @Override - public PageInfo listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize) { + public PageInfo listPageCAPI(WxCouponChannel record, Integer pageIndex, Integer pageSize, boolean couponChannel2) { List wxCouponChannelVoList = new ArrayList<>(); PageHelper.startPage(pageIndex, pageSize); - wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); + if (couponChannel2) + wxCouponChannelVoList = wxCouponChannelMapper.findVoListForCouponChannel2(record); + else + wxCouponChannelVoList = wxCouponChannelMapper.findVoList(record); if(wxCouponChannelVoList.isEmpty()){ return new PageInfo<>(wxCouponChannelVoList); } diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 621bd71f2..de15053be 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -41,7 +41,6 @@ and `coupon_id` = #{couponId} - and `type` = #{type} @@ -107,14 +106,6 @@ - - - - - update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} @@ -135,16 +126,101 @@ + + + + + update wx_coupon_channel SET status = 1, update_date = now() where status = 0 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.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now() + where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now() @@ -152,4 +228,9 @@ where cc.status = 0 and cc.coupon_id = c.id and c.status = 1 + + update wx_coupon_channel SET status = 1, update_date = now() + where status = 0 and target_ad = 2 and end_time < now() + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 8b50a042a..4ba7818c6 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -247,5 +247,9 @@ update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number} + + update wx_coupon SET status = 1, update_date = now() + where status = 0 and valid_type = 1 and valid_end_date < now() +