Ver código fonte

金额统计

周箭河 4 anos atrás
pai
commit
b37dc848db

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/FinancialExpenditureDao.java

@@ -17,4 +17,10 @@ public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpendit
     List<FinancialExpenditureDto> queryFinancialExpenditurePage(Map<String, Object> params);
 
     void batchDel(String ids);
+
+    /**
+     * 统计合作单位各类型的支出
+     * @return
+     */
+    List<FinancialExpenditure> getCooperationExpenditure();
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/FinancialExpenditure.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
@@ -29,6 +30,8 @@ public class FinancialExpenditure {
 	/**  */
 	@ApiModelProperty(value = "申请人编号",required = false)
 	private Integer applyUserId;
+	@ApiModelProperty(value = "支出类型(1:固定费用、2:变动费用:3:业务退费)",required = false)
+	private ExpenditureTypeEnum type;
 	/**  */
 	@ApiModelProperty(value = "费用",required = false)
 	private BigDecimal amount;
@@ -159,4 +162,12 @@ public class FinancialExpenditure {
 	public void setDelFlag(Integer delFlag) {
 		this.delFlag = delFlag;
 	}
+
+	public ExpenditureTypeEnum getType() {
+		return type;
+	}
+
+	public void setType(ExpenditureTypeEnum type) {
+		this.type = type;
+	}
 }

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

@@ -22,8 +22,8 @@ public class OperatingReport {
     /**
     * 学校id
     */
-    @ApiModelProperty(value="学校id")
-    private Integer schoolId;
+    @ApiModelProperty(value="合作单位id")
+    private Integer cooperationOrganId;
 
     @ApiModelProperty(value="学校名称")
     private String schoolName;
@@ -116,12 +116,12 @@ public class OperatingReport {
         this.organId = organId;
     }
 
-    public Integer getSchoolId() {
-        return schoolId;
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
     }
 
-    public void setSchoolId(Integer schoolId) {
-        this.schoolId = schoolId;
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
     }
 
     public BigDecimal getSellAmount() {

+ 5 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -21,7 +21,7 @@ public class SellOrder {
      * 学校id
      */
     @ApiModelProperty(value="学校id")
-    private Integer schoolId;
+    private Integer cooperationOrganId;
 
     /**
      * 学校名称
@@ -159,12 +159,12 @@ public class SellOrder {
         this.organId = organId;
     }
 
-    public Integer getSchoolId() {
-        return schoolId;
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
     }
 
-    public void setSchoolId(Integer schoolId) {
-        this.schoolId = schoolId;
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
     }
 
     public String getTransNo() {

+ 26 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExpenditureTypeEnum.java

@@ -0,0 +1,26 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum ExpenditureTypeEnum implements BaseEnum<Integer, ExpenditureTypeEnum> {
+    FIXED(1, "固定费用"),
+    VARIABLE(2, "变动费用"),
+    REFUND(3, "业务退费");
+    private Integer code;
+
+    private String desc;
+
+    private ExpenditureTypeEnum(Integer code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    @Override
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.OrganFullJobResourceNumDto;
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.OperatingReport;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
@@ -26,6 +27,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
     private MusicGroupDao musicGroupDao;
     private SellOrderDao sellOrderDao;
     private CooperationOrganDao cooperationOrganDao;
+    private FinancialExpenditureDao financialExpenditureDao;
 
 
     @Override
@@ -52,18 +54,20 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
         /**
          *         分摊费用计算公式:全职资源数*全职资源公摊金额/12
          *
-         *         成本费用合计:销售成本+固定支出+变动支出+分摊费用
+         *         成本费用合计:销售成本+固定支出+变动支出+业务退费+分摊费用
          *
          *         利润:收入合计-成本费用合计
          *
          *        【全职资源数】*【全职资源公摊金额】/12,该公式得出的值为【学校】【每月】的公摊费用
          */
+        Map<Integer, OperatingReport> cooperationOperating = new HashMap<>();
+        Map<Integer, OperatingReport> organOperating = new HashMap<>();
 
         //1、获取分部的全职资源数的分摊费用
         List<OrganFullJobResourceNumDto> organFullJobResourceNum = cooperationOrganDao.getOrganFullJobResourceNum();
 
-
         //2、获取支出费用
+        List<FinancialExpenditure> cooperationExpenditures = financialExpenditureDao.getCooperationExpenditure();
 
         //3.1、乐团订单的统计
         List<OperatingReport> musicReports = sellOrderDao.getMusicGroupMonthReport(startTime, endTime);
@@ -82,10 +86,6 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
         //3.6、零星收费(不是充值部分的)
         List<OperatingReport> sporadicReports = sellOrderDao.getSporadicMonthReport(startTime, endTime);
 
-
-        Map<String, OperatingReport> schoolOperating = new HashMap<>();
-        Map<String, OperatingReport> organOperating = new HashMap<>();
-
         return null;
 
     }

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

@@ -1,7 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
@@ -130,7 +129,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 
                 SellOrder sellOrder = new SellOrder();
                 sellOrder.setOrganId(studentPaymentRouteOrderDto.getOrganId());
-                sellOrder.setSchoolId(studentPaymentRouteOrderDto.getSchoolId());
+                sellOrder.setCooperationOrganId(studentPaymentRouteOrderDto.getSchoolId());
                 sellOrder.setTransNo(studentPaymentRouteOrderDto.getTransNo());
                 sellOrder.setOrderId(studentPaymentRouteOrderDto.getId());
                 sellOrder.setOrderNo(orderNo);

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

@@ -923,7 +923,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                             CostMap.put("SellCost2",goods.getAgreeCostPrice());
                         }
                         sellOrder.setOrganId(studentPaymentOrder.getOrganId());
-                        sellOrder.setSchoolId(musicGroup.getSchoolId());
+                        sellOrder.setCooperationOrganId(musicGroup.getCooperationOrganId());
                         sellOrder.setTransNo(studentPaymentOrder.getTransNo());
                         sellOrder.setOrderId(studentPaymentOrder.getId());
                         sellOrder.setOrderNo(studentPaymentOrder.getOrderNo());

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

@@ -14,6 +14,7 @@
         <result column="organ_id_" property="organId"/>
         <result column="cooperation_organ_id_" property="cooperationOrganId"/>
         <result column="apply_user_id_" property="applyUserId"/>
+        <result column="type_" property="type"/>
         <result column="amount_" property="amount"/>
         <result column="item_detail_" property="itemDetail"/>
         <result column="payment_time_" property="paymentTime"/>
@@ -173,4 +174,10 @@
         <include refid="queryPageSql"/>
         <include refid="global.limit"/>
     </select>
+
+    <!-- 统计合作单位的支出 -->
+    <select id="getCooperationExpenditure" resultMap="FinancialExpenditure">
+        SELECT organ_id_,cooperation_organ_id_, type_, SUM(amount_) amount_ FROM financial_expenditure WHERE del_flag_ =0
+        GROUP BY organ_id_,cooperation_organ_id_,type_
+    </select>
 </mapper>

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

@@ -7,7 +7,7 @@
     <id column="id_" property="id" />
     <result column="organ_id_" property="organId" />
     <result column="organ_name_" property="organName"/>
-    <result column="school_id_" property="schoolId" />
+    <result column="cooperation_organ_id_" property="cooperationOrganId" />
     <result column="school_name_" property="schoolName"/>
     <result column="sell_amount_" property="sellAmount" />
     <result column="service_amount_" property="serviceAmount" />
@@ -24,7 +24,7 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id_, organ_id_, school_id_, sell_amount_, service_amount_, refund_amount_, income_total_, 
+    id_, organ_id_, cooperation_organ_id_, sell_amount_, service_amount_, refund_amount_, income_total_, 
     sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, cost_amount_, 
     profit_, month_, create_time_
   </sql>
@@ -42,11 +42,11 @@
   </delete>
   <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.OperatingReport" useGeneratedKeys="true">
     <!--@mbg.generated-->
-    insert into operating_report (organ_id_, school_id_, sell_amount_, service_amount_, refund_amount_, 
-      income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_, 
+      insert into operating_report (organ_id_, cooperation_organ_id_, sell_amount_, service_amount_, refund_amount_,
+      income_total_, sell_cost_, expenses_amount_, variable_cost_, distribution_amount_,
       cost_amount_, profit_, month_, create_time_)
-    values (#{organId}, #{schoolId}, #{sellAmount}, #{serviceAmount}, #{refundAmount}, 
-      #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount}, 
+      values (#{organId}, #{cooperationOrganId}, #{sellAmount}, #{serviceAmount}, #{refundAmount},
+      #{incomeTotal}, #{sellCost}, #{expensesAmount}, #{variableCost}, #{distributionAmount},
       #{costAmount}, #{profit}, #{month}, #{createTime})
   </insert>
   <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReport">
@@ -56,8 +56,8 @@
       <if test="organId != null">
         organ_id_ = #{organId},
       </if>
-      <if test="schoolId != null">
-        school_id_ = #{schoolId},
+      <if test="cooperationOrganId != null">
+          cooperation_organ_id_ = #{cooperationOrganId},
       </if>
       <if test="sellAmount != null">
         sell_amount_ = #{sellAmount},
@@ -102,9 +102,9 @@
 
   <!-- 分页查询 -->
   <select id="queryPage" resultMap="OperatingReport" parameterType="map">
-    SELECT opr.*,o.name_ organ_name_,s.name_ school_name_ FROM operating_report opr
+    SELECT opr.*,o.name_ organ_name_,co.name_ school_name_ FROM operating_report opr
     LEFT JOIN organization o ON o.id_ = opr.organ_id_
-    LEFT JOIN school s ON s.id_= opr.school_id_
+    LEFT JOIN cooperation_organ co ON co.id_= opr.cooperation_organ_id_
     <include refid="queryPageSql"/>
     ORDER BY opr.month_ DESC,opr.organ_id_ ASC
     <include refid="global.limit"/>
@@ -121,8 +121,8 @@
       <if test="organIdList != null and organIdList != ''">
         AND FIND_IN_SET(opr.organ_id_,#{organIdList})
       </if>
-      <if test="schoolId != null">
-        AND opr.school_id_ = #{schoolId}
+      <if test="cooperationOrganId != null">
+        AND opr.cooperation_organ_id_ = #{cooperationOrganId}
       </if>
       <if test="startTime != null">
         AND opr.month_ >= #{startTime}

+ 17 - 17
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -6,7 +6,7 @@
         <!--@Table sell_order-->
         <id column="id_" property="id"/>
         <result column="organ_id_" property="organId"/>
-        <result column="school_id_" property="schoolId"/>
+        <result column="cooperation_organ_id_" property="cooperationOrganId"/>
         <result column="school_name_" property="schoolName"/>
         <result column="trans_no_" property="transNo"/>
         <result column="order_no_" property="orderNo"/>
@@ -33,7 +33,7 @@
     </resultMap>
     <sql id="Base_Column_List">
         <!--@mbg.generated-->
-        id_, organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        id_, organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
         balance_amount_, sell_cost_, sell_cost2_, type_, goods_id_,goods_name_, num_, user_id_, payment_channel_,
         mer_no_, sell_time_, create_ime_, update_time_
     </sql>
@@ -52,10 +52,10 @@
     <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SellOrder"
             useGeneratedKeys="true">
         <!--@mbg.generated-->
-        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
         balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_, sell_time_, create_ime_, update_time_)
-        values (#{organId}, #{schoolId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount}, #{actualAmount},
+        values (#{organId}, #{cooperationOrganId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount}, #{actualAmount},
         #{balanceAmount}, #{type}, #{goodsId}, #{goodsName}, #{sellCost}, #{sellCost2}, #{num}, #{userId},
         #{paymentChannel},
         #{merNo}, #{sellTime}, #{createIme}, #{updateTime})
@@ -67,8 +67,8 @@
             <if test="organId != null">
                 organ_id_ = #{organId},
             </if>
-            <if test="schoolId != null">
-                school_id_ = #{schoolId},
+            <if test="cooperationOrganId != null">
+                cooperation_organ_id_ = #{cooperationOrganId},
             </if>
             <if test="transNo != null">
                 trans_no_ = #{transNo},
@@ -129,12 +129,12 @@
     </update>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
-        insert into sell_order (organ_id_, school_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
         balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_, sell_time_, create_ime_, update_time_)
         VALUE
         <foreach collection="sellOrders" separator="," item="sellOrder">
-            (#{sellOrder.organId},#{sellOrder.schoolId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
+            (#{sellOrder.organId},#{sellOrder.cooperationOrganId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
             #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.goodsId},
             #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
             #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.sellTime},#{sellOrder.createIme},#{sellOrder.updateTime})
@@ -144,10 +144,10 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="SellOrder" parameterType="map">
-        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,s.name_ school_name_ FROM sell_order so
+        SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,co.name_ school_name_ FROM sell_order so
         LEFT JOIN sys_user su ON so.user_id_ = su.id_
         LEFT JOIN organization o ON o.id_ = so.organ_id_
-        LEFT JOIN school s ON s.id_= so.school_id_
+        LEFT JOIN cooperation_organ co ON co.id_= so.cooperation_organ_id_
         <include refid="queryPageSql"/>
         ORDER BY so.sell_time_ DESC
         <include refid="global.limit"/>
@@ -170,8 +170,8 @@
             <if test="goodsName != null and goodsName != ''">
                 AND so.goods_name_ = #{goodsName}
             </if>
-            <if test="schoolId != null">
-                AND so.school_id_ = #{schoolId}
+            <if test="cooperationOrganId != null">
+                AND so.cooperation_organ_id_ = #{cooperationOrganId}
             </if>
             <if test="type != null">
                 AND so.type_ = #{type}
@@ -188,7 +188,7 @@
     <!-- 获取分部学校的收入支出(乐团订单) -->
     <select id="getMusicGroupMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  school_id_,
+               co.id_                  cooperation_organ_id_,
                SUM(spo.actual_amount_) income_total_,
                SUM(so.actual_amount_)  sell_amount_,
                SUM(so.sell_cost_)      sellCost
@@ -206,7 +206,7 @@
     <!-- 获取分部学校的收入支出(VIP,网管课) -->
     <select id="getMusicVipPracticeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  school_id_,
+               co.id_                  cooperation_organ_id_,
                SUM(spo.actual_amount_) income_total_
         FROM student_payment_order spo
                  LEFT JOIN
@@ -228,7 +228,7 @@
     <!-- 获取分部学校的收入支出(外部添加订单) -->
     <select id="getOutOrderMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  school_id_,
+               co.id_                  cooperation_organ_id_,
                SUM(spo.actual_amount_) income_total_,
                SUM(so.actual_amount_)  sell_amount_,
                SUM(so.sell_cost_)      sellCost
@@ -245,7 +245,7 @@
     <!-- 获取分部学校的收入支出(充值) -->
     <select id="getRechargeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  school_id_,
+               co.id_                  cooperation_organ_id_,
                SUM(spo.actual_amount_) income_total_
         FROM student_payment_order spo
                  LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
@@ -262,7 +262,7 @@
     <!-- 获取分部学校的收入支出(零星支付) -->
     <select id="getSporadicMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  school_id_,
+               co.id_                  cooperation_organ_id_,
                SUM(spo.actual_amount_) income_total_
         FROM student_payment_order spo
                  LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_