TASK:查询交易记录 添加显示总金额和付款者邮箱

This commit is contained in:
2025-06-23 10:53:30 +08:00
parent 301a62a563
commit d6c5d0e95d
5 changed files with 69 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
package com.ai.da.common.response;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
@ApiModel("交易记录分页响应结果")
public class TransactionPageResponse<T> extends PageBaseResponse<T> {
private BigDecimal totalAmount;
}

View File

@@ -6,6 +6,7 @@ import com.ai.da.model.vo.PaymentInfoVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -24,6 +25,10 @@ public interface PaymentInfoMapper extends BaseMapper<PaymentInfo> {
String country, String city, String startTime, String endTime, String payer
);
BigDecimal queryTotalPaymentAmount(String paymentType,String payerTotal, String type, String status,
String country, String city, String startTime, String endTime, String payer
);
List<Map<String, String>> getCities();
List<Map<String, String>> getCountries();

View File

@@ -13,6 +13,8 @@ public class PaymentInfoVO {
private Long id;
@ApiModelProperty("付款用户名")
private String payer;
@ApiModelProperty("付款者邮箱")
private String email;
@ApiModelProperty("选择的支付平台 PayPal || Stripe || Alipay-HK")
private String platform;
@ApiModelProperty("支付的金额 单位:HKD")

View File

@@ -5,6 +5,7 @@ import com.ai.da.common.constant.CommonConstant;
import com.ai.da.common.context.UserContext;
import com.ai.da.common.enums.CreditsEventsEnum;
import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.common.response.TransactionPageResponse;
import com.ai.da.common.utils.CopyUtil;
import com.ai.da.common.utils.DateUtil;
import com.ai.da.mapper.primary.*;
@@ -610,16 +611,21 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
queryPaymentInfoDTO.getType(), queryPaymentInfoDTO.getStatus(),
queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(),
queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(), queryPaymentInfoDTO.getPayer());
// 查询符合查询条件的总金额
BigDecimal payerTotal = paymentInfoMapper.queryTotalPaymentAmount(queryPaymentInfoDTO.getPlatform(), queryPaymentInfoDTO.getPayerTotal(),
queryPaymentInfoDTO.getType(), queryPaymentInfoDTO.getStatus(),
queryPaymentInfoDTO.getCountry(), queryPaymentInfoDTO.getCity(),
queryPaymentInfoDTO.getStartTime(), queryPaymentInfoDTO.getEndTime(), queryPaymentInfoDTO.getPayer());
// 总页数
double totalPage = Math.ceil((double) total / size);
// 组装返回参数
PageBaseResponse<PaymentInfoVO> response = new PageBaseResponse<>();
TransactionPageResponse<PaymentInfoVO> response = new TransactionPageResponse<>();
response.setContent(paymentInfoVOS);
response.setPage(queryPaymentInfoDTO.getPage());
response.setSize(size);
response.setTotal(total);
response.setPages((long) totalPage);
response.setTotalAmount(Objects.isNull(payerTotal) ? BigDecimal.ZERO : payerTotal);
return response;
}

View File

@@ -48,6 +48,7 @@
SELECT
p.id,
a.user_name payer,
a.user_email email,
p.payment_type platform,
p.payer_total,
p.type,
@@ -149,6 +150,44 @@
AND p.transaction_id NOT LIKE 'cs_test%'
</select>
<select id="queryTotalPaymentAmount" resultType="java.math.BigDecimal">
SELECT SUM(p.payer_total)
FROM t_payment_info p
LEFT JOIN t_order_info o ON p.order_no = o.order_no
LEFT JOIN t_account a ON a.id = o.account_id
WHERE 1 = 1
<if test="paymentType != null and paymentType != ''">
AND p.payment_type = #{paymentType}
</if>
<if test="payerTotal != null and payerTotal != ''">
AND p.payer_total = #{payerTotal}
</if>
<if test="type != null and type != ''">
AND p.type = #{type}
</if>
<if test="status != null and status != ''">
AND
CASE
WHEN p.trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
WHEN p.trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
ELSE 'Pending'
END = #{status}
</if>
<if test="country != null and country != ''">
AND p.country = #{country}
</if>
<if test="city != null and city != ''">
AND p.city = #{city}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND p.create_time BETWEEN #{startTime} AND #{endTime}
</if>
<if test="payer != null and payer != ''">
AND a.user_name = #{payer}
</if>
AND p.transaction_id NOT LIKE 'cs_test%'
</select>
<select id="getCities" resultType="java.util.Map">
SELECT DISTINCT city
FROM t_payment_info