修复:已知问题

This commit is contained in:
2025-03-13 15:53:20 +08:00
parent 62dad7098f
commit df3ae32eb7
2 changed files with 15 additions and 19 deletions

View File

@@ -42,8 +42,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import static com.gxwebsoft.common.core.constants.OrderConstants.ORDER_STATUS_OVER;
import static com.gxwebsoft.common.core.constants.OrderConstants.PAY_STATUS_NO_PAY;
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
/**
* 订单记录表控制器
@@ -100,28 +99,25 @@ public class OrderPayController extends BaseController {
@GetMapping("/{id}")
public ApiResult<OrderPay> get(@PathVariable("id") Integer id) {
final OrderPay orderPay = orderPayService.getById(id);
final BigDecimal totalPrice = orderPay.getTotalPrice();
final List<OrderPay> list = orderPayService.list(new LambdaQueryWrapper<OrderPay>()
.eq(OrderPay::getUserId,orderPay.getUserId())
.eq(OrderPay::getPayStatus, PAY_STATUS_NO_PAY)
final BigDecimal rent = orderPay.getBatteryRent();
final OrderPay one = orderPayService.getOne(new LambdaQueryWrapper<OrderPay>()
.eq(OrderPay::getRentOrderId, orderPay.getRentOrderId())
.eq(OrderPay::getUserId, orderPay.getUserId())
.eq(OrderPay::getPayStatus, PAY_STATUS_SUCCESS)
.orderByDesc(OrderPay::getId)
.last("limit 1")
);
System.out.println("list.size = " + list.size());
final Integer goodsId = orderPay.getGoodsId();
final EquipmentGoods goods = equipmentGoodsService.getByIdRel(goodsId);
final BigDecimal batteryRent = goods.getBatteryRent();
System.out.println("batteryRent = " + batteryRent);
// 按新的续费价格
orderPay.setTotalPrice(batteryRent);
list.forEach(d -> {
final long between = DateUtil.between(new Date(), d.getExpirationTime(), DateUnit.DAY, false);
System.out.println("item.. = " + between);
if(between < 0){
orderPay.setTotalPrice(totalPrice);
}
});
final long between = DateUtil.between(new Date(), one.getExpirationTime(), DateUnit.DAY, false);
if(between < 0){
// 有逾期的订单不能享受折扣
orderPay.setTotalPrice(rent);
}
return success(orderPay);
// 使用关联查询
//return success(orderPayService.getByIdRel(id));
}
@GetMapping("/change-order-no")

View File

@@ -33,7 +33,7 @@ public class OrderPayServiceImpl extends ServiceImpl<OrderPayMapper, OrderPay> i
List<OrderPay> list = baseMapper.selectListRel(param);
// 排序
PageParam<OrderPay, OrderPayParam> page = new PageParam<>();
page.setDefaultOrder("pay_time desc");
page.setDefaultOrder("id desc");
return page.sortRecords(list);
}