diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index ea7dd28c..be7d182f 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -39,24 +39,12 @@ public class HighCouponController { @Autowired private UserCenter userCenter; - @Resource - private HighMerchantService highMerchantService; - @Resource private HighCouponService highCouponService; - @Resource - private HighCouponHandselService highCouponHandselService; - @Resource private BsCompanyService bsCompanyService; - @Resource - private HighCouponCodeService highCouponCodeService; - - @Resource - private HighApproveService highApproveService; - @RequestMapping(value="/getCouponList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷列表") diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java new file mode 100644 index 00000000..387ee4f1 --- /dev/null +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -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 userCoupons = highUserCouponService.getOverdueCoupon(); + for (HighUserCoupon highUserCoupon : userCoupons) { + highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponService.updateUserCoupon(highUserCoupon); + } + } +} diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java new file mode 100644 index 00000000..13830483 --- /dev/null +++ b/hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java @@ -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 orderList = highOrderService.getCloseOrder(); + if (orderList != null && orderList.size() > 0) { + for (HighOrder order : orderList) { + highOrderService.cancelOrder(order.getId()); + } + } + } +} diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index 9be3e394..05c05150 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1,7 +1,41 @@ 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扩展类 */ public interface HighOrderMapperExt { -} \ No newline at end of file + + @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 getCloseOrder(); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index 533102eb..b32fce52 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -61,6 +61,13 @@ public interface HighOrderService { **/ List getOrderList(Map map); + /** + * @Author 胡锐 + * @Description 查询需要关闭的订单列表 + * @Date 2021/3/27 15:43 + **/ + List getCloseOrder(); + /** * @Author 胡锐 * @Description 子订单完成 @@ -68,4 +75,11 @@ public interface HighOrderService { **/ void childOrderComplete(Long childOrderId); + /** + * @Author 胡锐 + * @Description 取消订单 + * @Date 2021/3/27 15:50 + **/ + void cancelOrder(Long orderId); + } diff --git a/hai-service/src/main/java/com/hai/service/HighUserCouponService.java b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java new file mode 100644 index 00000000..c20ea039 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighUserCouponService.java @@ -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 getOverdueCoupon(); + +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index eaebe53a..a3bdcbd1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -8,6 +8,7 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighOrderMapper; +import com.hai.dao.HighOrderMapperExt; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; import com.hai.model.HighCouponHandselModel; @@ -37,6 +38,9 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private HighOrderMapper highOrderMapper; + @Resource + private HighOrderMapperExt highOrderMapperExt; + @Resource private HighChildOrderMapper highChildOrderMapper; @@ -226,6 +230,11 @@ public class HighOrderServiceImpl implements HighOrderService { return highOrderMapper.selectByExample(example); } + @Override + public List getCloseOrder() { + return null; + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void childOrderComplete(Long childOrderId) { @@ -245,4 +254,26 @@ public class HighOrderServiceImpl implements HighOrderService { highOrderMapper.updateByPrimaryKey(order); } } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void cancelOrder(Long orderId) { + HighOrder order = getOrderById(orderId); + if (order != null) { + order.setOrderStatus(5); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + order.setCancelTime(new Date()); + + for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { + // 商品类型 1:卡卷 2:金币充值 + if (highChildOrder.getGoodsType() == 1) { + // 查询卡卷详情 + HighCouponCode couponCode = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); + couponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 + highCouponCodeService.updateCouponCode(couponCode); + } + highChildOrder.setChildOrdeStatus(5); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + } + updateOrder(order); + } + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java new file mode 100644 index 00000000..5da5eb9e --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java @@ -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 getOverdueCoupon() { + HighUserCouponExample example = new HighUserCouponExample(); + example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date()); + return highUserCouponMapper.selectByExample(example); + } +}