Jelajahi Sumber

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 tahun lalu
induk
melakukan
1b0da7565d
18 mengubah file dengan 664 tambahan dan 121 penghapusan
  1. 7 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysAccountDao.java
  2. 30 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java
  3. 26 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysAccount.java
  4. 24 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysUserCashAccountDetail.java
  5. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/PayService.java
  6. 8 6
      mec-biz/src/main/java/com/ym/mec/biz/service/SysAccountService.java
  7. 184 54
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  8. 147 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java
  9. 5 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  10. 4 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysAccountServiceImpl.java
  11. 21 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  12. 14 2
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  13. 25 8
      mec-biz/src/main/resources/config/mybatis/SysAccountMapper.xml
  14. 12 0
      mec-biz/src/main/resources/config/mybatis/SysUserCashAccountDetailMapper.xml
  15. 36 2
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/YqPayUtil.java
  16. 93 16
      mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java
  17. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/SysPaymentConfigController.java
  18. 17 12
      mec-web/src/main/java/com/ym/mec/web/controller/SysUserCashAccountDetailController.java

+ 7 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysAccountDao.java

@@ -10,21 +10,23 @@ import java.util.List;
 public interface SysAccountDao extends BaseDAO<Integer, SysAccount> {
 
     /**
-     * 获取一个私
+     * 获取支付账
      *
+     * @param company
+     * @param channel
+     * @param type
      * @param amount
      * @return
      */
-    SysAccount getPerAccount(@Param("amount") BigDecimal amount);
+    List<SysAccount> getAccount(@Param("company") String company, @Param("channel") String channel, @Param("type") String type, @Param("amount") BigDecimal amount);
 
     /**
-     * 获取一个支付账户
+     * 获取一个支付
      * @param company
      * @param channel
      * @param type
      * @param amount
      * @return
      */
-    SysAccount getAccount(@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);
 }

