Browse Source

优化订单导出接口

周箭河 5 năm trước cách đây
mục cha
commit
e8c577b27e

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -1,12 +1,13 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.UserGoodsDto;
-import com.ym.mec.biz.dal.dto.musicalListDetailDto;
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -172,4 +173,12 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
 
     List<StudentPaymentOrder> findFixOrder(@Param("status") DealStatusEnum status, @Param("paymentChannel") String paymentChannel);
+
+    /**
+     * 订单导出
+     *
+     * @param params
+     * @return
+     */
+    List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
 }

+ 113 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java

@@ -0,0 +1,113 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
+    //零星费用
+    private BigDecimal sporadicAmount;
+
+    //零星费用类型
+    private String sporadicType;
+
+    //乐器费用
+    private BigDecimal musicalFee;
+
+    //租赁费用
+    private BigDecimal leaseFee;
+
+    //教辅费用
+    private BigDecimal teachingFee;
+
+    //手续费
+    private BigDecimal transferFee;
+
+    private String organName;
+    private String schoolName;
+    private String subjectName;
+
+    private List<StudentPaymentOrderDetail> orderDetailList;
+
+    public BigDecimal getSporadicAmount() {
+        return sporadicAmount;
+    }
+
+    public void setSporadicAmount(BigDecimal sporadicAmount) {
+        this.sporadicAmount = sporadicAmount;
+    }
+
+    public BigDecimal getMusicalFee() {
+        return musicalFee;
+    }
+
+    public void setMusicalFee(BigDecimal musicalFee) {
+        this.musicalFee = musicalFee;
+    }
+
+    public BigDecimal getTeachingFee() {
+        return teachingFee;
+    }
+
+    public void setTeachingFee(BigDecimal teachingFee) {
+        this.teachingFee = teachingFee;
+    }
+
+    public BigDecimal getTransferFee() {
+        return transferFee;
+    }
+
+    public void setTransferFee(BigDecimal transferFee) {
+        this.transferFee = transferFee;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+
+    public String getSporadicType() {
+        return sporadicType;
+    }
+
+    public void setSporadicType(String sporadicType) {
+        this.sporadicType = sporadicType;
+    }
+
+    public BigDecimal getLeaseFee() {
+        return leaseFee;
+    }
+
+    public void setLeaseFee(BigDecimal leaseFee) {
+        this.leaseFee = leaseFee;
+    }
+
+    public List<StudentPaymentOrderDetail> getOrderDetailList() {
+        return orderDetailList;
+    }
+
+    public void setOrderDetailList(List<StudentPaymentOrderDetail> orderDetailList) {
+        this.orderDetailList = orderDetailList;
+    }
+}

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

@@ -108,28 +108,6 @@ public class StudentPaymentOrder {
 	
 	private SysUser user = new SysUser();
 
-	//零星费用
-	private BigDecimal sporadicAmount;
-
-	//零星费用类型
-	private String sporadicType;
-
-	//乐器费用
-	private BigDecimal musicalFee;
-
-	//租赁费用
-	private BigDecimal leaseFee;
-
-	//教辅费用
-	private BigDecimal teachingFee;
-
-	//手续费
-	private BigDecimal transferFee;
-
-	private String organName;
-	private String schoolName;
-	private String subjectName;
-
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -329,83 +307,6 @@ public class StudentPaymentOrder {
 		this.perAmount = perAmount;
 	}
 
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this);
-	}
-
-	public BigDecimal getSporadicAmount() {
-		return sporadicAmount;
-	}
-
-	public void setSporadicAmount(BigDecimal sporadicAmount) {
-		this.sporadicAmount = sporadicAmount;
-	}
-
-	public BigDecimal getMusicalFee() {
-		return musicalFee;
-	}
-
-	public void setMusicalFee(BigDecimal musicalFee) {
-		this.musicalFee = musicalFee;
-	}
-
-	public BigDecimal getTeachingFee() {
-		return teachingFee;
-	}
-
-	public void setTeachingFee(BigDecimal teachingFee) {
-		this.teachingFee = teachingFee;
-	}
-
-	public BigDecimal getTransferFee() {
-		return transferFee;
-	}
-
-	public void setTransferFee(BigDecimal transferFee) {
-		this.transferFee = transferFee;
-	}
-
-	public String getOrganName() {
-		return organName;
-	}
-
-	public void setOrganName(String organName) {
-		this.organName = organName;
-	}
-
-	public String getSchoolName() {
-		return schoolName;
-	}
-
-	public void setSchoolName(String schoolName) {
-		this.schoolName = schoolName;
-	}
-
-	public String getSubjectName() {
-		return subjectName;
-	}
-
-	public void setSubjectName(String subjectName) {
-		this.subjectName = subjectName;
-	}
-
-	public String getSporadicType() {
-		return sporadicType;
-	}
-
-	public void setSporadicType(String sporadicType) {
-		this.sporadicType = sporadicType;
-	}
-
-	public BigDecimal getLeaseFee() {
-		return leaseFee;
-	}
-
-	public void setLeaseFee(BigDecimal leaseFee) {
-		this.leaseFee = leaseFee;
-	}
-
 	public Integer getOrganId() {
 		return organId;
 	}
