pay:示例订单,接入退款回调逻辑
parent
eb660ca619
commit
44b0346e5e
@ -1,47 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.refund;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.refund.vo.AppPayRefundReqVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.refund.vo.AppPayRefundRespVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.convert.refund.PayRefundConvert;
|
|
||||||
import cn.iocoder.yudao.module.pay.service.order.dto.PayRefundReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.pay.service.refund.PayRefundService;
|
|
||||||
import cn.iocoder.yudao.module.pay.util.PaySeqUtils;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
|
||||||
|
|
||||||
@Tag(name = "用户 APP - 退款订单")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/pay/refund")
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
public class AppPayRefundController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PayRefundService refundService;
|
|
||||||
|
|
||||||
@PostMapping("/refund")
|
|
||||||
@Operation(summary = "提交退款订单")
|
|
||||||
public CommonResult<AppPayRefundRespVO> submitRefundOrder(@RequestBody AppPayRefundReqVO reqVO){
|
|
||||||
PayRefundReqDTO req = PayRefundConvert.INSTANCE.convert(reqVO);
|
|
||||||
req.setUserIp(getClientIP());
|
|
||||||
// TODO 测试暂时模拟生成商户退款订单
|
|
||||||
if(StrUtil.isEmpty(reqVO.getMerchantRefundId())) {
|
|
||||||
req.setMerchantRefundId(PaySeqUtils.genMerchantRefundNo());
|
|
||||||
}
|
|
||||||
return success(PayRefundConvert.INSTANCE.convert(refundService.submitRefundOrder(req)));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.refund.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 退款订单 Req VO")
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AppPayRefundReqVO {
|
|
||||||
|
|
||||||
@Schema(description = "支付订单编号自增", required = true, example = "10")
|
|
||||||
@NotNull(message = "支付订单编号自增")
|
|
||||||
private Long payOrderId;
|
|
||||||
|
|
||||||
@Schema(description = "退款金额", required = true, example = "1")
|
|
||||||
@NotNull(message = "退款金额")
|
|
||||||
private Long amount;
|
|
||||||
|
|
||||||
@Schema(description = "退款原因", required = true, example = "不喜欢")
|
|
||||||
@NotEmpty(message = "退款原因")
|
|
||||||
private String reason;
|
|
||||||
|
|
||||||
@Schema(description = "商户退款订单号", required = true, example = "MR202111180000000001")
|
|
||||||
//TODO 测试暂时模拟生成
|
|
||||||
//@NotEmpty(message = "商户退款订单号")
|
|
||||||
private String merchantRefundId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.refund.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 提交退款订单 Response VO")
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AppPayRefundRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "退款订单编号", required = true, example = "10")
|
|
||||||
private Long refundId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.service.order.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import javax.validation.constraints.DecimalMin;
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
// TODO 芋艿:可能需要改造
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款申请单 Request DTO
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class PayRefundReqDTO {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付订单编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "支付订单编号不能为空")
|
|
||||||
private Long payOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款金额
|
|
||||||
*/
|
|
||||||
@NotNull(message = "退款金额不能为空")
|
|
||||||
@DecimalMin(value = "0", inclusive = false, message = "退款金额必须大于零")
|
|
||||||
private Integer amount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 退款原因
|
|
||||||
*/
|
|
||||||
private String reason;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 商户退款订单号
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "商户退款订单号不能为空")
|
|
||||||
private String merchantRefundId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户 IP
|
|
||||||
*/
|
|
||||||
private String userIp;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue