| @@ -31,6 +31,7 @@ public class WxBusinessController extends BaseController | |||||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | ||||
| public ResultData list(@ModelAttribute WxBusiness wxBusiness,Integer pageNum, Integer pageSize) { | public ResultData list(@ModelAttribute WxBusiness wxBusiness,Integer pageNum, Integer pageSize) { | ||||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | if (null == wxBusiness) wxBusiness = new WxBusiness(); | ||||
| wxBusiness.setTenantId(getTenantId()); | |||||
| final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | ||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -25,18 +25,12 @@ public class CouponExpiringSchedule { | |||||
| private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class); | private final Logger logger = Logger.getLogger(CouponExpiringSchedule.class); | ||||
| @Autowired | |||||
| private WxMallMapper wxMallMapper; | |||||
| @Autowired | @Autowired | ||||
| private WxCouponChannelMapper wxCouponChannelMapper; | private WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| private WxCouponMapper wxCouponMapper; | |||||
| @Scheduled(cron = "0 30 0 * * ?") // 每天凌晨 | |||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void couponExpiringSchedule() { | public void couponExpiringSchedule() { | ||||
| @@ -45,11 +39,12 @@ public class CouponExpiringSchedule { | |||||
| } | } | ||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨 | |||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | ||||
| public void couponChannelExpiringSchedule() { | public void couponChannelExpiringSchedule() { | ||||
| wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(); | wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(); | ||||
| wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); | wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(); | ||||
| wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,53 @@ | |||||
| package com.simple.schedule; | |||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.config.PayProperty; | |||||
| import com.simple.domain.po.WxAppinfo; | |||||
| import com.simple.domain.po.WxCouponOrder; | |||||
| import com.simple.domain.po.WxMerchantBUser; | |||||
| import com.simple.domain.vo.WxCouponOrderCVo; | |||||
| import com.simple.enums.EnumPayWay; | |||||
| import com.simple.exception.MallinkException; | |||||
| import com.simple.mapper.WxCouponChannelMapper; | |||||
| import com.simple.mapper.WxCouponMapper; | |||||
| import com.simple.mapper.WxCouponOrderMapper; | |||||
| import com.simple.mapper.WxMallMapper; | |||||
| 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.util.List; | |||||
| @Component | |||||
| public class CouponOrderExpiringSchedule { | |||||
| private final Logger logger = Logger.getLogger(CouponOrderExpiringSchedule.class); | |||||
| @Autowired | |||||
| private WxCouponOrderMapper wxCouponOrderMapper; | |||||
| @Autowired | |||||
| private PayProperty payProperty; | |||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void couponOrderExpiringSchedule() { | |||||
| wxCouponOrderMapper.offExpiredCouponOrderByValidDate(); | |||||
| } | |||||
| @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| public void couponOrderRefundSchedule() { | |||||
| List<WxCouponOrder> list = wxCouponOrderMapper.findExpiredCouponOrderByValidDate(); | |||||
| } | |||||
| } | |||||
| @@ -1,15 +1,8 @@ | |||||
| package com.simple.schedule; | package com.simple.schedule; | ||||
| import com.simple.domain.po.WxCouponOrder; | |||||
| import com.simple.domain.po.WxMall; | |||||
| import com.simple.domain.po.WxMerchant; | |||||
| import com.simple.domain.po.WxOrder; | import com.simple.domain.po.WxOrder; | ||||
| import com.simple.enums.EnumOrderStatus; | import com.simple.enums.EnumOrderStatus; | ||||
| import com.simple.mapper.WxCouponOrderMapper; | |||||
| import com.simple.mapper.WxMallMapper; | |||||
| import com.simple.mapper.WxMerchantMapper; | |||||
| import com.simple.mapper.WxOrderMapper; | import com.simple.mapper.WxOrderMapper; | ||||
| import com.simple.service.WxDateAmountRecordService; | |||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.scheduling.annotation.Scheduled; | import org.springframework.scheduling.annotation.Scheduled; | ||||
| @@ -17,17 +10,15 @@ import org.springframework.stereotype.Component; | |||||
| import org.springframework.transaction.annotation.Propagation; | import org.springframework.transaction.annotation.Propagation; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @Component | @Component | ||||
| public class OrderExpireSchedule { | |||||
| public class OrderExpiringSchedule { | |||||
| private final Logger logger = Logger.getLogger(OrderExpireSchedule.class); | |||||
| private final Logger logger = Logger.getLogger(OrderExpiringSchedule.class); | |||||
| private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟 | private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟 | ||||
| @@ -17,6 +17,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| void offExpiriedCouponChannelByEndTime(); | void offExpiriedCouponChannelByEndTime(); | ||||
| void offExpiriedCouponChannelByValidDate(); | void offExpiriedCouponChannelByValidDate(); | ||||
| void offExpiriedCouponChannelByCouponStatus(); | |||||
| } | } | ||||
| @@ -62,4 +62,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| int queryPriceTotal(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); | int queryPriceTotal(@Param("tenantId")String tenantId, @Param("startTime") Date startTime, @Param("endTime")Date endTime); | ||||
| void offExpiredCouponOrderByValidDate(); | |||||
| List<WxCouponOrder> findExpiredCouponOrderByValidDate(); | |||||
| } | } | ||||
| @@ -155,8 +155,12 @@ | |||||
| <update id="offExpiriedCouponChannelByValidDate"> | <update id="offExpiriedCouponChannelByValidDate"> | ||||
| update wx_coupon_channel, wx_coupon c SET cc.status = 1, cc.update_date = 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(); | |||||
| where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date < now() | |||||
| </update> | </update> | ||||
| <update id="offExpiriedCouponChannelByCouponStatus"> | |||||
| 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.status = 1 | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -432,6 +432,14 @@ | |||||
| <update id="offExpiredCouponOrderByValidDate"> | |||||
| update wx_coupon_order SET coupon_order_status = 2, update_date = now() | |||||
| where expired_time < now() and coupon_price = 0 and coupon_order_status = 0 | |||||
| </update> | |||||
| <select id="findExpiredCouponOrderByValidDate" parameterType="com.simple.domain.po.WxCouponOrder" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_coupon_order | |||||
| where expired_time < now() and coupon_price > 0 and coupon_order_status = 0 | |||||
| </select> | |||||
| </mapper> | |||||
| </mapper> | |||||