退款金额展示有误fix
This commit is contained in:
@@ -40,4 +40,5 @@ public interface TbOrderInfoMapper extends BaseMapper<TbOrderInfo> {
|
|||||||
"order_amount=order_amount-#{priceAmount} where id=#{orderId} and origin_amount-#{priceAmount} >= 0")
|
"order_amount=order_amount-#{priceAmount} where id=#{orderId} and origin_amount-#{priceAmount} >= 0")
|
||||||
int updateOrderAmount(Integer orderId, BigDecimal priceAmount, BigDecimal packAmount);
|
int updateOrderAmount(Integer orderId, BigDecimal priceAmount, BigDecimal packAmount);
|
||||||
|
|
||||||
|
void cancelOrder();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import cn.ysk.cashier.repository.order.StockCountRepository;
|
|||||||
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||||
import cn.ysk.cashier.service.order.TbCashierCartService;
|
import cn.ysk.cashier.service.order.TbCashierCartService;
|
||||||
|
import cn.ysk.cashier.service.order.TbOrderInfoService;
|
||||||
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
import cn.ysk.cashier.service.shop.TbShopStorageService;
|
||||||
import cn.ysk.cashier.utils.CacheKey;
|
import cn.ysk.cashier.utils.CacheKey;
|
||||||
import cn.ysk.cashier.utils.DateUtil;
|
import cn.ysk.cashier.utils.DateUtil;
|
||||||
@@ -14,6 +15,7 @@ import cn.ysk.cashier.utils.QueryHelp;
|
|||||||
import cn.ysk.cashier.utils.RedisUtils;
|
import cn.ysk.cashier.utils.RedisUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -46,9 +48,11 @@ public class TestTask {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
private final TbCashierCartService tbCashierCartService;
|
private final TbCashierCartService tbCashierCartService;
|
||||||
|
private final TbOrderInfoService orderInfoService;
|
||||||
|
|
||||||
public TestTask(TbCashierCartService tbCashierCartService) {
|
public TestTask(TbCashierCartService tbCashierCartService, TbOrderInfoService orderInfoService) {
|
||||||
this.tbCashierCartService = tbCashierCartService;
|
this.tbCashierCartService = tbCashierCartService;
|
||||||
|
this.orderInfoService = orderInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,6 +95,12 @@ public class TestTask {
|
|||||||
log.info("购物车清楚记录开始结束");
|
log.info("购物车清楚记录开始结束");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void cancelOrder(){
|
||||||
|
log.info("订单取消定时任务执行");
|
||||||
|
orderInfoService.cancelOrder();
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void countStock(String str) {
|
public void countStock(String str) {
|
||||||
String startTime = "";
|
String startTime = "";
|
||||||
|
|||||||
@@ -289,11 +289,11 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
dto.setIsRefund(0);
|
dto.setIsRefund(0);
|
||||||
dto.setRefundAmount(BigDecimal.ZERO);
|
dto.setRefundAmount(BigDecimal.ZERO);
|
||||||
dto.setRefundRemark(tbOrderInfo.getRefundRemark());
|
dto.setRefundRemark(tbOrderInfo.getRefundRemark());
|
||||||
List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId());
|
// List<TbOrderInfo> tbOrderInfos = tbOrderInfoRepository.selTbOrdersBysource(tbOrderInfo.getId(), tbOrderInfo.getShopId());
|
||||||
if (!CollectionUtils.isEmpty(tbOrderInfos)) {
|
// if (!CollectionUtils.isEmpty(tbOrderInfos)) {
|
||||||
dto.setIsRefund(1);
|
// dto.setIsRefund(1);
|
||||||
dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
|
// dto.setRefundAmount(tbOrderInfos.stream().map(TbOrderInfo::getOrderAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
}
|
// }
|
||||||
dto.setDetailList(details);
|
dto.setDetailList(details);
|
||||||
TbCashierCart cashierCart = tbCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
|
TbCashierCart cashierCart = tbCashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getOrderId, id)
|
.eq(TbCashierCart::getOrderId, id)
|
||||||
@@ -622,4 +622,17 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
|||||||
orderInfoMapper.updateById(orderInfo);
|
orderInfoMapper.updateById(orderInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelOrder() {
|
||||||
|
List<TbOrderInfo> tbOrderInfos = orderInfoMapper.selectList(new LambdaQueryWrapper<TbOrderInfo>()
|
||||||
|
.eq(TbOrderInfo::getStatus, "unpaid")
|
||||||
|
.lt(TbOrderInfo::getCreatedAt, cn.hutool.core.date.DateUtil.current() - 15 * 60 * 1000));
|
||||||
|
log.info("超时订单: {}", tbOrderInfos);
|
||||||
|
List<Integer> ids = tbOrderInfos.stream().map(TbOrderInfo::getId).collect(Collectors.toList());
|
||||||
|
orderInfoMapper.update(null, new LambdaUpdateWrapper<TbOrderInfo>()
|
||||||
|
.in(TbOrderInfo::getId, ids)
|
||||||
|
.eq(TbOrderInfo::getStatus, "unpaid")
|
||||||
|
.set(TbOrderInfo::getStatus, "cancel"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,4 +108,9 @@ public interface TbOrderInfoService {
|
|||||||
* @param req
|
* @param req
|
||||||
*/
|
*/
|
||||||
void successReturn(Map<String, String> req);
|
void successReturn(Map<String, String> req);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消过期订单
|
||||||
|
*/
|
||||||
|
void cancelOrder();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user