| | |
| | | package com.ruoyi.system.task.utils; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.model.TbAccountDetail; |
| | | import com.ruoyi.system.model.TbCompany; |
| | | import com.ruoyi.system.model.TbOrder; |
| | | import com.ruoyi.system.service.TbAccountDetailService; |
| | | import com.ruoyi.system.service.TbCompanyService; |
| | | import com.ruoyi.system.service.TbOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @date 2023/7/11 8:39 |
| | | */ |
| | | @Component |
| | | public class TaskUtil { |
| | | |
| | | @Autowired |
| | | private TbOrderService orderService; |
| | | @Autowired |
| | | private TbCompanyService companyService; |
| | | @Autowired |
| | | private TbAccountDetailService accountDetailService; |
| | | |
| | | |
| | | |
| | | @Scheduled(fixedRate = 60000) |
| | | public void confirmOrder() { |
| | | String format = LocalDateTime.now().minusDays(5).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | List<TbOrder> list = orderService.list(new LambdaQueryWrapper<TbOrder>().eq(TbOrder::getStatus, 5).le(TbOrder::getSellerFinishTime, format)); |
| | | for (TbOrder tbOrder : list) { |
| | | successOrder(tbOrder.getId()); |
| | | } |
| | | } |
| | | |
| | | private void successOrder(String orderId){ |
| | | TbOrder order = orderService.getById(orderId); |
| | | TbCompany company = companyService.getById(order.getCompanyId()); |
| | | // 订单完成 商品已售卖 |
| | | order.setStatus(6); |
| | | order.updateById(); |
| | | order.setFinishTime( new Date()); |
| | | company.setStatus(3); |
| | | |
| | | // 分佣 |
| | | orderService.commission(order, company.getUserId()); |
| | | |
| | | // 卖家账户明细记录更新 |
| | | TbAccountDetail one = accountDetailService.getOne(new LambdaQueryWrapper<TbAccountDetail>().eq(TbAccountDetail::getOrderId, orderId).eq(TbAccountDetail::getCategory, 2)); |
| | | if (one != null) { |
| | | one.setStatus(2); |
| | | one.updateById(); |
| | | } |
| | | |
| | | company.updateById(); |
| | | } |
| | | } |