|
@@ -1,10 +1,49 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.function.BiPredicate;
|
|
|
+import java.util.function.Consumer;
|
|
|
+import java.util.function.Function;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.redisson.api.RBucket;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.DigestUtils;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
+import com.ym.mec.biz.dal.entity.SysConfig;
|
|
|
+import com.ym.mec.biz.dal.entity.SysPaymentConfig;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantConfig;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantOrderRecord;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
|
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.service.*;
|
|
|
+import com.ym.mec.biz.service.CloudTeacherOrderService;
|
|
|
+import com.ym.mec.biz.service.OrderPayOpsService;
|
|
|
+import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
+import com.ym.mec.biz.service.SysConfigService;
|
|
|
+import com.ym.mec.biz.service.SysPaymentConfigService;
|
|
|
+import com.ym.mec.biz.service.TenantConfigService;
|
|
|
+import com.ym.mec.biz.service.TenantOrderRecordService;
|
|
|
+import com.ym.mec.biz.service.TenantPaymentOrderService;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
@@ -12,24 +51,6 @@ import com.ym.mec.thirdparty.adapay.Payment;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.http.HttpUtil;
|
|
|
import com.ym.mec.util.json.JsonUtil;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.redisson.api.RBucket;
|
|
|
-import org.redisson.api.RedissonClient;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.DigestUtils;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
-import java.util.function.BiPredicate;
|
|
|
-import java.util.function.Consumer;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
|
/**
|
|
|
* @author hgw
|
|
@@ -56,6 +77,9 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
|
private SysConfigService sysConfigService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private SysConfigDao sysConfigDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private SysPaymentConfigService sysPaymentConfigService;
|
|
|
|
|
|
//支付类型
|
|
@@ -300,77 +324,77 @@ 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());
|
|
|
-
|
|
|
- List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
|
+ 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);
|
|
|
- }
|
|
|
-
|
|
|
- Map<String, Object> divMember1 = new HashMap<>();
|
|
|
- divMember1.put("member_id", merNos);
|
|
|
- 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());
|
|
|
+ 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());
|
|
|
+ }*/
|
|
|
+
|
|
|
+ String platformAccount = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(platformAccount)){
|
|
|
+ throw new BizException("平台收款账户查询失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> divMember = new HashMap<>();
|
|
|
+ divMember.put("member_id", platformAccount);
|
|
|
+ divMember.put("amount", amount);
|
|
|
+ divMember.put("fee_flag", "Y");
|
|
|
+ divMemberList.add(divMember);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> divMember1 = new HashMap<>();
|
|
|
+ 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;
|
|
|
+
|
|
|
+ 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");
|