瀏覽代碼

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父節點
當前提交
c231a3ff9b

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -256,4 +256,11 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
     StudentPaymentOrder getOrderMoneyAmount(Map<String, Object> params);
     StudentPaymentOrder getOrderMoneyAmount(Map<String, Object> params);
 
 
     List<StudentPaymentOrder> queryPageOrder(Map<String, Object> params);
     List<StudentPaymentOrder> queryPageOrder(Map<String, Object> params);
+
+    /**
+     * 统计收款金额
+     * @param merNo
+     * @return
+     */
+    BigDecimal sumPerAccountAmount(String merNo);
 }
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysAccountDao.java

@@ -22,6 +22,7 @@ public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
 
 
     /**
     /**
      * 获取一个支付
      * 获取一个支付
+     *
      * @param company
      * @param company
      * @param channel
      * @param channel
      * @param type
      * @param type
@@ -29,4 +30,11 @@ public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
      * @return
      * @return
      */
      */
     SysAccount getOneAccount(@Param("company") String company, @Param("channel") String channel, @Param("type") String type, @Param("amount") BigDecimal amount);
     SysAccount getOneAccount(@Param("company") String company, @Param("channel") String channel, @Param("type") String type, @Param("amount") BigDecimal amount);
+
+    /**
+     * 获取所有私有账户
+     * @param channel
+     * @return
+     */
+    List<SysAccount> getPerAccount(@Param("channel") String channel);
 }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysAccountService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
@@ -29,4 +30,12 @@ public interface SysAccountService extends BaseService<Integer, SysAccount> {
      */
      */
     SysAccount getOneAccount(String company, String channel, String type,  BigDecimal amount);
     SysAccount getOneAccount(String company, String channel, String type,  BigDecimal amount);
 
 
+
+    /**
+     * 获取私有账户
+     * @param channel
+     * @return
+     */
+    SysAccount getPerAccount(@Param("channel") String channel,SysAccount account);
+
 }
 }

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

@@ -282,11 +282,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         }
 
 
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
         OrderTypeEnum type = OrderTypeEnum.SPORADIC;
-        String receiver = null;
-        if (chargeInfo.getChargeType().equals("6")) {
-            type = OrderTypeEnum.LUCK;
-            receiver = "PER";
-        }
+        String receiver = "PER";
 
 
         Integer userId = sporadicPayDto.getUserId();
         Integer userId = sporadicPayDto.getUserId();
         String orderNo = idGeneratorService.generatorId("payment") + "";
         String orderNo = idGeneratorService.generatorId("payment") + "";
@@ -325,7 +321,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
 
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setOrganId(chargeInfo.getOrganId());
         studentPaymentOrder.setOrganId(chargeInfo.getOrganId());
-        studentPaymentOrder.setRoutingOrganId(42);
+        studentPaymentOrder.setRoutingOrganId(chargeInfo.getOrganId());
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
         studentPaymentOrderService.update(studentPaymentOrder);
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);

+ 16 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -118,7 +118,7 @@ public class PayServiceImpl implements PayService {
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 tempRoutingList.add(routingList);
                 tempRoutingList.add(routingList);
             }
             }
-            if(accounts.size() ==1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())){
+            if (accounts.size() == 1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())) {
                 tempRoutingList = null;
                 tempRoutingList = null;
             }
             }
 
 
@@ -134,8 +134,8 @@ public class PayServiceImpl implements PayService {
         unionPay.put("orderNo", orderNo);
         unionPay.put("orderNo", orderNo);
         unionPay.put("type", type);
         unionPay.put("type", type);
         unionPay.put("payMap", payMap);
         unionPay.put("payMap", payMap);
-        unionPay.put("routingFee",routingFee);
-        unionPay.put("routingMerNos",routingMerNos);
+        unionPay.put("routingFee", routingFee);
+        unionPay.put("routingMerNos", routingMerNos);
         return unionPay;
         return unionPay;
     }
     }
 
 
@@ -151,7 +151,7 @@ public class PayServiceImpl implements PayService {
 
 
         //支付通道决策
         //支付通道决策
         Map unionPay = new HashMap();
         Map unionPay = new HashMap();
-        Map<String, BigDecimal> routingFee = getRoutingFee(company, amount, fee, organId,receiver);
+        Map<String, BigDecimal> routingFee = getRoutingFee(company, amount, fee, organId, receiver);
         List<SysAccount> accounts = getRoutingAccount(routingFee, company);
         List<SysAccount> accounts = getRoutingAccount(routingFee, company);
         SysAccount routingAccount = accounts.get(0);
         SysAccount routingAccount = accounts.get(0);
 
 
@@ -165,7 +165,7 @@ public class PayServiceImpl implements PayService {
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 routingList.put("routingFee", account.getRoutingFee().subtract((account.getRoutingFee().multiply(new BigDecimal("0.28")).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP))); //分佣金额
                 tempRoutingList.add(routingList);
                 tempRoutingList.add(routingList);
             }
             }
-            if(accounts.size() ==1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())){
+            if (accounts.size() == 1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())) {
                 tempRoutingList = null;
                 tempRoutingList = null;
             }
             }
 
 
