Przeglądaj źródła

修改支付分润规则

周箭河 5 lat temu
rodzic
commit
d0618d5474

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysPaymentConfigDao.java

@@ -4,6 +4,10 @@ import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface SysPaymentConfigDao extends BaseDAO<Integer, SysPaymentConfig> {
     SysPaymentConfig findPaymentConfigByOrganId(@Param("organId") Integer organId);
+
+    List<SysPaymentConfig> findPaymentConfigByOrganIds(@Param("organIds") List<Integer> organIds);
 }

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PayChannelDto.java

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class PayChannelDto {
+
+    //支付渠道类型
+    private PaymentChannelEnum payType;
+
+    //分佣列表
+    private List<Map<String, Object>> tempRoutingList = new ArrayList<>();
+
+    public PaymentChannelEnum getPayType() {
+        return payType;
+    }
+
+    public void setPayType(PaymentChannelEnum payType) {
+        this.payType = payType;
+    }
+
+    public List<Map<String, Object>> getTempRoutingList() {
+        return tempRoutingList;
+    }
+
+    public void setTempRoutingList(List<Map<String, Object>> tempRoutingList) {
+        this.tempRoutingList = tempRoutingList;
+    }
+}

+ 69 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RouteScaleDto.java

@@ -0,0 +1,69 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+
+import java.math.BigDecimal;
+
+public class RouteScaleDto {
+
+    private Integer organId;
+
+    private PaymentChannelEnum payType;
+
+    private Integer scale;
+
+    private String merNo;
+
+    private BigDecimal amount = BigDecimal.ONE;
+
+    private String feeFlag;
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public String getMerNo() {
+        return merNo;
+    }
+
+    public void setMerNo(String merNo) {
+        this.merNo = merNo;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getFeeFlag() {
+        return feeFlag;
+    }
+
+    public void setFeeFlag(String feeFlag) {
+        this.feeFlag = feeFlag;
+    }
+
+
+    public Integer getScale() {
+        return scale;
+    }
+
+    public void setScale(Integer scale) {
+        this.scale = scale;
+    }
+
+    public PaymentChannelEnum getPayType() {
+        return payType;
+    }
+
+    public void setPayType(PaymentChannelEnum payType) {
+        this.payType = payType;
+    }
+}

+ 58 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysPaymentConfig.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import io.swagger.annotations.ApiModelProperty;
 import java.util.Date;
 
@@ -11,12 +12,37 @@ public class SysPaymentConfig {
     private Integer id;
 
     /**
+     * 支付渠道
+     */
+    @ApiModelProperty(value = "支付渠道")
+    private PaymentChannelEnum payType;
+
+    /**
+     * 双乾商户号
+     */
+    @ApiModelProperty(value = "双乾商户号")
+    private String yqMerNo;
+
+
+    /**
+     * 双乾商户号
+     */
+    @ApiModelProperty(value = "汇付商户号")
+    private String hfMerNo;
+
+    /**
      * type
      */
     @ApiModelProperty(value = "type(1-比例 2-类型)")
     private Integer type;
 
     /**
+     * 分润规则
+     */
+    @ApiModelProperty(value = "分润规则")
+    private String routeScale;
+
+    /**
      * 分部id
      */
     @ApiModelProperty(value = "分部id")
@@ -86,6 +112,14 @@ public class SysPaymentConfig {
         this.id = id;
     }
 
+    public PaymentChannelEnum getPayType() {
+        return payType;
+    }
+
+    public void setPayType(PaymentChannelEnum payType) {
+        this.payType = payType;
+    }
+
     public Integer getOrganId() {
         return organId;
     }
@@ -173,5 +207,29 @@ public class SysPaymentConfig {
     public void setType(Integer type) {
         this.type = type;
     }
+
+    public String getYqMerNo() {
+        return yqMerNo;
+    }
+
+    public void setYqMerNo(String yqMerNo) {
+        this.yqMerNo = yqMerNo;
+    }
+
+    public String getHfMerNo() {
+        return hfMerNo;
+    }
+
+    public void setHfMerNo(String hfMerNo) {
+        this.hfMerNo = hfMerNo;
+    }
+
+    public String getRouteScale() {
+        return routeScale;
+    }
+
+    public void setRouteScale(String routeScale) {
+        this.routeScale = routeScale;
+    }
 }
 

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/PayService.java

@@ -58,6 +58,24 @@ public interface PayService {
      */
     Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId,Map<String,BigDecimal> fee,Integer organId,String receiver) throws Exception;
 
+
+    /**
+     *
+     * @param amount 支付金额
+     * @param orderNo 订单编号
+     * @param notifyUrl 回调地址
+     * @param returnUrl 返回地址
+     * @param orderSubject 订单主题
+     * @param orderBody 订单内容
+     * @param organId 分部编号
+     * @param receiver 指定接收
+     * @return
+     * @throws Exception
+     */
+    Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody,Integer organId,String receiver) throws Exception;
+
+
+
     Map query(String orderNo) throws Exception;
 
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysPaymentConfigService.java

@@ -3,8 +3,12 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface SysPaymentConfigService extends BaseService<Integer, SysPaymentConfig> {
 
     SysPaymentConfig findPaymentConfigByOrganId(Integer organId);
 
+    List<SysPaymentConfig> findPaymentConfigByOrganIds(List<Integer> organIds);
+
 }

+ 261 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -1,18 +1,28 @@
 package com.ym.mec.biz.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.ym.mec.biz.dal.dao.MusicGroupDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dto.PayChannelDto;
+import com.ym.mec.biz.dal.dto.RouteScaleDto;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.thirdparty.adapay.ConfigInit;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.union.UnionPay;
 import com.ym.mec.thirdparty.union.UnionPayFeignService;
 import com.ym.mec.thirdparty.yqpay.YqPayUtil;
+import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.support.atomic.RedisAtomicDouble;
+import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
@@ -37,7 +47,28 @@ public class PayServiceImpl implements PayService {
     private SysConfigDao sysConfigDao;
     @Autowired
     private SysPaymentConfigService sysPaymentConfigService;
-
+    @Autowired
+    private RedisTemplate<String, String> redisTemplate;
+
+
+    public static void main(String[] args) {
+        String baseApiUrl = "http://dev.dayaedu.com";
+
+        try {
+            Map<String, Object> payMap = new PayServiceImpl().getPayMap(
+                    BigDecimal.TEN,
+                    "5435253245",
+                    baseApiUrl + "/api-student/studentOrder/notify",
+                    baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=5435253245",
+                    "对外课程组购买",
+                    "测试购买",
+                    1,
+                    null
+            );
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
     /**
      * 返回订单提交数据
@@ -99,7 +130,7 @@ public class PayServiceImpl implements PayService {
 
         Map<String, Object> payMap = null;
         String type = null;
-        List<Map<String, Object>> tempRoutingList = new ArrayList();
+        List<Map<String, Object>> tempRoutingList = new ArrayList<>();
         for (SysAccount account : accounts) {
             Map<String, Object> routingList = new HashMap<>();
             if (account.getChannel().equals("YQPAY")) {
@@ -154,7 +185,6 @@ public class PayServiceImpl implements PayService {
             receiver = null;
         }
 
-
         //直接收到深圳的分部
         String sDaYaOrganIds = sysConfigDao.findConfigValue(SysConfigService.SZ_DA_YA_ORGAN_IDS);
         if (StringUtils.isNotBlank(sDaYaOrganIds)) {
@@ -172,7 +202,7 @@ public class PayServiceImpl implements PayService {
 
         Map<String, Object> payMap = null;
         String type = null;
-        List<Map<String, Object>> tempRoutingList = new ArrayList();
+        List<Map<String, Object>> tempRoutingList = new ArrayList<>();
         for (SysAccount account : accounts) {
             Map<String, Object> routingList = new HashMap<>();
             if (account.getChannel().equals("YQPAY")) {
@@ -212,6 +242,233 @@ public class PayServiceImpl implements PayService {
     }
 
     @Override
+    public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer organId, String receiver) throws Exception {
+        //根据金额获取分润
+        PayChannelDto payChannelDto = getAmountChannel(amount);
+        //零星支付,收到指定
+        if (payChannelDto == null && receiver != null) {
+            payChannelDto = getSporadicChannel(amount);
+        }
+        //比例或者笔数分佣
+        if (payChannelDto == null) {
+            payChannelDto = getPaymentConfigChannel(organId, amount);
+        }
+
+        return getPayRoute(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, payChannelDto);
+    }
+
+    private PayChannelDto getPaymentConfigChannel(Integer organId, BigDecimal amount) {
+        PayChannelDto payChannelDto = new PayChannelDto();
+        List<Map<String, Object>> tempRoutingList = new ArrayList<>();
+        Map<String, Object> routingList = new HashMap<>();
+        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
+        if (paymentConfig == null) {
+            String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
+            if (paymentChannel.equals("YQPAY")) {
+                routingList.put("organId", organId);
+                routingList.put("routingMerNo", YqPayUtil.merNo);//分佣账户
+                routingList.put("routingFee", amount.subtract((amount.multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)))); //分佣金额
+                payChannelDto.setPayType(PaymentChannelEnum.YQPAY);
+            } else {
+                routingList.put("organId", organId);
+                routingList.put("member_id", ConfigInit.merNo);//分佣账户
+                routingList.put("amount", amount);//分佣金额
+                routingList.put("fee_flag", "Y"); //承担手续费
+                payChannelDto.setPayType(PaymentChannelEnum.ADAPAY);
+            }
+            tempRoutingList.add(routingList);
+            payChannelDto.setTempRoutingList(tempRoutingList);
+            return payChannelDto;
+        }
+
+        String routeScale = paymentConfig.getRouteScale();
+        List<RouteScaleDto> routeScaleDtos = JSON.parseArray(routeScale, RouteScaleDto.class);
+        List<Integer> organIds = routeScaleDtos.stream().map(RouteScaleDto::getOrganId).collect(Collectors.toList());
+        List<SysPaymentConfig> paymentConfigByOrganIds = sysPaymentConfigService.findPaymentConfigByOrganIds(organIds);
+        for (RouteScaleDto routeScaleDto : routeScaleDtos) {
+            routeScaleDto.setPayType(paymentConfig.getPayType());
+            routeScaleDto.setAmount(amount);
+            for (SysPaymentConfig paymentConfigByOrganId : paymentConfigByOrganIds) {
+                if (!paymentConfigByOrganId.getOrganId().equals(routeScaleDto.getOrganId())) continue;
+                if (paymentConfig.getPayType().equals(PaymentChannelEnum.YQPAY)) {
+                    routeScaleDto.setMerNo(paymentConfigByOrganId.getYqMerNo());
+                } else {
+                    routeScaleDto.setMerNo(paymentConfigByOrganId.getHfMerNo());
+                }
+            }
+        }
+
+        //笔数比例
+        if (paymentConfig.getType().equals(1)) {
+            int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
+            int rem = payOrderNums % 10;
+            rem = rem == 0 ? 10 : rem;
+
+            int scale = 0;
+            Iterator<RouteScaleDto> iterator = routeScaleDtos.iterator();
+            while (iterator.hasNext()) {
+                RouteScaleDto routeScaleDto = iterator.next();
+                Integer num = routeScaleDto.getScale();
+                if (rem > scale && rem <= scale + num) {
+                    routeScaleDto.setScale(100);
+                    continue;
+                }
+                scale += num;
+                iterator.remove();
+            }
+        }
+        BigDecimal routingAmount = amount.subtract((amount.multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)));
+        int i = 0;
+        BigDecimal hasRouteAmount = BigDecimal.ZERO;
+        for (RouteScaleDto routeScaleDto : routeScaleDtos) {
+            routingList = new HashMap<>();
+            i++;
+            if (routeScaleDto.getPayType().equals(PaymentChannelEnum.YQPAY)) {
+                BigDecimal routingFee = routingAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                if (i == routeScaleDtos.size()) {
+                    routingFee = routingAmount.subtract(hasRouteAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                hasRouteAmount = hasRouteAmount.add(routingFee);
+                if (routingFee.compareTo(BigDecimal.ZERO) <= 0) {
+                    continue;
+                }
+                routingList.put("organId", routeScaleDto.getOrganId());
+                routingList.put("routingMerNo", routeScaleDto.getMerNo());//分佣账户
+                routingList.put("routingFee", routingFee); //分佣金额
+            } else if (paymentConfig.getPayType().equals(PaymentChannelEnum.ADAPAY)) {
+                BigDecimal routingFee = amount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                if (i == routeScaleDtos.size()) {
+                    routingFee = amount.subtract(hasRouteAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                hasRouteAmount = hasRouteAmount.add(routingFee);
+                if (routingFee.compareTo(BigDecimal.ZERO) <= 0) {
+                    continue;
+                }
+                routingList.put("organId", routeScaleDto.getOrganId());
+                routingList.put("member_id", routeScaleDto.getMerNo());//分佣账户
+                routingList.put("amount", routingFee);//分佣金额
+                routingList.put("fee_flag", "Y"); //承担手续费
+            }
+            tempRoutingList.add(routingList);
+        }
+
+        payChannelDto.setPayType(paymentConfig.getPayType());
+        payChannelDto.setTempRoutingList(tempRoutingList);
+        return payChannelDto;
+    }
+
+
+    /**
+     * 根据金额获取渠道
+     *
+     * @param amount 金额
+     */
+    private PayChannelDto getAmountChannel(BigDecimal amount) {
+        String amountChannel = sysConfigDao.findConfigValue("amount_channel");
+        if (StringUtils.isBlank(amountChannel)) {
+            return null;
+        }
+        Integer organId = null;
+        List<Map<String, Object>> tempRoutingList = new ArrayList<>();
+        Map<String, Integer> channel = (Map<String, Integer>) JSON.parseObject(amountChannel, Map.class);
+        for (Map.Entry<String, Integer> amountStr : channel.entrySet()) {
+            if (new BigDecimal(amountStr.getKey()).compareTo(amount) == 0) {
+                organId = amountStr.getValue();
+                break;
+            }
+        }
+        if (organId == null) {
+            return null;
+        }
+        PayChannelDto payChannelDto = new PayChannelDto();
+        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
+        Map<String, Object> routingList = new HashMap<>();
+        if (paymentConfig.getPayType().equals(PaymentChannelEnum.YQPAY)) {
+            routingList.put("organId", paymentConfig.getOrganId());
+            routingList.put("routingMerNo", paymentConfig.getYqMerNo());//分佣账户
+            routingList.put("routingFee", amount.subtract((amount.multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)))); //分佣金额
+        } else if (paymentConfig.getPayType().equals(PaymentChannelEnum.ADAPAY)) {
+            routingList.put("organId", paymentConfig.getOrganId());
+            routingList.put("member_id", paymentConfig.getHfMerNo());//分佣账户
+            routingList.put("amount", amount);//分佣金额
+            routingList.put("fee_flag", "Y"); //承担手续费
+        }
+        tempRoutingList.add(routingList);
+        payChannelDto.setPayType(paymentConfig.getPayType());
+        payChannelDto.setTempRoutingList(tempRoutingList);
+        return payChannelDto;
+    }
+
+    /**
+     * 零星支付获取渠道
+     *
+     * @param amount
+     * @return
+     */
+    private PayChannelDto getSporadicChannel(BigDecimal amount) {
+        String SporadicChannel = sysConfigDao.findConfigValue("sporadic_channel");
+        if (StringUtils.isBlank(SporadicChannel)) {
+            return null;
+        }
+
+        List<Map<String, Object>> tempRoutingList = new ArrayList<>();
+        Map<String, String> channel = (Map<String, String>) JSON.parseObject(SporadicChannel, Map.class);
+        Integer organId = Integer.parseInt(channel.get("organId"));
+        BigDecimal maxReceipt = new BigDecimal(channel.get("maxReceipt"));
+
+        //已收金额
+        BigDecimal hasReceipt = new BigDecimal("7800");
+        if (hasReceipt.compareTo(maxReceipt) >= 0) {
+            return null;
+        }
+
+        PayChannelDto payChannelDto = new PayChannelDto();
+        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
+        Map<String, Object> routingList = new HashMap<>();
+        if (paymentConfig.getPayType().equals(PaymentChannelEnum.YQPAY)) {
+            routingList.put("organId", paymentConfig.getOrganId());
+            routingList.put("routingMerNo", paymentConfig.getYqMerNo());//分佣账户
+            routingList.put("routingFee", amount.subtract((amount.multiply(new BigDecimal("0.28")).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP)))); //分佣金额
+        } else if (paymentConfig.getPayType().equals(PaymentChannelEnum.ADAPAY)) {
+            routingList.put("organId", paymentConfig.getOrganId());
+            routingList.put("member_id", paymentConfig.getHfMerNo());//分佣账户
+            routingList.put("amount", amount);//分佣金额
+            routingList.put("fee_flag", "Y"); //承担手续费
+        }
+        tempRoutingList.add(routingList);
+        payChannelDto.setPayType(paymentConfig.getPayType());
+        payChannelDto.setTempRoutingList(tempRoutingList);
+        return payChannelDto;
+    }
+
+    private Map<String, Object> getPayRoute(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, PayChannelDto payChannelDto) throws Exception {
+        Map<String, Object> unionPay = new HashMap<>();
+        Map<String, Object> payMap = null;
+        String type;
+        String routingMerNos;
+
+        List<Map<String, Object>> tempRoutingList = payChannelDto.getTempRoutingList();
+
+        if (payChannelDto.getPayType().equals(PaymentChannelEnum.YQPAY)) {
+            if (tempRoutingList.size() == 1 && YqPayUtil.merNo.equals(tempRoutingList.get(0).get("routingMerNo").toString())) {
+                tempRoutingList = null;
+            }
+            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, YqPayUtil.merNo, tempRoutingList);
+            type = "YQPAY";
+            routingMerNos = payChannelDto.getTempRoutingList().stream().map(e -> e.get("routingMerNo").toString()).collect(Collectors.joining(","));
+        } else {
+            payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, ConfigInit.merNo, tempRoutingList);
+            type = "ADAPAY";
+            routingMerNos = payChannelDto.getTempRoutingList().stream().map(e -> e.get("member_id").toString()).collect(Collectors.joining(","));
+        }
+        unionPay.put("orderNo", orderNo);
+        unionPay.put("type", type);
+        unionPay.put("payMap", payMap);
+        unionPay.put("routingMerNos", routingMerNos);
+        return unionPay;
+    }
+
+    @Override
     public Map<String, Object> query(String orderNo) throws Exception {
         return new UnionPay(unionPayFeignService).query(orderNo);
     }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRechargeServiceImpl.java

