From cdadf240ff5bedf5b7418ab1ad702b16d49d75e1 Mon Sep 17 00:00:00 2001 From: yangqingyuan Date: Wed, 21 Aug 2024 16:03:17 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E7=BA=BF?= =?UTF-8?q?=E4=B8=8A=E7=BB=AD=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/controller/OrderPayController.java | 42 ++++++++++++++++++- .../shop/mapper/xml/OrderPayMapper.xml | 6 +++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java index 7838780..5bd6235 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java @@ -1,5 +1,7 @@ package com.gxwebsoft.shop.controller; +import cn.hutool.core.bean.copier.BeanCopier; +import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; @@ -33,6 +35,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.Date; import java.util.List; import static com.gxwebsoft.common.core.constants.OrderConstants.ORDER_STATUS_OVER; @@ -76,9 +79,9 @@ public class OrderPayController extends BaseController { public ApiResult> list(OrderPayParam param) { PageParam page = new PageParam<>(param); page.setDefaultOrder("create_time desc"); - return success(orderPayService.list(page.getOrderWrapper())); + //return success(orderPayService.list(page.getOrderWrapper())); // 使用关联查询 - //return success(orderPayService.listRel(param)); + return success(orderPayService.listRel(param)); } @GetMapping("/{id}") @@ -215,6 +218,41 @@ public class OrderPayController extends BaseController { return fail("添加失败"); } + + @OperationLog + @ApiOperation("线上续费") + @PostMapping("/renew") + public ApiResult renew(@RequestBody OrderPay orderPay) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + orderPay.setUserId(loginUser.getUserId()); + } + + + Order order = new Order(); + order.setOrderId(orderPay.getRentOrderId()); + order.setStartTime(orderPay.getStartTime()); + order.setExpirationTime(orderPay.getExpirationTime()); + orderService.updateById(order); + + OrderPay olderPay = orderPayService.getOne(Wrappers.lambdaQuery(OrderPay.class).eq(OrderPay::getOrderNo,orderPay.getOrderNo())); + OrderPay newOrderPay = new OrderPay(); + BeanCopier.create(olderPay, newOrderPay, CopyOptions.create().ignoreNullValue().setIgnoreProperties("id","orderNo")).copy(); + + newOrderPay.setPayPrice(orderPay.getOrderPrice()); + newOrderPay.setStartTime(orderPay.getStartTime()); + newOrderPay.setPayTime(new Date()); + newOrderPay.setCreateTime(new Date()); + newOrderPay.setExpirationTime(orderPay.getExpirationTime()); + newOrderPay.setOrderNo(IdUtil.getSnowflakeNextIdStr()); + + if (orderPayService.save(newOrderPay)) { + return success("添加成功"); + } + return fail("添加失败"); + } + @OperationLog @ApiOperation("修改订单记录表") @PutMapping() diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderPayMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderPayMapper.xml index f107c0d..80f9987 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderPayMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderPayMapper.xml @@ -22,6 +22,12 @@ AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%') + + AND a.rent_order_id = #{param.rentOrderId} + + + AND a.pay_status = #{param.payStatus} + AND a.deleted = 0