Compare commits
2 Commits
5874571200
...
cd7d23d348
| Author | SHA1 | Date | |
|---|---|---|---|
| cd7d23d348 | |||
| 0f2ecc5b7d |
@@ -1,8 +1,11 @@
|
||||
package com.czg.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.enums.OrderNoPrefixEnum;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.market.service.OrderInfoService;
|
||||
import com.czg.order.entity.CashierCart;
|
||||
import com.czg.order.entity.GbOrder;
|
||||
@@ -19,6 +22,7 @@ import com.czg.utils.CzgRandomUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -47,17 +51,24 @@ public class OTimeTask {
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@DubboReference
|
||||
private ShopTableService shopTableService;
|
||||
|
||||
/**
|
||||
* order 过期
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void run() {
|
||||
OrderInfo orderInfo = new OrderInfo();
|
||||
orderInfo.setStatus(OrderStatusEnums.CANCELLED.getCode());
|
||||
orderInfoService.update(orderInfo, QueryWrapper.create()
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode())
|
||||
.lt(OrderInfo::getTradeDay, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")));
|
||||
.lt(OrderInfo::getTradeDay, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
|
||||
List<OrderInfo> list = orderInfoService.list(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.forEach(orderInfo -> shopTableService.updateStatus(orderInfo.getShopId(), null, orderInfo.getTableCode(), ShopTableStatusEnum.IDLE.getValue()));
|
||||
OrderInfo orderInfo = new OrderInfo();
|
||||
orderInfo.setStatus(OrderStatusEnums.CANCELLED.getCode());
|
||||
orderInfoService.update(orderInfo, queryWrapper);
|
||||
}
|
||||
|
||||
QueryWrapper cartUpdateWrapper = new QueryWrapper();
|
||||
cartUpdateWrapper.lt(CashierCart::getCreateTime, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd HH:mm:ss"))
|
||||
|
||||
@@ -78,30 +78,30 @@ public class ProductRpcServiceImpl implements ProductRpcService {
|
||||
continue;
|
||||
}
|
||||
// 商品未开启库存
|
||||
if (product.getIsStock() == SystemConstants.OneZero.ZERO) {
|
||||
continue;
|
||||
}
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setAfterNumber(NumberUtil.sub(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
cleanCategoryProduct(shopId, product.getCategoryId());
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine))) {
|
||||
isLowWarnLine = true;
|
||||
if (product.getIsStock() == SystemConstants.OneZero.ONE) {
|
||||
productMapper.updateProductStockNum(dto.getProductId(), dto.getShopId(), "sub", dto.getNum());
|
||||
// 记录商品库存流水
|
||||
ProductStockFlow flow = new ProductStockFlow();
|
||||
flow.setCreateUserId(1L);
|
||||
flow.setCreateUserName("银收客");
|
||||
flow.setShopId(shopId);
|
||||
flow.setProductId(product.getId());
|
||||
flow.setProductName(product.getName());
|
||||
flow.setBeforeNumber(NumberUtil.toBigDecimal(product.getStockNumber()));
|
||||
flow.setInOutNumber(NumberUtil.sub(BigDecimal.ZERO, NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setAfterNumber(NumberUtil.sub(NumberUtil.toBigDecimal(product.getStockNumber()), NumberUtil.toBigDecimal(dto.getNum())));
|
||||
flow.setInOutType(InOutTypeEnum.OUT.value());
|
||||
flow.setInOutItem(InOutItemEnum.ORDER_OUT.value());
|
||||
flow.setOrderId(orderId);
|
||||
productStockFlowService.saveFlow(flow);
|
||||
cleanCategoryProduct(shopId, product.getCategoryId());
|
||||
refreshRedisProdStock(shopId, product.getId(), flow.getAfterNumber());
|
||||
Integer warnLine = ObjUtil.defaultIfNull(product.getWarnLine(), 10);
|
||||
if (!isLowWarnLine && NumberUtil.isLess(flow.getAfterNumber(), Convert.toBigDecimal(warnLine))) {
|
||||
isLowWarnLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询商品绑定耗材信息
|
||||
List<ProdConsRelation> relationList = prodConsRelationMapper.selectListByQuery(QueryWrapper.create().eq(ProdConsRelation::getProductId, dto.getProductId()));
|
||||
if (CollUtil.isEmpty(relationList)) {
|
||||
|
||||
Reference in New Issue
Block a user