|  | @@ -49,6 +49,7 @@
 | 
	
		
			
				|  |  |          <result column="create_time_" property="createTime"/>
 | 
	
		
			
				|  |  |          <result column="update_time" property="updateTime"/>
 | 
	
		
			
				|  |  |          <result column="version_" property="version"/>
 | 
	
		
			
				|  |  | +        <result column="delivery_batch_no_" property="deliveryBatchNo"/>
 | 
	
		
			
				|  |  |      </resultMap>
 | 
	
		
			
				|  |  |      <sql id="Base_Column_List">
 | 
	
		
			
				|  |  |          <!--@mbg.generated-->
 | 
	
	
		
			
				|  | @@ -60,7 +61,7 @@
 | 
	
		
			
				|  |  |          original_cost_,change_musical_price_,change_accessories_, change_accessories_price_,change_cost_, goods_margin_,
 | 
	
		
			
				|  |  |          course_margin_,cost_margin_,sell_amount_,order_id_,order_no_,trans_no_,
 | 
	
		
			
				|  |  |          status_,payment_channel_,mer_no_,sell_time_,create_time_,
 | 
	
		
			
				|  |  | -        update_time,version_,tenant_id_
 | 
	
		
			
				|  |  | +        update_time,version_,tenant_id_,delivery_batch_no_
 | 
	
		
			
				|  |  |      </sql>
 | 
	
		
			
				|  |  |      <select id="get" parameterType="java.lang.Integer" resultMap="SubjectChange">
 | 
	
		
			
				|  |  |          <!--@mbg.generated-->
 | 
	
	
		
			
				|  | @@ -84,7 +85,7 @@
 | 
	
		
			
				|  |  |          change_subject_id_,change_course_fee_, change_musical_, change_musical_price_,
 | 
	
		
			
				|  |  |          change_accessories_, change_accessories_price_, change_cost_,goods_margin_,
 | 
	
		
			
				|  |  |          course_margin_,cost_margin_,sell_amount_,order_id_,
 | 
	
		
			
				|  |  | -        order_no_,trans_no_,status_,sell_time_, create_time_, update_time,version_,tenant_id_)
 | 
	
		
			
				|  |  | +        order_no_,trans_no_,status_,sell_time_, create_time_, update_time,version_,tenant_id_,delivery_batch_no_)
 | 
	
		
			
				|  |  |          values
 | 
	
		
			
				|  |  |          (#{studentId},#{eduTeacherId},#{organId},#{cooperationOrganId},#{musicGroupId},#{originalOrderId},#{originalSubjectId},#{originalCourseFee},
 | 
	
		
			
				|  |  |          #{originalMusical},
 | 
	
	
		
			
				|  | @@ -96,7 +97,7 @@
 | 
	
		
			
				|  |  |          #{changeMusicalPrice}, #{changeAccessories}, #{changeAccessoriesPrice},#{changeCost}, #{goodsMargin},
 | 
	
		
			
				|  |  |          #{courseMargin},#{costMargin},
 | 
	
		
			
				|  |  |          #{sellAmount},#{orderId},#{orderNo},#{transNo},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{sellTime},
 | 
	
		
			
				|  |  | -        #{createTime}, #{updateTime},#{version},#{tenantId})
 | 
	
		
			
				|  |  | +        #{createTime}, #{updateTime},#{version},#{tenantId},#{deliveryBatchNo})
 | 
	
		
			
				|  |  |      </insert>
 | 
	
		
			
				|  |  |      <update id="update" parameterType="com.ym.mec.biz.dal.entity.SubjectChange">
 | 
	
		
			
				|  |  |          <!--@mbg.generated-->
 | 
	
	
		
			
				|  | @@ -189,10 +190,114 @@
 | 
	
		
			
				|  |  |              <if test="updateTime != null">
 | 
	
		
			
				|  |  |                  update_time = #{updateTime},
 | 
	
		
			
				|  |  |              </if>
 | 
	
		
			
				|  |  | +            <if test="deliveryBatchNo != null">
 | 
	
		
			
				|  |  | +                delivery_batch_no_ = #{deliveryBatchNo},
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  |              version_ = version_+1
 | 
	
		
			
				|  |  |          </set>
 | 
	
		
			
				|  |  |          where id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
 | 
	
		
			
				|  |  |      </update>
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    <update id="batchUpdate" parameterType="java.util.List">
 | 
	
		
			
				|  |  | +        <foreach collection="list" item="item" index="index" open="" close="" separator=";">
 | 
	
		
			
				|  |  | +	        <!--@mbg.generated-->
 | 
	
		
			
				|  |  | +	        update subject_change
 | 
	
		
			
				|  |  | +	        <set>
 | 
	
		
			
				|  |  | +	            <if test="item.eduTeacherId !=null ">
 | 
	
		
			
				|  |  | +	                edu_teacher_id_ = #{item.eduTeacherId},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.studentId != null">
 | 
	
		
			
				|  |  | +	                student_id_ = #{item.studentId},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.organId != null">
 | 
	
		
			
				|  |  | +	                organ_id_ = #{item.organId},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.musicGroupId != null">
 | 
	
		
			
				|  |  | +	                music_group_id_ = #{item.musicGroupId},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalCourseFee != null">
 | 
	
		
			
				|  |  | +	                original_course_fee_ = #{item.originalCourseFee},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalMusical != null">
 | 
	
		
			
				|  |  | +	                original_musical_ = #{item.originalMusical},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalMusicalPrice != null">
 | 
	
		
			
				|  |  | +	                original_musical_price_ = #{item.originalMusicalPrice},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalAccessories != null">
 | 
	
		
			
				|  |  | +	                original_accessories_ = #{item.originalAccessories},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalAccessoriesPrice != null">
 | 
	
		
			
				|  |  | +	                original_accessories_price_ = #{item.originalAccessoriesPrice},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.originalCost != null">
 | 
	
		
			
				|  |  | +	                original_cost_ = #{item.originalCost},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeCourseFee != null">
 | 
	
		
			
				|  |  | +	                change_course_fee_ = #{item.changeCourseFee},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeMusical != null">
 | 
	
		
			
				|  |  | +	                change_musical_ = #{item.changeMusical},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeMusicalPrice != null">
 | 
	
		
			
				|  |  | +	                change_musical_price_ = #{item.changeMusicalPrice},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeAccessories != null">
 | 
	
		
			
				|  |  | +	                change_accessories_ = #{item.changeAccessories},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeAccessoriesPrice != null">
 | 
	
		
			
				|  |  | +	                change_accessories_price_ = #{item.changeAccessoriesPrice},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.changeCost != null">
 | 
	
		
			
				|  |  | +	                change_cost_ = #{item.changeCost},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.goodsMargin != null">
 | 
	
		
			
				|  |  | +	                goods_margin_ = #{item.goodsMargin},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.courseMargin != null">
 | 
	
		
			
				|  |  | +	                course_margin_ = #{item.courseMargin},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.costMargin != null">
 | 
	
		
			
				|  |  | +	                cost_margin_ = #{item.costMargin},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.sellAmount != null">
 | 
	
		
			
				|  |  | +	                sell_amount_ = #{item.sellAmount},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.orderId != null">
 | 
	
		
			
				|  |  | +	                order_id_ = #{item.orderId},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.orderNo != null">
 | 
	
		
			
				|  |  | +	                order_no_ = #{item.orderNo},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.transNo != null">
 | 
	
		
			
				|  |  | +	                trans_no_ = #{item.transNo},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.status != null">
 | 
	
		
			
				|  |  | +	                status_ = #{item.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.paymentChannel != null">
 | 
	
		
			
				|  |  | +	                payment_channel_=#{item.paymentChannel},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.merNo != null">
 | 
	
		
			
				|  |  | +	                mer_no_ = #{item.merNo},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.sellTime != null">
 | 
	
		
			
				|  |  | +	                sell_time_ = #{item.sellTime},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.createTime != null">
 | 
	
		
			
				|  |  | +	                create_time_ = #{item.createTime},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.updateTime != null">
 | 
	
		
			
				|  |  | +	                update_time = #{item.updateTime},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            <if test="item.deliveryBatchNo != null">
 | 
	
		
			
				|  |  | +	                delivery_batch_no_ = #{item.deliveryBatchNo},
 | 
	
		
			
				|  |  | +	            </if>
 | 
	
		
			
				|  |  | +	            version_ = version_+1
 | 
	
		
			
				|  |  | +	        </set>
 | 
	
		
			
				|  |  | +	        where id_ = #{item.id} AND version_ = #{item.version} and tenant_id_ = #{item.tenantId}
 | 
	
		
			
				|  |  | +        </foreach>
 | 
	
		
			
				|  |  | +    </update>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      <select id="getStudentLastChange" resultMap="SubjectChange">
 | 
	
		
			
				|  |  |          SELECT *
 | 
	
	
		
			
				|  | @@ -258,6 +363,9 @@
 | 
	
		
			
				|  |  |              <if test="endTime != null">
 | 
	
		
			
				|  |  |                  AND sc.sell_time_ <= #{endTime}
 | 
	
		
			
				|  |  |              </if>
 | 
	
		
			
				|  |  | +            <if test="deliveryBatchNo != null">
 | 
	
		
			
				|  |  | +                AND sc.delivery_batch_no_ = #{deliveryBatchNo}
 | 
	
		
			
				|  |  | +            </if>
 | 
	
		
			
				|  |  |          </where>
 | 
	
		
			
				|  |  |      </sql>
 | 
	
		
			
				|  |  |      <select id="queryCount" resultType="int">
 | 
	
	
		
			
				|  | @@ -272,10 +380,16 @@
 | 
	
		
			
				|  |  |                 GROUP_CONCAT(sc.change_musical_)       trans_no_,
 | 
	
		
			
				|  |  |                 GROUP_CONCAT(sc.change_accessories_)   change_accessories_
 | 
	
		
			
				|  |  |          FROM subject_change sc
 | 
	
		
			
				|  |  | -                 LEFT JOIN student_registration sr ON sc.student_id_ = sr.user_id_
 | 
	
		
			
				|  |  | +                 LEFT JOIN student_registration sr ON sc.student_id_ = sr.user_id_ and sc.music_group_id_ = sr.music_group_id_
 | 
	
		
			
				|  |  |          WHERE sc.music_group_id_ = #{musicGroupId}
 | 
	
		
			
				|  |  |            AND sc.status_ = 2
 | 
	
		
			
				|  |  |            AND sr.music_group_status_ != 'QUIT'
 | 
	
		
			
				|  |  | +          <if test="deliveryStatus != null and deliveryStatus == 1">
 | 
	
		
			
				|  |  | +          	and sc.delivery_batch_no_ is NOT NULL
 | 
	
		
			
				|  |  | +          </if>
 | 
	
		
			
				|  |  | +          <if test="deliveryStatus != null and deliveryStatus == 0">
 | 
	
		
			
				|  |  | +          	and sc.delivery_batch_no_ is NULL
 | 
	
		
			
				|  |  | +          </if>
 | 
	
		
			
				|  |  |          GROUP BY sc.music_group_id_
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  |      <resultMap id="SubjectChangeDto" type="com.ym.mec.biz.dal.entity.SubjectChange" extends="SubjectChange">
 | 
	
	
		
			
				|  | @@ -317,6 +431,7 @@
 | 
	
		
			
				|  |  |            AND status_ = 2
 | 
	
		
			
				|  |  |          GROUP BY student_id_
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      <select id="getTotalCourseMargin" resultType="java.math.BigDecimal">
 | 
	
		
			
				|  |  |          SELECT SUM(course_margin_)
 | 
	
	
		
			
				|  | @@ -325,4 +440,11 @@
 | 
	
		
			
				|  |  |            AND status_ = 2
 | 
	
		
			
				|  |  |          GROUP BY music_group_id_
 | 
	
		
			
				|  |  |      </select>
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    <select id="queryWaitDeliveryList" resultMap="SubjectChange">
 | 
	
		
			
				|  |  | +        SELECT * FROM subject_change
 | 
	
		
			
				|  |  | +        WHERE music_group_id_ = #{musicGroupId}
 | 
	
		
			
				|  |  | +          AND status_ = 2 and delivery_batch_no_ is NULL
 | 
	
		
			
				|  |  | +    </select>
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |  </mapper>
 |