瀏覽代碼

增加分润逻辑

周箭河 5 年之前
父節點
當前提交
664b8f0ab9

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysAccount.java

@@ -21,6 +21,11 @@ public class SysAccount {
     private String merNo;
 
     /**
+     * 分佣账户
+     */
+    private String routingMerNo;
+
+    /**
     * 最大收款金额
     */
     private BigDecimal maxReceipt;
@@ -104,4 +109,12 @@ public class SysAccount {
     public void setCompany(String company) {
         this.company = company;
     }
+
+    public String getRoutingMerNo() {
+        return routingMerNo;
+    }
+
+    public void setRoutingMerNo(String routingMerNo) {
+        this.routingMerNo = routingMerNo;
+    }
 }

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

@@ -25,8 +25,6 @@ public interface PayService {
      * @return
      * @throws Exception
      */
-    Map<String,Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception;
-
     Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId) throws Exception;
 
 

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

@@ -1162,7 +1162,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         try {
             Map<String, Object> payMap = payService.getPayMap(amount, studentPaymentOrder.getOrderNo(), "https://pay.dayaedu.com/api/yqpay/notify",
-                    "http://dev.dayaedu.com", "续费", "乐团续费");
+                    "http://dev.dayaedu.com", "续费", "乐团续费",userId);
             studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
             studentPaymentOrder.setUpdateTime(date);
             studentPaymentOrderService.update(studentPaymentOrder);

+ 11 - 37
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -8,7 +8,6 @@ import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.service.PayService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.SysAccountService;
-import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.thirdparty.adapay.Pay;
 import com.ym.mec.thirdparty.union.UnionPay;
 import com.ym.mec.thirdparty.union.UnionPayFeignService;
@@ -50,23 +49,6 @@ public class PayServiceImpl implements PayService {
      * @return
      * @throws Exception
      */
-    @Override
-    public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
-
-        //支付通道决策
-        SysAccount routingAccount = getRoutingAccount(amount);
-        Map unionPay = new HashMap();
-        //Map payMap = new Pay().getPayMap(amount, orderNo, notifyUrl, orderSubject, orderBody);
-        // unionPay.put("type", "ADAPAY");
-
-        unionPay.put("orderNo", orderNo);
-        Map payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, null);
-        unionPay.put("type", "YQPAY");
-        unionPay.put("payMap", payMap);
-
-        return unionPay;
-    }
-
     public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId) throws Exception {
 
         String company = "daya";
@@ -83,7 +65,7 @@ public class PayServiceImpl implements PayService {
         Map payMap = null;
         String type = null;
         if (routingAccount.getChannel().equals("YQPAY")) {
-            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, null);
+            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody,routingAccount.getMerNo(), routingAccount.getRoutingMerNo());
             type = "YQPAY";
         } else {
             payMap = new Pay().getPayMap(amount, orderNo, notifyUrl, orderSubject, orderBody);
@@ -102,37 +84,29 @@ public class PayServiceImpl implements PayService {
     }
 
     /**
-     * 获取收款账户
-     *
+     * 获取收款账户
+     * @param company
      * @param money
      * @return
      */
-    private SysAccount getRoutingAccount(BigDecimal money) {
-        SysAccount routingAccount = null;
-        int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
-        //分佣账户(1、每10笔,前2笔收入私户)
-        int rem = (payOrderNums + 1) % 10;
-        if (rem > 0 && rem <= 2) { //私人账户
-            routingAccount = sysAccountService.getPerAccount(money);
-        }
-        return routingAccount;
-    }
-
     private SysAccount getRoutingAccount(String company, BigDecimal money) {
         SysAccount routingAccount = null;
         int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
         //前几笔收入私户
         Integer nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
 
+        String type = null;
+        String channel = null;
         int rem = (payOrderNums + 1) % 10;
-
         if (rem > 0 && rem <= nums) { //私人账户
-            String channel = sysConfigDao.findConfigValue("per_account_channel");
-            routingAccount = sysAccountService.getAccount(company, channel, "PER", money);
+            channel = sysConfigDao.findConfigValue("per_account_channel");
+            type = "PER";
         } else {
-            String channel = sysConfigDao.findConfigValue("com_account_channel");
-            routingAccount = sysAccountService.getAccount(company, channel,"COM",money);
+            channel = sysConfigDao.findConfigValue("com_account_channel");
+            type = "COM";
         }
+        routingAccount = sysAccountService.getAccount(company, channel, type, money);
+
         return routingAccount;
     }
 

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/SysAccountMapper.xml

@@ -6,6 +6,7 @@
         <id column="id_" jdbcType="INTEGER" property="id"/>
         <result column="company_" jdbcType="VARCHAR" property="company"/>
         <result column="mer_no_" jdbcType="VARCHAR" property="merNo"/>
+        <result column="routing_mer_no_" jdbcType="VARCHAR" property="routingMerNo"/>
         <result column="max_receipt_" jdbcType="DECIMAL" property="maxReceipt"/>
         <result column="has_receipt_" jdbcType="DECIMAL" property="hasReceipt"/>
         <result column="channel_" jdbcType="VARCHAR" property="channel"/>
@@ -16,6 +17,7 @@
             id_,
             company_,
             mer_no_,
+            routing_mer_no_,
             max_receipt_,
             has_receipt_,
             channel_,
@@ -45,6 +47,9 @@
             <if test="merNo != null">
                 mer_no_,
             </if>
+            <if test="merNo != null">
+                routing_mer_no_,
+            </if>
             <if test="maxReceipt != null">
                 max_receipt_,
             </if>
@@ -68,6 +73,9 @@
             <if test="merNo != null">
                 #{merNo,jdbcType=VARCHAR},
             </if>
+            <if test="routingMerNo != null">
+                #{routingMerNo,jdbcType=VARCHAR},
+            </if>
             <if test="maxReceipt != null">
                 #{maxReceipt,jdbcType=DECIMAL},
             </if>
@@ -95,6 +103,9 @@
             <if test="merNo != null">
                 mer_no_ = #{merNo,jdbcType=VARCHAR},
             </if>
+            <if test="routingMerNo != null">
+                routing_mer_no_ = #{routingMerNo,jdbcType=VARCHAR},
+            </if>
             <if test="maxReceipt != null">
                 max_receipt_ = #{maxReceipt,jdbcType=DECIMAL},
             </if>

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

@@ -40,7 +40,7 @@ public class YqPayUtil {
      * @return
      * @throws Exception
      */
-    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String routingMerNo) throws Exception {
+    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody,String merNo, String routingMerNo) throws Exception {
         List<Map> tempRoutingList = new ArrayList();
         Map<String, Object> routingList = new HashMap<>();
         routingList.put("routingMerNo", routingMerNo);//分佣账户
@@ -57,7 +57,7 @@ public class YqPayUtil {
         contentMap.put("merMerOrderNo", orderNo); //商户订单号
         contentMap.put("orderSubject", orderSubject); //订单标题
         contentMap.put("returnUrl", returnUrl); //前台页面地址
-        if (routingMerNo != null && !routingMerNo.isEmpty()) {
+        if (routingMerNo != null && !routingMerNo.isEmpty() && !merNo.equals(routingMerNo)) {
             contentMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
         }
         Map<String, Object> payMap = getRequestMap(notifyUrl, contentMap);