浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父节点
当前提交
0824bd3725

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

@@ -264,4 +264,11 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @return
      * @return
      */
      */
     BigDecimal sumPerAccountAmount(@Param("merNo") String merNo, @Param("firstDate") Date firstDate);
     BigDecimal sumPerAccountAmount(@Param("merNo") String merNo, @Param("firstDate") Date firstDate);
+
+    /**
+     * 统计充值金额
+     * @param params
+     * @return
+     */
+    BigDecimal getChargeAmount(Map<String, Object> params);
 }
 }

+ 22 - 15
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserCashAccountDao.java

@@ -4,25 +4,32 @@ import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.List;
 import java.util.Set;
 import java.util.Set;
 
 
 public interface SysUserCashAccountDao extends BaseDAO<Integer, SysUserCashAccount> {
 public interface SysUserCashAccountDao extends BaseDAO<Integer, SysUserCashAccount> {
-	
-	/**
-	 * 获取行级锁
-	 * @param userId
-	 * @return
-	 */
-	SysUserCashAccount getLocked(Integer userId);
 
 
-	/**
-	 * @describe 根据用户编号获取现金账户信息
-	 * @author Joburgess
-	 * @date 2019/11/17
-	 * @param userIds: 用户编号列表
-	 * @return java.util.List<com.ym.mec.biz.dal.entity.SysUserCashAccount>
-	 */
-	List<SysUserCashAccount> findByUserIds(@Param("userIds") Set<Integer> userIds);
+    /**
+     * 获取行级锁
+     *
+     * @param userId
+     * @return
+     */
+    SysUserCashAccount getLocked(Integer userId);
 
 
+    /**
+     * @param userIds: 用户编号列表
+     * @return java.util.List<com.ym.mec.biz.dal.entity.SysUserCashAccount>
+     * @describe 根据用户编号获取现金账户信息
+     * @author Joburgess
+     * @date 2019/11/17
+     */
+    List<SysUserCashAccount> findByUserIds(@Param("userIds") Set<Integer> userIds);
+
+    /**
+     * 获取预收余额
+     * @return
+     */
+    BigDecimal getTotalUserBalance();
 }
 }

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PageInfoOrder.java

@@ -8,6 +8,9 @@ public class PageInfoOrder<T> extends PageInfo<T> {
 
 
     private BigDecimal totalExpectAmount =BigDecimal.ZERO;
     private BigDecimal totalExpectAmount =BigDecimal.ZERO;
     private BigDecimal totalActualAmount =BigDecimal.ZERO;
     private BigDecimal totalActualAmount =BigDecimal.ZERO;
+    private BigDecimal totalAdvanceAmount = BigDecimal.ZERO;
+    private BigDecimal totalRevenueAmount = BigDecimal.ZERO;
+    private BigDecimal totalUserBalance = BigDecimal.ZERO;
 
 
     public PageInfoOrder() {
     public PageInfoOrder() {
     }
     }
@@ -35,4 +38,28 @@ public class PageInfoOrder<T> extends PageInfo<T> {
     public void setTotalActualAmount(BigDecimal totalActualAmount) {
     public void setTotalActualAmount(BigDecimal totalActualAmount) {
         this.totalActualAmount = totalActualAmount;
         this.totalActualAmount = totalActualAmount;
     }
     }
+
+    public BigDecimal getTotalAdvanceAmount() {
+        return totalAdvanceAmount;
+    }
+
+    public void setTotalAdvanceAmount(BigDecimal totalAdvanceAmount) {
+        this.totalAdvanceAmount = totalAdvanceAmount;
+    }
+
+    public BigDecimal getTotalRevenueAmount() {
+        return totalRevenueAmount;
+    }
+
+    public void setTotalRevenueAmount(BigDecimal totalRevenueAmount) {
+        this.totalRevenueAmount = totalRevenueAmount;
+    }
+
+    public BigDecimal getTotalUserBalance() {
+        return totalUserBalance;
+    }
+
+    public void setTotalUserBalance(BigDecimal totalUserBalance) {
+        this.totalUserBalance = totalUserBalance;
+    }
 }
 }

+ 21 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -3,15 +3,13 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.huifu.adapay.model.payment.Payment;
 import com.huifu.adapay.model.payment.Payment;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.biz.service.*;
@@ -53,6 +51,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private SporadicChargeInfoService sporadicChargeInfoService;
     private SporadicChargeInfoService sporadicChargeInfoService;
     @Autowired
     @Autowired
     private PracticeGroupService practiceGroupService;
     private PracticeGroupService practiceGroupService;
+    @Autowired
+    private SysUserCashAccountDao sysUserCashAccountDao;
 
 
     @Override
     @Override
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
@@ -285,17 +285,27 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
 
         List<StudentPaymentOrder> dataList = new ArrayList<>();
         List<StudentPaymentOrder> dataList = new ArrayList<>();
         int count = this.findCount(params);
         int count = this.findCount(params);
