feat:增加线上续费
This commit is contained in:
@@ -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<OrderPay>> list(OrderPayParam param) {
|
||||
PageParam<OrderPay, OrderPayParam> 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()
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
<if test="param.orderNo != null">
|
||||
AND a.order_no LIKE CONCAT('%', #{param.orderNo}, '%')
|
||||
</if>
|
||||
<if test="param.rentOrderId != null">
|
||||
AND a.rent_order_id = #{param.rentOrderId}
|
||||
</if>
|
||||
<if test="param.payStatus != null">
|
||||
AND a.pay_status = #{param.payStatus}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user