@@ -76,7 +76,7 @@ public class StudentRechargeServiceImpl extends BaseServiceImpl<String, StudentR
 
 		try {
 			return payService.getPayMap(amount, studentRecharge.getOrderNo(), "https://pay.dayaedu.com/api/yqpay/notify", "http://dev.dayaedu.com", "充值",
-					"充值",userId);
+					"充值",userId,null);
 		} catch (Exception e) {
 			throw new BizException("调用支付接口出错", e);
 		}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysPaymentConfigServiceImpl.java

@@ -8,6 +8,8 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class SysPaymentConfigServiceImpl extends BaseServiceImpl<Integer, SysPaymentConfig> implements SysPaymentConfigService {
     @Autowired
@@ -22,4 +24,9 @@ public class SysPaymentConfigServiceImpl extends BaseServiceImpl<Integer, SysPay
     public SysPaymentConfig findPaymentConfigByOrganId(Integer organId) {
         return sysPaymentConfigDao.findPaymentConfigByOrganId(organId);
     }
+
+    @Override
+    public List<SysPaymentConfig> findPaymentConfigByOrganIds(List<Integer> organIds) {
+        return sysPaymentConfigDao.findPaymentConfigByOrganIds(organIds);
+    }
 }

+ 17 - 2
mec-biz/src/main/resources/config/mybatis/SysPaymentConfigMapper.xml

