|  | @@ -83,16 +83,19 @@
 | 
	
		
			
				|  |  |      <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_,organ_id_,routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_, per_amount_,
 | 
	
		
			
				|  |  | +        (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
 | 
	
		
			
				|  |  | +         per_amount_,
 | 
	
		
			
				|  |  |           balance_payment_amount_, remit_fee_, trans_no_,
 | 
	
		
			
				|  |  |           status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
 | 
	
		
			
				|  |  |           payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_)
 | 
	
		
			
				|  |  |          VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 | 
	
		
			
				|  |  | -                #{userId},#{organId},#{routingOrganId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 | 
	
		
			
				|  |  | +                #{userId}, #{organId}, #{routingOrganId},
 | 
	
		
			
				|  |  | +                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 | 
	
		
			
				|  |  |                  #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
 | 
	
		
			
				|  |  |                  #{remitFee}, #{transNo},
 | 
	
		
			
				|  |  |                  #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
 | 
	
		
			
				|  |  | -                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo}, #{musicGroupId},
 | 
	
		
			
				|  |  | +                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
 | 
	
		
			
				|  |  | +                #{musicGroupId},
 | 
	
		
			
				|  |  |                  #{classGroupId})
 | 
	
		
			
				|  |  |      </insert>
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -251,15 +254,13 @@
 | 
	
		
			
				|  |  |                                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
 | 
	
		
			
				|  |  | -        SELECT
 | 
	
		
			
				|  |  | -        spo.*
 | 
	
		
			
				|  |  | -        FROM
 | 
	
		
			
				|  |  | -        student_payment_order spo
 | 
	
		
			
				|  |  | -        WHERE spo.user_id_=#{userId}
 | 
	
		
			
				|  |  | -        AND spo.music_group_id_=#{musicGroupId}
 | 
	
		
			
				|  |  | -        AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | -        AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | -        and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | +        SELECT spo.*
 | 
	
		
			
				|  |  | +        FROM student_payment_order spo
 | 
	
		
			
				|  |  | +        WHERE spo.user_id_ = #{userId}
 | 
	
		
			
				|  |  | +          AND spo.music_group_id_ = #{musicGroupId}
 | 
	
		
			
				|  |  | +          AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | +          AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | +          and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  |          SELECT
 | 
	
	
		
			
				|  | @@ -347,9 +348,11 @@
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  | -        SELECT * FROM student_payment_order
 | 
	
		
			
				|  |  | +        SELECT *
 | 
	
		
			
				|  |  | +        FROM student_payment_order
 | 
	
		
			
				|  |  |          WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | -        AND payment_channel_ = #{paymentChannel} LIMIT 100
 | 
	
		
			
				|  |  | +          AND payment_channel_ = #{paymentChannel}
 | 
	
		
			
				|  |  | +        LIMIT 100
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <!-- 查询支付中超时订单 -->
 | 
	
	
		
			
				|  | @@ -382,7 +385,7 @@
 | 
	
		
			
				|  |  |          FROM student_payment_order
 | 
	
		
			
				|  |  |          WHERE group_type_ = #{groupType}
 | 
	
		
			
				|  |  |            AND music_group_id_ = #{musicGroupId}
 | 
	
		
			
				|  |  | -          AND status_='SUCCESS'
 | 
	
		
			
				|  |  | +          AND status_ = 'SUCCESS'
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  |          SELECT *
 | 
	
	
		
			
				|  | @@ -416,7 +419,13 @@
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="findFixOrder" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  | -        SELECT * FROM student_payment_order where status_ ='SUCCESS' AND type_='APPLY' AND actual_amount_> 0 and mer_nos_ IS NULL LIMIT 100
 | 
	
		
			
				|  |  | +        SELECT *
 | 
	
		
			
				|  |  | +        FROM student_payment_order
 | 
	
		
			
				|  |  | +        where status_ = 'SUCCESS'
 | 
	
		
			
				|  |  | +          AND type_ = 'APPLY'
 | 
	
		
			
				|  |  | +          AND actual_amount_ > 0
 | 
	
		
			
				|  |  | +          and mer_nos_ IS NULL
 | 
	
		
			
				|  |  | +        LIMIT 100
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -439,7 +448,8 @@
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <!-- 分页查询 -->
 | 
	
		
			
				|  |  |      <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
 | 
	
		
			
				|  |  | -        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_ detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
 | 
	
		
			
				|  |  | +        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
 | 
	
		
			
				|  |  | +        detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
 | 
	
		
			
				|  |  |          o.name_ organ_name,sci.charge_type_,g.id_ goods_id, g.name_ goods_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_
 | 
	
	
		
			
				|  | @@ -500,22 +510,37 @@
 | 
	
		
			
				|  |  |          <result property="money" column="money"/>
 | 
	
		
			
				|  |  |      </resultMap>
 | 
	
		
			
				|  |  |      <select id="getLuckStatis" resultMap="luckStatis">
 | 
	
		
			
				|  |  | -        SELECT o.name_ organName, SUM(spo.actual_amount_) money ,COUNT(spo.id_) nums FROM student_payment_order spo LEFT JOIN organization o ON o.id_=spo.organ_id_
 | 
	
		
			
				|  |  | -        WHERE spo.type_='LUCK' AND spo.status_='SUCCESS' GROUP BY spo.organ_id_ ORDER BY nums DESC;
 | 
	
		
			
				|  |  | +        SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
 | 
	
		
			
				|  |  | +        FROM student_payment_order spo
 | 
	
		
			
				|  |  | +                 LEFT JOIN organization o ON o.id_ = spo.organ_id_
 | 
	
		
			
				|  |  | +        WHERE spo.type_ = 'LUCK'
 | 
	
		
			
				|  |  | +          AND spo.status_ = 'SUCCESS'
 | 
	
		
			
				|  |  | +        GROUP BY spo.organ_id_
 | 
	
		
			
				|  |  | +        ORDER BY nums DESC;
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
 | 
	
		
			
				|  |  | -    	select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
 | 
	
		
			
				|  |  | -    	where actual_amount_ > 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )  AND status_ = 'SUCCESS'
 | 
	
		
			
				|  |  | -   		<if test="organId != null">
 | 
	
		
			
				|  |  | -   			and FIND_IN_SET(organ_id_,#{organId})
 | 
	
		
			
				|  |  | -   		</if>
 | 
	
		
			
				|  |  | -  	</select>
 | 
	
		
			
				|  |  | +        select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
 | 
	
		
			
				|  |  | +        where actual_amount_ > 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
 | 
	
		
			
				|  |  | +        status_ = 'SUCCESS'
 | 
	
		
			
				|  |  | +        <if test="organId != null">
 | 
	
		
			
				|  |  | +            and FIND_IN_SET(organ_id_,#{organId})
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  |      <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
 | 
	
		
			
				|  |  | -      select count(*) from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP' and status_='SUCCESS'
 | 
	
		
			
				|  |  | +        select count(*)
 | 
	
		
			
				|  |  | +        from student_payment_order
 | 
	
		
			
				|  |  | +        where user_id_ = #{userId}
 | 
	
		
			
				|  |  | +          and music_group_id_ = #{vipGroupId}
 | 
	
		
			
				|  |  | +          and group_type_ = 'VIP'
 | 
	
		
			
				|  |  | +          and status_ = 'SUCCESS'
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  | -      select * from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP'
 | 
	
		
			
				|  |  | +        select *
 | 
	
		
			
				|  |  | +        from student_payment_order
 | 
	
		
			
				|  |  | +        where user_id_ = #{userId}
 | 
	
		
			
				|  |  | +          and music_group_id_ = #{vipGroupId}
 | 
	
		
			
				|  |  | +          and group_type_ = 'VIP'
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  |          select * from student_payment_order
 | 
	
	
		
			
				|  | @@ -543,13 +568,19 @@
 | 
	
		
			
				|  |  |      <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
 | 
	
		
			
				|  |  |          SELECT * FROM student_payment_order
 | 
	
		
			
				|  |  |          WHERE music_group_id_=#{groupId}
 | 
	
		
			
				|  |  | -            and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | -            <if test="status!=null">
 | 
	
		
			
				|  |  | -                and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | -            </if>
 | 
	
		
			
				|  |  | +        and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | +        <if test="status!=null">
 | 
	
		
			
				|  |  | +            and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 | 
	
		
			
				|  |  | +        </if>
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal">
 | 
	
		
			
				|  |  | -        SELECT SUM(per_amount_) FROM student_payment_order WHERE FIND_IN_SET(status_,'SUCCESS,ING') AND FIND_IN_SET(#{merNo},mer_nos_)
 | 
	
		
			
				|  |  | +    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
 | 
	
		
			
				|  |  | +        SELECT SUM(per_amount_)
 | 
	
		
			
				|  |  | +        FROM student_payment_order
 | 
	
		
			
				|  |  | +        WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
 | 
	
		
			
				|  |  | +          AND create_time_ >= #{firstDate}
 | 
	
		
			
				|  |  | +          AND create_time_ <= NOW()
 | 
	
		
			
				|  |  | +          AND FIND_IN_SET(#{merNo}, mer_nos_)
 | 
	
		
			
				|  |  | +        ]]>
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |  </mapper>
 |