Просмотр исходного кода

[系统][新增]:卡券自动过期定时任务

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
8ddb02799c
8 измененных файлов: 78 добавлений и 21 удалений
  1. +1
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxBusinessController.java
  2. +3
    -8
      mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java
  3. +53
    -0
      mallinkAdmin/src/main/java/com/simple/schedule/CouponOrderExpiringSchedule.java
  4. +2
    -11
      mallinkAdmin/src/main/java/com/simple/schedule/OrderExpiringSchedule.java
  5. +2
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java
  6. +3
    -0
      mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java
  7. +5
    -1
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml
  8. +9
    -1
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 1
- 0
mallinkAdmin/src/main/java/com/simple/controller/WxBusinessController.java Просмотреть файл

@@ -31,6 +31,7 @@ public class WxBusinessController extends BaseController
@ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
public ResultData list(@ModelAttribute WxBusiness wxBusiness,Integer pageNum, Integer pageSize) {
if (null == wxBusiness) wxBusiness = new WxBusiness();
wxBusiness.setTenantId(getTenantId());
final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize);
return new ResultData(page);
}


+ 3
- 8
mallinkAdmin/src/main/java/com/simple/schedule/CouponExpiringSchedule.java Просмотреть файл

@@ -25,18 +25,12 @@ 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 = "0 5 0 * * ?") // 每天凌晨00:05
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
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秒中一次
public void couponChannelExpiringSchedule() {

wxCouponChannelMapper.offExpiriedCouponChannelByEndTime();
wxCouponChannelMapper.offExpiriedCouponChannelByValidDate();
wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus();
}
}

+ 53
- 0
mallinkAdmin/src/main/java/com/simple/schedule/CouponOrderExpiringSchedule.java Просмотреть файл

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

}

}

mallinkAdmin/src/main/java/com/simple/schedule/OrderExpireSchedule.java → mallinkAdmin/src/main/java/com/simple/schedule/OrderExpiringSchedule.java Просмотреть файл

@@ -1,15 +1,8 @@
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.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.service.WxDateAmountRecordService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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.Transactional;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@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分钟


+ 2
- 0
mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java Просмотреть файл

@@ -17,6 +17,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str
void offExpiriedCouponChannelByEndTime();

void offExpiriedCouponChannelByValidDate();

void offExpiriedCouponChannelByCouponStatus();
}

+ 3
- 0
mallinkService/src/main/java/com/simple/mapper/WxCouponOrderMapper.java Просмотреть файл

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



void offExpiredCouponOrderByValidDate();
List<WxCouponOrder> findExpiredCouponOrderByValidDate();
}

+ 5
- 1
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml Просмотреть файл

@@ -155,8 +155,12 @@

<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 &lt; now();
where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and valid_end_date &lt; now()
</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>

+ 9
- 1
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -432,6 +432,14 @@



<update id="offExpiredCouponOrderByValidDate">
update wx_coupon_order SET coupon_order_status = 2, update_date = now()
where expired_time &lt; 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 &lt; now() and coupon_price &gt; 0 and coupon_order_status = 0
</select>

</mapper>
</mapper>

Загрузка…
Отмена
Сохранить