@@ -413,4 +314,10 @@ public class StudentPaymentOrder {
 	public void setOrganId(Integer organId) {
 		this.organId = organId;
 	}
+
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
 }

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -4,14 +4,13 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
-import com.huifu.adapay.model.payment.PayChannelEnum;
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.common.service.BaseService;
-import org.apache.ibatis.annotations.Param;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 
@@ -77,4 +76,7 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
 	 * @return
 	 */
 	Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
+
+
+	List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
 }

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

@@ -10,6 +10,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -196,6 +198,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return studentPaymentOrderDao.findOrderByGroupType(userId,sporadicId,sporadic,status);
     }
 
+
     private void closeOrders(List<String> orderNoList) throws Exception {
         if (orderNoList.size() == 0) {
             return;
@@ -226,4 +229,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
 
     }
-}
+
+    @Override
+    public List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params) {
+        return studentPaymentOrderDao.ExportQueryPage(params);
+    }
+}

+ 1 - 2
mec-biz/src/main/resources/config/mybatis/SporadicChargeInfo.xml

@@ -99,7 +99,6 @@
 		<include refid="queryPageSql"/>
 	</select>
 	<select id="findInfoById" resultMap="SporadicChargeInfo">
-		SELECT sci.*,o.name_ organ_name_ FROM sporadic_charge_info sci
-		LEFT JOIN organization o on sci.organ_id_ = o.id_ WHERE sci.id_ = #{id}
+		SELECT * FROM sporadic_charge_info where id_ = #{id}
 	</select>
 </mapper>

+ 135 - 78
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -65,7 +65,9 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order WHERE id_ = #{id}
+        SELECT *
+        FROM student_payment_order
+        WHERE id_ = #{id}
     </select>
 
     <!-- 全查询 -->
@@ -79,14 +81,16 @@
     <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_,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},#{comAmount},#{perAmount},#{balancePaymentAmount},#{transNo},
-        #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{memo},now(),now(),
-        #{paymentChannel},#{paymentBusinessChannel},#{paymentAccountNo},#{orderNo},#{musicGroupId},#{classGroupId})
+        (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}, #{comAmount}, #{perAmount}, #{balancePaymentAmount}, #{transNo},
+                #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
+                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{orderNo}, #{musicGroupId},
+                #{classGroupId})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -165,7 +169,9 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-        DELETE FROM student_payment_order WHERE id_ = #{id}
+        DELETE
+        FROM student_payment_order
+        WHERE id_ = #{id}
     </delete>
 
     <!-- 分页查询 -->
@@ -220,59 +226,73 @@
     </sql>
 
     <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