+ 30 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -42,6 +42,14 @@ public class StudentPaymentOrder {
 	/** 实际金额 */
 	@ApiModelProperty(value = "实际金额",required = true)
 	private BigDecimal actualAmount;
+
+	/** 公户金额 */
+	@ApiModelProperty(value = "公户金额",required = true)
+	private BigDecimal comAmount;
+
+	/** 私户金额 */
+	@ApiModelProperty(value = "私户金额",required = true)
+	private BigDecimal perAmount;
 	
 	@ApiModelProperty(value = "余额付款金额",required = true)
 	private BigDecimal balancePaymentAmount;
@@ -90,7 +98,8 @@ public class StudentPaymentOrder {
 
 	private Date payTime;
 
-	private Integer accountId;
+	//收款账户
+	private String merNos;
 
 	private PaymentChannelTypeEnum paymentChannelType;
 	
@@ -255,12 +264,12 @@ public class StudentPaymentOrder {
 	public void setPayTime(Date payTime) {
 		this.payTime = payTime;
 	}
-    public Integer getAccountId() {
-        return accountId;
+    public String getMerNos() {
+        return merNos;
     }
 
-    public void setAccountId(Integer accountId) {
-        this.accountId = accountId;
+    public void setMerNos(String merNos) {
+        this.merNos = merNos;
     }
 
     public PaymentChannelTypeEnum getPaymentChannelType() {
@@ -279,9 +288,24 @@ public class StudentPaymentOrder {
 		this.user = user;
 	}
 
+	public BigDecimal getComAmount() {
+		return comAmount;
+	}
+
+	public void setComAmount(BigDecimal comAmount) {
+		this.comAmount = comAmount;
+	}
+
+	public BigDecimal getPerAmount() {
+		return perAmount;
+	}
+
+	public void setPerAmount(BigDecimal perAmount) {
+		this.perAmount = perAmount;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
-
 }

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

@@ -45,6 +45,16 @@ public class SysAccount {
     */
     private String type;
 
+    /**
+     * 状态 0-停用 1-使用
+     */
+    private Integer status;
+
+    /**
+    * 分佣金额
+    */
+    private BigDecimal routingFee;
+
 
     public Integer getId() {
         return id;
@@ -117,4 +127,20 @@ public class SysAccount {
     public void setRoutingMerNo(String routingMerNo) {
         this.routingMerNo = routingMerNo;
     }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public BigDecimal getRoutingFee() {
+        return routingFee;
+    }
+
+    public void setRoutingFee(BigDecimal routingFee) {
+        this.routingFee = routingFee;
+    }
 }

+ 24 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysUserCashAccountDetail.java

@@ -43,6 +43,14 @@ public class SysUserCashAccountDetail {
 	@ApiModelProperty(value = "交易金额",required = false)
 	private BigDecimal amount;
 
+	/** 公户金额 */
+	@ApiModelProperty(value = "公户金额",required = false)
+	private BigDecimal comAmount;
+
+	/** 私户金额 */
+	@ApiModelProperty(value = "私户金额",required = false)
+	private BigDecimal perAmount;
+
 	/** 账户可用余额 */
 	@ApiModelProperty(value = "账户可用余额",required = false)
 	private BigDecimal balance;
@@ -191,9 +199,24 @@ public class SysUserCashAccountDetail {
 		this.platformAccountNo = platformAccountNo;
 	}
 
+	public BigDecimal getComAmount() {
+		return comAmount;
+	}
+
+	public void setComAmount(BigDecimal comAmount) {
+		this.comAmount = comAmount;
+	}
+
+	public BigDecimal getPerAmount() {
+		return perAmount;
+	}
+
+	public void setPerAmount(BigDecimal perAmount) {
+		this.perAmount = perAmount;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
-
 }

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

@@ -1,9 +1,16 @@
 package com.ym.mec.biz.service;
 
 
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.SysAccount;
+import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
+import com.ym.mec.thirdparty.adapay.Pay;
 import com.ym.mec.thirdparty.yqpay.Msg;
+import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 
 import java.math.BigDecimal;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -28,6 +35,9 @@ public interface PayService {
     Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId) throws Exception;
 
 
+    Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId,Map<String,BigDecimal> fee,Integer organId) throws Exception;
+
+
     Map query(String orderNo) throws Exception;
 
 }

+ 8 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/SysAccountService.java

@@ -10,21 +10,23 @@ import java.util.List;
 public interface SysAccountService extends BaseService<Integer, SysAccount> {
 
     /**
-     * 获取一个私户
-     *
+     * 获取收款账户
+     * @param company
+     * @param channel
+     * @param type
+     * @param amount
      * @return
      */
-    SysAccount getPerAccount(BigDecimal amount);
-
+    List<SysAccount> getAccount(String company, String channel, String type,  BigDecimal amount);
 
     /**
-     * 获取一个收款账户
+     * 获取一个支付账户
      * @param company
      * @param channel
      * @param type
      * @param amount
      * @return
      */
-    SysAccount getAccount(String company, String channel, String type,  BigDecimal amount);
+    SysAccount getOneAccount(String company, String channel, String type,  BigDecimal amount);
 
 }

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

@@ -128,13 +128,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Autowired
     private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
-    
+
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 
     @Autowired
     private CooperationOrganDao cooperationOrganDao;
-    
+
     @Autowired
     private TeacherAttendanceDao teacherAttendanceDao;
 
@@ -152,19 +152,19 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Autowired
     private EmployeeDao employeeDao;
-	
+
 	@Autowired
 	private SysMessageService sysMessageService;
 
 	@Autowired
 	private SysConfigDao sysConfigDao;
-	
+
 	@Autowired
 	private ClassGroupService classGroupService;
-	
+
 	@Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
-	
+
     @Autowired
     private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
     @Autowired
@@ -175,12 +175,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
     @Autowired
     private GoodsService goodsService;
-    
+
     @Autowired
     private ImFeignService imFeignService;
-    
+
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
-    
+
     private SimpleDateFormat sdf_hms=new SimpleDateFormat("HH:mm:ss");
 
     @Override
@@ -358,6 +358,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion()+1);
 
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course",BigDecimal.ZERO);
+        classFee.put("instrument",BigDecimal.ZERO);
+        classFee.put("accessories",BigDecimal.ZERO);
+        classFee.put("other",amount);
+
         Map payMap = payService.getPayMap(
                 amount,
                 orderNo,
@@ -365,8 +372,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
                 chargeInfo.getTitle(),
                 chargeInfo.getTitle(),
-                userId);
-
+                userId,
+                classFee,
+                chargeInfo.getOrganId()
+        );
+
+        Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+        studentPaymentOrder.setComAmount(routingFee.get("COM"));
+        studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
         studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
@@ -395,10 +409,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         orderAmount = orderAmount.add(courseFee);
 
+        BigDecimal instrumentFee = BigDecimal.ZERO;
+        BigDecimal accessoriesFee = BigDecimal.ZERO;
+        BigDecimal otherFee = BigDecimal.ZERO;
 
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-
         if (studentRegistration.getTemporaryCourseFee() != null) {
             List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), DealStatusEnum.WAIT_PAY);
             for (StudentPaymentOrderDetail orderDetail : orderDetails) {
@@ -415,6 +431,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
 
                 goodsGroups.add(musicGroupSubjectGoodsGroup);
+                if(musicGroupSubjectGoodsGroup.getType().equals(GoodsType.INSTRUMENT)){
+                    instrumentFee = instrumentFee.add(orderDetail.getPrice());
+                }else if(musicGroupSubjectGoodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    accessoriesFee = accessoriesFee.add(orderDetail.getPrice());
+                }else {
+                    otherFee = otherFee.add(orderDetail.getPrice());
+                }
 
                 orderAmount = orderAmount.add(orderDetail.getPrice());
             }
@@ -422,18 +445,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
                     goodsGroup.setPrice(musicOneSubjectClassPlan.getDepositFee());
-                    continue;
                 }
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
                 	goodsGroup.setPrice(new BigDecimal(0));
-                	continue;
                 }
                 orderAmount = orderAmount.add(goodsGroup.getPrice());
+                if(goodsGroup.getType().equals(GoodsType.INSTRUMENT)){
+                    instrumentFee = instrumentFee.add(goodsGroup.getPrice());
+                }else if(goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    accessoriesFee = accessoriesFee.add(goodsGroup.getPrice());
+                }else {
+                    otherFee = otherFee.add(goodsGroup.getPrice());
+                }
                 //团购乐器减免课程费用
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
                     orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
+                    courseFee.subtract(goodsGroup.getRemissionCourseFee());
                 }
             }
         }
@@ -444,6 +472,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
             for (Goods goods : goodsList) {
                 orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+                accessoriesFee = accessoriesFee.add(goods.getGroupPurchasePrice());
             }
         }
 
@@ -453,14 +482,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
             for (Goods goods : otherGoodsList) {
                 orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+                otherFee = otherFee.add(goods.getGroupPurchasePrice());
             }
         }
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
-
         String orderNo = idGeneratorService.generatorId("payment") + "";
-        
+
         String channelType = "";
 
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList);
@@ -504,6 +533,28 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion()+1);
 
+        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+        //分类费用 course,instrument,accessories,other
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course",courseFee);
+        classFee.put("instrument",instrumentFee);
+        classFee.put("accessories",accessoriesFee);
+        classFee.put("other",otherFee);
+        BigDecimal classFeeAmount = courseFee.add(instrumentFee).add(accessoriesFee).add(otherFee);
+
+        if(amount.compareTo(classFeeAmount) < 0){
+            BigDecimal subAmount = classFeeAmount.subtract(amount);
+            for (Map.Entry<String, BigDecimal> feeEntry : classFee.entrySet()) {
+                if(subAmount.compareTo(feeEntry.getValue()) > 0){
+                    classFee.put(feeEntry.getKey(),BigDecimal.ZERO);
+                    subAmount = subAmount.subtract(feeEntry.getValue());
+                }else {
+                    classFee.put(feeEntry.getKey(),feeEntry.getValue().subtract(subAmount));
+                    break;
+                }
+            }
+        }
+
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
         Map payMap = payService.getPayMap(
                 amount,
@@ -512,8 +563,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
                 "乐团报名缴费",
                 "乐团报名缴费",
-                userId);
-
+                userId,
+                classFee,
+                musicGroup.getOrganId()
+        );
+
+        Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+        studentPaymentOrder.setComAmount(routingFee.get("COM"));
+        studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
         studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
