|
@@ -324,49 +324,30 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
|
paymentParams.put("pay_amt", payParam.getAmount().setScale(2, RoundingMode.HALF_UP));
|
|
|
paymentParams.put("goods_title", payParam.getOrderSubject());
|
|
|
paymentParams.put("goods_desc", payParam.getOrderBody());
|
|
|
+
|
|
|
+ TenantConfig tenantConfig = tenantConfigService.queryByTenantId(payParam.getTenantId());
|
|
|
+ if (tenantConfig == null) {
|
|
|
+ throw new BizException("机构[{}]信息找不到", payParam.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (clazz instanceof StudentPaymentOrder || clazz instanceof TenantPaymentOrder) {
|
|
|
+
|
|
|
+ if (payParam.getTenantId() == 1) {
|
|
|
+ // 延时分账
|
|
|
+ paymentParams.put("pay_mode", "delay");
|
|
|
+ } else {
|
|
|
|
|
|
- if (payParam.getTenantId() == 1) {
|
|
|
- // 延时分账
|
|
|
- paymentParams.put("pay_mode", "delay");
|
|
|
- } else {
|
|
|
- TenantConfig tenantConfig = tenantConfigService.queryByTenantId(payParam.getTenantId());
|
|
|
- if (tenantConfig == null) {
|
|
|
- throw new BizException("机构[{}]信息找不到", payParam.getTenantId());
|
|
|
- }
|
|
|
- String merNos;
|
|
|
- BigDecimal amount;
|
|
|
- Function<BigDecimal, BigDecimal> amountTo = (a) -> a
|
|
|
- .multiply(tenantConfig.getChargeRate())
|
|
|
- .divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
|
|
-
|
|
|
- if (clazz instanceof StudentPaymentOrder) {
|
|
|
- StudentPaymentOrder st = (StudentPaymentOrder) clazz;
|
|
|
- merNos = st.getMerNos();
|
|
|
- amount = amountTo.apply(st.getActualAmount());
|
|
|
+ Function<BigDecimal, BigDecimal> amountTo = (a) -> a
|
|
|
+ .multiply(tenantConfig.getChargeRate())
|
|
|
+ .divide(new BigDecimal(1000), 2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ StudentPaymentOrder st = (StudentPaymentOrder) clazz;
|
|
|
+ BigDecimal amount = amountTo.apply(st.getActualAmount());
|
|
|
|
|
|
List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
|
// 实时分账
|
|
|
if (amount.doubleValue() > 0) {
|
|
|
|
|
|
- SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
|
|
|
- if (Objects.isNull(config)) {
|
|
|
- throw new BizException("平台收款账户没有设置[platform_collection_organ]");
|
|
|
- }
|
|
|
-
|
|
|
- SysPaymentConfig sysPaymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(Integer.parseInt(config.getParanValue()));
|
|
|
-
|
|
|
- if(sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())){
|
|
|
- throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> divMember = new HashMap<>();
|
|
|
- divMember.put("member_id", sysPaymentConfig.getHfMerNo());
|
|
|
- divMember.put("amount", amount);
|
|
|
- divMember.put("fee_flag", "Y");
|
|
|
- divMemberList.add(divMember);
|
|
|
- }
|
|
|
- if (amount.doubleValue() > 0) {
|
|
|
-
|
|
|
/*SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
|
|
|
if (Objects.isNull(config)) {
|
|
|
throw new BizException("平台收款账户没有设置[platform_collection_organ]");
|
|
@@ -392,34 +373,28 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> divMember1 = new HashMap<>();
|
|
|
- divMember1.put("member_id", merNos);
|
|
|
+ divMember1.put("member_id", st.getMerNos());
|
|
|
divMember1.put("amount", payParam.getAmount().subtract(amount));
|
|
|
divMember1.put("fee_flag", "N");
|
|
|
divMemberList.add(divMember1);
|
|
|
|
|
|
paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
|
|
|
-
|
|
|
- } else if (clazz instanceof TenantOrderRecord) {//向平台支付,不分账
|
|
|
- TenantOrderRecord tor = (TenantOrderRecord) clazz;
|
|
|
- merNos = tor.getMerNos();
|
|
|
-
|
|
|
- List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
|
- Map<String, Object> divMember = new HashMap<>();
|
|
|
- divMember.put("member_id", merNos);
|
|
|
- divMember.put("amount", tor.getActualAmount());
|
|
|
- divMember.put("fee_flag", "Y");
|
|
|
- divMemberList.add(divMember);
|
|
|
-
|
|
|
- paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
|
|
|
-
|
|
|
- } /*else if (clazz instanceof TenantPaymentOrder) {
|
|
|
- TenantPaymentOrder tpo = (TenantPaymentOrder) clazz;
|
|
|
- merNos = tpo.getMerNos();
|
|
|
- amount = amountTo.apply(tpo.getActualAmount());
|
|
|
- } */else {
|
|
|
- throw new BizException("订单[{}]找不到", payParam.getOrderNo());
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ } else if (clazz instanceof TenantOrderRecord) {//向平台支付,不分账
|
|
|
+ TenantOrderRecord tor = (TenantOrderRecord) clazz;
|
|
|
+
|
|
|
+ List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
|
+ Map<String, Object> divMember = new HashMap<>();
|
|
|
+ divMember.put("member_id", tor.getMerNos());
|
|
|
+ divMember.put("amount", tor.getActualAmount());
|
|
|
+ divMember.put("fee_flag", "Y");
|
|
|
+ divMemberList.add(divMember);
|
|
|
+
|
|
|
+ paymentParams.put("div_members", JsonUtil.toJSONString(divMemberList));
|
|
|
+ } else {
|
|
|
+ throw new BizException("订单[{}]找不到", payParam.getOrderNo());
|
|
|
+ }
|
|
|
|
|
|
//手续费收取模式:O-商户手续费账户扣取手续费,I-交易金额中扣取手续费;值为空时,默认值为I;若为O时,分账对象列表中不支持传入手续费承担方
|
|
|
//paymentParams.put("fee_mode", "I");
|