- 前端:支付单列表
- 前端:退款单列表
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package cn.iocoder.mall.pay.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayRefundService;
|
||||
import cn.iocoder.mall.pay.api.PayTransactionService;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundPageBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundPageDTO;
|
||||
import cn.iocoder.mall.pay.application.convert.PayRefundConvert;
|
||||
import cn.iocoder.mall.pay.application.vo.admins.AdminsPayRefundPageVO;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/refund")
|
||||
public class AdminsPayRefundController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.PayRefundService.version}")
|
||||
private PayRefundService payRefundService;
|
||||
@Reference(validation = "true", version = "${dubbo.provider.PayTransactionService.version}")
|
||||
private PayTransactionService payTransactionService;
|
||||
|
||||
@GetMapping("/page")
|
||||
public CommonResult<AdminsPayRefundPageVO> page(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "createBeginTime", required = false) Date createBeginTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "createEndTime", required = false) Date createEndTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "finishBeginTime", required = false) Date finishBeginTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "finishEndTime", required = false) Date finishEndTime,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "payChannel", required = false) Integer payChannel,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
PayRefundPageDTO payRefundPageDTO = new PayRefundPageDTO()
|
||||
.setCreateBeginTime(createBeginTime).setCreateEndTime(createEndTime)
|
||||
.setFinishBeginTime(finishBeginTime).setFinishEndTime(finishEndTime)
|
||||
.setStatus(status).setPayChannel(payChannel)
|
||||
.setPageNo(pageNo).setPageSize(pageSize);
|
||||
// 执行查询
|
||||
PayRefundPageBO refundBOPage = payRefundService.getRefundPage(payRefundPageDTO);
|
||||
AdminsPayRefundPageVO result = new AdminsPayRefundPageVO()
|
||||
.setList(PayRefundConvert.INSTANCE.convertList(refundBOPage.getList()))
|
||||
.setTotal(refundBOPage.getTotal());
|
||||
if (result.getList().isEmpty()) {
|
||||
return success(result);
|
||||
}
|
||||
// 拼接结果
|
||||
Map<Integer, PayTransactionBO> transactionMap = payTransactionService.getTransactionList(
|
||||
result.getList().stream().map(PayRefundBO::getTransactionId).collect(Collectors.toSet()))
|
||||
.stream().collect(Collectors.toMap(PayTransactionBO::getId, transaction -> transaction));
|
||||
result.getList().forEach(refund -> refund.setTransaction(transactionMap.get(refund.getTransactionId())));
|
||||
return success(result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.mall.pay.application.controller.admins;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayTransactionService;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionPageBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionPageDTO;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admins/transaction")
|
||||
public class AdminsPayTransactionController {
|
||||
|
||||
@Reference(validation = "true", version = "${dubbo.provider.PayTransactionService.version}")
|
||||
private PayTransactionService payTransactionService;
|
||||
|
||||
@GetMapping("/page")
|
||||
public CommonResult<PayTransactionPageBO> page(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "createBeginTime", required = false) Date createBeginTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "createEndTime", required = false) Date createEndTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "paymentBeginTime", required = false) Date paymentBeginTime,
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@RequestParam(value = "paymentEndTime", required = false) Date paymentEndTime,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "hasRefund", required = false) Boolean hasRefund,
|
||||
@RequestParam(value = "payChannel", required = false) Integer payChannel,
|
||||
@RequestParam(value = "orderSubject", required = false) String orderSubject,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
PayTransactionPageDTO payTransactionPageDTO = new PayTransactionPageDTO()
|
||||
.setCreateBeginTime(createBeginTime).setCreateEndTime(createEndTime)
|
||||
.setPaymentBeginTime(paymentBeginTime).setPaymentEndTime(paymentEndTime)
|
||||
.setStatus(status).setHasRefund(hasRefund)
|
||||
.setPayChannel(payChannel).setOrderSubject(orderSubject)
|
||||
.setPageNo(pageNo).setPageSize(pageSize);
|
||||
// 执行查询
|
||||
return success(payTransactionService.getTransactionPage(payTransactionPageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package cn.iocoder.mall.pay.application.controller.users;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayRefundService;
|
||||
import cn.iocoder.mall.pay.api.constant.PayChannelEnum;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -17,11 +17,11 @@ import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("users/refund") // TODO 芋艿,理论来说,是用户无关的。这里先酱紫先~
|
||||
public class PayRefundController {
|
||||
public class UsersPayRefundController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
@Reference(validation = "true", version = "${dubbo.provider.PayRefundService.version}")
|
||||
private PayRefundService payRefundService;
|
||||
|
||||
@PostMapping(value = "pingxx_refund_success", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@@ -20,14 +20,15 @@ import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("users/transaction") // TODO 芋艿,理论来说,是用户无关的。这里先酱紫先~
|
||||
public class PayTransactionController {
|
||||
public class UsersPayTransactionController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Reference(validation = "true")
|
||||
@Reference(validation = "true", version = "${dubbo.provider.PayTransactionService.version}")
|
||||
private PayTransactionService payTransactionService;
|
||||
|
||||
@GetMapping("/get")
|
||||
// TODO result 后面改下
|
||||
public CommonResult<PayTransactionBO> get(@RequestParam("appId") String appId,
|
||||
@RequestParam("orderId") String orderId) {
|
||||
return payTransactionService.getTransaction(UserSecurityContextHolder.getContext().getUserId(), appId, orderId);
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.pay.application.convert;
|
||||
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundBO;
|
||||
import cn.iocoder.mall.pay.application.vo.admins.AdminsPayRefundDetailVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PayRefundConvert {
|
||||
|
||||
PayRefundConvert INSTANCE = Mappers.getMapper(PayRefundConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<AdminsPayRefundDetailVO> convertList(List<PayRefundBO> refunds);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.pay.application.vo.admins;
|
||||
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付退款详细 VO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsPayRefundDetailVO extends PayRefundBO { // TODO 芋艿,暂时偷懒下
|
||||
|
||||
/**
|
||||
* 支付交易
|
||||
*/
|
||||
private PayTransactionBO transaction;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.pay.application.vo.admins;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付退款 Page VO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsPayRefundPageVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 支付退款数组
|
||||
*/
|
||||
private List<AdminsPayRefundDetailVO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package cn.iocoder.mall.pay.api;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundPageBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundSubmitBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundPageDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundSubmitDTO;
|
||||
|
||||
public interface PayRefundService {
|
||||
@@ -20,4 +22,6 @@ public interface PayRefundService {
|
||||
*/
|
||||
CommonResult<Boolean> updateRefundSuccess(Integer payChannel, String params);
|
||||
|
||||
PayRefundPageBO getRefundPage(PayRefundPageDTO payRefundPageDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,15 @@ package cn.iocoder.mall.pay.api;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionPageBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionSubmitBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionPageDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface PayTransactionService {
|
||||
|
||||
CommonResult<PayTransactionBO> getTransaction(Integer userId, String appId, String orderId);
|
||||
@@ -26,6 +31,10 @@ public interface PayTransactionService {
|
||||
*/
|
||||
CommonResult<Boolean> updateTransactionPaySuccess(Integer payChannel, String params);
|
||||
|
||||
List<PayTransactionBO> getTransactionList(Collection<Integer> ids);
|
||||
|
||||
PayTransactionPageBO getTransactionPage(PayTransactionPageDTO payTransactionPageDTO);
|
||||
|
||||
CommonResult cancelTransaction(); // TODO 1. params 2. result
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package cn.iocoder.mall.pay.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付退款 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundBO {
|
||||
|
||||
/**
|
||||
* 编号,自增
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 支付交易编号
|
||||
*/
|
||||
private Integer transactionId;
|
||||
/**
|
||||
* 生成传输给第三方的退款号
|
||||
*
|
||||
* 唯一索引
|
||||
*/
|
||||
private String refundCode;
|
||||
/**
|
||||
* 应用编号
|
||||
*
|
||||
* 不同业务线分配不同的 appId
|
||||
* 举个例子,
|
||||
* 1. 电商系统的订单,appId = 1024
|
||||
* 2. 活动系统的订单,appId = 2048
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 业务线的订单编号
|
||||
*
|
||||
* 1. 使用 String 的原因是,业务线可能使用 String 做为编号
|
||||
* 2. 每个 appId 下,orderId 唯一
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 发起交易的 IP
|
||||
*/
|
||||
private String createIp;
|
||||
/**
|
||||
* 业务退款描述
|
||||
*/
|
||||
private String orderDescription;
|
||||
/**
|
||||
* 退款金额,单位:分。
|
||||
*
|
||||
* TODO 暂时不考虑货币类型。
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 退款状态
|
||||
*
|
||||
* @see cn.iocoder.mall.pay.api.constant.PayRefundStatus
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 回调业务线完成时间
|
||||
*/
|
||||
private Date finishTime;
|
||||
/**
|
||||
* 异步通知地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 扩展内容
|
||||
*
|
||||
* 异步通知的时候填充回调的数据
|
||||
*/
|
||||
private String extensionData;
|
||||
/**
|
||||
* 退款渠道
|
||||
*/
|
||||
private Integer refundChannel;
|
||||
/**
|
||||
* 第三方退款成功的时间
|
||||
*/
|
||||
private Date refundTime;
|
||||
/**
|
||||
* 收到第三方系统通知的时间
|
||||
*
|
||||
* 一般情况下,即第三方系统的异步通知
|
||||
*/
|
||||
private Date notifyTime;
|
||||
/**
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.pay.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付退款 Page BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundPageBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 支付退款数组
|
||||
*/
|
||||
private List<PayRefundBO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
|
||||
}
|
||||
@@ -92,4 +92,11 @@ public class PayTransactionBO implements Serializable {
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
// ========== 退款相关 ==========
|
||||
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.pay.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付交易 Page BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionPageBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 支付交易数组
|
||||
*/
|
||||
private List<PayTransactionBO> list;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private Integer total;
|
||||
|
||||
}
|
||||
@@ -6,9 +6,9 @@ package cn.iocoder.mall.pay.api.constant;
|
||||
public enum PayChannelEnum {
|
||||
|
||||
WEIXIN_APP(100, "wx", "微信 App 支付"),
|
||||
WEIXIN_PUB(100, "wx", "微信 JS API 支付"),
|
||||
WEIXIN_PUB(101, "wxjs", "微信 JS API 支付"),
|
||||
|
||||
ALIPAY(200, "alipay", "微信支付"),
|
||||
ALIPAY(200, "alipay", "支付宝 App 支付"),
|
||||
|
||||
PINGXX(9999, "ping++", "ping++ 支付"),
|
||||
;
|
||||
@@ -44,4 +44,4 @@ public enum PayChannelEnum {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.iocoder.mall.pay.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付退款分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayRefundPageDTO {
|
||||
|
||||
/**
|
||||
* 创建时间(开始)
|
||||
*/
|
||||
private Date createBeginTime;
|
||||
/**
|
||||
* 创建时间(结束)
|
||||
*/
|
||||
private Date createEndTime;
|
||||
/**
|
||||
* 完成时间(开始)
|
||||
*/
|
||||
private Date finishBeginTime;
|
||||
/**
|
||||
* 完成时间(结束)
|
||||
*/
|
||||
private Date finishEndTime;
|
||||
/**
|
||||
* 退款状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.iocoder.mall.pay.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付交易分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionPageDTO {
|
||||
|
||||
/**
|
||||
* 创建时间(开始)
|
||||
*/
|
||||
private Date createBeginTime;
|
||||
/**
|
||||
* 创建时间(结束)
|
||||
*/
|
||||
private Date createEndTime;
|
||||
/**
|
||||
* 支付时间(开始)
|
||||
*/
|
||||
private Date paymentBeginTime;
|
||||
/**
|
||||
* 支付时间(结束)
|
||||
*/
|
||||
private Date paymentEndTime;
|
||||
/**
|
||||
* 支付状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否有退款
|
||||
*/
|
||||
private Boolean hasRefund;
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 商品标题
|
||||
*
|
||||
* 模糊匹配
|
||||
*/
|
||||
private String orderSubject;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package cn.iocoder.mall.pay.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundBO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundSubmitDTO;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayRefundDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PayRefundConvert {
|
||||
|
||||
@@ -14,4 +17,10 @@ public interface PayRefundConvert {
|
||||
@Mappings({})
|
||||
PayRefundDO convert(PayRefundSubmitDTO payRefundSubmitDTO);
|
||||
|
||||
@Mappings({})
|
||||
PayRefundBO convert(PayRefundDO refund);
|
||||
|
||||
@Mappings({})
|
||||
List<PayRefundBO> convertList(List<PayRefundDO> refunds);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PayTransactionConvert {
|
||||
|
||||
@@ -20,6 +22,9 @@ public interface PayTransactionConvert {
|
||||
@Mappings({})
|
||||
PayTransactionBO convert(PayTransactionDO payTransactionDO);
|
||||
|
||||
@Mappings({})
|
||||
List<PayTransactionBO> convertList(List<PayTransactionDO> list);
|
||||
|
||||
@Mappings({})
|
||||
PayTransactionExtensionDO convert(PayTransactionSubmitDTO payTransactionSubmitDTO);
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@ import cn.iocoder.mall.pay.biz.dataobject.PayRefundDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface PayRefundMapper {
|
||||
|
||||
@@ -16,4 +19,20 @@ public interface PayRefundMapper {
|
||||
|
||||
PayRefundDO selectByRefundCode(@Param("refundCode") String refundCode);
|
||||
|
||||
List<PayRefundDO> selectListByPage(@Param("createBeginTime") Date createBeginTime,
|
||||
@Param("createEndTime") Date createEndTime,
|
||||
@Param("finishBeginTime") Date finishBeginTime,
|
||||
@Param("finishEndTime") Date finishEndTime,
|
||||
@Param("status") Integer status,
|
||||
@Param("payChannel") Integer payChannel,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByPage(@Param("createBeginTime") Date createBeginTime,
|
||||
@Param("createEndTime") Date createEndTime,
|
||||
@Param("finishBeginTime") Date finishBeginTime,
|
||||
@Param("finishEndTime") Date finishEndTime,
|
||||
@Param("status") Integer status,
|
||||
@Param("payChannel") Integer payChannel);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface PayTransactionMapper {
|
||||
|
||||
@@ -20,4 +24,26 @@ public interface PayTransactionMapper {
|
||||
|
||||
PayTransactionDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<PayTransactionDO> selectListByIds(@Param("ids") Collection<Integer> ids);
|
||||
|
||||
List<PayTransactionDO> selectListByPage(@Param("createBeginTime") Date createBeginTime,
|
||||
@Param("createEndTime") Date createEndTime,
|
||||
@Param("paymentBeginTime") Date paymentBeginTime,
|
||||
@Param("paymentEndTime") Date paymentEndTime,
|
||||
@Param("status") Integer status,
|
||||
@Param("hasRefund") Boolean hasRefund,
|
||||
@Param("payChannel") Integer payChannel,
|
||||
@Param("orderSubject") String orderSubject,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByPage(@Param("createBeginTime") Date createBeginTime,
|
||||
@Param("createEndTime") Date createEndTime,
|
||||
@Param("paymentBeginTime") Date paymentBeginTime,
|
||||
@Param("paymentEndTime") Date paymentEndTime,
|
||||
@Param("status") Integer status,
|
||||
@Param("hasRefund") Boolean hasRefund,
|
||||
@Param("payChannel") Integer payChannel,
|
||||
@Param("orderSubject") String orderSubject);
|
||||
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import cn.iocoder.common.framework.util.MathUtil;
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayRefundService;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundPageBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayRefundSubmitBO;
|
||||
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
|
||||
import cn.iocoder.mall.pay.api.constant.PayRefundStatus;
|
||||
import cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundPageDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayRefundSubmitDTO;
|
||||
import cn.iocoder.mall.pay.biz.client.AbstractPaySDK;
|
||||
import cn.iocoder.mall.pay.biz.client.PaySDKFactory;
|
||||
@@ -30,7 +32,7 @@ import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.PayRefundService.version}")
|
||||
public class PayRefundServiceImpl implements PayRefundService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@@ -120,6 +122,7 @@ public class PayRefundServiceImpl implements PayRefundService {
|
||||
PayRefundDO updatePayRefundDO = new PayRefundDO()
|
||||
.setId(payRefund.getId())
|
||||
.setStatus(status)
|
||||
.setTradeNo(paySuccessResult.getData().getTradeNo())
|
||||
.setExtensionData(params);
|
||||
int updateCounts = payRefundMapper.update(updatePayRefundDO, PayRefundStatus.WAITING.getValue());
|
||||
if (updateCounts == 0) { // 校验状态,必须是待支付
|
||||
@@ -147,6 +150,24 @@ public class PayRefundServiceImpl implements PayRefundService {
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayRefundPageBO getRefundPage(PayRefundPageDTO payRefundPageDTO) {
|
||||
PayRefundPageBO payRefundPageBO = new PayRefundPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (payRefundPageDTO.getPageNo() - 1) * payRefundPageDTO.getPageSize();
|
||||
payRefundPageBO.setList(PayRefundConvert.INSTANCE.convertList(payRefundMapper.selectListByPage(
|
||||
payRefundPageDTO.getCreateBeginTime(), payRefundPageDTO.getCreateEndTime(),
|
||||
payRefundPageDTO.getFinishBeginTime(), payRefundPageDTO.getFinishEndTime(),
|
||||
payRefundPageDTO.getStatus(), payRefundPageDTO.getPayChannel(),
|
||||
offset, payRefundPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
payRefundPageBO.setTotal(payRefundMapper.selectCountByPage(
|
||||
payRefundPageDTO.getCreateBeginTime(), payRefundPageDTO.getCreateEndTime(),
|
||||
payRefundPageDTO.getFinishBeginTime(), payRefundPageDTO.getFinishEndTime(),
|
||||
payRefundPageDTO.getStatus(), payRefundPageDTO.getPayChannel()));
|
||||
return payRefundPageBO;
|
||||
}
|
||||
|
||||
private String generateTransactionCode() {
|
||||
// wx
|
||||
// 2014
|
||||
|
||||
@@ -6,18 +6,20 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.pay.api.PayTransactionService;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionPageBO;
|
||||
import cn.iocoder.mall.pay.api.bo.PayTransactionSubmitBO;
|
||||
import cn.iocoder.mall.pay.api.constant.PayErrorCodeEnum;
|
||||
import cn.iocoder.mall.pay.api.constant.PayTransactionStatusEnum;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionCreateDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionPageDTO;
|
||||
import cn.iocoder.mall.pay.api.dto.PayTransactionSubmitDTO;
|
||||
import cn.iocoder.mall.pay.biz.client.AbstractPaySDK;
|
||||
import cn.iocoder.mall.pay.biz.client.PaySDKFactory;
|
||||
import cn.iocoder.mall.pay.biz.client.TransactionSuccessBO;
|
||||
import cn.iocoder.mall.pay.biz.convert.PayTransactionConvert;
|
||||
import cn.iocoder.mall.pay.biz.dao.PayNotifyTaskMapper;
|
||||
import cn.iocoder.mall.pay.biz.dao.PayTransactionExtensionMapper;
|
||||
import cn.iocoder.mall.pay.biz.dao.PayTransactionMapper;
|
||||
import cn.iocoder.mall.pay.biz.dao.PayNotifyTaskMapper;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayAppDO;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO;
|
||||
import cn.iocoder.mall.pay.biz.dataobject.PayTransactionExtensionDO;
|
||||
@@ -27,10 +29,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true")
|
||||
@org.apache.dubbo.config.annotation.Service(validation = "true", version = "${dubbo.provider.PayTransactionService.version}")
|
||||
public class PayTransactionServiceImpl implements PayTransactionService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@@ -193,6 +197,31 @@ public class PayTransactionServiceImpl implements PayTransactionService {
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayTransactionBO> getTransactionList(Collection<Integer> ids) {
|
||||
return PayTransactionConvert.INSTANCE.convertList(payTransactionMapper.selectListByIds(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayTransactionPageBO getTransactionPage(PayTransactionPageDTO payTransactionPageDTO) {
|
||||
PayTransactionPageBO payTransactionPage = new PayTransactionPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (payTransactionPageDTO.getPageNo() - 1) * payTransactionPageDTO.getPageSize();
|
||||
payTransactionPage.setList(PayTransactionConvert.INSTANCE.convertList(payTransactionMapper.selectListByPage(
|
||||
payTransactionPageDTO.getCreateBeginTime(), payTransactionPageDTO.getCreateEndTime(),
|
||||
payTransactionPageDTO.getPaymentBeginTime(), payTransactionPageDTO.getPaymentEndTime(),
|
||||
payTransactionPageDTO.getStatus(), payTransactionPageDTO.getHasRefund(),
|
||||
payTransactionPageDTO.getPayChannel(), payTransactionPageDTO.getOrderSubject(),
|
||||
offset, payTransactionPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
payTransactionPage.setTotal(payTransactionMapper.selectCountByPage(
|
||||
payTransactionPageDTO.getCreateBeginTime(), payTransactionPageDTO.getCreateEndTime(),
|
||||
payTransactionPageDTO.getPaymentBeginTime(), payTransactionPageDTO.getPaymentEndTime(),
|
||||
payTransactionPageDTO.getStatus(), payTransactionPageDTO.getHasRefund(),
|
||||
payTransactionPageDTO.getPayChannel(), payTransactionPageDTO.getOrderSubject()));
|
||||
return payTransactionPage;
|
||||
}
|
||||
|
||||
@Override // TODO 芋艿,后面去实现
|
||||
public CommonResult cancelTransaction() {
|
||||
return null;
|
||||
|
||||
@@ -23,6 +23,11 @@ dubbo:
|
||||
name: dubbo
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.pay.biz.service
|
||||
provider:
|
||||
PayTransactionService:
|
||||
version: 1.0.0
|
||||
PayRefundService:
|
||||
version: 1.0.0
|
||||
|
||||
# rocketmq
|
||||
rocketmq:
|
||||
|
||||
@@ -66,4 +66,57 @@
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectListByPage" resultType="PayRefundDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM refund
|
||||
<where>
|
||||
<if test="createBeginTime != null">
|
||||
AND create_time >= #{createBeginTime}
|
||||
</if>
|
||||
<if test="createEndTime != null">
|
||||
AND #{createEndTime} >= create_time
|
||||
</if>
|
||||
<if test="finishBeginTime != null">
|
||||
AND finish_time >= #{finishBeginTime}
|
||||
</if>
|
||||
<if test="finishEndTime != null">
|
||||
AND #{finishEndTime} >= finish_time
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="payChannel != null">
|
||||
AND pay_channel = #{payChannel}
|
||||
</if>
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByPage" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM refund
|
||||
<where>
|
||||
<if test="createBeginTime != null">
|
||||
AND create_time >= #{createBeginTime}
|
||||
</if>
|
||||
<if test="createEndTime != null">
|
||||
AND #{createEndTime} >= create_time
|
||||
</if>
|
||||
<if test="finishBeginTime != null">
|
||||
AND finish_time >= #{finishBeginTime}
|
||||
</if>
|
||||
<if test="finishEndTime != null">
|
||||
AND #{finishEndTime} >= finish_time
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="payChannel != null">
|
||||
AND pay_channel = #{payChannel}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -75,4 +75,85 @@
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectListByIds" resultType="PayTransactionDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM transaction
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="ids" separator="," open="(" close=")" index="">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectListByPage" resultType="PayTransactionDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM transaction
|
||||
<where>
|
||||
<if test="createBeginTime != null">
|
||||
AND create_time >= #{createBeginTime}
|
||||
</if>
|
||||
<if test="createEndTime != null">
|
||||
AND #{createEndTime} >= create_time
|
||||
</if>
|
||||
<if test="paymentBeginTime != null">
|
||||
AND payment_time >= #{paymentBeginTime}
|
||||
</if>
|
||||
<if test="paymentEndTime != null">
|
||||
AND #{paymentEndTime} >= payment_time
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="hasRefund == true">
|
||||
AND refund_total > 0
|
||||
</if>
|
||||
<if test="hasRefund == false">
|
||||
AND refund_total = 0
|
||||
</if>
|
||||
<if test="payChannel != null">
|
||||
AND pay_channel = #{payChannel}
|
||||
</if>
|
||||
<if test="orderSubject != null">
|
||||
order_subject LIKE "%"#{orderSubject}"%"
|
||||
</if>
|
||||
</where>
|
||||
LIMIT #{offset}, #{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectCountByPage" resultType="Integer">
|
||||
SELECT
|
||||
COUNT(1)
|
||||
FROM transaction
|
||||
<where>
|
||||
<if test="createBeginTime != null">
|
||||
AND create_time >= #{createBeginTime}
|
||||
</if>
|
||||
<if test="createEndTime != null">
|
||||
AND #{createEndTime} >= create_time
|
||||
</if>
|
||||
<if test="paymentBeginTime != null">
|
||||
AND payment_time >= #{paymentBeginTime}
|
||||
</if>
|
||||
<if test="paymentEndTime != null">
|
||||
AND #{paymentEndTime} >= payment_time
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="hasRefund == true">
|
||||
AND refund_total > 0
|
||||
</if>
|
||||
<if test="hasRefund == false">
|
||||
AND refund_total = 0
|
||||
</if>
|
||||
<if test="payChannel != null">
|
||||
AND pay_channel = #{payChannel}
|
||||
</if>
|
||||
<if test="orderSubject != null">
|
||||
order_subject LIKE "%"#{orderSubject}"%"
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user