|
@@ -1,48 +1,10 @@
|
|
package com.ym.mec.biz.service.impl;
|
|
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.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-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.entity.*;
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
-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.biz.service.*;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
import com.ym.mec.thirdparty.adapay.ConfigInit;
|
|
@@ -50,6 +12,24 @@ import com.ym.mec.thirdparty.adapay.Payment;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.http.HttpUtil;
|
|
import com.ym.mec.util.http.HttpUtil;
|
|
import com.ym.mec.util.json.JsonUtil;
|
|
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
|
|
* @author hgw
|
|
@@ -71,10 +51,10 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
private CloudTeacherOrderService cloudTeacherOrderService;
|
|
private CloudTeacherOrderService cloudTeacherOrderService;
|
|
@Autowired
|
|
@Autowired
|
|
private TenantConfigService tenantConfigService;
|
|
private TenantConfigService tenantConfigService;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SysConfigService sysConfigService;
|
|
private SysConfigService sysConfigService;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SysPaymentConfigService sysPaymentConfigService;
|
|
private SysPaymentConfigService sysPaymentConfigService;
|
|
|
|
|
|
@@ -102,25 +82,17 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
}
|
|
}
|
|
//签名验证
|
|
//签名验证
|
|
checkSing(payParam);
|
|
checkSing(payParam);
|
|
-
|
|
|
|
- Map<String, Object> payment = new HashMap<>();
|
|
|
|
|
|
+ //返回值
|
|
|
|
+ Map<String, Object> payment;
|
|
|
|
+ //如果platform is null 则应该是这一个,因为老代码就是这样写的。
|
|
if (StringUtils.isBlank(platform)) {
|
|
if (StringUtils.isBlank(platform)) {
|
|
|
|
+ payment = student(payParam);
|
|
|
|
+ } else {
|
|
//根据传入platform 来判断执行哪个操作
|
|
//根据传入platform 来判断执行哪个操作
|
|
Function<PaymentParam, Map<String, Object>> function = checkOrderType.get(platform);
|
|
Function<PaymentParam, Map<String, Object>> function = checkOrderType.get(platform);
|
|
//如果以上操作都没有 则应该是这一个,因为老代码就是这样写的。
|
|
//如果以上操作都没有 则应该是这一个,因为老代码就是这样写的。
|
|
if (Objects.isNull(function)) {
|
|
if (Objects.isNull(function)) {
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
|
|
|
|
- if (Objects.isNull(studentPaymentOrder)) {
|
|
|
|
- throw new BizException("订单不存在");
|
|
|
|
- }
|
|
|
|
- payParam.setTenantId(studentPaymentOrder.getTenantId());
|
|
|
|
- payment = checkOrderAndGetParam(payParam,
|
|
|
|
- studentPaymentOrder,
|
|
|
|
- StudentPaymentOrder::getStatus,
|
|
|
|
- StudentPaymentOrder::getCreateTime,
|
|
|
|
- studentPaymentOrder::setTransNo,
|
|
|
|
- studentPaymentOrderService::update
|
|
|
|
- );
|
|
|
|
|
|
+ payment = student(payParam);
|
|
} else {
|
|
} else {
|
|
payment = function.apply(payParam);
|
|
payment = function.apply(payParam);
|
|
}
|
|
}
|
|
@@ -128,6 +100,24 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
return payment;
|
|
return payment;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //platform is null 或者 student
|
|
|
|
+ private Map<String, Object> student(PaymentParam payParam) throws Exception {
|
|
|
|
+ Map<String, Object> payment;
|
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
|
|
|
|
+ if (Objects.isNull(studentPaymentOrder)) {
|
|
|
|
+ throw new BizException("订单不存在");
|
|
|
|
+ }
|
|
|
|
+ payParam.setTenantId(studentPaymentOrder.getTenantId());
|
|
|
|
+ payment = checkOrderAndGetParam(payParam,
|
|
|
|
+ studentPaymentOrder,
|
|
|
|
+ StudentPaymentOrder::getStatus,
|
|
|
|
+ StudentPaymentOrder::getCreateTime,
|
|
|
|
+ studentPaymentOrder::setTransNo,
|
|
|
|
+ studentPaymentOrderService::update
|
|
|
|
+ );
|
|
|
|
+ return payment;
|
|
|
|
+ }
|
|
|
|
+
|
|
//teacher
|
|
//teacher
|
|
private Map<String, Object> teacher(PaymentParam payParam) {
|
|
private Map<String, Object> teacher(PaymentParam payParam) {
|
|
Map<String, Object> payment;
|
|
Map<String, Object> payment;
|
|
@@ -329,55 +319,55 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
|
|
StudentPaymentOrder st = (StudentPaymentOrder) clazz;
|
|
StudentPaymentOrder st = (StudentPaymentOrder) clazz;
|
|
merNos = st.getMerNos();
|
|
merNos = st.getMerNos();
|
|
amount = amountTo.apply(st.getActualAmount());
|
|
amount = amountTo.apply(st.getActualAmount());
|
|
-
|
|
|
|
- List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
|
|
|
|
+
|
|
|
|
+ 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));
|
|
|
|
-
|
|
|
|
|
|
+ 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) {//向平台支付,不分账
|
|
} else if (clazz instanceof TenantOrderRecord) {//向平台支付,不分账
|
|
TenantOrderRecord tor = (TenantOrderRecord) clazz;
|
|
TenantOrderRecord tor = (TenantOrderRecord) clazz;
|
|
merNos = tor.getMerNos();
|
|
merNos = tor.getMerNos();
|
|
-
|
|
|
|
|
|
+
|
|
List<Map<String, Object>> divMemberList = new ArrayList<>();
|
|
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));
|
|
|
|
-
|
|
|
|
|
|
+ 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) {
|
|
} /*else if (clazz instanceof TenantPaymentOrder) {
|
|
TenantPaymentOrder tpo = (TenantPaymentOrder) clazz;
|
|
TenantPaymentOrder tpo = (TenantPaymentOrder) clazz;
|
|
merNos = tpo.getMerNos();
|
|
merNos = tpo.getMerNos();
|
|
amount = amountTo.apply(tpo.getActualAmount());
|
|
amount = amountTo.apply(tpo.getActualAmount());
|
|
- } */else {
|
|
|
|
|
|
+ } */ else {
|
|
throw new BizException("订单[{}]找不到", payParam.getOrderNo());
|
|
throw new BizException("订单[{}]找不到", payParam.getOrderNo());
|
|
}
|
|
}
|
|
}
|
|
}
|