-        select g.* from goods g where g.id_ in (SELECT spod.goods_id_list_ FROM student_payment_order spo left join
-        student_payment_order_detail spod on spo.id_ = spod.payment_order_id_ where spo.music_group_id_ =
-        #{musicGroupId} and spo.type_ = 'APPLY' and spod.type_ =
-        #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        select g.*
+        from goods g
+        where g.id_ in (SELECT spod.goods_id_list_
+                        FROM student_payment_order spo
+                                 left join
+                             student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
+                        where spo.music_group_id_ =
+                              #{musicGroupId}
+                          and spo.type_ = 'APPLY'
+                          and spod.type_ =
+                              #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </select>
     <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
         SELECT
-          spo.*
+        spo.*
         FROM
-          student_payment_order spo
+        student_payment_order spo
         WHERE spo.user_id_=#{userId}
-            AND spo.music_group_id_=#{vipGroupId}
-            <if test="status!=null and status!=''">
-                AND spo.status_=#{status}
-            </if>
-            AND spo.type_ = 'SMALL_CLASS_TO_BUY'
+        AND spo.music_group_id_=#{vipGroupId}
+        <if test="status!=null and status!=''">
+            AND spo.status_=#{status}
+        </if>
+        AND spo.type_ = 'SMALL_CLASS_TO_BUY'
     </select>
     <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
-        SELECT
-            SUM(cssp.expect_price_)
-        FROM
-            course_schedule_student_payment cssp
-            LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-        WHERE
-            cssp.user_id_ = #{userId}
-            AND cssp.music_group_id_ = #{vipGroupId}
-            AND CONCAT(cs.class_date_	,' ',cs.start_class_time_) &gt; NOW()
+        SELECT SUM(cssp.expect_price_)
+        FROM course_schedule_student_payment cssp
+                 LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+        WHERE cssp.user_id_ = #{userId}
+          AND cssp.music_group_id_ = #{vipGroupId}
+          AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
     </select>
     <select id="findNotFailedOrderByStudentVipGroup" resultMap="StudentPaymentOrder">
-        SELECT
-          spo.*
-        FROM
-          student_payment_order spo
-        WHERE spo.user_id_=#{userId}
-            AND spo.music_group_id_=#{vipGroupId}
-            AND spo.status_!='FAILED'
-            AND spo.type_ = 'SMALL_CLASS_TO_BUY'
+        SELECT spo.*
+        FROM student_payment_order spo
+        WHERE spo.user_id_ = #{userId}
+          AND spo.music_group_id_ = #{vipGroupId}
+          AND spo.status_ != 'FAILED'
+          AND spo.type_ = 'SMALL_CLASS_TO_BUY'
     </select>
     <!-- 查询报名订单 -->
     <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND user_id_=#{userId} AND type_ =
-        'APPLY' AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-         ORDER BY id_ DESC LIMIT 1
+        SELECT *
+        FROM student_payment_order
+        WHERE music_group_id_ = #{musicGroupId}
+          AND user_id_ = #{userId}
+          AND type_ =
+              'APPLY'
+          AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        ORDER BY id_ DESC
+        LIMIT 1
     </select>
 
     <!-- 根据订单号查询订单 -->
     <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order WHERE order_no_ = #{orderNo}
+        SELECT *
+        FROM student_payment_order
+        WHERE order_no_ = #{orderNo}
     </select>
 
     <select id="queryByDealStatus" resultMap="StudentPaymentOrder" parameterType="map">
-        SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND type_ =
-        #{type} AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        SELECT *
+        FROM student_payment_order
+        WHERE music_group_id_ = #{musicGroupId}
+          AND type_ =
+              #{type}
+          AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
 
     <!-- 查找支付成功和支付中订单 -->
@@ -280,7 +300,7 @@
         <![CDATA[
         SELECT COUNT(*)
         FROM student_payment_order
-        WHERE FIND_IN_SET(status_,'SUCCESS,ING,WAIT_PAY')
+        WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
         ]]>
     </select>
 
@@ -292,17 +312,24 @@
     </resultMap>
 
     <select id="findGoodsIds" resultMap="userGoodsDto">
-        SELECT g.id_ goods_id_,g.name_ goods_name_ FROM student_payment_order spo
-        LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
-        LEFT JOIN goods g ON FIND_IN_SET(g.id_,spod.goods_id_list_)
-        WHERE spo.type_ = 'APPLY' AND spo.status_ = 'SUCCESS' AND spod.goods_id_list_ IS NOT NULL
-        AND spo.music_group_id_ = #{musicGroupId} AND spo.user_id_ = #{userId}
+        SELECT g.id_ goods_id_, g.name_ goods_name_
+        FROM student_payment_order spo
+                 LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
+                 LEFT JOIN goods g ON FIND_IN_SET(g.id_, spod.goods_id_list_)
+        WHERE spo.type_ = 'APPLY'
+          AND spo.status_ = 'SUCCESS'
+          AND spod.goods_id_list_ IS NOT NULL
+          AND spo.music_group_id_ = #{musicGroupId}
+          AND spo.user_id_ = #{userId}
     </select>
 
     <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order
-        WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
-        #{paymentChannel} LIMIT 100
+        SELECT *
+        FROM student_payment_order
+        WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND payment_channel_ =
+              #{paymentChannel}
+        LIMIT 100
     </select>
 
     <!-- 查询支付中超时订单 -->
@@ -315,35 +342,39 @@
         <![CDATA[ AND create_time_ <= ]]> #{beforeTime}
     </select>
     <select id="countStudentPaymentNum" resultType="int">
-        select count(1) from student_payment_order
-        where  music_group_id_=#{musicGroupId}
-        AND status_ = 'SUCCESS' AND type_='SMALL_CLASS_TO_BUY'
+        select count(1)
+        from student_payment_order
+        where music_group_id_ = #{musicGroupId}
+          AND status_ = 'SUCCESS'
+          AND type_ = 'SMALL_CLASS_TO_BUY'
     </select>
 
     <select id="countSurplusCourseByMusicGroupAndUser" resultType="int">
-        SELECT
-            COUNT(*)
-        FROM
-            course_schedule_student_payment cssp
-            LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
-        WHERE
-            cssp.user_id_ = #{userId}
-            AND cssp.music_group_id_ = #{musicGroupId}
-            AND CONCAT(cs.class_date_	,' ',cs.start_class_time_) &gt; NOW()
+        SELECT COUNT(*)
+        FROM course_schedule_student_payment cssp
+                 LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+        WHERE cssp.user_id_ = #{userId}
+          AND cssp.music_group_id_ = #{musicGroupId}
+          AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW()
     </select>
     <select id="sumGroupIncomeFee" resultType="java.math.BigDecimal">
-        SELECT
-            SUM(expect_amount_)
-        FROM
-            student_payment_order
-        WHERE
-            group_type_ = #{groupType}
-            AND music_group_id_ = #{musicGroupId}
+        SELECT SUM(expect_amount_)
+        FROM student_payment_order
+        WHERE group_type_ = #{groupType}
+          AND music_group_id_ = #{musicGroupId}
     </select>
     <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order WHERE id_ IN (SELECT MAX(sp.id_) FROM (SELECT * FROM student_payment_order
-        WHERE group_type_ = #{groupType} AND type_ = 'APPLY' AND music_group_id_ = #{musicGroupId} AND status_ = 'SUCCESS'
-        ORDER BY id_ DESC) sp GROUP BY sp.user_id_)
+        SELECT *
+        FROM student_payment_order
+        WHERE id_ IN (SELECT MAX(sp.id_)
+                      FROM (SELECT *
+                            FROM student_payment_order
+                            WHERE group_type_ = #{groupType}
+                              AND type_ = 'APPLY'
+                              AND music_group_id_ = #{musicGroupId}
+                              AND status_ = 'SUCCESS'
+                            ORDER BY id_ DESC) sp
+                      GROUP BY sp.user_id_)
     </select>
     <select id="findOrderByGroupType" resultType="int">
         SELECT COUNT(id_) FROM student_payment_order
@@ -364,8 +395,34 @@
     </select>
 
     <select id="findFixOrder" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order
-        WHERE status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} AND payment_channel_ =
-        #{paymentChannel} AND com_amount_ IS NULL LIMIT 100
+        SELECT *
+        FROM student_payment_order
+        WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND payment_channel_ =
+              #{paymentChannel}
+          AND com_amount_ IS NULL
+        LIMIT 100
+    </select>
+
+
+    <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto" id="orderAndDetail"
+               extends="StudentPaymentOrder">
+        <result column="organ_name" property="organName"/>
+        <result column="username_" property="user.username"/>
+        <collection property="orderDetailList" ofType="com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail">
+            <result column="detail_type_" property="type"/>
+            <result column="detail_price_" property="price"/>
+        </collection>
+    </resultMap>
+
+    <!-- 分页查询 -->
+    <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
+        SELECT spo.*,u.username_,spod.type_ detail_type_,spod.price_ detail_price_,o.name_ organ_name
+        FROM student_payment_order spo
+        LEFT JOIN sys_user u on spo.user_id_ = u.id_
+        LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
+        LEFT JOIN organization o on spo.organ_id_ = o.id_
+        <include refid="queryPaymentOrder"/>
+        ORDER BY spo.id_ ASC
     </select>
 </mapper>

+ 1 - 2
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -588,10 +588,9 @@
     </update>
 
     <select id="findStudentByMusicGroupIdAndUserId" resultMap="StudentRegistration">
-        SELECT sr.*,o.name_ organ_name_,s.name_ school_name_,s2.name_ subject_name_,mgsp.kit_group_purchase_type_ kit_group_purchase_type_ FROM student_registration sr
+        SELECT sr.*,s.name_ school_name_,s2.name_ subject_name_,mgsp.kit_group_purchase_type_ kit_group_purchase_type_ FROM student_registration sr
         LEFT JOIN music_group mg ON mg.id_ =sr.music_group_id_
         LEFT JOIN school s on mg.school_id_ = s.id_
-        LEFT JOIN organization o on mg.organ_id_ = o.id_
         LEFT JOIN subject s2 on sr.subject_id_ = s2.id_
         LEFT JOIN music_group_subject_plan mgsp on mg.id_ = sr.subject_id_
         WHERE sr.music_group_id_ = #{musicGroupId} AND sr.user_id_ = #{userId} AND sr.music_group_status_ != 'QUIT' LIMIT 1

+ 1 - 2
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -891,9 +891,8 @@
     </select>
 
     <select id="findVipGroupInfo" resultMap="VipGroup">
-        SELECT vg.*,s.name_ subject_name_,o.name_ organ_name_,s2.name_ school_name_ FROM vip_group vg
+        SELECT vg.*,s.name_ subject_name_,s2.name_ school_name_ FROM vip_group vg
         LEFT JOIN class_group cg on vg.id_ = cg.music_group_id_
-        LEFT JOIN organization o on vg.organ_id_ = o.id_
         LEFT JOIN subject s on cg.subject_id_list_ = s.id_
         LEFT JOIN school s2 on vg.teacher_school_id_ = s2.id_
         WHERE vg.id_ = #{id} AND cg.id_=#{classGroupId} AND cg.group_type_='VIP'

+ 16 - 21
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -3,10 +3,7 @@ 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.*;
-import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
-import com.ym.mec.biz.dal.dto.StudentHasCourseDto;
-import com.ym.mec.biz.dal.dto.TeacherSalaryDto;
-import com.ym.mec.biz.dal.dto.musicalListDetailDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.KitPurchaseMethodEnum;
@@ -19,6 +16,7 @@ import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
 import io.swagger.annotations.Api;
@@ -33,9 +31,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @RequestMapping
 @Api(tags = "数据导出服务")
@@ -172,11 +169,12 @@ public class ExportController extends BaseController {
             }
         }
         queryInfo.setRows(999999999);
