增加订单过期耗材消息发送
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.ysk.cashier.service.impl.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoDto;
|
||||
import cn.ysk.cashier.dto.order.TbOrderInfoQueryCriteria;
|
||||
import cn.ysk.cashier.dto.order.TbPayCountQueryCriteria;
|
||||
@@ -24,10 +25,13 @@ import cn.ysk.cashier.thirdpay.service.ThirdPayService;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.*;
|
||||
@@ -66,6 +70,7 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
private final RedisUtils redisUtils;
|
||||
private final ThirdPayService thirdPayService;
|
||||
private final TbCashierCartRepository cartRepository;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
private String url;
|
||||
@@ -232,11 +237,20 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void expired(String orderId) {
|
||||
//修改耗材数据
|
||||
JSONObject jsonObject1=new JSONObject();
|
||||
jsonObject1.put("type","delete");
|
||||
|
||||
Optional<TbOrderInfo> byId = tbOrderInfoRepository.findById(Integer.valueOf(orderId));
|
||||
if (byId != null && byId.isPresent()) {
|
||||
TbOrderInfo tbOrderInfo = byId.get();
|
||||
if (tbOrderInfo.getStatus().equals("unpaid")) {
|
||||
upOrderStatus(tbOrderInfo);
|
||||
jsonObject1.put("orderId",tbOrderInfo.getId());
|
||||
|
||||
// 发送取消订单mq消息
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
||||
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
} else if (tbOrderInfo.getStatus().equals("paying") &&
|
||||
(StringUtils.isBlank(tbOrderInfo.getPayType()) ||
|
||||
!tbOrderInfo.getPayType().equals("deposit"))) {
|
||||
@@ -249,6 +263,11 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
redisUtils.set(CacheKey.ORDER_EXPIRED + tbOrderInfo.getId(), tbOrderInfo.getId(), 60 * 2);
|
||||
} else {
|
||||
upOrderStatus(tbOrderInfo);
|
||||
jsonObject1.put("orderId",tbOrderInfo.getId());
|
||||
|
||||
// 发送取消订单mq消息
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT,
|
||||
jsonObject1.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,4 +439,4 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
||||
// 查询单位
|
||||
TbShopUnit tbShopUnit = tbShopUnitRepository.findById(product.getUnitId()).orElse(null);
|
||||
|
||||
int phaseNum = productStocktakinDTO.getStocktakinNum() - product.getStockNumber();
|
||||
int phaseNum;
|
||||
|
||||
long times = Instant.now().toEpochMilli();
|
||||
TbProductStockOperate stockOperate = new TbProductStockOperate();
|
||||
@@ -125,12 +125,12 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
||||
snap.put("coverImg", product.getCoverImg());
|
||||
snap.put("productId", product.getId());
|
||||
snap.put("name", product.getName());
|
||||
snap.put("number", phaseNum);
|
||||
snap.put("unitName", tbShopUnit == null ? null : tbShopUnit.getName());
|
||||
// snap.put("specSnap", tbShopUnit == null ? null : tbShopUnit.getName());
|
||||
|
||||
// 共享库存
|
||||
if (product.getIsDistribute() == 1) {
|
||||
phaseNum = productStocktakinDTO.getStocktakinNum() - product.getStockNumber();
|
||||
round = (int) Math.floor( product.getStockNumber());
|
||||
productStocktakin.setPhasePrice(
|
||||
productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(phaseNum))
|
||||
@@ -148,13 +148,13 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
||||
snap.put("stockNumber", product.getStockNumber());
|
||||
|
||||
}else {
|
||||
|
||||
if (productStocktakinDTO.getSkuId() == null) {
|
||||
throw new BadRequestException("非共享库存必须传入skuId");
|
||||
}
|
||||
|
||||
TbProductSku productSku = producSkutMapper.selectByProIdAndId(productStocktakinDTO.getSkuId(),
|
||||
productStocktakinDTO.getProductId());
|
||||
phaseNum = (int) (productStocktakinDTO.getStocktakinNum() - productSku.getStockNumber());
|
||||
|
||||
productStocktakinDTO.setPrice(productSku.getSalePrice());
|
||||
|
||||
@@ -177,6 +177,7 @@ public class TbProductStocktakinServiceImpl implements TbProductStocktakinServic
|
||||
snap.put("stockNumber", productSku.getStockNumber());
|
||||
|
||||
}
|
||||
snap.put("number", phaseNum);
|
||||
productStocktakin.setPrice(productStocktakinDTO.getPrice());
|
||||
productStockDetail.setStockNumber((double) phaseNum);
|
||||
productStockDetail.setCostAmount(productStocktakinDTO.getPrice().multiply(BigDecimal.valueOf(Math.abs(phaseNum))));
|
||||
|
||||
Reference in New Issue
Block a user