@@ -5,7 +5,11 @@
         <!--@Table sys_payment_config-->
         <id column="id_" jdbcType="INTEGER" property="id"/>
         <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
+        <result column="pay_type_" jdbcType="VARCHAR" property="payType"/>
+        <result column="yq_mer_no_" jdbcType="VARCHAR" property="yqMerNo"/>
+        <result column="hf_mer_no_" jdbcType="VARCHAR" property="hfMerNo"/>
         <result column="type_" jdbcType="INTEGER" property="type"/>
+        <result column="route_scale_" jdbcType="VARCHAR" property="routeScale"/>
         <result column="organ_name" jdbcType="VARCHAR" property="organName"/>
         <result column="per_scale_" jdbcType="INTEGER" property="perScale"/>
         <result column="com_scale_" jdbcType="INTEGER" property="comScale"/>
@@ -29,7 +33,8 @@
         where id_ = #{id,jdbcType=INTEGER}
     </select>
     <delete id="delete" parameterType="java.lang.Integer">
-        delete from sys_payment_config
+        delete
+        from sys_payment_config
         where id_ = #{id,jdbcType=INTEGER}
     </delete>
     <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysPaymentConfig"
@@ -160,6 +165,16 @@
 
     <!-- 按分部编号查配置 -->
     <select id="findPaymentConfigByOrganId" resultMap="SysPaymentConfig">
