feat 支付订单和退款订单页面添加实时金额汇总展示

This commit is contained in:
DaxPay
2024-05-06 20:10:58 +08:00
parent 9a34ed51c5
commit dfbdc83b62
33 changed files with 132 additions and 76 deletions

View File

@@ -103,4 +103,10 @@ public class PayOrderController {
allocationService.allocation(param);
return Res.ok();
}
@Operation(summary = "查询金额汇总")
@GetMapping("/getTotalAmount")
public ResResult<Integer> getTotalAmount(PayOrderQuery param){
return Res.ok(queryService.getTotalAmount(param));
}
}

View File

@@ -12,6 +12,7 @@ import cn.bootx.platform.daxpay.service.core.payment.sync.service.RefundSyncServ
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundOrderDetailDto;
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundOrderDto;
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundOrderExtraDto;
import cn.bootx.platform.daxpay.service.param.order.PayOrderQuery;
import cn.bootx.platform.daxpay.service.param.order.PayOrderRefundParam;
import cn.bootx.platform.daxpay.service.param.order.RefundOrderQuery;
import io.swagger.v3.oas.annotations.Operation;
@@ -30,36 +31,36 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor
public class RefundOrderController {
private final RefundOrderService refundOrderService;
private final RefundOrderQueryService refundOrderQueryService;
private final RefundOrderQueryService queryService;
private final RefundSyncService refundSyncService;
@Operation(summary = "分页查询")
@GetMapping("/page")
public ResResult<PageResult<RefundOrderDto>> page(PageParam pageParam, RefundOrderQuery query){
return Res.ok(refundOrderQueryService.page(pageParam, query));
return Res.ok(queryService.page(pageParam, query));
}
@Operation(summary = "查询退款订单详情")
@GetMapping("/findByOrderNo")
public ResResult<RefundOrderDetailDto> findByRefundNo(String refundNo){
RefundOrderDto order = refundOrderQueryService.findByRefundNo(refundNo);
RefundOrderDto order = queryService.findByRefundNo(refundNo);
RefundOrderDetailDto detailDto = new RefundOrderDetailDto();
detailDto.setRefundOrder(order);
detailDto.setRefundOrderExtra(refundOrderQueryService.findExtraById(order.getId()));
detailDto.setRefundOrderExtra(queryService.findExtraById(order.getId()));
return Res.ok(detailDto);
}
@Operation(summary = "查询单条")
@GetMapping("/findById")
public ResResult<RefundOrderDto> findById(Long id){
return Res.ok(refundOrderQueryService.findById(id));
return Res.ok(queryService.findById(id));
}
@Operation(summary = "查询扩展信息")
@GetMapping("/findExtraById")
public ResResult<RefundOrderExtraDto> findExtraById(Long id){
return Res.ok(refundOrderQueryService.findExtraById(id));
return Res.ok(queryService.findExtraById(id));
}
@Operation(summary = "手动发起退款")
@@ -83,4 +84,10 @@ public class RefundOrderController {
refundSyncParam.setRefundNo(refundNo);
return Res.ok(refundSyncService.sync(refundSyncParam));
}
@Operation(summary = "查询金额汇总")
@GetMapping("/getTotalAmount")
public ResResult<Integer> getTotalAmount(PayOrderQuery param){
return Res.ok(queryService.getTotalAmount(param));
}
}

View File

@@ -41,7 +41,7 @@ public interface AliPayCode {
/** 对交易或商品的描述(在没有公用回传参数的时候, 这个作为公用回传参数) */
String BODY = "body";
/** 外部支付订单号 - 商户订单号 */
/** 通道支付订单号 - 商户订单号 */
String OUT_TRADE_NO = "out_trade_no";
/** 支付流水号 */

View File

@@ -44,9 +44,9 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction<
private String bizAllocationNo;
/**
* 外部分账号
* 通道分账号
*/
@DbColumn(comment = "外部分账号")
@DbColumn(comment = "通道分账号")
private String outAllocationNo;
/** 支付订单ID */
@@ -66,9 +66,9 @@ public class AllocationOrder extends MpBaseEntity implements EntityBaseFunction<
private String bizOrderNo;
/**
* 外部系统支付订单号
* 通道系统支付订单号
*/
@DbColumn(comment = "外部支付订单号")
@DbColumn(comment = "通道支付订单号")
private String outOrderNo;
/**

View File

@@ -68,4 +68,13 @@ public class PayOrderManager extends BaseManager<PayOrderMapper, PayOrder> {
.list();
}
/**
* 查询汇总金额
*/
public Integer getTalAmount(PayOrderQuery query){
QueryWrapper<PayOrder> generator = QueryGenerator.generator(query);
generator.eq(MpUtil.getColumnName(PayOrder::getStatus), PayStatusEnum.SUCCESS.getCode());
return baseMapper.getTalAmount(generator);
}
}

