|
|
@@ -857,7 +857,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setShopId(null);
|
|
|
}
|
|
|
//支付宝退款
|
|
|
- AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfigMapper.getByAppId(Optional.ofNullable(orderDon.getShopId()).orElse(ShopConfig.ZFB_DEFAULT_APP_ID)));
|
|
|
+ AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfigMapper.getByAppId(Optional.ofNullable(orderDon.getShopId()).orElse(ShopConfig.ZFB_DEFAULT_APP_ID)), false);
|
|
|
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
|
|
|
AlipayTradeRefundModel model = new AlipayTradeRefundModel();
|
|
|
//支付宝交易号
|
|
|
@@ -1150,7 +1150,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean transferAccounts(TransferAccountsReq transferAccountsReq) throws Exception {
|
|
|
+ public AlipayResponse transferAccounts(TransferAccountsReq transferAccountsReq) throws Exception {
|
|
|
Long userId = transferAccountsReq.getUserId();
|
|
|
String account = transferAccountsReq.getAccount();
|
|
|
String name = transferAccountsReq.getName();
|
|
|
@@ -1165,7 +1165,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
Integer scope = transferAccountsReq.getScope();
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByAppId(ShopConfig.ZFB_DEFAULT_APP_ID);
|
|
|
|
|
|
- AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
|
|
|
+ AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig, true);
|
|
|
|
|
|
AlipayRequest alipayRequest = aliPayTransferAccountsRequest(donNo, account, name, money);
|
|
|
|
|
|
@@ -1173,17 +1173,17 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (response.isSuccess()) {
|
|
|
log.info("支付宝转账金额:{}至用户:{}成功", money.divide(BigDecimal.valueOf(100)), userId);
|
|
|
saveTransferRecord(userId, donNo, account, name, money, points, type, scope, response.getBody(), null);
|
|
|
- return true;
|
|
|
+ return response;
|
|
|
}
|
|
|
log.info("支付宝转账金额:{}至用户:{}失败", money.divide(BigDecimal.valueOf(100)), userId);
|
|
|
saveTransferRecord(userId, donNo, account, name, money, points, type, scope, response.getBody(), response.getSubMsg());
|
|
|
- return false;
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getTransFerStatusByTid(String translationId) throws Exception {
|
|
|
+ public AlipayFundTransCommonQueryResponse getTransFerStatusByTid(String translationId) throws Exception {
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByAppId(ShopConfig.ZFB_DEFAULT_APP_ID);
|
|
|
- AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
|
|
|
+ AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig, true);
|
|
|
AlipayFundTransCommonQueryRequest request = new AlipayFundTransCommonQueryRequest();
|
|
|
AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel();
|
|
|
model.setOrderId(translationId);
|
|
|
@@ -1191,7 +1191,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
model.setProductCode(ZfbProductCode.STD_RED_PACKET.getProductCode());
|
|
|
request.setBizModel(model);
|
|
|
AlipayFundTransCommonQueryResponse response = alipayClient.certificateExecute(request);
|
|
|
- return response.getBody();
|
|
|
+ return response;
|
|
|
}
|
|
|
|
|
|
private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money) {
|
|
|
@@ -1200,16 +1200,20 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//转账参数
|
|
|
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
|
|
model.setOutBizNo(donNo);
|
|
|
- model.setTransAmount(money.toString());
|
|
|
+ //单位元
|
|
|
+ model.setTransAmount(money.divide(BigDecimal.valueOf(100)).toString());
|
|
|
model.setProductCode(ZfbProductCode.STD_RED_PACKET.getProductCode());
|
|
|
model.setBizScene(TransferConstant.DIRECT_TRANSFER);
|
|
|
model.setOrderTitle("红包转账");
|
|
|
//红包业务必传,取值REDPACKET
|
|
|
- model.setBusinessParams(TransferConstant.RED_PACKET);
|
|
|
+ JSONObject businessParams = new JSONObject();
|
|
|
+ businessParams.putOpt(TransferConstant.SUB_BIZ_SCENE, TransferConstant.RED_PACKET);
|
|
|
+ model.setBusinessParams(businessParams.toString());
|
|
|
Participant payeeInfo = new Participant();
|
|
|
payeeInfo.setIdentity(account);
|
|
|
payeeInfo.setIdentityType(TransferConstant.ALIPAY_LOGON_ID);
|
|
|
payeeInfo.setName(name);
|
|
|
+ model.setPayeeInfo(payeeInfo);
|
|
|
transUniTransferRequest.setBizModel(model);
|
|
|
return transUniTransferRequest;
|
|
|
}
|
|
|
@@ -1217,7 +1221,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public AliPayParams commonAliPay(Long orderId, String productCode, String appId, String qrPayMode) throws Exception {
|
|
|
ShopConfig shopConfig = shopConfigMapper.getByAppId(Optional.ofNullable(appId).orElse(ShopConfig.ZFB_DEFAULT_APP_ID));
|
|
|
|
|
|
- AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig);
|
|
|
+ AlipayClient alipayClient = AliPayCommon.getAlipayClient(shopConfig, false);
|
|
|
// 创建API对应的request
|
|
|
AlipayRequest alipayRequest = getAliAayRequest(orderId, productCode, qrPayMode);
|
|
|
if (alipayRequest == null) {
|
|
|
@@ -1610,8 +1614,9 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
public void saveTransferRecord(Long userId, String donNo, String account, String name, BigDecimal money, BigDecimal points, String type, Integer scope, String body, String error) throws Exception {
|
|
|
TransferAccountsRecord record = new TransferAccountsRecord();
|
|
|
JSONObject re = Jsons.parseObject(body, JSONObject.class);
|
|
|
- String transactionId = re.getStr("order_id");
|
|
|
- String transDate = re.getStr("trans_date");
|
|
|
+ JSONObject response = Jsons.parseObject(re.get("alipay_fund_trans_uni_transfer_response"), JSONObject.class);
|
|
|
+ String transactionId = response.getStr("order_id");
|
|
|
+ String transDate = response.getStr("trans_date");
|
|
|
record.setUserId(userId);
|
|
|
record.setAccount(account);
|
|
|
record.setName(name);
|
|
|
@@ -1625,7 +1630,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
record.setPoints(points);
|
|
|
record.setTransferOutNo(donNo);
|
|
|
record.setTransactionId(transactionId);
|
|
|
- record.setTransferTime(DateTime.of(transDate, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ Optional.ofNullable(transDate).ifPresent(transferTime -> record.setTransferTime(DateTime.of(transferTime, "yyyy-MM-dd HH:mm:ss")));
|
|
|
transferAccountsRecordMapper.insert(record);
|
|
|
}
|
|
|
}
|