-        SELECT * FROM sys_payment_config WHERE organ_id_ = #{organId}
+        SELECT *
+        FROM sys_payment_config
+        WHERE organ_id_ = #{organId}
+    </select>
+    <select id="findPaymentConfigByOrganIds" resultMap="SysPaymentConfig">
+        SELECT *
+        FROM sys_payment_config
+        WHERE organ_id_ IN
+        <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
+            #{organId}
+        </foreach>
     </select>
 </mapper>

+ 24 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.impl.PayServiceImpl;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.util.date.DateUtil;
@@ -693,4 +694,27 @@ public class StudentOrderController extends BaseController {
         practice4Organs = practice4Organs.stream().sorted(Comparator.comparingDouble(Practice4OrganDto::getScale).reversed()).collect(Collectors.toList());
         return succeed(practice4Organs);
     }
+@Autowired
+PayService payService;
+    @GetMapping("/test")
+    public HttpResponseResult test(){
+        String baseApiUrl = "http://dev.dayaedu.com";
+        Map<String, Object> payMap = new HashMap<>();
+        try {
+            payMap = payService.getPayMap(
+                    BigDecimal.TEN,
+                    "5435253245",
+                    baseApiUrl + "/api-student/studentOrder/notify",
+                    baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=5435253245",
+                    "对外课程组购买",
+                    "测试购买",
+                    2,
+                    null
+            );
+            return succeed(payMap);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return succeed(payMap);
+    }
 }

+ 2 - 2
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/YqPayUtil.java

@@ -7,7 +7,7 @@ import java.util.*;
 
 public class YqPayUtil {
 
-    private static final String merNo = "0021677"; //商户号
+    public static final String merNo = "0021677"; //商户号
     private static final String version = "1.1";
     private static final String signType = "CFCA";
     private static final String payUrl = "https://qyfapi.95epay.com/api/api/hPay/toPayHtml";//支付提交地址
@@ -41,7 +41,7 @@ public class YqPayUtil {
      * @throws Exception
      */
     public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sellerNo, String routingMerNo) throws Exception {
-        List<Map> tempRoutingList = new ArrayList();
+        List<Map> tempRoutingList = new ArrayList<>();
         Map<String, Object> routingList = new HashMap<>();
         routingList.put("routingMerNo", routingMerNo);//分佣账户
         routingList.put("routingFee", amount.subtract((amount.multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额