@@ -529,7 +587,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         Integer userId = studentRegistration.getUserId();
-        
+
         StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.ING);
         if (ApplyOrder == null) {
             throw new BizException("没有支付中的订单,请勿非法请求");
@@ -546,6 +604,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         orderAmount = orderAmount.add(courseFee);
 
+        BigDecimal instrumentFee = BigDecimal.ZERO;
+        BigDecimal accessoriesFee = BigDecimal.ZERO;
+        BigDecimal otherFee = BigDecimal.ZERO;
+
 
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
@@ -564,23 +626,38 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
                 musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
                 goodsGroups.add(musicGroupSubjectGoodsGroup);
+
+                if(musicGroupSubjectGoodsGroup.getType().equals(GoodsType.INSTRUMENT)){
+                    instrumentFee = instrumentFee.add(orderDetail.getPrice());
+                }else if(musicGroupSubjectGoodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    accessoriesFee = accessoriesFee.add(orderDetail.getPrice());
+                }else {
+                    otherFee = otherFee.add(orderDetail.getPrice());
+                }
                 orderAmount = orderAmount.add(orderDetail.getPrice());
             }
         } else if (studentRegistration.getTemporaryCourseFee() == null && !registerPayDto.getGoodsGroupIds().equals("")) {
             goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
-                    continue;
+                    goodsGroup.setPrice(musicOneSubjectClassPlan.getDepositFee());
                 }
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
-                    continue;
+                    goodsGroup.setPrice(new BigDecimal(0));
                 }
 
                 orderAmount = orderAmount.add(goodsGroup.getPrice());
+                if(goodsGroup.getType().equals(GoodsType.INSTRUMENT)){
+                    instrumentFee = instrumentFee.add(goodsGroup.getPrice());
+                }else if(goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    accessoriesFee = accessoriesFee.add(goodsGroup.getPrice());
+                }else {
+                    otherFee = otherFee.add(goodsGroup.getPrice());
+                }
                 //团购乐器减免课程费用
                 if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
                     orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
+                    courseFee.subtract(goodsGroup.getRemissionCourseFee());
                 }
             }
         }
@@ -591,6 +668,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
             for (Goods goods : goodsList) {
                 orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+                accessoriesFee = accessoriesFee.add(goods.getGroupPurchasePrice());
             }
         }
 
@@ -600,6 +678,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
             for (Goods goods : otherGoodsList) {
                 orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+                otherFee = otherFee.add(goods.getGroupPurchasePrice());
             }
         }
         if (amount.compareTo(orderAmount) != 0) {
@@ -607,13 +686,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         String orderNo = idGeneratorService.generatorId("payment") + "";
-        
+
         String channelType = "";
 
         StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder);
         studentPaymentOrder.setVersion(0);
         Date date = new Date();
-        
+
         if(registerPayDto.getIsUseBalancePayment() || amount.doubleValue() == 0){
         	SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
         	if(userCashAccount == null){
@@ -648,6 +727,28 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion()+1);
 
+        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+        //分类费用 course,instrument,accessories,other
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course",courseFee);
+        classFee.put("instrument",instrumentFee);
+        classFee.put("accessories",accessoriesFee);
+        classFee.put("other",otherFee);
+        BigDecimal classFeeAmount = courseFee.add(instrumentFee).add(accessoriesFee).add(otherFee);
+
+        if(amount.compareTo(classFeeAmount) < 0){
+            BigDecimal subAmount = classFeeAmount.subtract(amount);
+            for (Map.Entry<String, BigDecimal> feeEntry : classFee.entrySet()) {
+                if(subAmount.compareTo(feeEntry.getValue()) > 0){
+                    classFee.put(feeEntry.getKey(),BigDecimal.ZERO);
+                    subAmount = subAmount.subtract(feeEntry.getValue());
+                }else {
+                    classFee.put(feeEntry.getKey(),feeEntry.getValue().subtract(subAmount));
+                    break;
+                }
+            }
+        }
+
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
         Map payMap = payService.getPayMap(
                 amount,
@@ -656,12 +757,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
                 "乐团报名缴费",
                 "乐团报名缴费",
-                userId);
-        
+                userId,
+                classFee,
+                musicGroup.getOrganId()
+        );
+
+        Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+        studentPaymentOrder.setComAmount(routingFee.get("COM"));
+        studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
         studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
-        
 		return payMap;
 	}
 
@@ -926,7 +1033,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentPaymentOrders != null && studentPaymentOrders.size() > 0) {
             throw new BizException("缴费存在交易中的数据,不能取消乐团");
         }
-        
+
         //删除续费记录
         musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId);
 
@@ -935,7 +1042,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		// 删除每节课的课酬
 		courseScheduleStudentPaymentDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
 		courseScheduleTeacherSalaryDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
-        
+
         //删除考勤
 		teacherAttendanceDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
 
@@ -992,10 +1099,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         // 清除下次缴费时间
         musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, null);
         musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"暂停乐团",sysUser.getId(),""));
-        
+
         //删除课表
         courseScheduleDao.logicDeleteCourseSchedulesByMusicGroupID(musicGroup.getId());
-        
+
         return true;
     }
 
@@ -1022,10 +1129,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         // 重新设置下次缴费时间
         musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
         musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"恢复乐团",sysUser.getId(),""));
-        
+
         //恢复课表
         courseScheduleDao.resumeCourseScheduleByMusicGroupId(musicGroup.getId());
-        
+
         return true;
     }
 
@@ -1121,7 +1228,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 			}
 			//更新学员在班级的状态
 			classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
-			
+
 			List<Integer> classGroupIdList = classGroupStudentMapperDao.queryClassGroupIdList(musicGroupId, userId, GroupType.MUSIC);
 			if (classGroupIdList != null && classGroupIdList.size() > 0) {
 				//更新班级人数
@@ -1134,21 +1241,21 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 }
                 imFeignService.groupBatchQuit(imGroupModels);
 			}
-			
+
 			List<CourseSchedule> musicGroupCourseSchedules = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId,GroupType.MUSIC.getCode(), CourseStatusEnum.NOT_START.getCode(),userId);
 			if(!CollectionUtils.isEmpty(musicGroupCourseSchedules)){
 				List<Long> courseScheduleIds = musicGroupCourseSchedules.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
 
 				// 删除未上课
 	            courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudent(courseScheduleIds,userId);
-				
+
 				//删除学生缴费表
 				courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(userId, musicGroupCourseSchedules);
 			}
-			
+
 			//删除续费周期
 			musicGroupStudentFeeDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
-			
+
 			// 退团
 			studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
 			studentRegistration.setUpdateTime(date);
@@ -1229,7 +1336,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		}
 		//更新学员在班级的状态
 		classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
-		
+
 		List<Integer> classGroupIdList = classGroupStudentMapperDao.queryClassGroupIdList(musicGroupId, userId, GroupType.MUSIC);
 		if (classGroupIdList != null && classGroupIdList.size() > 0) {
 			//更新班级人数
@@ -1243,21 +1350,21 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 			}
             imFeignService.groupBatchQuit(imGroupModels);
 		}
-		
+
 		List<CourseSchedule> musicGroupCourseSchedules = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId,GroupType.MUSIC.getCode(), CourseStatusEnum.NOT_START.getCode(),userId);
 		if(!CollectionUtils.isEmpty(musicGroupCourseSchedules)){
 			List<Long> courseScheduleIds = musicGroupCourseSchedules.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
 
 			// 删除未上课
             courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudent(courseScheduleIds,userId);
-			
+
 			// 删除学生缴费表
 			courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(userId, musicGroupCourseSchedules);
 		}
-		
+
 		//删除续费周期
 		musicGroupStudentFeeDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
-		
+
 		// 退团
 		studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.QUIT);
 		studentRegistration.setUpdateTime(date);
