|
|
|
@ -526,6 +526,10 @@ public class BankServiceImpl implements BankService { |
|
|
|
@Override |
|
|
|
public Result getFirstdata(BankDTO bankDTO) { |
|
|
|
try { |
|
|
|
CashCollection cashCollection = cashCollectionMapper.selectByBankCode(bankDTO.getOrderNo()); |
|
|
|
if (cashCollection == null) { |
|
|
|
return Result.error("金币系统当前日期 " + " 该银行订单号 " + bankDTO.getOrderNo() + " 未查到"); |
|
|
|
} |
|
|
|
// 获取签名参数 |
|
|
|
FirstdataRequestDTO firstdataRequestDTO = generatePaymentAsiaSignature(); |
|
|
|
|
|
|
|
@ -580,6 +584,24 @@ public class BankServiceImpl implements BankService { |
|
|
|
firstdataDTO.setCurrency(currency); |
|
|
|
firstdataDTO.setTotal(total); |
|
|
|
|
|
|
|
// 根据要求设置amount为永久金币×100 |
|
|
|
Integer amount = cashCollection.getPermanentGold() ; |
|
|
|
firstdataDTO.setAmount(amount); |
|
|
|
|
|
|
|
// 根据国家计算fee |
|
|
|
double feeValue; |
|
|
|
if ("Singapore".equals(country)) { |
|
|
|
// 新加坡:amount的值×百分之2.8加上20保留整数四舍五入 |
|
|
|
feeValue = Math.round(amount * 0.028 + 20); |
|
|
|
} else { |
|
|
|
// 其他国家:amount的值×百分之3加20 |
|
|
|
feeValue = Math.round(amount * 0.03 + 20); |
|
|
|
} |
|
|
|
firstdataDTO.setFee((int) feeValue); |
|
|
|
|
|
|
|
// net的值为amount减去fee |
|
|
|
firstdataDTO.setNet(amount - (int) feeValue); |
|
|
|
|
|
|
|
// 将firstdataDTO存入bankVO |
|
|
|
bankVO.setFirstdataDTO(firstdataDTO); |
|
|
|
|
|
|
|
@ -589,6 +611,9 @@ public class BankServiceImpl implements BankService { |
|
|
|
extractedData.put("orderId", orderId); |
|
|
|
extractedData.put("currency", currency); |
|
|
|
extractedData.put("total", total); |
|
|
|
extractedData.put("amount", amount); |
|
|
|
extractedData.put("fee", (int) feeValue); |
|
|
|
extractedData.put("net", amount - (int) feeValue); |
|
|
|
extractedData.put("success", true); // 添加成功标识 |
|
|
|
|
|
|
|
// 将提取的数据转换为JSON字符串并添加到message列表 |
|
|
|
@ -597,6 +622,8 @@ public class BankServiceImpl implements BankService { |
|
|
|
// 将message存入bankVO |
|
|
|
bankVO.setMessage(message); |
|
|
|
|
|
|
|
cashCollectionMapper.updateByGoldCoinOrderCodeByFirstdata(bankVO.getFirstdataDTO()); |
|
|
|
|
|
|
|
return Result.success(bankVO); |
|
|
|
} else { |
|
|
|
// 没有数据时也添加失败标识 |
|
|
|
@ -625,6 +652,7 @@ public class BankServiceImpl implements BankService { |
|
|
|
return Result.error("Firstdata银行接口调用失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成PaymentAsia API所需的签名 |
|
|
|
* @return 签名字符串 |
|
|
|
|