1. 增加支付交易分页 API 接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
|
||||
|
||||
/**
|
||||
@@ -40,4 +41,12 @@ public interface PayTransactionRpc {
|
||||
*/
|
||||
CommonResult<Boolean> updatePayTransactionSuccess(PayTransactionSuccessReqDTO successReqDTO);
|
||||
|
||||
/**
|
||||
* 获得交易支付单分页
|
||||
*
|
||||
* @param pageReqDTO 分页条件
|
||||
* @return 交易支付单分页
|
||||
*/
|
||||
CommonResult<PageResult<PayTransactionRespDTO>> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 支付交易分页 Request DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class PayTransactionPageReqDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 创建时间(开始)
|
||||
*/
|
||||
private Date createBeginTime;
|
||||
/**
|
||||
* 创建时间(结束)
|
||||
*/
|
||||
private Date createEndTime;
|
||||
/**
|
||||
* 支付时间(开始)
|
||||
*/
|
||||
private Date paymentBeginTime;
|
||||
/**
|
||||
* 支付时间(结束)
|
||||
*/
|
||||
private Date paymentEndTime;
|
||||
/**
|
||||
* 支付状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 是否有退款
|
||||
*/
|
||||
private Boolean hasRefund;
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
/**
|
||||
* 商品标题
|
||||
*
|
||||
* 模糊匹配
|
||||
*/
|
||||
private String orderSubject;
|
||||
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
package cn.iocoder.mall.payservice.convert.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionExtensionDO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionCreateReqDTO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionRespDTO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionSubmitReqDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
@@ -19,4 +22,7 @@ public interface PayTransactionConvert {
|
||||
|
||||
PayTransactionRespDTO convert(PayTransactionDO bean);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<PayTransactionRespDTO> convertPage(IPage<PayTransactionDO> bean);
|
||||
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class PayTransactionDO extends DeletableDO {
|
||||
* 支付成功的支付渠道
|
||||
*/
|
||||
private Integer payChannel;
|
||||
|
||||
/**
|
||||
* 第三方支付成功的时间
|
||||
*/
|
||||
@@ -91,17 +92,12 @@ public class PayTransactionDO extends DeletableDO {
|
||||
* 第三方的流水号
|
||||
*/
|
||||
private String tradeNo;
|
||||
|
||||
// ========== 退款相关 ==========
|
||||
|
||||
/**
|
||||
* 退款总金额
|
||||
*/
|
||||
private Integer refundTotal;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,53 +1,36 @@
|
||||
package cn.iocoder.mall.payservice.dal.mysql.mapper.transaction;
|
||||
|
||||
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.mybatis.core.util.PageUtil;
|
||||
import cn.iocoder.mall.payservice.dal.mysql.dataobject.transaction.PayTransactionDO;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.PayTransactionPageReqDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PayTransactionMapper extends BaseMapper<PayTransactionDO> {
|
||||
//
|
||||
// UPDATE `transaction`
|
||||
// SET refund_total = refund_total + ${refundTotalIncr}
|
||||
// WHERE price >= refund_total + ${refundTotalIncr}
|
||||
//
|
||||
|
||||
// int updateForRefundTotal(@Param("id") Integer id,
|
||||
// @Param("refundTotalIncr") Integer refundTotalIncr);
|
||||
|
||||
// <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>
|
||||
|
||||
// default IPage<PayTransactionDO> selectPage(TransactionPageBO pageBO) {
|
||||
// return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
// new QueryWrapperX<PayTransactionDO>());
|
||||
// }
|
||||
default IPage<PayTransactionDO> selectPage(PayTransactionPageReqDTO pageReqDTO) {
|
||||
QueryWrapperX<PayTransactionDO> query = new QueryWrapperX<PayTransactionDO>()
|
||||
.betweenIfPresent("create_time", pageReqDTO.getCreateBeginTime(), pageReqDTO.getPaymentEndTime())
|
||||
.betweenIfPresent("payment_time", pageReqDTO.getPaymentBeginTime(), pageReqDTO.getPaymentEndTime())
|
||||
.eqIfPresent("status", pageReqDTO.getStatus())
|
||||
.eqIfPresent("payChannel", pageReqDTO.getPayChannel())
|
||||
.likeIfPresent("order_subject", pageReqDTO.getOrderSubject());
|
||||
if (pageReqDTO.getHasRefund() != null) {
|
||||
if (pageReqDTO.getHasRefund()) {
|
||||
query.gt("refund_total", 0);
|
||||
} else {
|
||||
query.eq("refund_total", 0);
|
||||
}
|
||||
}
|
||||
return selectPage(PageUtil.build(pageReqDTO), query);
|
||||
}
|
||||
|
||||
default int update(PayTransactionDO entity, Integer whereStatus) {
|
||||
return update(entity, new QueryWrapper<PayTransactionDO>()
|
||||
@@ -59,4 +42,6 @@ public interface PayTransactionMapper extends BaseMapper<PayTransactionDO> {
|
||||
.eq("order_id", orderId));
|
||||
}
|
||||
|
||||
int updatePriceTotalIncr(@Param("id") Integer id, @Param("refundTotalIncr") Integer refundTotalIncr);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.mall.payservice.rpc.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
|
||||
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
@@ -35,4 +36,9 @@ public class PayTransactionRpcImpl implements PayTransactionRpc {
|
||||
successReqDTO.getParams()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<PayTransactionRespDTO>> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO) {
|
||||
return success(payTransactionService.pagePayTransaction(pageReqDTO));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.payservice.service.transaction;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
|
||||
|
||||
/**
|
||||
@@ -43,4 +44,21 @@ public interface PayTransactionService {
|
||||
*/
|
||||
Boolean updateTransactionPaySuccess(Integer payChannel, String params);
|
||||
|
||||
/**
|
||||
* 获得交易支付单分页
|
||||
*
|
||||
* @param pageReqDTO 分页条件
|
||||
* @return 交易支付单分页
|
||||
*/
|
||||
PageResult<PayTransactionRespDTO> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO);
|
||||
|
||||
/**
|
||||
* 增加交易支付单的退款总金额
|
||||
*
|
||||
* @param payTransactionId 支付交易单
|
||||
* @param incr 新增的退款金额
|
||||
* @return 是否增加成功
|
||||
*/
|
||||
boolean updateTransactionPriceTotalIncr(Integer payTransactionId, Integer incr);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.util.DateUtil;
|
||||
import cn.iocoder.common.framework.util.MathUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.payservice.client.thirdpay.AbstractThirdPayClient;
|
||||
import cn.iocoder.mall.payservice.client.thirdpay.ThirdPayClientFactory;
|
||||
import cn.iocoder.mall.payservice.client.thirdpay.dto.ThirdPayTransactionSuccessRespDTO;
|
||||
@@ -18,6 +19,7 @@ import cn.iocoder.mall.payservice.rpc.transaction.dto.*;
|
||||
import cn.iocoder.mall.payservice.service.app.PayAppService;
|
||||
import cn.iocoder.mall.payservice.service.notify.PayNotifyService;
|
||||
import cn.iocoder.mall.payservice.service.transaction.PayTransactionService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -165,6 +167,17 @@ public class PayTransactionServiceImpl implements PayTransactionService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<PayTransactionRespDTO> pagePayTransaction(PayTransactionPageReqDTO pageReqDTO) {
|
||||
IPage<PayTransactionDO> payTransactionDOPage = payTransactionMapper.selectPage(pageReqDTO);
|
||||
return PayTransactionConvert.INSTANCE.convertPage(payTransactionDOPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTransactionPriceTotalIncr(Integer payTransactionId, Integer incr) {
|
||||
return payTransactionMapper.updatePriceTotalIncr(payTransactionId, incr) > 0;
|
||||
}
|
||||
|
||||
private String generateTransactionCode() {
|
||||
// wx
|
||||
// 2014
|
||||
@@ -183,4 +196,6 @@ public class PayTransactionServiceImpl implements PayTransactionService {
|
||||
;
|
||||
}
|
||||
|
||||
// CommonResult cancelTransaction(); // TODO 1. params 2. result
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="cn.iocoder.mall.payservice.dal.mysql.mapper.transaction.PayTransactionMapper">
|
||||
|
||||
<update id="updatePriceTotalIncr">
|
||||
UPDATE pay_transaction
|
||||
SET refund_total = refund_total + ${refundTotalIncr}
|
||||
WHERE id = #{id}
|
||||
AND price >= refund_total + ${refundTotalIncr}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user