@@ -181,8 +181,8 @@ public class PayServiceImpl implements PayService {
         unionPay.put("orderNo", orderNo);
         unionPay.put("orderNo", orderNo);
         unionPay.put("type", type);
         unionPay.put("type", type);
         unionPay.put("payMap", payMap);
         unionPay.put("payMap", payMap);
-        unionPay.put("routingFee",routingFee);
-        unionPay.put("routingMerNos",routingMerNos);
+        unionPay.put("routingFee", routingFee);
+        unionPay.put("routingMerNos", routingMerNos);
         return unionPay;
         return unionPay;
     }
     }
 
 
@@ -249,6 +249,13 @@ public class PayServiceImpl implements PayService {
             if (account.getType().equals("COM")) {
             if (account.getType().equals("COM")) {
                 account.setRoutingFee(routingFee.get("COM"));
                 account.setRoutingFee(routingFee.get("COM"));
             } else {
             } else {
+                SysAccount perAccount = sysAccountService.getPerAccount(channel, account);
+                if (perAccount != null) {
+                    account.setRoutingMerNo(perAccount.getRoutingMerNo());
+                    if (!account.getCompany().equals("daya")) {
+                        account.setMerNo(perAccount.getRoutingMerNo());
+                    }
+                }
                 account.setRoutingFee(routingFee.get("PER"));
                 account.setRoutingFee(routingFee.get("PER"));
             }
             }
         }
         }
@@ -312,7 +319,7 @@ public class PayServiceImpl implements PayService {
     }
     }
 
 
 
 
-    private Map<String, BigDecimal> getRoutingFee(String company, BigDecimal amount, Map<String, BigDecimal> fee, Integer organId,String receiver) {
+    private Map<String, BigDecimal> getRoutingFee(String company, BigDecimal amount, Map<String, BigDecimal> fee, Integer organId, String receiver) {
         Map<String, BigDecimal> routingFee = new HashMap<>(2);
         Map<String, BigDecimal> routingFee = new HashMap<>(2);
         routingFee.put("COM", BigDecimal.ZERO);
         routingFee.put("COM", BigDecimal.ZERO);
         routingFee.put("PER", BigDecimal.ZERO);
         routingFee.put("PER", BigDecimal.ZERO);
@@ -321,7 +328,7 @@ public class PayServiceImpl implements PayService {
             return routingFee;
             return routingFee;
         }
         }
 
 
-        if(receiver != null){
+        if (receiver != null) {
             routingFee.put(receiver, amount);
             routingFee.put(receiver, amount);
             return routingFee;
             return routingFee;
         }
         }

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dao.SysAccountDao;
 import com.ym.mec.biz.dal.dao.SysAccountDao;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.biz.dal.entity.SysArea;
@@ -18,6 +19,8 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
 
 
     @Autowired
     @Autowired
     private SysAccountDao sysAccountDao;
     private SysAccountDao sysAccountDao;
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
 
 
     @Override
     @Override
     public BaseDAO<Integer, SysAccount> getDAO() {
     public BaseDAO<Integer, SysAccount> getDAO() {
@@ -31,7 +34,28 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
 
 
     @Override
     @Override
     public SysAccount getOneAccount(String company, String channel, String type, BigDecimal amount) {
     public SysAccount getOneAccount(String company, String channel, String type, BigDecimal amount) {
-        return sysAccountDao.getOneAccount(company,channel,type,amount);
+        return sysAccountDao.getOneAccount(company, channel, type, amount);
+    }
+
+    @Override
+    public SysAccount getPerAccount(String channel, SysAccount account) {
+        BigDecimal maxReceive = new BigDecimal("75000");
+        BigDecimal amount = studentPaymentOrderDao.sumPerAccountAmount(account.getRoutingMerNo());
+
+        if (amount == null || amount.compareTo(maxReceive) < 0) {
+            return account;
+        }
+
+        SysAccount newAccount = null;
+        List<SysAccount> perAccounts = sysAccountDao.getPerAccount(channel);
+        for (SysAccount perAccount : perAccounts) {
+            amount = studentPaymentOrderDao.sumPerAccountAmount(perAccount.getRoutingMerNo());
+            if (amount == null || amount.compareTo(maxReceive) < 0) {
+                newAccount = perAccount;
+                break;
+            }
+        }
+        return newAccount;
     }
     }
 
 
 }
 }

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -548,4 +548,8 @@
                 and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
                 and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
             </if>
     </select>
     </select>
+
+    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal">
+        SELECT SUM(per_amount_) FROM student_payment_order WHERE FIND_IN_SET(status_,'SUCCESS,ING') AND FIND_IN_SET(#{merNo},mer_nos_)
+    </select>
 </mapper>
 </mapper>

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

@@ -161,4 +161,11 @@
             <![CDATA[AND max_receipt_ < has_receipt_+ #{amount}]]>
             <![CDATA[AND max_receipt_ < has_receipt_+ #{amount}]]>
         </if>
         </if>
     </select>
     </select>
+
+    <select id="getPerAccount" resultMap="SysAccount">
+        SELECT * FROM sys_account WHERE status_=1 AND type_='PER'
+        <if test="channel != null">
+            AND channel_ = #{channel}
+        </if>
+    </select>
 </mapper>
 </mapper>