修复:已知问题

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

View File

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