@@ -1356,7 +1463,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
 
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
-        
+
         if(isUseBalancePayment || amount.doubleValue() == 0){
         	SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
         	if(userCashAccount == null){
@@ -1369,9 +1476,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
                 studentPaymentOrder.setUpdateTime(date);
                 studentPaymentOrderService.update(studentPaymentOrder);
-                
+
         		sysUserCashAccountService.updateBalance(userId, amount.negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"乐团续费");
-        		
+
         		//更新下次续费时间
         		musicGroupStudentFee.setUpdateTime(date);
                 musicGroupStudentFee.setLatestPaidTime(date);
@@ -1392,12 +1499,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 
+        //分类费用 course,instrument,accessories,other
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course",amount);
+        classFee.put("instrument",BigDecimal.ZERO);
+        classFee.put("accessories",BigDecimal.ZERO);
+        classFee.put("other",BigDecimal.ZERO);
+
         try {
 
             Map<String, Object> payMap = payService.getPayMap(amount, studentPaymentOrder.getOrderNo(),
                     baseApiUrl+"/api-student/studentOrder/notify",
                     baseApiUrl+"/#/paymentresult?orderNo=" + studentPaymentOrder.getOrderNo(),
-                    "续费", "乐团续费",userId);
+                    "续费",
+                    "乐团续费",
+                    userId,
+                    classFee,
+                    musicGroup.getOrganId()
+            );
+
+            Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+            studentPaymentOrder.setComAmount(routingFee.get("COM"));
+            studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+            studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
             studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
             studentPaymentOrder.setUpdateTime(date);
             studentPaymentOrderService.update(studentPaymentOrder);
@@ -1412,7 +1536,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) throws IOException {
 
-        studentPaymentOrderDao.update(studentPaymentOrder);
+        studentPaymentOrderService.update(studentPaymentOrder);
 
         Integer userId = studentPaymentOrder.getUserId();
         String musicGroupId = studentPaymentOrder.getMusicGroupId();
@@ -1436,7 +1560,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
             musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
             musicGroupStudentFeeDao.update(musicGroupStudentFee);
-            
+
             //插入交易明细
             SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
             BigDecimal amount = studentPaymentOrder.getActualAmount();
@@ -1451,21 +1575,27 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
             rechargeDetail.setUpdateTime(date);
             rechargeDetail.setUserId(userId);
+            rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
             sysUserCashAccountDetailService.insert(rechargeDetail);
-            
+
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
-            paymentDetail.setAmount(amount);
+            paymentDetail.setAmount(amount.negate());
             paymentDetail.setBalance(cashAccount.getBalance());
-            paymentDetail.setComment("费");
+            paymentDetail.setComment("费");
             paymentDetail.setCreateTime(date);
             paymentDetail.setStatus(DealStatusEnum.SUCCESS);
             paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
             paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
             paymentDetail.setUpdateTime(date);
             paymentDetail.setUserId(userId);
+            rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             sysUserCashAccountDetailService.insert(paymentDetail);
-            
+
             // 发送续费结果通知
             sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_MUSIC_GROUP_RENEW_SUCCESS, push, null, 0, "1",
                     studentRegistration.getParentsName(),studentPaymentOrder.getActualAmount());

+ 147 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -5,10 +5,12 @@ import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.SysAccount;
+import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
 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.SysPaymentConfigService;
 import com.ym.mec.thirdparty.adapay.Pay;
 import com.ym.mec.thirdparty.union.UnionPay;
 import com.ym.mec.thirdparty.union.UnionPayFeignService;
@@ -17,8 +19,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 支付服务类
@@ -36,6 +41,8 @@ public class PayServiceImpl implements PayService {
     private MusicGroupDao musicGroupDao;
     @Autowired
     private SysConfigDao sysConfigDao;
+    @Autowired
+    private SysPaymentConfigService sysPaymentConfigService;
 
 
     /**
@@ -50,6 +57,7 @@ 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, Integer userId) throws Exception {
 
         String company = "daya";
@@ -85,6 +93,53 @@ public class PayServiceImpl implements PayService {
     }
 
     @Override
+    public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, Integer userId, Map<String, BigDecimal> fee, Integer organId) throws Exception {
+        String company = "daya";
+        if (userId != null) {
+            MusicGroup musicGroup = musicGroupDao.findUserMusicGroup(userId);
+            if (musicGroup != null && musicGroup.getOwnershipType().equals(CooperationOrgan.OwnershipType.COOPERATION)) {
+                company = "yadie";
+            }
+        }
+
+        //支付通道决策
+        Map unionPay = new HashMap();
+        Map<String, BigDecimal> routingFee = getRoutingFee(company, amount, fee, organId);
+        List<SysAccount> accounts = getRoutingAccount(routingFee, company);
+        SysAccount routingAccount = accounts.get(0);
+
+        Map payMap = null;
+        String type = null;
+        if (routingAccount.getChannel().equals("YQPAY")) {
+            List<Map> tempRoutingList = new ArrayList();
+            for (SysAccount account : accounts) {
+                Map<String, Object> routingList = new HashMap<>();
+                routingList.put("routingMerNo", account.getRoutingMerNo());//分佣账户
+                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);
+            }
+            if(accounts.size() ==1 && routingAccount.getMerNo().equals(routingAccount.getRoutingMerNo())){
+                tempRoutingList = null;
+            }
+
+            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routingAccount.getMerNo(), tempRoutingList);
+            type = "YQPAY";
+        } else {
+            payMap = new Pay().getPayMap(amount, orderNo, notifyUrl, orderSubject, orderBody);
+            type = "ADAPAY";
+        }
+
+        String routingMerNos = accounts.stream().map(sysAccount -> sysAccount.getRoutingMerNo()).collect(Collectors.joining(","));
+
+        unionPay.put("orderNo", orderNo);
+        unionPay.put("type", type);
+        unionPay.put("payMap", payMap);
+        unionPay.put("routingFee",routingFee);
+        unionPay.put("routingMerNos",routingMerNos);
+        return unionPay;
+    }
+
+    @Override
     public Map<String, Object> query(String orderNo) throws Exception {
         return new UnionPay(unionPayFeignService).query(orderNo);
     }
@@ -115,9 +170,99 @@ public class PayServiceImpl implements PayService {
         if (company.equals("yadie")) {
             type = "PER";
         }
-        routingAccount = sysAccountService.getAccount(company, channel, type, null);
+        SysAccount account = sysAccountService.getOneAccount(company, channel, type, null);
 
-        return routingAccount;
+        return account;
     }
 
+    /**
+     * 获取收款账户
+     *
+     * @param routingFee
+     * @param company
+     * @return
+     */
+    private List<SysAccount> getRoutingAccount(Map<String, BigDecimal> routingFee, String company) {
+        String channel = "";
+        String type = "";
+
+        if (routingFee.get("COM").compareTo(BigDecimal.ZERO) > 0 && routingFee.get("PER").compareTo(BigDecimal.ZERO) > 0) {
+            channel = "YQPAY";
+            type = "COM,PER";
+        } else if (routingFee.get("COM").compareTo(BigDecimal.ZERO) > 0 && routingFee.get("PER").compareTo(BigDecimal.ZERO) == 0) {
+            channel = sysConfigDao.findConfigValue("com_account_channel");
+            type = "COM";
+        } else if (routingFee.get("COM").compareTo(BigDecimal.ZERO) == 0 && routingFee.get("PER").compareTo(BigDecimal.ZERO) > 0) {
+            channel = sysConfigDao.findConfigValue("per_account_channel");
+            type = "PER";
+        }
+        List<SysAccount> accounts = sysAccountService.getAccount(company, channel, type, null);
+
+        for (SysAccount account : accounts) {
+            if (account.getType().equals("COM")) {
+                account.setRoutingFee(routingFee.get("COM"));
+            } else {
+                account.setRoutingFee(routingFee.get("PER"));
+            }
+        }
+        return accounts;
+    }
+
+    /**
+     * 获取分佣金额
+     *
+     * @param fee
+     * @param organId
+     * @return
+     */
+    private Map<String, BigDecimal> getRoutingFee(String company, BigDecimal amount, Map<String, BigDecimal> fee, Integer organId) {
+        Map<String, BigDecimal> routingFee = new HashMap<>(2);
+        routingFee.put("COM", BigDecimal.ZERO);
+        routingFee.put("PER", BigDecimal.ZERO);
+        if (company.equals("yadie")) {
+            routingFee.put("PER", amount);
+            return routingFee;
+        }
+
+        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
+
+        int payOrderNums = studentPaymentOrderService.findPayOrderNum(); //获取支付中和成功的订单数
+        //前几笔收入私户
+        Integer nums = Integer.parseInt(sysConfigDao.findConfigValue("per_account_nums"));
+        if (paymentConfig != null && paymentConfig.getType().equals(1)) {
+            nums = paymentConfig.getPerScale();
+        }
+
+        String type = null;
+        int rem = (payOrderNums + 1) % 10;
+        if (rem > 0 && rem <= nums) { //私人账户
+            type = "PER";
+        } else {
+            type = "COM";
+        }
+        routingFee.put(type, amount);
+
+        if (paymentConfig == null || !paymentConfig.getType().equals(2)) {
+            return routingFee;
+        }
+        routingFee.put(type, BigDecimal.ZERO);
+        for (Map.Entry<String, BigDecimal> feeEntry : fee.entrySet()) {
+            if (feeEntry.getKey().equals("course")) {
+                BigDecimal RoutingFee = routingFee.get(paymentConfig.getCourseFee()).add(feeEntry.getValue());
+                routingFee.put(paymentConfig.getCourseFee(), RoutingFee);
+            } else if (feeEntry.getKey().equals("instrument")) {
+                BigDecimal RoutingFee = routingFee.get(paymentConfig.getInstrumentFee()).add(feeEntry.getValue());
+                routingFee.put(paymentConfig.getInstrumentFee(), RoutingFee);
+            } else if (feeEntry.getKey().equals("accessories")) {
+                BigDecimal RoutingFee = routingFee.get(paymentConfig.getAccessoriesFee()).add(feeEntry.getValue());
+                routingFee.put(paymentConfig.getAccessoriesFee(), RoutingFee);
+            } else if (feeEntry.getKey().equals("other")) {
+                BigDecimal RoutingFee = routingFee.get(paymentConfig.getOtherFee()).add(feeEntry.getValue());
+                routingFee.put(paymentConfig.getOtherFee(), RoutingFee);
+            }
+        }
+        return routingFee;
+    }
+
+
 }

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

@@ -752,11 +752,13 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             rechargeDetail.setUpdateTime(nowDate);
             rechargeDetail.setUserId(studentRegistration.getUserId());
             rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
             sysUserCashAccountDetailService.insert(rechargeDetail);
 
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
-            paymentDetail.setAmount(amount);
+            paymentDetail.setAmount(amount.negate());
             paymentDetail.setBalance(cashAccount.getBalance());
             paymentDetail.setComment("报名缴费");
             paymentDetail.setCreateTime(nowDate);
@@ -766,6 +768,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             paymentDetail.setUpdateTime(nowDate);
             paymentDetail.setUserId(studentRegistration.getUserId());
             rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             sysUserCashAccountDetailService.insert(paymentDetail);
 
             //发送缴费成功通知(短信 + push)

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

@@ -25,13 +25,13 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
     }
 
     @Override
