parent
272dd3d0b1
commit
a5ef591cc9
@ -0,0 +1,31 @@ |
|||||||
|
package com.hai.schedule; |
||||||
|
|
||||||
|
import com.hai.entity.HighUserCoupon; |
||||||
|
import com.hai.service.HighUserCouponService; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: 卡卷定时任务 |
||||||
|
* @Date: 2021/3/27 15:39 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
public class HighCouponSchedule { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighUserCouponService highUserCouponService; |
||||||
|
|
||||||
|
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
|
||||||
|
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
|
||||||
|
public void certification() { |
||||||
|
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon(); |
||||||
|
for (HighUserCoupon highUserCoupon : userCoupons) { |
||||||
|
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用
|
||||||
|
highUserCouponService.updateUserCoupon(highUserCoupon); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.hai.schedule; |
||||||
|
|
||||||
|
import com.hai.entity.HighOrder; |
||||||
|
import com.hai.service.HighOrderService; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.xml.ws.RespectBinding; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: 订单定时任务 |
||||||
|
* @Date: 2021/3/27 15:41 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
public class HighOrderSchedule { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighOrderService highOrderService; |
||||||
|
|
||||||
|
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
|
||||||
|
public void certification() { |
||||||
|
|
||||||
|
List<HighOrder> orderList = highOrderService.getCloseOrder(); |
||||||
|
if (orderList != null && orderList.size() > 0) { |
||||||
|
for (HighOrder order : orderList) { |
||||||
|
highOrderService.cancelOrder(order.getId()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,7 +1,41 @@ |
|||||||
package com.hai.dao; |
package com.hai.dao; |
||||||
|
|
||||||
|
import com.hai.entity.HighOrder; |
||||||
|
import org.apache.ibatis.annotations.Result; |
||||||
|
import org.apache.ibatis.annotations.Results; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
import org.apache.ibatis.type.JdbcType; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
/** |
/** |
||||||
* mapper扩展类 |
* mapper扩展类 |
||||||
*/ |
*/ |
||||||
public interface HighOrderMapperExt { |
public interface HighOrderMapperExt { |
||||||
|
|
||||||
|
@Select({"SELECT * FROM high_order ho WHERE TIMESTAMPDIFF(MINUTE,ho.create_time,SYSDATE()) > 15 AND ho.order_status = 1"}) |
||||||
|
@Results({ |
||||||
|
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), |
||||||
|
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT), |
||||||
|
@Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="pay_model", property="payModel", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), |
||||||
|
@Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL), |
||||||
|
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER), |
||||||
|
@Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL), |
||||||
|
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), |
||||||
|
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP), |
||||||
|
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), |
||||||
|
@Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP), |
||||||
|
@Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), |
||||||
|
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) |
||||||
|
}) |
||||||
|
List<HighOrder> getCloseOrder(); |
||||||
|
|
||||||
} |
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.hai.service; |
||||||
|
|
||||||
|
import com.hai.entity.HighUserCoupon; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: 用户的卡卷 |
||||||
|
* @Date: 2021/3/27 16:06 |
||||||
|
*/ |
||||||
|
public interface HighUserCouponService { |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 胡锐 |
||||||
|
* @Description 增加 |
||||||
|
* @Date 2021/3/27 16:08 |
||||||
|
**/ |
||||||
|
void insertUserCoupon(HighUserCoupon highUserCoupon); |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 胡锐 |
||||||
|
* @Description 修改 |
||||||
|
* @Date 2021/3/27 16:08 |
||||||
|
**/ |
||||||
|
void updateUserCoupon(HighUserCoupon highUserCoupon); |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 胡锐 |
||||||
|
* @Description 获取已到期的卡卷 |
||||||
|
* @Date 2021/3/27 16:09 |
||||||
|
**/ |
||||||
|
List<HighUserCoupon> getOverdueCoupon(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package com.hai.service.impl; |
||||||
|
|
||||||
|
import com.hai.dao.HighUserCouponMapper; |
||||||
|
import com.hai.entity.HighUserCoupon; |
||||||
|
import com.hai.entity.HighUserCouponExample; |
||||||
|
import com.hai.service.HighUserCouponService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Auther: 胡锐 |
||||||
|
* @Description: |
||||||
|
* @Date: 2021/3/27 16:10 |
||||||
|
*/ |
||||||
|
@Service("highUserCouponService") |
||||||
|
public class HighUserCouponServiceImpl implements HighUserCouponService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighUserCouponMapper highUserCouponMapper; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void insertUserCoupon(HighUserCoupon highUserCoupon) { |
||||||
|
highUserCouponMapper.insert(highUserCoupon); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateUserCoupon(HighUserCoupon highUserCoupon) { |
||||||
|
highUserCouponMapper.updateByPrimaryKey(highUserCoupon); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<HighUserCoupon> getOverdueCoupon() { |
||||||
|
HighUserCouponExample example = new HighUserCouponExample(); |
||||||
|
example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date()); |
||||||
|
return highUserCouponMapper.selectByExample(example); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue