瀏覽代碼

修改订单统计

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

+ 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);
 }
 }

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

@@ -8,6 +8,8 @@ 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;
 
 
     public PageInfoOrder() {
     public PageInfoOrder() {
     }
     }
@@ -35,4 +37,20 @@ 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;
+    }
 }
 }

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

@@ -8,10 +8,7 @@ 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.*;
@@ -285,17 +282,25 @@ 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);
-        }
         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>