View File

@@ -1,9 +1,12 @@
package cn.bootx.platform.daxpay.service.core.order.pay.dao;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@@ -16,4 +19,7 @@ import java.util.List;
public interface PayOrderMapper extends BaseMapper<PayOrder> {
int insertList(@Param("list")List<PayOrder> list);
@Select("select sum(amount) from pay_order ${ew.customSqlSegment}")
Integer getTalAmount(@Param(Constants.WRAPPER) QueryWrapper<PayOrder> param);
}

View File

@@ -41,9 +41,9 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction<PayOrde
private String orderNo;
/**
* 外部系统交易号
* 通道系统交易号
*/
@DbColumn(comment = "外部支付订单号")
@DbColumn(comment = "通道支付订单号")
private String outOrderNo;
/** 标题 */

View File

@@ -11,7 +11,6 @@ import cn.bootx.platform.daxpay.result.order.PayOrderResult;
import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayOrderExtraManager;
import cn.bootx.platform.daxpay.service.core.order.pay.dao.PayOrderManager;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrder;
import cn.bootx.platform.daxpay.service.core.order.pay.entity.PayOrderExtra;
import cn.bootx.platform.daxpay.service.dto.order.pay.PayOrderDto;
import cn.bootx.platform.daxpay.service.param.order.PayOrderQuery;
import cn.hutool.core.bean.BeanUtil;
@@ -21,8 +20,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
@@ -80,8 +77,6 @@ public class PayOrderQueryService {
return Optional.empty();
}
/**
* 查询支付记录
*/
@@ -94,10 +89,17 @@ public class PayOrderQueryService {
PayOrder payOrder = this.findByBizOrOrderNo(param.getBizOrderNoeNo(), param.getOrderNo())
.orElseThrow(() -> new DataNotExistException("未查询到支付订单"));
// 查询扩展数据
PayOrderExtra payOrderExtra = payOrderExtraManager.findById(payOrder.getId())
payOrderExtraManager.findById(payOrder.getId())
.orElseThrow(() -> new PayFailureException("支付订单不完整"));
PayOrderResult payOrderResult = new PayOrderResult();
BeanUtil.copyProperties(payOrder, payOrderResult);
return payOrderResult;
}
/**
* 查询支付总金额
*/
public Integer getTotalAmount(PayOrderQuery param) {
return payOrderManager.getTalAmount(param);
}
}

View File

@@ -55,8 +55,8 @@ public class ReconcileDiff extends MpBaseEntity implements EntityBaseFunction<Re
@DbColumn(comment = "本地交易号")
private String tradeNo;
/** 外部交易号 */
@DbColumn(comment = "外部交易号")
/** 通道交易号 */
@DbColumn(comment = "通道交易号")
private String outTradeNo;
/** 交易时间 */
@@ -79,8 +79,8 @@ public class ReconcileDiff extends MpBaseEntity implements EntityBaseFunction<Re
private Integer amount;
/** 外部交易金额 */
@DbColumn(comment = "外部交易金额")
/** 通道交易金额 */
@DbColumn(comment = "通道交易金额")
private Integer outAmount;
/**

View File

@@ -49,8 +49,8 @@ public class ReconcileTradeDetail extends MpCreateEntity implements EntityBaseFu
@DbColumn(comment = "本地交易号")
private String tradeNo;
/** 外部交易号 - 支付宝/微信的订单号 */
@DbColumn(comment = "外部交易号")
/** 通道交易号 - 支付宝/微信的订单号 */
@DbColumn(comment = "通道交易号")
private String outTradeNo;
/** 交易时间 */

View File

@@ -4,8 +4,10 @@ import cn.bootx.platform.common.core.rest.param.PageParam;
import cn.bootx.platform.common.mybatisplus.impl.BaseManager;
import cn.bootx.platform.common.mybatisplus.util.MpUtil;
import cn.bootx.platform.common.query.generator.QueryGenerator;
import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.code.RefundStatusEnum;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundOrder;
import cn.bootx.platform.daxpay.service.param.order.PayOrderQuery;
import cn.bootx.platform.daxpay.service.param.order.RefundOrderQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -85,4 +87,13 @@ public class RefundOrderManager extends BaseManager<RefundOrderMapper, RefundOrd
.in(RefundOrder::getStatus, status)
.list();
}
/**
* 查询汇总金额
*/
public Integer getTalAmount(PayOrderQuery query){
QueryWrapper<RefundOrder> generator = QueryGenerator.generator(query);
generator.eq(MpUtil.getColumnName(RefundOrder::getStatus), PayStatusEnum.SUCCESS.getCode());
return baseMapper.getTalAmount(generator);
}
}

