| @@ -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(); | |||||
| } | |||||
| } | |||||
| @@ -7,6 +7,7 @@ import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxCUser; | import com.simple.domain.po.WxCUser; | ||||
| import com.simple.domain.po.WxCouponOrder; | import com.simple.domain.po.WxCouponOrder; | ||||
| import com.simple.domain.vo.WxCouponOrderCVo; | import com.simple.domain.vo.WxCouponOrderCVo; | ||||
| import com.simple.enums.EnumCouponOrderStatus; | |||||
| import com.simple.exception.MallinkException; | import com.simple.exception.MallinkException; | ||||
| import com.simple.service.WxCouponOrderService; | import com.simple.service.WxCouponOrderService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -72,7 +73,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| wxCouponOrder.setCUserId(getUser().getId()); | wxCouponOrder.setCUserId(getUser().getId()); | ||||
| if (wxCouponOrder.getCouponOrderStatus() == null) | if (wxCouponOrder.getCouponOrderStatus() == null) | ||||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | 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); | wxCouponOrder.setSortColumns(WxCouponOrder.Field.CreateDate_DESC); | ||||
| else | else | ||||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); | wxCouponOrder.setSortColumns(WxCouponOrder.Field.UpdateDate_DESC); | ||||
| @@ -13,10 +13,10 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | ||||
| void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | ||||
| void offExpiriedCouponChannelByEndTime(); | |||||
| void offExpiriedCouponChannelByValidDate(); | |||||
| } | } | ||||
| @@ -20,7 +20,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| WxCouponOrderCVo selectDetailOfUser(Map paramMap); | WxCouponOrderCVo selectDetailOfUser(Map paramMap); | ||||
| List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder); | List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder); | ||||
| List<WxCouponOrderCVo> findListOfAdmin(WxCouponOrder wxCouponOrder); | |||||
| List<WxCouponOrderBVo> findListOfAdmin(WxCouponOrder wxCouponOrder); | |||||
| //营销报表 券数据图表 | //营销报表 券数据图表 | ||||
| List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params); | List<MarkingCouponDataReportVo> couponDataMap(HashMap<String,Object> params); | ||||
| @@ -147,7 +147,16 @@ | |||||
| <update id="offExpiriedCouponChannelByEndTime"> | |||||
| update wx_coupon_channel SET status = 1, update_date = now() | |||||
| where status = 0 and end_time < now() | |||||
| </update> | |||||
| <update id="offExpiriedCouponChannelByValidDate"> | |||||
| 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(); | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -148,7 +148,7 @@ | |||||
| <if test="startDate != null"> | <if test="startDate != null"> | ||||
| AND co.create_date > #{startDate,jdbcType=TIMESTAMP} | AND co.create_date > #{startDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| <if test="startDate != null"> | |||||
| <if test="endDate != null"> | |||||
| AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | ||||
| @@ -167,7 +167,7 @@ | |||||
| <if test="startDate != null"> | <if test="startDate != null"> | ||||
| AND co.update_date > #{startDate,jdbcType=TIMESTAMP} | AND co.update_date > #{startDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| <if test="startDate != null"> | |||||
| <if test="endDate != null"> | |||||
| AND co.update_date < #{endDate,jdbcType=TIMESTAMP} | AND co.update_date < #{endDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| AND co.coupon_order_status = '1' | AND co.coupon_order_status = '1' | ||||
| @@ -250,7 +250,7 @@ | |||||
| <if test="startDate != null"> | <if test="startDate != null"> | ||||
| AND co.create_date > #{startDate,jdbcType=TIMESTAMP} | AND co.create_date > #{startDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| <if test="startDate != null"> | |||||
| <if test="endDate != null"> | |||||
| AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | AND (co.coupon_order_status = '0' or co.coupon_order_status = '1') | ||||
| @@ -265,7 +265,7 @@ | |||||
| <if test="startDate != null"> | <if test="startDate != null"> | ||||
| AND co.update_date > #{startDate,jdbcType=TIMESTAMP} | AND co.update_date > #{startDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| <if test="startDate != null"> | |||||
| <if test="endDate != null"> | |||||
| AND co.update_date < #{endDate,jdbcType=TIMESTAMP} | AND co.update_date < #{endDate,jdbcType=TIMESTAMP} | ||||
| </if> | </if> | ||||
| AND co.coupon_order_status = '1' | AND co.coupon_order_status = '1' | ||||