-    public SysAccount getPerAccount(BigDecimal money) {
-        return sysAccountDao.getPerAccount(money);
+    public List<SysAccount> getAccount(String company, String channel, String type, BigDecimal amount) {
+        return sysAccountDao.getAccount(company, channel, type, amount);
     }
 
     @Override
-    public SysAccount getAccount(String company, String channel, String type, BigDecimal amount) {
-        return sysAccountDao.getAccount(company, channel, type, amount);
+    public SysAccount getOneAccount(String company, String channel, String type, BigDecimal amount) {
+        return sysAccountDao.getOneAccount(company,channel,type,amount);
     }
 
 }

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

@@ -1079,6 +1079,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 
 		String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+		//分类费用 course,instrument,accessories,other
+		Map<String, BigDecimal> classFee = new HashMap<>();
+		classFee.put("course",amount);
+		classFee.put("instrument",BigDecimal.ZERO);
+		classFee.put("accessories",BigDecimal.ZERO);
+		classFee.put("other",BigDecimal.ZERO);
 		try {
 			Map<String,Object> payMap = payService.getPayMap(
 					amount,
@@ -1087,7 +1093,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 					baseApiUrl+"/#/paymentresult?orderNo=" + orderNo,
 					"vip课购买",
 					vipGroup.getName(),
-					user.getId());
+					user.getId(),
+					classFee,
+					vipGroup.getOrganId()
+			);
+
+			Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+			studentPaymentOrder.setComAmount(routingFee.get("COM"));
+			studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+			studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 			studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 			studentPaymentOrder.setUpdateTime(date);
 			studentPaymentOrderService.update(studentPaymentOrder);
@@ -1143,6 +1157,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
 		sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
 		sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
+		sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+		sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
+		sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
 
 		//支出
 		SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
@@ -1152,6 +1169,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
 		sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
 		sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
+		sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+		sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+		sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
 
 		sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
 		sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);

+ 14 - 2
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -13,6 +13,8 @@
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="expect_amount_" property="expectAmount"/>
         <result column="actual_amount_" property="actualAmount"/>
+        <result column="com_amount_" property="comAmount"/>
+        <result column="per_amount_" property="perAmount"/>
         <result column="balance_payment_amount_" property="balancePaymentAmount"/>
         <result column="trans_no_" property="transNo"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
@@ -22,6 +24,7 @@
         <result column="payment_channel_" property="paymentChannel"/>
         <result column="payment_business_channel_" property="paymentBusinessChannel"/>
         <result column="payment_account_no_" property="paymentAccountNo"/>
+        <result column="mer_nos_" property="merNos"/>
         <result column="order_no_" property="orderNo"/>
         <result column="music_group_id_" property="musicGroupId"/>
         <result column="class_group_id_" property="classGroupId"/>
@@ -75,12 +78,12 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
         INSERT INTO student_payment_order