View File

@@ -1,8 +1,12 @@
package cn.bootx.platform.daxpay.service.core.order.refund.dao;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundOrder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @author xxm
@@ -11,4 +15,6 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RefundOrderMapper extends BaseMapper<RefundOrder> {
@Select("select sum(amount) from pay_refund_order ${ew.customSqlSegment}")
Integer getTalAmount(@Param(Constants.WRAPPER) QueryWrapper<RefundOrder> generator);
}

View File

@@ -39,7 +39,7 @@ public class RefundOrder extends MpBaseEntity implements EntityBaseFunction<Refu
@DbColumn(comment = "商户支付订单号")
private String bizOrderNo;
/** 外部支付订单号 */
/** 通道支付订单号 */
@DbColumn(comment = "商户支付订单号")
private String outOrderNo;

View File

@@ -14,6 +14,7 @@ import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundOrder;
import cn.bootx.platform.daxpay.service.core.order.refund.entity.RefundOrderExtra;
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundOrderDto;
import cn.bootx.platform.daxpay.service.dto.order.refund.RefundOrderExtraDto;
import cn.bootx.platform.daxpay.service.param.order.PayOrderQuery;
import cn.bootx.platform.daxpay.service.param.order.RefundOrderQuery;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -104,4 +105,11 @@ public class RefundOrderQueryService {
return RefundOrderConvert.CONVERT.convertResult(refundOrder);
}
/**
* 查询支付总金额
*/
public Integer getTotalAmount(PayOrderQuery param) {
return refundOrderManager.getTalAmount(param);
}
}

View File

