feat(rental): 完善租赁订单退款功能并新增相关接口
- 新增租赁订单物品记录相关接口和DTO - 完善租赁订单状态管理和退款流程- 新增获取租赁订单信息接口 - 优化租赁订单列表展示,增加退款申请信息
This commit is contained in:
parent
43529c2a60
commit
e26f51b982
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
@Tag(name = "RPC 服务 - 租赁订单金额记录")
|
@Tag(name = "RPC 服务 - 租赁订单金额记录")
|
||||||
@ -25,5 +26,5 @@ public interface RentalDepositRecordApi {
|
|||||||
|
|
||||||
@GetMapping(PREFIX + "/getRecordAmount")
|
@GetMapping(PREFIX + "/getRecordAmount")
|
||||||
@Operation(summary = "获取租赁订单已收取的金额")
|
@Operation(summary = "获取租赁订单已收取的金额")
|
||||||
CommonResult<BigDecimal> getRecordAmount(@RequestParam("orderNo") String orderNo);
|
CommonResult<Map<String, BigDecimal>> getRecordAmount(@RequestParam("orderNo") String orderNo);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.api.rental;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.system.api.rental.dto.RentalDepositRecordDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.rental.dto.RentalItemsRecordDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||||
|
@Tag(name = "RPC 服务 - 租赁订单物品记录")
|
||||||
|
public interface RentalItemsRecordApi {
|
||||||
|
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/rental-items";
|
||||||
|
|
||||||
|
@PutMapping(PREFIX + "/create")
|
||||||
|
@Operation(summary = "创建租赁订单出入库记录")
|
||||||
|
CommonResult<Boolean> create(@RequestBody List<RentalItemsRecordDTO> createReqVO);
|
||||||
|
}
|
@ -22,4 +22,9 @@ public interface RentalOrderApi {
|
|||||||
@PutMapping(PREFIX + "/update")
|
@PutMapping(PREFIX + "/update")
|
||||||
@Operation(summary = "更新租赁订单信息")
|
@Operation(summary = "更新租赁订单信息")
|
||||||
CommonResult<Boolean> updateOrder(@RequestBody RentalOrderDTO updateReqVO);
|
CommonResult<Boolean> updateOrder(@RequestBody RentalOrderDTO updateReqVO);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/get")
|
||||||
|
@Operation(summary = "获取租赁订单信息")
|
||||||
|
@Parameter(name = "orderNo", description = "订单编号", required = true)
|
||||||
|
CommonResult<RentalOrderDTO> getOrder(@RequestParam("orderNo") String orderNo);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.api.rental.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 租赁物品记录新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class RentalItemsRecordDTO {
|
||||||
|
|
||||||
|
@Schema(description = "租赁订单表单主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "订单编号不能为空")
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
|
@Schema(description = "租赁物品种类 | 字典值参考 system_rental_items_type", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "租赁物品种类不能为空")
|
||||||
|
private Integer rentalItemsType;
|
||||||
|
|
||||||
|
@Schema(description = "租赁数量", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "租赁数量不能为空")
|
||||||
|
private Integer number;
|
||||||
|
|
||||||
|
@Schema(description = "类型 | 1租借 2归还", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "类型不能为空")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
}
|
@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
@ -33,8 +35,11 @@ public class RentalDepositRecordApiImpl implements RentalDepositRecordApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<BigDecimal> getRecordAmount(String orderNo) {
|
public CommonResult<Map<String, BigDecimal>> getRecordAmount(String orderNo) {
|
||||||
RentalDepositAmountReqVO reqVO = rentalDepositRecordService.getRentalDepositRecordAmount(orderNo, false);
|
RentalDepositAmountReqVO reqVO = rentalDepositRecordService.getRentalDepositRecordAmount(orderNo, false);
|
||||||
return success(reqVO.getReceivedAmount());
|
Map<String, BigDecimal> result = new HashMap<>();
|
||||||
|
result.put("receivedAmount", reqVO.getReceivedAmount());
|
||||||
|
result.put("refundAmount", reqVO.getRefundAmount());
|
||||||
|
return success(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.api.rental;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.system.api.rental.dto.RentalDepositRecordDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.rental.dto.RentalItemsRecordDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.itemsrecord.RentalItemsRecordSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositAmountReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositRecordSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.rental.RentalDepositRecordService;
|
||||||
|
import cn.iocoder.yudao.module.system.service.rental.RentalItemsRecordService;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||||
|
@Validated
|
||||||
|
public class RentalItemsRecordApiImpl implements RentalItemsRecordApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RentalItemsRecordService rentalItemsRecordService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<Boolean> create(List<RentalItemsRecordDTO> createReqVO) {
|
||||||
|
rentalItemsRecordService.createRentalItemsRecordBath(BeanUtils.toBean(createReqVO, RentalItemsRecordSaveReqVO.class));
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.rental.dto.RentalOrderDTO;
|
import cn.iocoder.yudao.module.system.api.rental.dto.RentalOrderDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.rental.RentalOrderDO;
|
||||||
import cn.iocoder.yudao.module.system.service.rental.RentalOrderService;
|
import cn.iocoder.yudao.module.system.service.rental.RentalOrderService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -21,7 +22,13 @@ public class RentalOrderApiImpl implements RentalOrderApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommonResult<Boolean> updateOrder(RentalOrderDTO updateReqVO) {
|
public CommonResult<Boolean> updateOrder(RentalOrderDTO updateReqVO) {
|
||||||
rentalOrderService.update(BeanUtils.toBean(updateReqVO, RentalOrderSaveReqVO.class));
|
rentalOrderService.update(BeanUtils.toBean(updateReqVO, RentalOrderDO.class));
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<RentalOrderDTO> getOrder(String orderNo) {
|
||||||
|
RentalOrderDO rentalOrder = rentalOrderService.getRentalOrder(orderNo);
|
||||||
|
return success(BeanUtils.toBean(rentalOrder, RentalOrderDTO.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package cn.iocoder.yudao.module.system.controller.admin.rental;
|
package cn.iocoder.yudao.module.system.controller.admin.rental;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.oa.BpmOARefundApi;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOARefundDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.order.RentalOrderSaveReqVO;
|
||||||
@ -28,8 +31,12 @@ import javax.validation.Valid;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +55,9 @@ public class RentalOrderController {
|
|||||||
@Resource
|
@Resource
|
||||||
private RentalDepositRecordService rentalDepositRecordService;
|
private RentalDepositRecordService rentalDepositRecordService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOARefundApi refundApi;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建租赁订单")
|
@Operation(summary = "创建租赁订单")
|
||||||
@PreAuthorize("@ss.hasPermission('system:rental-order:create')")
|
@PreAuthorize("@ss.hasPermission('system:rental-order:create')")
|
||||||
@ -103,6 +113,22 @@ public class RentalOrderController {
|
|||||||
@PreAuthorize("@ss.hasPermission('system:rental-order:query')")
|
@PreAuthorize("@ss.hasPermission('system:rental-order:query')")
|
||||||
public CommonResult<PageResult<RentalOrderRespVO>> getRentalOrderPage(@Valid RentalOrderPageReqVO pageReqVO) {
|
public CommonResult<PageResult<RentalOrderRespVO>> getRentalOrderPage(@Valid RentalOrderPageReqVO pageReqVO) {
|
||||||
PageResult<RentalOrderRespVO> pageResult = rentalOrderService.getRentalOrderPage(pageReqVO);
|
PageResult<RentalOrderRespVO> pageResult = rentalOrderService.getRentalOrderPage(pageReqVO);
|
||||||
|
// 获取等待退款的订单号
|
||||||
|
List<String> orderNos = pageResult.getList().stream()
|
||||||
|
.filter(item -> Objects.equals(item.getStatus(), RentalOrderDO.WAITING_FOR_REFUND))
|
||||||
|
.map(RentalOrderRespVO::getOrderNo)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 获取订单号对应的退款申请
|
||||||
|
Map<String, BpmOARefundDTO> refundMap = refundApi.getListByOrderNo(orderNos).getCheckedData();
|
||||||
|
|
||||||
|
if (CollectionUtil.isNotEmpty(refundMap)) {
|
||||||
|
// 设置对应的订单号中的 申请退款和扣款金额
|
||||||
|
pageResult.getList().forEach(item -> {
|
||||||
|
item.setApplyRefundAmount(refundMap.get(item.getOrderNo()).getRefundAmount());
|
||||||
|
item.setApplyChargebacksAmount(refundMap.get(item.getOrderNo()).getChargebacksAmount());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return success(pageResult);
|
return success(pageResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,6 +43,12 @@ public class RentalOrderRespVO {
|
|||||||
@Schema(description = "扣款金额")
|
@Schema(description = "扣款金额")
|
||||||
private BigDecimal chargebacksAmount;
|
private BigDecimal chargebacksAmount;
|
||||||
|
|
||||||
|
@Schema(description = "申请退款金额")
|
||||||
|
private BigDecimal applyRefundAmount;
|
||||||
|
|
||||||
|
@Schema(description = "申请扣款金额")
|
||||||
|
private BigDecimal applyChargebacksAmount;
|
||||||
|
|
||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String notes;
|
private String notes;
|
||||||
|
|
||||||
|
@ -40,6 +40,9 @@ public class RentalDepositRecordSaveReqVO {
|
|||||||
@NotNull(message = "收款/退款金额不能为空")
|
@NotNull(message = "收款/退款金额不能为空")
|
||||||
private BigDecimal amount;
|
private BigDecimal amount;
|
||||||
|
|
||||||
|
@Schema(description = "扣款金额")
|
||||||
|
private BigDecimal chargebacksAmount;
|
||||||
|
|
||||||
@Schema(description = "收款/退款日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "收款/退款日期", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "收款/退款日期不能为空")
|
@NotNull(message = "收款/退款日期不能为空")
|
||||||
private LocalDate paymentDate;
|
private LocalDate paymentDate;
|
||||||
|
@ -23,6 +23,23 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class RentalOrderDO extends BaseDO {
|
public class RentalOrderDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 1 租赁中
|
||||||
|
*/
|
||||||
|
public static final Integer ON_LEASE = 1;
|
||||||
|
/**
|
||||||
|
* 状态 2 退款申请中
|
||||||
|
*/
|
||||||
|
public static final Integer REFUND_REQUESTED = 2;
|
||||||
|
/**
|
||||||
|
* 状态 3 等待退款中
|
||||||
|
*/
|
||||||
|
public static final Integer WAITING_FOR_REFUND = 3;
|
||||||
|
/**
|
||||||
|
* 状态 4 已退款
|
||||||
|
*/
|
||||||
|
public static final Integer REFUNDED = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租赁订单表单主键
|
* 租赁订单表单主键
|
||||||
*/
|
*/
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package cn.iocoder.yudao.module.system.framework.rpc.config;
|
package cn.iocoder.yudao.module.system.framework.rpc.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.bpm.api.model.BpmModelApi;
|
import cn.iocoder.yudao.module.bpm.api.model.BpmModelApi;
|
||||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAEntryApi;
|
import cn.iocoder.yudao.module.bpm.api.oa.*;
|
||||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAEvectionApi;
|
|
||||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAGoOutApi;
|
|
||||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAReplacementCardApi;
|
|
||||||
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||||
@ -14,6 +11,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class, ConfigApi.class,
|
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class, ConfigApi.class,
|
||||||
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class})
|
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class, BpmOARefundApi.class})
|
||||||
public class RpcConfiguration {
|
public class RpcConfiguration {
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,17 @@ package cn.iocoder.yudao.module.system.service.rental;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.bpm.api.oa.BpmOARefundApi;
|
||||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositAmountReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositAmountReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositRecordPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositRecordSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.rental.vo.rentaldepositrecord.RentalDepositRecordSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.rental.RentalDepositRecordDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.rental.RentalDepositRecordDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.rental.RentalOrderDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.rental.RentalDepositRecordMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.rental.RentalDepositRecordMapper;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -40,7 +43,11 @@ public class RentalDepositRecordServiceImpl implements RentalDepositRecordServic
|
|||||||
@Resource
|
@Resource
|
||||||
private FileApi fileApi;
|
private FileApi fileApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmOARefundApi refundApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createRentalDepositRecord(RentalDepositRecordSaveReqVO createReqVO) {
|
public Long createRentalDepositRecord(RentalDepositRecordSaveReqVO createReqVO) {
|
||||||
|
|
||||||
// 获取当前订单的 剩余押金金额
|
// 获取当前订单的 剩余押金金额
|
||||||
@ -60,11 +67,25 @@ public class RentalDepositRecordServiceImpl implements RentalDepositRecordServic
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
RentalOrderDO updateOrder = new RentalOrderDO();
|
||||||
// 押金退款
|
// 押金退款
|
||||||
// 判断当前退款金额 大于 实际已收的金额时
|
// 判断当前退款金额 + 扣款金额 大于 剩余已收金额时
|
||||||
if (amount.compareTo(createReqVO.getAmount()) < 0) {
|
BigDecimal refundAmount = createReqVO.getAmount().add(createReqVO.getChargebacksAmount() == null ? BigDecimal.ZERO : createReqVO.getChargebacksAmount());
|
||||||
|
if (amount.compareTo(refundAmount) < 0) {
|
||||||
throw exception(RENTAL_REFUND_AMOUNT_EXCESS);
|
throw exception(RENTAL_REFUND_AMOUNT_EXCESS);
|
||||||
|
} else if (amount.compareTo(refundAmount) == 0) { // 判断当前退款金额 是否等于 实际已收的金额 - 扣款金额时
|
||||||
|
// 更新订单状态为 已退款
|
||||||
|
updateOrder.setOrderNo(createReqVO.getOrderNo());
|
||||||
|
updateOrder.setStatus(RentalOrderDO.REFUNDED);
|
||||||
|
}else { // 判断当前退款金额 是否小于 实际已收的金额 - 扣款金额时
|
||||||
|
// 更新订单状态为 租赁中
|
||||||
|
updateOrder.setOrderNo(createReqVO.getOrderNo());
|
||||||
|
updateOrder.setStatus(RentalOrderDO.ON_LEASE);
|
||||||
}
|
}
|
||||||
|
// 同步更新 退款申请流程中的 退款状态
|
||||||
|
refundApi.updateStatus(createReqVO.getOrderNo());
|
||||||
|
// 同步更新 租赁订单状态
|
||||||
|
rentalOrderService.update(updateOrder);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public interface RentalOrderService {
|
|||||||
* 更新租赁订单
|
* 更新租赁订单
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void update(RentalOrderSaveReqVO updateReqVO);
|
void update(RentalOrderDO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除租赁订单
|
* 删除租赁订单
|
||||||
@ -52,6 +52,14 @@ public interface RentalOrderService {
|
|||||||
*/
|
*/
|
||||||
RentalOrderDO getRentalOrder(Long id);
|
RentalOrderDO getRentalOrder(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得租赁订单
|
||||||
|
*
|
||||||
|
* @param orderNo 订单编号
|
||||||
|
* @return 租赁订单
|
||||||
|
*/
|
||||||
|
RentalOrderDO getRentalOrder(String orderNo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得租赁订单分页
|
* 获得租赁订单分页
|
||||||
*
|
*
|
||||||
|
@ -119,15 +119,14 @@ public class RentalOrderServiceImpl implements RentalOrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(RentalOrderSaveReqVO updateReqVO) {
|
public void update(RentalOrderDO updateReqVO) {
|
||||||
Long count = rentalOrderMapper.selectCount(RentalOrderDO::getOrderNo, updateReqVO.getOrderNo());
|
Long count = rentalOrderMapper.selectCount(RentalOrderDO::getOrderNo, updateReqVO.getOrderNo());
|
||||||
if (count <= 0L) {
|
if (count <= 0L) {
|
||||||
throw exception(RENTAL_ORDER_NOT_EXISTS);
|
throw exception(RENTAL_ORDER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
RentalOrderDO updateObj = BeanUtils.toBean(updateReqVO, RentalOrderDO.class);
|
rentalOrderMapper.update(updateReqVO, new LambdaQueryWrapperX<RentalOrderDO>()
|
||||||
rentalOrderMapper.update(updateObj, new LambdaQueryWrapperX<RentalOrderDO>()
|
|
||||||
.eq(RentalOrderDO::getOrderNo, updateReqVO.getOrderNo()));
|
.eq(RentalOrderDO::getOrderNo, updateReqVO.getOrderNo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,9 +146,16 @@ public class RentalOrderServiceImpl implements RentalOrderService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RentalOrderDO getRentalOrder(Long id) {
|
public RentalOrderDO getRentalOrder(Long id) {
|
||||||
|
|
||||||
return rentalOrderMapper.selectById(id);
|
return rentalOrderMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RentalOrderDO getRentalOrder(String orderNo) {
|
||||||
|
|
||||||
|
return rentalOrderMapper.selectOne(RentalOrderDO::getOrderNo, orderNo);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<RentalOrderRespVO> getRentalOrderPage(RentalOrderPageReqVO pageReqVO) {
|
public PageResult<RentalOrderRespVO> getRentalOrderPage(RentalOrderPageReqVO pageReqVO) {
|
||||||
return rentalOrderMapper.selectPage(pageReqVO);
|
return rentalOrderMapper.selectPage(pageReqVO);
|
||||||
@ -158,7 +164,7 @@ public class RentalOrderServiceImpl implements RentalOrderService {
|
|||||||
@Override
|
@Override
|
||||||
@Cacheable(value = RedisKeyConstants.RENTAL_ORDER_AMOUNT, key = "#orderNo", unless = "#result == null")
|
@Cacheable(value = RedisKeyConstants.RENTAL_ORDER_AMOUNT, key = "#orderNo", unless = "#result == null")
|
||||||
public BigDecimal getOrderAmount(String orderNo) {
|
public BigDecimal getOrderAmount(String orderNo) {
|
||||||
|
|
||||||
return rentalOrderMapper.selectOrderAmount(orderNo);
|
return rentalOrderMapper.selectOrderAmount(orderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -19,6 +19,8 @@
|
|||||||
WHERE
|
WHERE
|
||||||
order_no = #{orderNo}
|
order_no = #{orderNo}
|
||||||
AND deleted = 0
|
AND deleted = 0
|
||||||
|
GROUP BY
|
||||||
|
rental_items_type
|
||||||
<if test="isUpdate">
|
<if test="isUpdate">
|
||||||
FOR UPDATE
|
FOR UPDATE
|
||||||
</if>
|
</if>
|
||||||
|
Loading…
Reference in New Issue
Block a user