-        (id_,group_type_,user_id_,type_,expect_amount_,actual_amount_,balance_payment_amount_,trans_no_,
+        (id_,group_type_,user_id_,type_,expect_amount_,actual_amount_,com_amount_,per_amount_,balance_payment_amount_,trans_no_,
         status_,memo_,create_time_,update_time_,payment_channel_,payment_business_channel_,
         payment_account_no_,order_no_,music_group_id_,class_group_id_)
         VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{userId},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{expectAmount},#{actualAmount},#{balancePaymentAmount},#{transNo},
+        #{expectAmount},#{actualAmount},#{comAmount},#{perAmount},#{balancePaymentAmount},#{transNo},
         #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},now(),now(),
         #{paymentChannel},#{paymentBusinessChannel},#{paymentAccountNo},#{orderNo},#{musicGroupId},#{classGroupId})
     </insert>
@@ -116,6 +119,9 @@
             <if test="paymentAccountNo != null">
                 payment_account_no_ = #{paymentAccountNo},
             </if>
+            <if test="merNos != null">
+                mer_nos_ = #{merNos},
+            </if>
             <if test="updateTime != null">
                 update_time_ = NOW(),
             </if>
@@ -128,6 +134,12 @@
             <if test="actualAmount != null">
                 actual_amount_ = #{actualAmount},
             </if>
+            <if test="comAmount != null">
+                com_amount_ = #{comAmount},
+            </if>
+            <if test="perAmount != null">
+                per_amount_ = #{perAmount},
+            </if>
             <if test="balancePaymentAmount != null">
                 balance_payment_amount_ = #{balancePaymentAmount},
             </if>

+ 25 - 8
mec-biz/src/main/resources/config/mybatis/SysAccountMapper.xml

@@ -11,6 +11,7 @@
         <result column="has_receipt_" jdbcType="DECIMAL" property="hasReceipt"/>
         <result column="channel_" jdbcType="VARCHAR" property="channel"/>
         <result column="type_" jdbcType="CHAR" property="type"/>
+        <result column="status_" jdbcType="TINYINT" property="status"/>
         <result column="version" jdbcType="INTEGER" property="version"/>
     </resultMap>
     <sql id="Base_Column_List">
@@ -22,6 +23,7 @@
             has_receipt_,
             channel_,
             type_,
+            status_,
             version
     </sql>
     <select id="get" parameterType="java.lang.Integer" resultMap="SysAccount">
@@ -62,6 +64,9 @@
             <if test="type != null">
                 type_,
             </if>
+            <if test="status != null">
+                status_,
+            </if>
             <if test="version != null">
                 version,
             </if>
@@ -88,6 +93,9 @@
             <if test="type != null">
                 #{type,jdbcType=CHAR},
             </if>
+            <if test="status != null">
+                #{status,jdbcType=TINYINT},
+            </if>
             <if test="version != null">
                 #{version,jdbcType=INTEGER},
             </if>
@@ -118,22 +126,31 @@
             <if test="type != null">
                 type_ = #{type,jdbcType=CHAR},
             </if>
+            <if test="status != null">
+                status_ = #{status,jdbcType=TINYINT},
+            </if>
             <if test="version != null">
                 version = version+1,
             </if>
         </set>
         where id_ = #{id,jdbcType=INTEGER} AND version =#{version}
     </update>
-    <!-- 获取一个私户账户 -->
-    <select id="getPerAccount" resultMap="SysAccount">
-        SELECT *
-        FROM sys_account
-        WHERE channel_ = 'YQPAY'
-          AND type_ = 'PER'
-    </select>
 
     <select id="getAccount" resultMap="SysAccount">
-        SELECT * FROM sys_account WHERE company_=#{company}
+        SELECT * FROM sys_account WHERE status_=1 AND company_=#{company}
+        <if test="channel != null">
+            AND channel_ = #{channel}
+        </if>
+        <if test="type != null">
+            AND FIND_IN_SET(type_,#{type})
+        </if>
+        <if test="amount != null">
+            <![CDATA[AND max_receipt_ < has_receipt_+ #{amount}]]>
+        </if>
+    </select>
+
+    <select id="getOneAccount" resultMap="SysAccount">
+        SELECT * FROM sys_account WHERE status_ =1 AND company_=#{company}
         <if test="channel != null">
             AND channel_ = #{channel}
         </if>

+ 12 - 0
mec-biz/src/main/resources/config/mybatis/SysUserCashAccountDetailMapper.xml

@@ -14,6 +14,8 @@
         <result column="trans_type_" property="transType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="amount_" property="amount"/>
+        <result column="com_amount_" property="comAmount"/>
+        <result column="per_amount_" property="perAmount"/>
         <result column="balance_" property="balance"/>
         <result column="description_" property="description"/>
         <result column="comment_" property="comment"/>
@@ -48,6 +50,8 @@
             <if test="transType!=null">trans_type_,</if>
             <if test="status!=null">status_,</if>
             <if test="amount!=null">amount_,</if>
+            <if test="comAmount!=null">com_amount_,</if>
+            <if test="perAmount!=null">per_amount_,</if>
             <if test="balance!=null">balance_,</if>
             <if test="description!=null">description_,</if>
             <if test="comment!=null">comment_,</if>
@@ -66,6 +70,8 @@
             <if test="transType!=null">#{transType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},</if>
             <if test="status!=null">#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},</if>
             <if test="amount!=null">#{amount},</if>
+            <if test="comAmount!=null">#{comAmount},</if>
+            <if test="perAmount!=null">#{perAmount},</if>
             <if test="balance!=null">#{balance},</if>
             <if test="description!=null">#{description},</if>
             <if test="comment!=null">#{comment},</if>
@@ -109,6 +115,12 @@
             <if test="amount != null">
                 amount_ = #{amount},
             </if>
+            <if test="comAmount != null">
+                com_amount_ = #{comAmount},
+            </if>
+            <if test="perAmount != null">
+                per_amount_ = #{perAmount},
+            </if>
             <if test="description != null">
                 description_ = #{description},
             </if>

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

@@ -15,7 +15,7 @@ public class YqPayUtil {
 
     public static Map<String, Object> getRequestMap(String notifyUrl, Map<String, Object> resultMap) throws Exception {
         Map<String, Object> rqMap = new LinkedHashMap<>();
-        rqMap.put("merNo",merNo);
+        rqMap.put("merNo", merNo);
         rqMap.put("version", version);
         rqMap.put("notifyUrl", notifyUrl);
         rqMap.put("timestamp", DateUtils.getDateTime());
@@ -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 sellerNo, String routingMerNo) 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();
         Map<String, Object> routingList = new HashMap<>();
         routingList.put("routingMerNo", routingMerNo);//分佣账户
@@ -66,6 +66,40 @@ public class YqPayUtil {
     }
 
     /**
+     * 获取支付Map
+     *
+     * @param amount
+     * @param orderNo
+     * @param notifyUrl
+     * @param returnUrl
+     * @param orderSubject
+     * @param orderBody
+     * @param sellerNo
+     * @param tempRoutingList
+     * @return
+     * @throws Exception
+     */
+    public static Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, String sellerNo, List<Map> tempRoutingList) throws Exception {
+        Map<String, Object> contentMap = new LinkedHashMap<>();
+        contentMap.put("sellerNo", sellerNo); //收款商户号
+        contentMap.put("payChannels", payChannels); //支付方式
+        contentMap.put("orderBody", orderBody); //订单信息
+        contentMap.put("payAmount", amount); //支付金额
+        contentMap.put("apiPayType", "1"); //*API支付类型1-即时支付,2-担保支付,3-预授权支付*/
+        contentMap.put("tradeType", "0"); //*交易类型1—充值,0—收款*
+        contentMap.put("merMerOrderNo", orderNo); //商户订单号
+        contentMap.put("orderSubject", orderSubject); //订单标题
+        contentMap.put("returnUrl", returnUrl); //前台页面地址
+        if (tempRoutingList != null) {
+            contentMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
+        }
+        Map<String, Object> payMap = getRequestMap(notifyUrl, contentMap);
+        payMap.put("host", payUrl);
+        return payMap;
+    }
+
+
+    /**
      * 验签
      *
      * @param rsMap

+ 93 - 16
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

@@ -3,11 +3,14 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 
@@ -28,12 +32,6 @@ import java.util.List;
 @RestController
 public class StudentPaymentOrderController extends BaseController {
 
-    @Value("${payment.hiddenMode}")
-    private Boolean hiddenMode;
-
-    @Value("${payment.channel}")
-    private String channel;
-
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
@@ -42,39 +40,118 @@ public class StudentPaymentOrderController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeDao employeeDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @ApiOperation(value = "获取订单列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('order/queryPage')")
-    public Object queryOrderPage(StudentPaymentOrderQueryInfo queryInfo){
+    public Object queryOrderPage(StudentPaymentOrderQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+                queryInfo.setOrganId(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                return failed("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                    return failed("非法请求");
+                }
+            }
+        }
+
+        PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.queryPage(queryInfo);
+
+        int openHideMode = Integer.parseInt(sysConfigDao.findConfigValue("open_hide_mode"));
+        if (openHideMode == 1) {
+            for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
+                BigDecimal balancePaymentAmount = row.getBalancePaymentAmount() == null ? BigDecimal.ZERO : row.getBalancePaymentAmount();
+                BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+                row.setExpectAmount(comAmount.add(balancePaymentAmount));
+                row.setActualAmount(comAmount.add(balancePaymentAmount));
+            }
+        }
+        return succeed(studentPaymentOrderPageInfo);
+    }
+
+    @ApiOperation(value = "获取订单列表1")
+    @GetMapping("/queryPage1")
+    @PreAuthorize("@pcs.hasPermissions('order/queryPage1')")
+    public Object queryOrderPage1(StudentPaymentOrderQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
-        if(!sysUser.getIsSuperAdmin()){
+        if (!sysUser.getIsSuperAdmin()) {
             Employee employee = employeeDao.get(sysUser.getId());
             if (StringUtils.isEmpty(queryInfo.getOrganId())) {
                 queryInfo.setOrganId(employee.getOrganIdList());
-            }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
                 return failed("用户所在分部异常");
-            }else {
+            } else {
                 List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-                if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
                     return failed("非法请求");
                 }
             }
         }
-        if(hiddenMode){
-            queryInfo.setPaymentChannel(channel);
+
+        PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.queryPage(queryInfo);
+
+        for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
+            BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+            if(row.getComAmount() != null) {
+                row.setExpectAmount(comAmount);
+                row.setActualAmount(comAmount);
+            }
+        }
+        return succeed(studentPaymentOrderPageInfo);
+    }
+
+    @ApiOperation(value = "获取订单列表2")
+    @GetMapping("/queryPage2")
+    @PreAuthorize("@pcs.hasPermissions('order/queryPage2')")
+    public Object queryOrderPage2(StudentPaymentOrderQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+                queryInfo.setOrganId(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                return failed("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                    return failed("非法请求");
+                }
+            }
+        }
+
+        PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.queryPage(queryInfo);
+
+        for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
+            BigDecimal perAmount = row.getPerAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+            if(row.getPerAmount() != null) {
+                row.setExpectAmount(perAmount);
+                row.setActualAmount(perAmount);
+            }
         }
-        return succeed(studentPaymentOrderService.queryPage(queryInfo));
+        return succeed(studentPaymentOrderPageInfo);
     }
 
     @ApiOperation(value = "获取乐器采购清单")
     @GetMapping("/getMusicalList")
     @PreAuthorize("@pcs.hasPermissions('order/getMusicalList')")
     @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
-    public Object getMusicalList(String musicGroupId){
+    public Object getMusicalList(String musicGroupId) {
         return succeed(studentPaymentOrderDetailService.getMusicalList(musicGroupId));
     }
 
@@ -82,7 +159,7 @@ public class StudentPaymentOrderController extends BaseController {
     @GetMapping("/verifyMusicalList")
     @PreAuthorize("@pcs.hasPermissions('order/verifyMusicalList')")
     @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
-    public Object verifyMusicalListMusicalList(String musicGroupId){
+    public Object verifyMusicalListMusicalList(String musicGroupId) {
         return succeed(studentPaymentOrderDetailService.verifyMusicalList(musicGroupId));
     }
 

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/SysPaymentConfigController.java

@@ -33,7 +33,7 @@ public class SysPaymentConfigController extends BaseController {
         }
         Date nowDate = new Date();
         sysPaymentConfig.setCreateTime(nowDate);
-        sysPaymentConfig.setCreateTime(nowDate);
+        sysPaymentConfig.setUpdateTime(nowDate);
         return succeed(sysPaymentConfigService.insert(sysPaymentConfig));
     }
 

+ 17 - 12
mec-web/src/main/java/com/ym/mec/web/controller/SysUserCashAccountDetailController.java

@@ -2,11 +2,14 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CashAccountDetail;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
 import com.ym.mec.biz.service.SysUserCashAccountDetailService;
 import com.ym.mec.common.controller.BaseController;
 
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -18,22 +21,18 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+
 @RequestMapping("userCashAccountDetail")
 @Api(tags = "用户交易明细服务")
 @RestController
 public class SysUserCashAccountDetailController extends BaseController {
-
-    @Value("${payment.hiddenMode}")
-    private Boolean hiddenMode;
-
-    @Value("${payment.channel}")
-    private String channel;
-
-
     @Autowired
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @ApiOperation(value = "新增用户交易明细")
     @PostMapping("/add")
@@ -51,11 +50,17 @@ public class SysUserCashAccountDetailController extends BaseController {
         if (user == null && user.getId() != null) {
             return failed("请重新登录");
         }
-        if (hiddenMode){
-            queryInfo.setChannel(channel);
-        }
         queryInfo.setUserId(user.getId());
-        return succeed(sysUserCashAccountDetailService.queryPage(queryInfo));
+        PageInfo<SysUserCashAccountDetail> sysUserCashAccountDetailPageInfo = sysUserCashAccountDetailService.queryPage(queryInfo);
+
+        int openHideMode = Integer.parseInt(sysConfigDao.findConfigValue("open_hide_mode"));
+        if(openHideMode == 1){
+            for (SysUserCashAccountDetail row : sysUserCashAccountDetailPageInfo.getRows()) {
+                BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+                row.setAmount(comAmount.add(comAmount));
+            }
+        }
+        return succeed(sysUserCashAccountDetailPageInfo);
     }
 
 }