@@ -35,7 +35,9 @@ import java.util.Optional;
public class RefundOrderService {
private final RefundService refundService;
private final PayApiConfigService apiConfigService;
private final PaymentAssistService paymentAssistService;
private final RefundOrderExtraManager refundOrderExtraManager;

View File

@@ -36,8 +36,8 @@ public class GeneralTradeInfo {
@ExcelProperty("本地交易号")
private String tradeNo;
/** 外部交易号 */
@ExcelProperty("外部交易号")
/** 通道交易号 */
@ExcelProperty("通道交易号")
private String outTradeNo;
/** 网关完成时间 */

View File

@@ -91,7 +91,7 @@ public class RefundSyncService {
this.saveRecord(refundOrder, syncResult, false, null, syncResult.getErrorMsg());
throw new PayFailureException(syncResult.getErrorMsg());
}
// 订单的外部交易号是否一致, 不一致进行更新
// 订单的通道交易号是否一致, 不一致进行更新
if (Objects.nonNull(syncResult.getOutRefundNo()) && !Objects.equals(syncResult.getOutRefundNo(), refundOrder.getOutRefundNo())){
refundOrder.setOutRefundNo(syncResult.getOutRefundNo());
refundOrderManager.updateById(refundOrder);

View File

@@ -33,8 +33,8 @@ public class PayCallbackRecord extends MpCreateEntity implements EntityBaseFunct
@DbColumn(comment = "本地交易号")
private String tradeNo;
/** 外部交易号 */
@DbColumn(comment = "外部交易号")
/** 通道交易号 */
@DbColumn(comment = "通道交易号")
private String outTradeNo;
/**

View File

@@ -37,8 +37,8 @@ public class PaySyncRecord extends MpCreateEntity implements EntityBaseFunction<
@DbColumn(comment = "商户交易号")
private String bizTradeNo;
/** 外部交易号 */
@DbColumn(comment = "外部交易号")
/** 通道交易号 */
@DbColumn(comment = "通道交易号")
private String outTradeNo;

View File

@@ -44,9 +44,9 @@ public class AllocationOrderDto extends BaseDto {
private String bizOrderNo;
/**
* 外部订单号
* 通道订单号
*/
@Schema(description = "外部订单号")
@Schema(description = "通道订单号")
private String outOrderNo;
/**
@@ -56,9 +56,9 @@ public class AllocationOrderDto extends BaseDto {
private String title;
/**
* 外部分账单号
* 通道分账单号
*/
@Schema(description = "外部分账单号")
@Schema(description = "通道分账单号")
private String outAllocationNo;
/**

View File

@@ -29,9 +29,9 @@ public class PayOrderDto extends BaseDto {
private String orderNo;
/**
* 外部系统交易号
* 通道系统交易号
*/
@Schema(description = "外部支付订单号")
@Schema(description = "通道支付订单号")
private String outOrderNo;
/** 标题 */

View File

@@ -48,8 +48,8 @@ public class ReconcileDiffDto extends BaseDto {
@Schema(description = "本地交易号")
private String tradeNo;
/** 外部交易号 */
@Schema(description = "外部交易号")
/** 通道交易号 */
@Schema(description = "通道交易号")
private String outTradeNo;
/** 交易时间 */
@@ -71,8 +71,8 @@ public class ReconcileDiffDto extends BaseDto {
@Schema(description = "交易金额")
private Integer amount;
/** 外部交易金额 */
@DbColumn(comment = "外部交易金额")
/** 通道交易金额 */
@DbColumn(comment = "通道交易金额")
private Integer outAmount;
/**

View File

@@ -51,9 +51,9 @@ public class ReconcileDiffExcel {
@ExcelProperty("本地交易号")
private String tradeNo;
/** 外部交易号 */
@Schema(description = "外部交易号")
@ExcelProperty("外部交易号")
/** 通道交易号 */
@Schema(description = "通道交易号")
@ExcelProperty("通道交易号")
private String outTradeNo;
/** 交易时间 */
@@ -79,9 +79,9 @@ public class ReconcileDiffExcel {
@ExcelProperty(value = "交易金额(元)", converter = AmountConverter.class)
private Integer amount;
/** 外部交易金额 */
@DbColumn(comment = "外部交易金额")
@ExcelProperty(value = "外部交易金额(元)", converter = AmountConverter.class)
/** 通道交易金额 */
@DbColumn(comment = "通道交易金额")
@ExcelProperty(value = "通道交易金额(元)", converter = AmountConverter.class)
private Integer outAmount;
/**

View File

@@ -54,9 +54,9 @@ public class ReconcileTradeDetailDto extends BaseDto {
@ExcelProperty("本地交易号")
private String tradeNo;
/** 外部交易号 - 支付宝/微信的订单号 */
@Schema(description = "外部交易号")
@ExcelProperty("外部交易号")
/** 通道交易号 - 支付宝/微信的订单号 */
@Schema(description = "通道交易号")
@ExcelProperty("通道交易号")
private String outTradeNo;
/** 交易时间 */

View File

@@ -43,9 +43,9 @@ public class ReconcileTradeDetailExcel {
@ExcelProperty("本地交易号")
private String tradeNo;
/** 外部交易号 - 支付宝/微信的订单号 */
@Schema(description = "外部交易号")
@ExcelProperty("外部交易号")
/** 通道交易号 - 支付宝/微信的订单号 */
@Schema(description = "通道交易号")
@ExcelProperty("通道交易号")
private String outTradeNo;
/** 交易时间 */

View File

@@ -23,7 +23,7 @@ public class PayCallbackRecordDto extends BaseDto {
@Schema(description = "交易号")
private String tradeNo;
@Schema(description = "外部交易号")
@Schema(description = "通道交易号")
private String outTradeNo;
/**
* 支付通道

View File

@@ -32,8 +32,8 @@ public class PaySyncRecordDto extends BaseDto {
@Schema(description = "商户交易号")
private String bizTradeNo;
/** 外部交易号 */
@Schema(description = "外部交易号")
/** 通道交易号 */
@Schema(description = "通道交易号")
private String outTradeNo;

View File

@@ -31,9 +31,9 @@ public class PayOrderQuery extends QueryOrder {
private String orderNo;
/**
* 外部系统交易号
* 通道系统交易号
*/
@Schema(description = "外部支付订单号")
@Schema(description = "通道支付订单号")
private String outOrderNo;
/** 标题 */

View File

@@ -29,8 +29,8 @@ public class ReconcileDiffQuery extends QueryOrder {
@Schema(description = "本地交易号")
private String tradeNo;
/** 外部交易号 */
@Schema(description = "外部交易号")
/** 通道交易号 */
@Schema(description = "通道交易号")
private String outTradeNo;
/** 订单标题 */

View File

@@ -30,8 +30,8 @@ public class PaySyncRecordQuery {
@Schema(description = "商户交易号")
private String bizTradeNo;
/** 外部交易号 */
@Schema(description = "外部交易号")
/** 通道交易号 */
@Schema(description = "通道交易号")
private String outTradeNo;

View File

@@ -11,5 +11,4 @@
#{item.deleted,jdbcType=BIT})
</foreach>
</insert>
</mapper>
</mapper>