-        StudentPaymentOrder orderMoneyAmount = studentPaymentOrderDao.getOrderMoneyAmount(params);
-        if(orderMoneyAmount != null){
-            BigDecimal totalExpectAmount = orderMoneyAmount.getExpectAmount() !=null? orderMoneyAmount.getExpectAmount():BigDecimal.ZERO;
-            BigDecimal totalActualAmount = orderMoneyAmount.getActualAmount() !=null? orderMoneyAmount.getActualAmount():BigDecimal.ZERO;
-            pageInfo.setTotalExpectAmount(totalExpectAmount);
-            pageInfo.setTotalActualAmount(totalActualAmount);
-        }
+        BigDecimal totalUserBalance = sysUserCashAccountDao.getTotalUserBalance();
+        pageInfo.setTotalUserBalance(totalUserBalance);
         if (count > 0) {
         if (count > 0) {
             pageInfo.setTotal(count);
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             params.put("offset", pageInfo.getOffset());
             dataList = studentPaymentOrderDao.queryPageOrder(params);
             dataList = studentPaymentOrderDao.queryPageOrder(params);
+
+            StudentPaymentOrder orderMoneyAmount = studentPaymentOrderDao.getOrderMoneyAmount(params);
+            BigDecimal totalExpectAmount = orderMoneyAmount.getExpectAmount() != null ? orderMoneyAmount.getExpectAmount() : BigDecimal.ZERO;
+            BigDecimal totalActualAmount = orderMoneyAmount.getActualAmount() != null ? orderMoneyAmount.getActualAmount() : BigDecimal.ZERO;
+            BigDecimal totalBalancePaymentAmount = orderMoneyAmount.getBalancePaymentAmount() != null ? orderMoneyAmount.getBalancePaymentAmount() : BigDecimal.ZERO;
+
+            params.put("chargeType", SporadicChargeTypeEnum.RECHARGE);
+            BigDecimal totalChargeAmount = studentPaymentOrderDao.getChargeAmount(params);
+            totalChargeAmount = totalChargeAmount != null ? totalChargeAmount : BigDecimal.ZERO;
+            BigDecimal totalAdvanceAmount = totalChargeAmount.subtract(totalBalancePaymentAmount);
+
+            pageInfo.setTotalAdvanceAmount(totalAdvanceAmount);
+            pageInfo.setTotalExpectAmount(totalExpectAmount);
+            pageInfo.setTotalActualAmount(totalActualAmount);
+            pageInfo.setTotalRevenueAmount(totalActualAmount.subtract(totalAdvanceAmount));
         }
         }
         pageInfo.setRows(dataList);
         pageInfo.setRows(dataList);
         return pageInfo;
         return pageInfo;

+ 11 - 1
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -244,6 +244,10 @@
             <if test="balancePaymentAmount != null">
             <if test="balancePaymentAmount != null">
                 AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
                 AND spo.balance_payment_amount_ >= #{balancePaymentAmount}
             </if>
             </if>
+            <if test="chargeType != null">
+                AND spo.group_type_='SPORADIC'
+                AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
         </where>
         </where>
     </sql>
     </sql>
 
 
@@ -572,7 +576,7 @@
     </select>
     </select>
 
 
     <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
     <select id="getOrderMoneyAmount" parameterType="map" resultMap="StudentPaymentOrder">
-        SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_ FROM student_payment_order spo
+        SELECT SUM(spo.expect_amount_) expect_amount_,SUM(actual_amount_) actual_amount_,SUM(balance_payment_amount_) balance_payment_amount_ FROM student_payment_order spo
         <include refid="queryPaymentOrder"/>
         <include refid="queryPaymentOrder"/>
     </select>
     </select>
 
 
@@ -602,4 +606,10 @@
           AND FIND_IN_SET(#{merNo}, mer_nos_)
           AND FIND_IN_SET(#{merNo}, mer_nos_)
         ]]>
         ]]>
     </select>
     </select>
+
+    <select id="getChargeAmount" parameterType="map" resultType="java.math.BigDecimal">
+        SELECT SUM(actual_amount_) FROM student_payment_order spo
+        LEFT JOIN sporadic_charge_info sci ON spo.music_group_id_ = sci.id_
+        <include refid="queryPaymentOrder"/>
+    </select>
 </mapper>
 </mapper>

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

@@ -94,4 +94,8 @@
         </foreach>
         </foreach>
     </select>
     </select>
 
 
+    <select id="getTotalUserBalance" resultType="java.math.BigDecimal">
+        SELECT SUM(balance_) FROM sys_user_cash_account
+    </select>
+
 </mapper>
 </mapper>