-
-        PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.queryPage(queryInfo);
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
 
         long i = 1;
-        for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
+        for (StudentPaymentOrderExportDto row : studentPaymentOrderExportDtos) {
             if (queryInfo.getOrderType().equals("1")) {
                 BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
                 row.setActualAmount(comAmount);
@@ -189,11 +187,10 @@ public class ExportController extends BaseController {
             }
             BigDecimal transferFee = (row.getActualAmount().multiply(new BigDecimal(0.28)).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_UP);
             row.setTransferFee(transferFee);
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.findApplyOrderGoods(row.getId());
             BigDecimal musicalFee = BigDecimal.ZERO;
             BigDecimal teachingFee = BigDecimal.ZERO;
-            if (orderDetails.size() > 0) {
-                for (StudentPaymentOrderDetail orderDetail : orderDetails) {
+            if (row.getOrderDetailList() != null) {
+                for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
                     if (orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL)) {
                         musicalFee = musicalFee.add(orderDetail.getPrice());
                     } else if (orderDetail.getType().equals(OrderDetailTypeEnum.ACCESSORIES) || orderDetail.getType().equals(OrderDetailTypeEnum.TEACHING)) {
@@ -208,7 +205,6 @@ public class ExportController extends BaseController {
                 StudentRegistration studentRegistration = studentRegistrationDao.findStudentByMusicGroupIdAndUserId(row.getMusicGroupId(), row.getUserId());
                 if (studentRegistration != null) {
                     row.setSubjectName(studentRegistration.getSubjectName());
-                    row.setOrganName(studentRegistration.getOrganName());
                     row.setSchoolName(studentRegistration.getSchoolName());
                     if (studentRegistration.getKitType() != null && studentRegistration.getKitType().equals(KitPurchaseMethodEnum.LEASE)) {
                         row.setLeaseFee(musicalFee);
@@ -218,18 +214,17 @@ public class ExportController extends BaseController {
             } else if (row.getGroupType().equals(GroupType.VIP)) {
                 VipGroup vipGroupInfo = vipGroupDao.findVipGroupInfo(Integer.parseInt(row.getMusicGroupId()), row.getClassGroupId());
                 if (vipGroupInfo != null) {
-                    row.setOrganName(vipGroupInfo.getOrganName());
                     row.setSchoolName(vipGroupInfo.getSchoolName());
                     row.setSubjectName(vipGroupInfo.getSubjectName());
                 }
 
             } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
                 SporadicChargeInfo sporadicChargeInfo = sporadicChargeInfoDao.findInfoById(Integer.parseInt(row.getMusicGroupId()));
-                if(sporadicChargeInfo != null) {
-                    row.setSporadicAmount(row.getActualAmount());
-                    row.setMusicalFee(BigDecimal.ZERO);
-                    row.setTeachingFee(BigDecimal.ZERO);
-                    row.setTeachingFee(BigDecimal.ZERO);
+                row.setSporadicAmount(row.getActualAmount());
+                row.setMusicalFee(BigDecimal.ZERO);
+                row.setTeachingFee(BigDecimal.ZERO);
+                row.setTeachingFee(BigDecimal.ZERO);
+                if (sporadicChargeInfo != null) {
                     if (sporadicChargeInfo.getChargeType().equals("1")) {
                         row.setSporadicType("考级");
                     } else if (sporadicChargeInfo.getChargeType().equals("2")) {
@@ -261,7 +256,7 @@ public class ExportController extends BaseController {
                     "关联乐团ID/VIP课ID", "课程形态", "押金", "乐器", "教辅费用", "零星收款费用", "零星收款类别", "手续费", "专业", "分部", "单位/学校", "备注"};
             String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "actualAmount", "payTime", "musicGroupId",
                     "groupType.desc", "leaseFee", "musicalFee", "teachingFee", "sporadicAmount", "sporadicType", "transferFee", "subjectName", "organName", "schoolName", "memo"};
-            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderPageInfo.getRows());
+            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
             response.flushBuffer();