Browse Source

12月3日银行接口同步

sunjiabei/feature-20251202094523-银行接口同步
sunjiabei 1 month ago
parent
commit
2e13f73e5a
  1. 27
      src/main/java/com/example/demo/serviceImpl/cash/BankServiceImpl.java
  2. 17
      src/main/resources/cashMapper/CashCollectionMapper.xml

27
src/main/java/com/example/demo/serviceImpl/cash/BankServiceImpl.java

@ -3,7 +3,6 @@ package com.example.demo.serviceImpl.cash;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.Util.DateConvertUtil;
import com.example.demo.domain.DTO.BankDTO;
import com.example.demo.domain.DTO.PaymentDTO;
import com.example.demo.domain.DTO.StripeDTO;
@ -99,14 +98,18 @@ public class BankServiceImpl implements BankService {
if (response.getStatusCode().is2xxSuccessful()) {
String responseBody = response.getBody();
log.info("第三方API响应: {}", responseBody);
// 解析JSON获取payload.transactions数组
JSONObject jsonObject = JSON.parseObject(responseBody);
JSONArray transactions = jsonObject.getJSONObject("payload").getJSONArray("transactions");
// 创建BankDTO并设置paymentDTOList
BankVO bankVO = new BankVO();
List<PaymentDTO> paymentDTOList = transactions.toJavaList(PaymentDTO.class);
List<PaymentDTO> paymentDTOList;
try {
paymentDTOList = transactions.toJavaList(PaymentDTO.class);
} catch (Exception e) {
log.error("解析JSON响应时发生错误: {}", e.getMessage(), e);
return Result.error("payment当天无数据请切换日期");
}
bankVO.setPaymentDTOList(paymentDTOList);
// 获取订单号
String orderNo = bankDTO.getOrderNo();
@ -121,7 +124,7 @@ public class BankServiceImpl implements BankService {
paymentDTO.setOrder_amount(paymentDTO.getOrder_amount().multiply(BigDecimal.valueOf(100)));
paymentDTO.setCharge(paymentDTO.getCharge().multiply(BigDecimal.valueOf(100)));
paymentDTO.setNet_amount(paymentDTO.getNet_amount().multiply(BigDecimal.valueOf(100)));
paymentDTO.setCurrency("2");
paymentDTO.setCurrency("港币HKD");
bankVO.setPaymentDTO(paymentDTO);
found = true;
break;
@ -197,7 +200,13 @@ public class BankServiceImpl implements BankService {
// 创建BankVO并设置paymentDTOList
BankVO bankVO = new BankVO();
List<PaymentDTO> paymentDTOList = transactions.toJavaList(PaymentDTO.class);
List<PaymentDTO> paymentDTOList;
try {
paymentDTOList = transactions.toJavaList(PaymentDTO.class);
} catch (Exception e) {
log.error("解析JSON响应时发生错误: {}", e.getMessage(), e);
return Result.error("payment当天无数据请切换日期");
}
bankVO.setPaymentDTOList(paymentDTOList);
// 收集处理信息
List<String> messages = new ArrayList<>();
@ -214,7 +223,7 @@ public class BankServiceImpl implements BankService {
paymentDTO.setCharge(paymentDTO.getCharge().multiply(BigDecimal.valueOf(100)));
paymentDTO.setNet_amount(paymentDTO.getNet_amount().multiply(BigDecimal.valueOf(100)));
// 设置货币代码
paymentDTO.setCurrency("2");
paymentDTO.setCurrency("港币HKD");
// 获取订单号
String orderNo = paymentDTO.getMerchant_reference();
@ -232,6 +241,7 @@ public class BankServiceImpl implements BankService {
messages.add("金币系统中未找到订单: " + orderNo);
}
} catch (Exception e) {
messages.add("处理单个支付记录时发生错误: " + paymentDTO.getMerchant_reference() + ",错误信息: " + e.getMessage());
log.error("处理单个支付记录时发生错误: {}", paymentDTO.getMerchant_reference(), e);
}
}
@ -397,7 +407,10 @@ public class BankServiceImpl implements BankService {
ChargeListParams params = ChargeListParams.builder()
.setLimit((long) currentPageSize)
.setStartingAfter(startingAfter)
.setCreated(1764738449L)
.build();
// 加时间过滤大于等于2024-12-04 00:00:00的时间戳
try {
// 执行分页查询

17
src/main/resources/cashMapper/CashCollectionMapper.xml

@ -275,10 +275,10 @@
</if>
</select>
<select id="selectByGoldCoinOrderCode" resultType="com.example.demo.domain.vo.cash.CashCollection">
select * from cash_record_collection where order_no=#{orderNo}
select * from cash_record_collection where order_code=#{orderNo}
</select>
<!--根据glodcoin订单号更新收款订单-->
<!--根据goldcoin订单号更新收款订单-->
<update id="updateByGoldCoinOrderCode">
update cash_record_collection
<set>
@ -301,20 +301,21 @@
AND status = 0
AND version = #{version}
</update>
<!--根据glodcoin订单号更新收款订单-->
<!--根据OrderCode订单号更新收款订单-->
<update id="updateByGoldCoinOrderCodeByPayment">
update cash_record_collection
SET
received_time=#{time},
payment_currency=#{currency},
received_currency=#{currency},
payment_currency='2',
received_currency='2',
payment_amount=#{order_amount},
received_amount=#{net_amount},
handling_charge=#{charge},
order_no_status=0
where order_no=#{merchant_reference}
where order_code=#{merchant_reference}
</update>
<!--根据glodcoin订单号更新收款订单-->
<!--根据OrderCode订单号更新收款订单-->
<update id="updateByGoldCoinOrderCodeByStripe">
update cash_record_collection
SET
@ -325,6 +326,6 @@
received_amount=#{net},
handling_charge=#{fee},
order_no_status=0
where order_no=#{orderNo}
where order_code=#{orderNo}
</update>
</mapper>
Loading…
Cancel
Save