From 91cb64a4d9eba968b136f0e4e68e175f1e631ae1 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Thu, 17 Aug 2023 17:12:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B1=87=E4=BB=98API=20=E6=96=B0=E5=A2=9Emerch?= =?UTF-8?q?antKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsowell/api/uniapp/TempController.java | 2 +- .../test/java/SpringBootTestController.java | 2 +- .../jsowell/adapay/dto/SettleAccountDTO.java | 3 + .../com/jsowell/adapay/dto/WithdrawDTO.java | 3 +- .../adapay/service/AdapayMemberService.java | 132 +++++++++++++----- .../impl/OrderBasicInfoServiceImpl.java | 41 +----- 6 files changed, 108 insertions(+), 75 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/TempController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/TempController.java index 3bc1de1ab..1107e2141 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/TempController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/TempController.java @@ -245,7 +245,7 @@ public class TempController extends BaseController { public RestApiResponse testCreateBalancePayment(@RequestBody BalancePaymentRequestDTO dto) { RestApiResponse response = null; try { - adapayMemberService.createBalancePaymentRequest(dto.getOutMemberId(), dto.getInMemberId(), dto.getTransAmt(), "测试余额支付", "测试余额支付描述"); + adapayMemberService.createBalancePaymentRequest(dto.getOutMemberId(), dto.getInMemberId(), dto.getTransAmt(), "测试余额支付", "测试余额支付描述", ""); response = new RestApiResponse<>(); } catch (BusinessException e) { logger.warn("测试余额支付接口warn", e); diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 46138bc6f..26858f477 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -710,7 +710,7 @@ public class SpringBootTestController { try { // adapayMemberService.queryAdapayMemberInfo(adapayMemberId); - adapayMemberService.queryAdapaySettleAccount(adapayMemberId, settleAccountId); + adapayMemberService.queryAdapaySettleAccount(adapayMemberId, settleAccountId, ""); } catch (BaseAdaPayException e) { throw new RuntimeException(e); } diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/dto/SettleAccountDTO.java b/jsowell-pile/src/main/java/com/jsowell/adapay/dto/SettleAccountDTO.java index ce2f7bd2c..e6fb4d218 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/dto/SettleAccountDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/dto/SettleAccountDTO.java @@ -18,6 +18,9 @@ public class SettleAccountDTO { // 运营商id private String merchantId; + // 微信小程序appId + private String wechatAppId; + // 账户类型:1-对公;2-对私 private String bankAcctType; diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/dto/WithdrawDTO.java b/jsowell-pile/src/main/java/com/jsowell/adapay/dto/WithdrawDTO.java index 4bc6a1c99..bd71164d0 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/dto/WithdrawDTO.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/dto/WithdrawDTO.java @@ -14,5 +14,6 @@ public class WithdrawDTO { // 提现金额 private String cashAmt; - + // 微信小程序appId + private String wechatAppId; } diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayMemberService.java b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayMemberService.java index a81b2511a..23482fb40 100644 --- a/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayMemberService.java +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/service/AdapayMemberService.java @@ -55,8 +55,6 @@ public class AdapayMemberService { @Value("${adapay.jsowell.appId}") private String ADAPAY_APP_ID; - // private final String CALLBACK_URL = "https://api.jsowellcloud.com/uniapp/pay/callbackAdapay"; - @Value("${adapay.callback}") private String ADAPAY_CALLBACK_URL; @@ -81,6 +79,11 @@ public class AdapayMemberService { */ public void createSettleAccount(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException { String bankAcctType = dto.getBankAcctType(); + + // 设置wechatAppId + String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); + dto.setWechatAppId(wechatAppId); + if (StringUtils.equals(bankAcctType, Constants.ONE)) { createCorpMember(dto); } else if (StringUtils.equals(bankAcctType, Constants.TWO)) { @@ -96,22 +99,28 @@ public class AdapayMemberService { */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) public void createMember(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getWechatAppId()); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + // 查询汇付会员关系 AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId()); if (adapayMemberAccount != null) { - log.error("通过merchantId:{}, 没有查询到结算账户配置", dto.getMerchantId()); + log.error("通过merchantId:{}, 查询到结算账户配置:{}", dto.getMerchantId(), JSON.toJSONString(adapayMemberAccount)); return; } log.info("=======execute CreateMember begin======="); Map memberParams = Maps.newHashMap(); String adapayMemberId = Constants.ADAPAY_MEMBER_PREFIX + IdUtils.getMemberId(); memberParams.put("member_id", adapayMemberId); - memberParams.put("app_id", ADAPAY_APP_ID); + memberParams.put("app_id", config.getAdapayAppId()); memberParams.put("location", dto.getLocation()); memberParams.put("email", dto.getEmail()); memberParams.put("gender", dto.getGender()); memberParams.put("nickname", dto.getNickname()); log.info("创建用户,请求参数:" + JSON.toJSONString(memberParams)); - Map member = Member.create(memberParams); + Map member = Member.create(memberParams, config.getWechatAppId()); log.info("创建用户,返回参数:" + JSON.toJSONString(member)); log.info("=======execute CreateMember end======="); @@ -151,12 +160,12 @@ public class AdapayMemberService { Map settleCountParams = Maps.newHashMap(); settleCountParams.put("member_id", adapayMemberId); - settleCountParams.put("app_id", ADAPAY_APP_ID); + settleCountParams.put("app_id", config.getAdapayAppId()); // channel String Y 目前仅支持:bank_account(银行卡) settleCountParams.put("channel", "bank_account"); settleCountParams.put("account_info", accountInfo); log.info("创建汇付结算账户param:{}", settleCountParams); - Map settleCount = SettleAccount.create(settleCountParams); + Map settleCount = SettleAccount.create(settleCountParams, config.getWechatAppId()); log.info("创建汇付结算账户result:{}", settleCount); if (settleCount == null || StringUtils.equals((String) settleCount.get("status"), "failed")) { @@ -189,7 +198,7 @@ public class AdapayMemberService { } // 通过merchantId获取appId - String wechatAppid = pileMerchantInfoService.queryAppIdByMerchantId(merchantId); + String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId); String adapayMemberId = adapayMemberAccount.getAdapayMemberId(); String bankAcctType; @@ -199,11 +208,11 @@ public class AdapayMemberService { if (StringUtils.startsWith(adapayMemberId, Constants.ADAPAY_MEMBER_PREFIX)) { bankAcctType = Constants.TWO; // 查询个人用户 - adapayMemberInfoVO = queryAdapayMemberInfo(adapayMemberId, wechatAppid); + adapayMemberInfoVO = queryAdapayMemberInfo(adapayMemberId, wechatAppId); if (adapayMemberInfoVO != null) { adapayMemberInfoVO.setMerchantId(merchantId); } - AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberId, adapayMemberAccount.getSettleAccountId()); + AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberId, adapayMemberAccount.getSettleAccountId(), wechatAppId); if (adapaySettleAccountVO != null) { adapaySettleAccountVO.setMerchantId(merchantId); } @@ -214,7 +223,7 @@ public class AdapayMemberService { } else { bankAcctType = Constants.ONE; // 查询企业用户 - adapayCorpMemberVO = queryCorpAdapayMemberInfo(adapayMemberId); + adapayCorpMemberVO = queryCorpAdapayMemberInfo(adapayMemberId, wechatAppId); } map.put("bankAcctType", bankAcctType); @@ -229,13 +238,19 @@ public class AdapayMemberService { * 查询汇付会员信息 */ public AdapayMemberInfoVO queryAdapayMemberInfo(String adapayMemberId, String wechatAppId) throws BaseAdaPayException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + if (StringUtils.isBlank(adapayMemberId)) { return null; } Map memberParams = Maps.newHashMap(); memberParams.put("member_id", adapayMemberId); - memberParams.put("app_id", ADAPAY_APP_ID); - Map member = Member.query(memberParams, wechatAppId); + memberParams.put("app_id", config.getAdapayAppId()); + Map member = Member.query(memberParams, config.getWechatAppId()); log.info("==查询个人用户,请求参数:{},返回参数:{}", JSON.toJSONString(memberParams), JSON.toJSONString(member)); if (member == null || member.isEmpty() || !"succeeded".equals(member.get("status"))) { @@ -255,11 +270,17 @@ public class AdapayMemberService { /** * 查询企业用户信息 */ - public AdapayCorpMemberVO queryCorpAdapayMemberInfo(String adapayMemberId) throws BaseAdaPayException { + public AdapayCorpMemberVO queryCorpAdapayMemberInfo(String adapayMemberId, String wechatAppId) throws BaseAdaPayException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + Map memberParams = Maps.newHashMap(); memberParams.put("member_id", adapayMemberId); - memberParams.put("app_id", ADAPAY_APP_ID); - Map member = CorpMember.query(memberParams); + memberParams.put("app_id", config.getAdapayAppId()); + Map member = CorpMember.query(memberParams, config.getWechatAppId()); log.info("==查询企业用户信息 param:{}, result:{}", JSON.toJSONString(memberParams), JSON.toJSONString(member)); if (member == null || member.isEmpty() || !"succeeded".equals(member.get("status"))) { return null; @@ -294,7 +315,7 @@ public class AdapayMemberService { JSONObject jsonObject = JSON.parseObject(response.getSettle_accounts()); String settleAccountId = jsonObject.getString("id"); if (StringUtils.isNotEmpty(settleAccountId)) { - AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberId, settleAccountId); + AdapaySettleAccountVO adapaySettleAccountVO = queryAdapaySettleAccount(adapayMemberId, settleAccountId, config.getWechatAppId()); if (adapaySettleAccountVO != null) { corpMemberVO.setBankCode(adapaySettleAccountVO.getBankCode()); corpMemberVO.setCardName(adapaySettleAccountVO.getCardName()); @@ -308,7 +329,13 @@ public class AdapayMemberService { /** * 查询汇付结算账户信息 */ - public AdapaySettleAccountVO queryAdapaySettleAccount(String adapayMemberId, String settleAccountId) throws BaseAdaPayException { + public AdapaySettleAccountVO queryAdapaySettleAccount(String adapayMemberId, String settleAccountId, String wechatAppId) throws BaseAdaPayException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + if (StringUtils.isBlank(adapayMemberId) || StringUtils.isBlank(settleAccountId)) { return null; } @@ -316,9 +343,8 @@ public class AdapayMemberService { Map settleCountParams = Maps.newHashMap(); settleCountParams.put("settle_account_id", settleAccountId); settleCountParams.put("member_id", adapayMemberId); - settleCountParams.put("app_id", ADAPAY_APP_ID); - - Map settleAccount = SettleAccount.query(settleCountParams); + settleCountParams.put("app_id", config.getAdapayAppId()); + Map settleAccount = SettleAccount.query(settleCountParams, config.getWechatAppId()); log.info("==查询汇付结算账户信息param:{}, result:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleAccount)); if (settleAccount == null || settleAccount.isEmpty() || !"succeeded".equals(settleAccount.get("status"))) { @@ -349,6 +375,12 @@ public class AdapayMemberService { * 查询汇付会员账户余额 */ public AdapayAccountBalanceVO queryAdapayAccountBalance(String merchantId) throws BaseAdaPayException { + String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(merchantId); + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } AdapayAccountBalanceVO vo = AdapayAccountBalanceVO.builder().build(); // 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额 AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(merchantId); @@ -360,8 +392,8 @@ public class AdapayMemberService { Map queryParams = Maps.newHashMap(); queryParams.put("settle_account_id", settle_account_id); queryParams.put("member_id", member_id); - queryParams.put("app_id", ADAPAY_APP_ID); - Map settleCount = SettleAccount.balance(queryParams); + queryParams.put("app_id", config.getAdapayAppId()); + Map settleCount = SettleAccount.balance(queryParams, config.getWechatAppId()); if (settleCount == null || settleCount.isEmpty() || !"succeeded".equals(settleCount.get("status"))) { return vo; } @@ -381,6 +413,13 @@ public class AdapayMemberService { * @throws BaseAdaPayException */ public void updateSettleAccountConfig(UpdateAccountConfigDTO dto) throws BaseAdaPayException { + String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + // 通过merchantId 查询出汇付会员id 和 结算账户id,用来查询余额 AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId()); if (adapayMemberAccount == null) { @@ -389,7 +428,7 @@ public class AdapayMemberService { } // 修改账户配置 Map params = Maps.newHashMap(); - params.put("app_id", ADAPAY_APP_ID); + params.put("app_id", config.getAdapayAppId()); params.put("member_id", adapayMemberAccount.getAdapayMemberId()); params.put("settle_account_id", adapayMemberAccount.getSettleAccountId()); if (StringUtils.isNotBlank(dto.getMinAmt())) { @@ -409,10 +448,16 @@ public class AdapayMemberService { * 创建企业用户 */ public void createCorpMember(SettleAccountDTO dto) throws BaseAdaPayException, BusinessException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getWechatAppId()); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + Map memberParams = Maps.newHashMap(); String adapayMemberId = Constants.ADAPAY_CORP_MEMBER_PREFIX + IdUtils.getMemberId(); memberParams.put("member_id", adapayMemberId); - memberParams.put("app_id", ADAPAY_APP_ID); + memberParams.put("app_id", config.getAdapayAppId()); memberParams.put("order_no", "jsdk_order" + System.currentTimeMillis()); memberParams.put("social_credit_code_expires", dto.getSocialCreditCodeExpires()); memberParams.put("business_scope", dto.getBusinessScope()); @@ -434,7 +479,7 @@ public class AdapayMemberService { memberParams.put("card_name", dto.getCardName()); memberParams.put("notify_url", ADAPAY_CALLBACK_URL); File file = ZipUtil.createZipFileFromImages(dto.getImgList()); - Map member = CorpMember.create(memberParams, file); + Map member = CorpMember.create(memberParams, file, config.getWechatAppId()); log.info("创建企业账户param:{}, result:{}", JSON.toJSONString(memberParams), JSON.toJSONString(member)); if (StringUtils.equals((String) member.get("status"), "failed")) { throw new BusinessException("", (String) member.get("error_msg")); @@ -464,6 +509,12 @@ public class AdapayMemberService { * @throws BaseAdaPayException */ public void drawCash(WithdrawDTO dto) throws BaseAdaPayException { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getWechatAppId()); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + // 查询余额 AdapayAccountBalanceVO adapayAccountBalanceVO = queryAdapayAccountBalance(dto.getMerchantId()); if (adapayAccountBalanceVO == null) { @@ -486,11 +537,11 @@ public class AdapayMemberService { settleCountParams.put("order_no", "drawcash_" + System.currentTimeMillis()); settleCountParams.put("cash_amt", AdapayUtil.formatAmount(cashAmt)); settleCountParams.put("member_id", adapayAccountBalanceVO.getAdapayMemberId()); - settleCountParams.put("app_id", ADAPAY_APP_ID); + settleCountParams.put("app_id", config.getAdapayAppId()); settleCountParams.put("settle_account_id", adapayAccountBalanceVO.getSettleAccountId()); settleCountParams.put("cash_type", "T1"); settleCountParams.put("notify_url", ADAPAY_CALLBACK_URL); - Map settleCount = Drawcash.create(settleCountParams); + Map settleCount = Drawcash.create(settleCountParams, config.getWechatAppId()); log.info("申请取现接口,请求参数:{}, 返回参数:{}", JSON.toJSONString(settleCountParams), JSON.toJSONString(settleCount)); if (settleCount == null) { @@ -500,7 +551,7 @@ public class AdapayMemberService { String id = (String) settleCount.get("id"); // 发起支付手续费请求 inMemberId为0表示本商户 - createBalancePaymentRequest(adapayAccountBalanceVO.getAdapayMemberId(), Constants.ZERO, feeAmt.toString(), "提现手续费", "提现单号:" + id); + createBalancePaymentRequest(adapayAccountBalanceVO.getAdapayMemberId(), Constants.ZERO, feeAmt.toString(), "提现手续费", "提现单号:" + id, config.getWechatAppId()); // 保存提现记录 ClearingWithdrawInfo record = new ClearingWithdrawInfo(); @@ -528,6 +579,13 @@ public class AdapayMemberService { * @throws BaseAdaPayException */ public Map updateAdapayMember(SettleAccountDTO dto) throws BaseAdaPayException { + String wechatAppId = pileMerchantInfoService.queryAppIdByMerchantId(dto.getMerchantId()); + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + AdapayMemberAccount adapayMemberAccount = adapayMemberAccountService.selectByMerchantId(dto.getMerchantId()); if (adapayMemberAccount == null) { log.error("通过merchantId:{}, 没有查询到结算账户配置", dto.getMerchantId()); @@ -537,7 +595,7 @@ public class AdapayMemberService { Map memberParams = Maps.newHashMap(); memberParams.put("adapay_func_code", "corp_members.update"); memberParams.put("member_id", adapayMemberAccount.getAdapayMemberId()); - memberParams.put("app_id", ADAPAY_APP_ID); + memberParams.put("app_id", config.getAdapayAppId()); memberParams.put("order_no", "jsdk_order_" + System.currentTimeMillis()); memberParams.put("social_credit_code_expires", dto.getSocialCreditCodeExpires()); memberParams.put("business_scope", dto.getBusinessScope()); @@ -553,7 +611,7 @@ public class AdapayMemberService { memberParams.put("telphone", dto.getTelphone()); memberParams.put("email", dto.getEmail()); File file = ZipUtil.createZipFileFromImages(dto.getImgList()); - Map member = AdapayCommon.requestAdapayFile(memberParams, file); + Map member = AdapayCommon.requestAdapayFile(memberParams, file, config.getWechatAppId()); log.info("更新企业账户param:{}, result:{}", JSON.toJSONString(memberParams), JSON.toJSONString(member)); if (AdapayStatusEnum.FAILED.getValue().equals((String) member.get("status"))) { throw new BusinessException("", (String) member.get("error_msg")); @@ -611,9 +669,15 @@ public class AdapayMemberService { * @param title 标题 * @param desc 描述信息 */ - public BalancePaymentResponse createBalancePaymentRequest(String outMemberId, String inMemberId, String transAmt, String title, String desc) { + public BalancePaymentResponse createBalancePaymentRequest(String outMemberId, String inMemberId, String transAmt, String title, String desc, String wechatAppId) { + // 获取汇付支付配置 + AbstractAdapayConfig config = AdapayConfigFactory.getConfig(wechatAppId); + if (config == null) { + throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR); + } + Map balanceParam = Maps.newHashMap(); - balanceParam.put("app_id", ADAPAY_APP_ID); + balanceParam.put("app_id", config.getAdapayAppId()); balanceParam.put("adapay_func_code", "settle_accounts.balancePay"); balanceParam.put("order_no", IdUtils.fastSimpleUUID()); balanceParam.put("out_member_id", outMemberId); @@ -623,7 +687,7 @@ public class AdapayMemberService { balanceParam.put("goods_desc", desc); Map paymentResult = null; try { - paymentResult = AdapayCommon.requestAdapay(balanceParam); + paymentResult = AdapayCommon.requestAdapay(balanceParam, config.getWechatAppId()); } catch (BaseAdaPayException e) { log.error("创建余额支付请求error", e); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 4625779d7..cfd2f9b42 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -16,7 +16,6 @@ import com.jsowell.adapay.common.CreateAdaPaymentParam; import com.jsowell.adapay.common.DivMember; import com.jsowell.adapay.config.AbstractAdapayConfig; import com.jsowell.adapay.factory.AdapayConfigFactory; -import com.jsowell.adapay.response.BalancePaymentResponse; import com.jsowell.adapay.response.PaymentConfirmResponse; import com.jsowell.adapay.response.PaymentReverseResponse; import com.jsowell.adapay.service.AdapayMemberService; @@ -1025,8 +1024,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService { OrderSettleResult orderSettleResult; if (OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) { // 余额支付的订单 - // orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount); - orderSettleResult = doBalancePaymentV2(orderBasicInfo, adapayMemberAccount); + orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount); } else { // 在线支付,进行支付确认分账 orderSettleResult = doPaymentConfirm(orderBasicInfo, adapayMemberAccount); @@ -1129,7 +1127,7 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService { if (OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue().equals(orderBasicInfo.getPayMode())) { logger.info("手动接口执行订单分账逻辑-order:{}, result:{}", JSON.toJSONString(orderBasicInfo), JSON.toJSONString(orderSettleResult)); // 余额支付的订单 只用余额支付转账 - orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount); + // orderSettleResult = doBalancePayment(orderBasicInfo, adapayMemberAccount); } else { // 在线支付,进行支付确认分账 orderSettleResult = doPaymentConfirm(orderBasicInfo, adapayMemberAccount); @@ -1147,46 +1145,13 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService { } /** - * 余额支付订单,使用余额支付转账 + * 余额支付订单,使用余额分账 * * @param orderBasicInfo * @param adapayMemberAccount * @return */ public OrderSettleResult doBalancePayment(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException { - // 计算应该支付金额,和手续费 - SplitSettleAmountVO splitSettleAmountVO = splitSettleAmount(orderBasicInfo.getSettleAmount()); - BigDecimal feeAmount = splitSettleAmountVO.getFeeAmount(); - BigDecimal tradeAmount = splitSettleAmountVO.getTradeAmount(); - logger.info("余额支付订单使用余额支付转账, orderCode:{}, inMemberId:{}, transAmt:{}", orderBasicInfo.getOrderCode(), orderBasicInfo, tradeAmount); - - String orderCode = orderBasicInfo.getOrderCode(); - // 使用汇付余额支付功能 - String outMemberId = Constants.ZERO; // 若为商户本身时,请传入0 - String inMemberId = adapayMemberAccount.getAdapayMemberId(); - String transAmt = AdapayUtil.formatAmount(tradeAmount); - String title = "订单结算入账"; - String desc = "订单号:" + orderCode + ", 结算金额"; - BalancePaymentResponse balancePaymentRequest = adapayMemberService.createBalancePaymentRequest(outMemberId, inMemberId, transAmt, title, desc); - - OrderSettleResult result = new OrderSettleResult(); - result.setConfirm_amt(balancePaymentRequest.getTrans_amt()); - result.setStatus(balancePaymentRequest.getStatus()); - result.setFee_amt(feeAmount.toString()); - // JSONObject jsonObject = new JSONObject(); - // jsonObject.put("orderCode", orderCode); - // result.setDescription(jsonObject.toJSONString()); - return result; - } - - /** - * 余额支付订单,使用余额支付转账 - * - * @param orderBasicInfo - * @param adapayMemberAccount - * @return - */ - public OrderSettleResult doBalancePaymentV2(OrderBasicInfo orderBasicInfo, AdapayMemberAccount adapayMemberAccount) throws BaseAdaPayException { BigDecimal settleAmount = orderBasicInfo.getSettleAmount(); String orderCode = orderBasicInfo.getOrderCode();