|  | @@ -1,39 +1,54 @@
 | 
											
												
													
														|  |  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.dao.SysConfigDao;
 |  |  import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.dal.dto.PaymentParam;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 |  |  import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.TenantConfig;
 |  |  import com.ym.mec.biz.dal.entity.TenantConfig;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 |  |  import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 |  |  import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 | 
											
												
													
														|  |  import com.ym.mec.biz.dal.enums.DealStatusEnum;
 |  |  import com.ym.mec.biz.dal.enums.DealStatusEnum;
 | 
											
												
													
														|  | -import com.ym.mec.biz.service.*;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.service.HfMerchantConfigService;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.service.OrderPayOpsService;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.biz.service.StudentPaymentOrderService;
 | 
											
												
													
														|  | 
 |  | +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.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;
 | 
											
												
													
														|  |  import com.ym.mec.thirdparty.adapay.Payment;
 |  |  import com.ym.mec.thirdparty.adapay.Payment;
 | 
											
												
													
														|  | 
 |  | +import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 | 
											
												
													
														|  |  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
 | 
											
										
											
												
													
														|  | @@ -49,6 +64,10 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |      private TenantPaymentOrderService tenantPaymentOrderService;
 |  |      private TenantPaymentOrderService tenantPaymentOrderService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private TenantOrderRecordService tenantOrderRecordService;
 |  |      private TenantOrderRecordService tenantOrderRecordService;
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private HfMerchantConfigService hfMerchantConfigService;
 | 
											
												
													
														|  | 
 |  | +    
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private RedissonClient redissonClient;
 |  |      private RedissonClient redissonClient;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
										
											
												
													
														|  | @@ -62,9 +81,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |      private static final BiPredicate<Object, DealStatusEnum> predicate = (o, s) -> Objects.nonNull(o) && !DealStatusEnum.ING.equals(s);
 |  |      private static final BiPredicate<Object, DealStatusEnum> predicate = (o, s) -> Objects.nonNull(o) && !DealStatusEnum.ING.equals(s);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  | -    public Map<String, Object> executePayment(BigDecimal amount, String orderNo, String payChannel, String returnUrl, String orderSubject, String orderBody, String sign, String code, String platform) throws Exception {
 |  | 
 | 
											
												
													
														|  | -        PaymentParam payParam = new PaymentParam(amount, orderNo, payChannel, returnUrl,
 |  | 
 | 
											
												
													
														|  | -                orderSubject, orderBody, sign, code, platform);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public Map<String, Object> executePayment(PaymentParam payParam) throws Exception {
 | 
											
												
													
														|  |          log.info("executePayment >>>>> {}", JSON.toJSONString(payParam));
 |  |          log.info("executePayment >>>>> {}", JSON.toJSONString(payParam));
 | 
											
												
													
														|  |          if (payParam.getAmount() == null) {
 |  |          if (payParam.getAmount() == null) {
 | 
											
												
													
														|  |              throw new Exception("PaymentParam query is null");
 |  |              throw new Exception("PaymentParam query is null");
 | 
											
										
											
												
													
														|  | @@ -74,13 +91,11 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          //返回值
 |  |          //返回值
 | 
											
												
													
														|  |          Map<String, Object> payment;
 |  |          Map<String, Object> payment;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if (WrapperUtil.checkStr(platform, tenantPlatform)) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (WrapperUtil.checkStr(payParam.getPlatform(), tenantPlatform)) {
 | 
											
												
													
														|  |              //tenant 机构开通、续费付款、 cloudTeacherOrder 团练宝激活支付、tenantRecharge 机构充值
 |  |              //tenant 机构开通、续费付款、 cloudTeacherOrder 团练宝激活支付、tenantRecharge 机构充值
 | 
											
												
													
														|  |              payment = tenantPlatformOrder(payParam);
 |  |              payment = tenantPlatformOrder(payParam);
 | 
											
												
													
														|  |              //主动延迟检查订单
 |  |              //主动延迟检查订单
 | 
											
												
													
														|  |              delayCheckTenant();
 |  |              delayCheckTenant();
 | 
											
												
													
														|  | -        } else if (platform.equals("teacher")) {
 |  | 
 | 
											
												
													
														|  | -            payment = teacher(payParam);
 |  | 
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  |              //如果以上操作都没有 则应该是这一个,因为老代码就是这样写的。
 |  |              //如果以上操作都没有 则应该是这一个,因为老代码就是这样写的。
 | 
											
												
													
														|  |              payment = student(payParam);
 |  |              payment = student(payParam);
 | 
											
										
											
												
													
														|  | @@ -90,13 +105,21 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      private void checkSing(PaymentParam param) {
 |  |      private void checkSing(PaymentParam param) {
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  | 
 |  | +        //查询商户支付账户
 | 
											
												
													
														|  | 
 |  | +        HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(param.getTenantId());
 | 
											
												
													
														|  | 
 |  | +        if(hfMerchantConfig == null){
 | 
											
												
													
														|  | 
 |  | +        	throw new BizException("请配置机构的汇付商户信息");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          Map<String, Object> signParams = new LinkedHashMap<>();
 |  |          Map<String, Object> signParams = new LinkedHashMap<>();
 | 
											
												
													
														|  | -        signParams.put("appId", ConfigInit.appId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        signParams.put("appId", hfMerchantConfig.getAppId());
 | 
											
												
													
														|  |          signParams.put("amount", param.getAmount().setScale(2, RoundingMode.HALF_UP));
 |  |          signParams.put("amount", param.getAmount().setScale(2, RoundingMode.HALF_UP));
 | 
											
												
													
														|  |          signParams.put("orderNo", param.getOrderNo());
 |  |          signParams.put("orderNo", param.getOrderNo());
 | 
											
												
													
														|  | 
 |  | +        signParams.put("notifyUrl", param.getNotifyUrl());
 | 
											
												
													
														|  | 
 |  | +        signParams.put("returnUrl", param.getReturnUrl());
 | 
											
												
													
														|  |          signParams.put("orderSubject", param.getOrderSubject());
 |  |          signParams.put("orderSubject", param.getOrderSubject());
 | 
											
												
													
														|  |          signParams.put("orderBody", param.getOrderBody());
 |  |          signParams.put("orderBody", param.getOrderBody());
 | 
											
												
													
														|  | -        signParams.put("wxAppId", ConfigInit.wxAppId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        signParams.put("wxAppId", hfMerchantConfig.getWxAppId());
 | 
											
												
													
														|  |          String originalStr = JSONObject.toJSONString(signParams);
 |  |          String originalStr = JSONObject.toJSONString(signParams);
 | 
											
												
													
														|  |          String newSign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
 |  |          String newSign = DigestUtils.md5DigestAsHex(originalStr.getBytes());
 | 
											
												
													
														|  |          if (!newSign.equals(param.getSign())) {
 |  |          if (!newSign.equals(param.getSign())) {
 | 
											
										
											
												
													
														|  | @@ -110,7 +133,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          //查询订单
 |  |          //查询订单
 | 
											
												
													
														|  |          TenantOrderRecord tenantOrderRecord = tenantOrderRecordService.getOne(new WrapperUtil<TenantOrderRecord>()
 |  |          TenantOrderRecord tenantOrderRecord = tenantOrderRecordService.getOne(new WrapperUtil<TenantOrderRecord>()
 | 
											
												
													
														|  |                  .hasEq("order_no_", payParam.getOrderNo()).queryWrapper());
 |  |                  .hasEq("order_no_", payParam.getOrderNo()).queryWrapper());
 | 
											
												
													
														|  | -        if (Objects.isNull(tenantOrderRecord)) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(tenantOrderRecord) || tenantOrderRecord.getTenantId().intValue() != payParam.getTenantId()) {
 | 
											
												
													
														|  |              throw new BizException("订单不存在");
 |  |              throw new BizException("订单不存在");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          if (tenantOrderRecord.getOrderState() != 0) {
 |  |          if (tenantOrderRecord.getOrderState() != 0) {
 | 
											
										
											
												
													
														|  | @@ -118,7 +141,6 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          //获取支付数据
 |  |          //获取支付数据
 | 
											
												
													
														|  |          Map<String, Object> payment;
 |  |          Map<String, Object> payment;
 | 
											
												
													
														|  | -        payParam.setTenantId(tenantOrderRecord.getTenantId());
 |  | 
 | 
											
												
													
														|  |          try {
 |  |          try {
 | 
											
												
													
														|  |              payment = checkOrderAndGetParam(payParam,
 |  |              payment = checkOrderAndGetParam(payParam,
 | 
											
												
													
														|  |                      tenantOrderRecord,
 |  |                      tenantOrderRecord,
 | 
											
										
											
												
													
														|  | @@ -159,10 +181,10 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |      private Map<String, Object> student(PaymentParam payParam) throws Exception {
 |  |      private Map<String, Object> student(PaymentParam payParam) throws Exception {
 | 
											
												
													
														|  |          Map<String, Object> payment;
 |  |          Map<String, Object> payment;
 | 
											
												
													
														|  |          StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
 |  |          StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
 | 
											
												
													
														|  | -        if (Objects.isNull(studentPaymentOrder)) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (Objects.isNull(studentPaymentOrder) || studentPaymentOrder.getTenantId().intValue() != payParam.getTenantId()) {
 | 
											
												
													
														|  |              throw new BizException("订单不存在");
 |  |              throw new BizException("订单不存在");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        payParam.setTenantId(studentPaymentOrder.getTenantId());
 |  | 
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  |          payment = checkOrderAndGetParam(payParam,
 |  |          payment = checkOrderAndGetParam(payParam,
 | 
											
												
													
														|  |                  studentPaymentOrder,
 |  |                  studentPaymentOrder,
 | 
											
												
													
														|  |                  StudentPaymentOrder::getStatus,
 |  |                  StudentPaymentOrder::getStatus,
 | 
											
										
											
												
													
														|  | @@ -185,12 +207,20 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          Date createTime = dateFunc.apply(clazz);
 |  |          Date createTime = dateFunc.apply(clazz);
 | 
											
												
													
														|  |          //校验订单是否超时
 |  |          //校验订单是否超时
 | 
											
												
													
														|  |          String timeExpire = checkOrderTimeOut(createTime);
 |  |          String timeExpire = checkOrderTimeOut(createTime);
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  | 
 |  | +        //查询商户支付账户
 | 
											
												
													
														|  | 
 |  | +        HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payParam.getTenantId());
 | 
											
												
													
														|  | 
 |  | +        if(hfMerchantConfig == null){
 | 
											
												
													
														|  | 
 |  | +        	throw new BizException("请配置机构的汇付商户信息");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        
 | 
											
												
													
														|  |          //初始化支付数据
 |  |          //初始化支付数据
 | 
											
												
													
														|  | -        Map<String, Object> paymentParams = getPaymentParam(payParam, clazz);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        Map<String, Object> paymentParams = getPaymentParam(payParam, clazz, hfMerchantConfig.getPlatformPayeeMemberId());
 | 
											
												
													
														|  |          paymentParams.put("time_expire", timeExpire);
 |  |          paymentParams.put("time_expire", timeExpire);
 | 
											
												
													
														|  | -        paymentParams.put("expend", getExpend(payParam));
 |  | 
 | 
											
												
													
														|  | 
 |  | +        paymentParams.put("expend", getExpend(hfMerchantConfig, payParam));
 | 
											
												
													
														|  | 
 |  | +        paymentParams.put("notify_url", payParam.getNotifyUrl());
 | 
											
												
													
														|  |          //向第三方发起支付,获取第三方的支付的信息
 |  |          //向第三方发起支付,获取第三方的支付的信息
 | 
											
												
													
														|  | -        Map<String, Object> payment = Payment.executePayment(paymentParams);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        Map<String, Object> payment = Payment.executePayment(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), paymentParams);
 | 
											
												
													
														|  |          log.info("executePayment create order param >>>>> {}", JSON.toJSONString(payment));
 |  |          log.info("executePayment create order param >>>>> {}", JSON.toJSONString(payment));
 | 
											
												
													
														|  |          String transNo = (String) payment.get("id");
 |  |          String transNo = (String) payment.get("id");
 | 
											
												
													
														|  |          //修改流水
 |  |          //修改流水
 | 
											
										
											
												
													
														|  | @@ -223,26 +253,26 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          action.accept(clazz);
 |  |          action.accept(clazz);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private Map<String, Object> getExpend(PaymentParam payParam) throws Exception {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private Map<String, Object> getExpend(HfMerchantConfig hfMerchantConfig, PaymentParam payParam) throws Exception {
 | 
											
												
													
														|  |          Map<String, Object> expendParams = new HashMap<>(5);
 |  |          Map<String, Object> expendParams = new HashMap<>(5);
 | 
											
												
													
														|  |          String openId = "";
 |  |          String openId = "";
 | 
											
												
													
														|  |          if (payParam.getPayChannel().equals("wx_pub")) {
 |  |          if (payParam.getPayChannel().equals("wx_pub")) {
 | 
											
												
													
														|  |              //微信支付则获取openId
 |  |              //微信支付则获取openId
 | 
											
												
													
														|  | -            openId = getOpenId(payParam.getCode());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            openId = getOpenId(hfMerchantConfig, payParam.getCode());
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          expendParams.put("open_id", openId);
 |  |          expendParams.put("open_id", openId);
 | 
											
												
													
														|  |          expendParams.put("is_raw", "1");
 |  |          expendParams.put("is_raw", "1");
 | 
											
												
													
														|  | -        expendParams.put("callback_url", payParam.getReturnUrl());
 |  | 
 | 
											
												
													
														|  | 
 |  | +        //expendParams.put("callback_url", payParam.getReturnUrl());
 | 
											
												
													
														|  |          expendParams.put("limit_pay", "1");
 |  |          expendParams.put("limit_pay", "1");
 | 
											
												
													
														|  |          return expendParams;
 |  |          return expendParams;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private String getOpenId(String code) throws Exception {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private String getOpenId(HfMerchantConfig hfMerchantConfig, String code) throws Exception {
 | 
											
												
													
														|  |          String openId;
 |  |          String openId;
 | 
											
												
													
														|  |          if (code == null || code.isEmpty()) {
 |  |          if (code == null || code.isEmpty()) {
 | 
											
												
													
														|  |              throw new BizException("微信支付请先授权");
 |  |              throw new BizException("微信支付请先授权");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        String wxMpOAuth2AccessTokenUrl = String.format(ConfigInit.wxMpOAuth2AccessTokenUrl, ConfigInit.wxAppId, ConfigInit.wxAppSecret, code);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        String wxMpOAuth2AccessTokenUrl = String.format(ConfigInit.wxMpOAuth2AccessTokenUrl, hfMerchantConfig.getWxAppId(), hfMerchantConfig.getWxAppSecret(), code);
 | 
											
												
													
														|  |          Map<String, String> weChatRes = JSON.parseObject(HttpUtil.get(wxMpOAuth2AccessTokenUrl, new HashMap<>()), Map.class);
 |  |          Map<String, String> weChatRes = JSON.parseObject(HttpUtil.get(wxMpOAuth2AccessTokenUrl, new HashMap<>()), Map.class);
 | 
											
												
													
														|  |          if (!weChatRes.containsKey("openid")) {
 |  |          if (!weChatRes.containsKey("openid")) {
 | 
											
												
													
														|  |              throw new BizException("授权失败,请重新授权");
 |  |              throw new BizException("授权失败,请重新授权");
 | 
											
										
											
												
													
														|  | @@ -251,9 +281,8 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          return openId;
 |  |          return openId;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    private <T> Map<String, Object> getPaymentParam(PaymentParam payParam, T clazz) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    private <T> Map<String, Object> getPaymentParam(PaymentParam payParam, T clazz, String platformAccount) {
 | 
											
												
													
														|  |          Map<String, Object> paymentParams = new HashMap<>();
 |  |          Map<String, Object> paymentParams = new HashMap<>();
 | 
											
												
													
														|  | -        paymentParams.put("app_id", ConfigInit.appId);
 |  | 
 | 
											
												
													
														|  |          paymentParams.put("order_no", payParam.getOrderNo());
 |  |          paymentParams.put("order_no", payParam.getOrderNo());
 | 
											
												
													
														|  |          paymentParams.put("pay_channel", payParam.getPayChannel());
 |  |          paymentParams.put("pay_channel", payParam.getPayChannel());
 | 
											
												
													
														|  |          paymentParams.put("pay_amt", payParam.getAmount().setScale(2, RoundingMode.HALF_UP));
 |  |          paymentParams.put("pay_amt", payParam.getAmount().setScale(2, RoundingMode.HALF_UP));
 | 
											
										
											
												
													
														|  | @@ -293,7 +322,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |      	        		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
 |  |      	        		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
 | 
											
												
													
														|  |      	        	}*/
 |  |      	        	}*/
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -                    String platformAccount = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
 |  | 
 | 
											
												
													
														|  | 
 |  | +                    //String platformAccount = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                      if (StringUtils.isBlank(platformAccount)) {
 |  |                      if (StringUtils.isBlank(platformAccount)) {
 | 
											
												
													
														|  |                          throw new BizException("平台收款账户查询失败");
 |  |                          throw new BizException("平台收款账户查询失败");
 | 
											
										
											
												
													
														|  | @@ -368,111 +397,5 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 | 
											
												
													
														|  |          });
 |  |          });
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    static class PaymentParam {
 |  | 
 | 
											
												
													
														|  | -        private BigDecimal amount;
 |  | 
 | 
											
												
													
														|  | -        private String orderNo;
 |  | 
 | 
											
												
													
														|  | -        private String payChannel;
 |  | 
 | 
											
												
													
														|  | -        private String returnUrl;
 |  | 
 | 
											
												
													
														|  | -        private String orderSubject;
 |  | 
 | 
											
												
													
														|  | -        private String orderBody;
 |  | 
 | 
											
												
													
														|  | -        private String sign;
 |  | 
 | 
											
												
													
														|  | -        private String code;
 |  | 
 | 
											
												
													
														|  | -        private String platform;
 |  | 
 | 
											
												
													
														|  | -        private Integer tenantId;
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        PaymentParam(BigDecimal amount, String orderNo, String payChannel, String returnUrl, String orderSubject,
 |  | 
 | 
											
												
													
														|  | -                     String orderBody, String sign, String code, String platform) {
 |  | 
 | 
											
												
													
														|  | -            this.amount = amount;
 |  | 
 | 
											
												
													
														|  | -            this.orderNo = orderNo;
 |  | 
 | 
											
												
													
														|  | -            this.payChannel = payChannel;
 |  | 
 | 
											
												
													
														|  | -            this.returnUrl = returnUrl;
 |  | 
 | 
											
												
													
														|  | -            this.orderSubject = orderSubject;
 |  | 
 | 
											
												
													
														|  | -            this.orderBody = orderBody;
 |  | 
 | 
											
												
													
														|  | -            this.sign = sign;
 |  | 
 | 
											
												
													
														|  | -            this.code = code;
 |  | 
 | 
											
												
													
														|  | -            this.platform = platform;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public BigDecimal getAmount() {
 |  | 
 | 
											
												
													
														|  | -            return amount;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setAmount(BigDecimal amount) {
 |  | 
 | 
											
												
													
														|  | -            this.amount = amount;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getOrderNo() {
 |  | 
 | 
											
												
													
														|  | -            return orderNo;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setOrderNo(String orderNo) {
 |  | 
 | 
											
												
													
														|  | -            this.orderNo = orderNo;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getPayChannel() {
 |  | 
 | 
											
												
													
														|  | -            return payChannel;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setPayChannel(String payChannel) {
 |  | 
 | 
											
												
													
														|  | -            this.payChannel = payChannel;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getReturnUrl() {
 |  | 
 | 
											
												
													
														|  | -            return returnUrl;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setReturnUrl(String returnUrl) {
 |  | 
 | 
											
												
													
														|  | -            this.returnUrl = returnUrl;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getOrderSubject() {
 |  | 
 | 
											
												
													
														|  | -            return orderSubject;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setOrderSubject(String orderSubject) {
 |  | 
 | 
											
												
													
														|  | -            this.orderSubject = orderSubject;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getOrderBody() {
 |  | 
 | 
											
												
													
														|  | -            return orderBody;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setOrderBody(String orderBody) {
 |  | 
 | 
											
												
													
														|  | -            this.orderBody = orderBody;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getSign() {
 |  | 
 | 
											
												
													
														|  | -            return sign;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setSign(String sign) {
 |  | 
 | 
											
												
													
														|  | -            this.sign = sign;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getCode() {
 |  | 
 | 
											
												
													
														|  | -            return code;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setCode(String code) {
 |  | 
 | 
											
												
													
														|  | -            this.code = code;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public String getPlatform() {
 |  | 
 | 
											
												
													
														|  | -            return platform;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setPlatform(String platform) {
 |  | 
 | 
											
												
													
														|  | -            this.platform = platform;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public Integer getTenantId() {
 |  | 
 | 
											
												
													
														|  | -            return tenantId;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        public void setTenantId(Integer tenantId) {
 |  | 
 | 
											
												
													
														|  | -            this.tenantId = tenantId;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 |