123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ym.mec.biz.dal.dao.CloudTeacherOrderDao">
- <resultMap id="CloudTeacherOrder" type="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
- <!--@mbg.generated-->
- <!--@Table cloud_teacher_order-->
- <id column="id_" property="id"/>
- <result column="organ_id_" property="organId"/>
- <result column="student_id_" property="studentId"/>
- <result column="type_" property="type"/>
- <result column="level_" property="level"/>
- <result column="time_" property="time"/>
- <result column="amount_" property="amount"/>
- <result column="refund_amount_" property="refundAmount"/>
- <result column="status_" property="status"/>
- <result column="start_time_" property="startTime"/>
- <result column="end_time_" property="endTime"/>
- <result column="order_id_" property="orderId"/>
- <result column="remark_" property="remark"/>
- <result column="active_remark_" property="activeRemark"/>
- <result column="version_" property="version"/>
- <result column="create_time_" property="createTime"/>
- <result column="update_time_" property="updateTime"/>
- <result column="music_group_id_" property="musicGroupId"/>
- <result column="tenant_id_" property="tenantId" />
- </resultMap>
-
- <resultMap type="com.ym.mec.biz.dal.dto.CloudTeacherOrderDto" id="CloudTeacherOrderDto">
- <id column="id_" property="cloudTeacherOrder.id"/>
- <result column="organ_id_" property="cloudTeacherOrder.organId"/>
- <result column="student_id_" property="cloudTeacherOrder.studentId"/>
- <result column="type_" property="cloudTeacherOrder.type"/>
- <result column="level_" property="cloudTeacherOrder.level"/>
- <result column="time_" property="cloudTeacherOrder.time"/>
- <result column="amount_" property="cloudTeacherOrder.amount"/>
- <result column="refund_amount_" property="cloudTeacherOrder.refundAmount"/>
- <result column="status_" property="cloudTeacherOrder.status"/>
- <result column="start_time_" property="cloudTeacherOrder.startTime"/>
- <result column="end_time_" property="cloudTeacherOrder.endTime"/>
- <result column="order_id_" property="cloudTeacherOrder.orderId"/>
- <result column="trans_status_" property="studentPaymentOrder.status"/>
- <result column="expect_amount_" property="studentPaymentOrder.expectAmount"/>
- <result column="pay_time_" property="studentPaymentOrder.payTime"/>
- <result column="order_create_time_" property="studentPaymentOrder.createTime"/>
- <result column="name_" property="memberRankSetting.name"/>
- <result column="icon_" property="memberRankSetting.icon"/>
- <result column="music_group_id_" property="studentPaymentOrder.musicGroupId"/>
- </resultMap>
- <select id="get" resultMap="CloudTeacherOrder">
- <!--@mbg.generated-->
- select * from cloud_teacher_order where id_ = #{id}
- </select>
- <delete id="delete">
- <!--@mbg.generated-->
- delete from cloud_teacher_order
- where id_ = #{id}
- </delete>
- <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder"
- useGeneratedKeys="true">
- <!--@mbg.generated-->
- insert into cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_, refund_amount_, status_,
- order_id_,start_time_,end_time_,remark_, create_time_, update_time_,music_group_id_,active_remark_,tenant_id_)
- values (#{organId},#{studentId}, #{type},#{level}, #{time}, #{amount}, #{refundAmount},
- #{status},#{orderId},#{startTime},#{endTime}, #{remark}, NOW(), NOW(),#{musicGroupId},#{activeRemark},#{tenantId})
- </insert>
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
- <!--@mbg.generated-->
- update cloud_teacher_order
- <set>
- <if test="activeRemark != null">
- active_remark_ = #{activeRemark},
- </if>
- <if test="musicGroupId != null">
- music_group_id_ = #{musicGroupId},
- </if>
- <if test="organId != null">
- organ_id_ = #{organId},
- </if>
- <if test="studentId != null">
- student_id_ = #{studentId},
- </if>
- <if test="type != null">
- type_ = #{type},
- </if>
- <if test="level != null">
- level_ = #{level},
- </if>
- <if test="time != null">
- time_ = #{time},
- </if>
- <if test="amount != null">
- amount_ = #{amount},
- </if>
- <if test="refundAmount != null">
- refund_amount_ = #{refundAmount},
- </if>
- <if test="status != null">
- status_ = #{status},
- </if>
- <if test="startTime != null">
- start_time_ = #{startTime},
- </if>
- <if test="endTime != null">
- end_time_ = #{endTime},
- </if>
- <if test="orderId != null">
- order_id_ = #{orderId},
- </if>
- <if test="remark != null">
- remark_ = #{remark},
- </if>
- version_ = version_+1,
- update_time_ = NOW(),
- </set>
- where id_ = #{id} AND version_ = #{version} and tenant_id_ = #{tenantId}
- </update>
- <!-- 全查询 -->
- <select id="findAll" resultMap="CloudTeacherOrder">
- SELECT *
- FROM cloud_teacher_order where tenant_id_ = #{tenantId}
- </select>
- <!-- 分页查询 -->
- <select id="queryPage" resultMap="CloudTeacherOrderDto" parameterType="map">
- SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,spo.pay_time_,spo.create_time_ order_create_time_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto
- left join student_payment_order spo on cto.order_id_ = spo.id_
- left join member_rank_setting mrs on mrs.id_ = cto.level_
- where spo.type_ = 'MEMBER'
- <if test="status != null">
- and cto.status_ = #{status}
- </if>
- <if test="studentId != null">
- and cto.student_id_ = #{studentId}
- </if>
- <if test="tenantId != null">
- and cto.tenant_id_ = #{tenantId}
- </if>
- order by spo.pay_time_ desc,spo.id_ desc
- <include refid="global.limit"/>
- </select>
- <!-- 查询当前表的总记录数 -->
- <select id="queryCount" resultType="int">
- SELECT COUNT(cto.id_)
- FROM cloud_teacher_order cto LEFT JOIN student_payment_order spo on cto.order_id_ = spo.id_
- where spo.type_ = 'MEMBER'
- <if test="status != null">
- and cto.status_ = #{status}
- </if>
- <if test="studentId != null">
- and cto.student_id_ = #{studentId}
- </if>
- <if test="tenantId != null">
- and cto.tenant_id_ = #{tenantId}
- </if>
- order by cto.create_time_ desc
- </select>
- <select id="getNoStartCloudTeacherOrder" resultMap="CloudTeacherOrder">
- SELECT cto.*
- FROM cloud_teacher_order cto
- WHERE cto.status_ = 1 and cto.tenant_id_ = #{tenantId}
- </select>
- <select id="getStudentCloudTeacherOrders" resultMap="CloudTeacherOrder">
- SELECT *
- FROM cloud_teacher_order
- WHERE order_id_ IN (
- SELECT id_
- FROM student_payment_order
- WHERE status_ = 'SUCCESS'
- AND user_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- GROUP BY user_id_
- )
- AND student_id_ IN
- <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
- #{studentId}
- </foreach>
- AND status_ IN (1,2)
- </select>
- <select id="getStudentCloudTeacherOrder" resultMap="CloudTeacherOrder">
- SELECT *
- FROM cloud_teacher_order
- WHERE student_id_ = #{studentId}
- <if test="musicGroupId != null and musicGroupId != ''">
- AND music_group_id_ = #{musicGroupId}
- </if>
- AND status_ IN (1, 2)
- </select>
- <select id="queryByOrderId" resultMap="CloudTeacherOrder">
- SELECT cto.* FROM cloud_teacher_order cto
- WHERE order_id_ = #{orderId}
- </select>
-
- <select id="queryOrderInfoByOrderId" resultMap="CloudTeacherOrderDto">
- SELECT cto.*,spo.status_ trans_status_,spo.expect_amount_,mrs.name_,mrs.icon_ FROM cloud_teacher_order cto
- left join student_payment_order spo on cto.order_id_ = spo.id_
- left join member_rank_setting mrs on mrs.id_ = cto.level_
- where spo.type_ = 'MEMBER' and order_id_ = #{orderId}
- </select>
- <select id="queryNoStartByUserIds" resultType="java.util.Map">
- SELECT student_id_ 'key',create_time_ 'value' FROM cloud_teacher_order
- WHERE status_ = 1
- <if test="userIds != null and userIds.size > 0">
- AND student_id_ IN
- <foreach collection="userIds" separator="," item="userId" open="(" close=")">
- #{userId}
- </foreach>
- </if>
- <if test="isMusicMember = 'true'">
- AND music_group_id_ IS NOT NULL
- </if>
- GROUP BY student_id_
- </select>
- <resultMap id="CloudTeacherActiveTargetDetailDto" type="com.ym.mec.biz.dal.dto.CloudTeacherActiveTargetDetailDto">
- <result property="userId" column="student_id_"/>
- <result property="username" column="username_"/>
- <result property="amount" column="amount_"/>
- <result property="remark" column="remark_"/>
- <result property="cooperationName" column="cooperation_name_"/>
- <result property="musicGroupName" column="music_group_name_"/>
- <result property="chargeType" column="charge_type_name_"/>
- <result property="subjectName" column="subject_name_"/>
- <result property="currentGradeNum" column="current_grade_num_"/>
- <result property="teacherName" column="teacher_name_"/>
- <result property="createTime" column="create_time_"/>
- </resultMap>
- <select id="queryCloudTeacherActiveDetail" resultMap="CloudTeacherActiveTargetDetailDto">
- SELECT su.username_,cto.remark_,cto.amount_,cto.student_id_,GROUP_CONCAT(DISTINCT co.name_) cooperation_name_,
- GROUP_CONCAT(DISTINCT mg.name_) music_group_name_,GROUP_CONCAT(DISTINCT ct.name_) charge_type_name_,
- sj.name_ subject_name_,st.current_grade_num_,sus.real_name_ teacher_name_,cto.create_time_
- FROM cloud_teacher_order cto
- LEFT JOIN sys_user su ON su.id_ = cto.student_id_
- LEFT JOIN student_registration sr ON sr.user_id_ = cto.student_id_ AND sr.music_group_status_ = 'NORMAL'
- LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_ AND mg.status_ = 'PROGRESS'
- LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
- LEFT JOIN charge_type ct ON ct.id_ = mg.charge_type_id_
- LEFT JOIN student st ON st.user_id_ = cto.student_id_
- LEFT JOIN sys_user sus ON sus.id_ = st.teacher_id_
- LEFT JOIN `subject` sj ON sj.id_ = st.subject_id_list_
- <include refid="queryCloudTeacherActiveDetailSql"/>
- GROUP BY cto.id_
- ORDER BY cto.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="countCloudTeacherActiveDetail" resultType="int">
- SELECT COUNT(DISTINCT cto.id_)
- FROM cloud_teacher_order cto
- LEFT JOIN sys_user su ON su.id_ = cto.student_id_
- LEFT JOIN student st ON st.user_id_ = cto.student_id_
- LEFT JOIN student_registration sr ON sr.user_id_ = cto.student_id_ AND sr.music_group_status_ = 'NORMAL'
- LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_ AND mg.status_ = 'PROGRESS'
- <include refid="queryCloudTeacherActiveDetailSql"/>
- </select>
- <select id="queryActiveOrderPage" resultType="string">
- SELECT GROUP_CONCAT(DISTINCT cto.remark_) FROM cloud_teacher_order cto
- LEFT JOIN student_payment_order spo ON spo.id_ = cto.order_id_
- WHERE spo.status_ = 'SUCCESS' AND cto.active_remark_ = #{activeRemark}
- AND cto.student_id_ = #{userId} AND cto.remark_ != '单月'
- <if test="remark != null and remark != ''">
- AND cto.remark_ = #{remark}
- </if>
- </select>
- <select id="getStudentIds" resultType="java.lang.Integer">
- SELECT DISTINCT student_id_ FROM cloud_teacher_order WHERE active_remark_ IS NULL AND status_ != 0 and tenant_id_ = #{tenantId}
- </select>
- <select id="queryActiveAmountMap" resultType="java.util.Map">
- SELECT student_id_ 'key',SUM(amount_) 'value' FROM cloud_teacher_order
- WHERE status_ != 0 AND active_remark_ = '202109'
- <if test="studentIds != null and studentIds.size > 0">
- AND student_id_ IN
- <foreach collection="studentIds" separator="," item="userId" open="(" close=")">
- #{userId}
- </foreach>
- </if>
- GROUP BY student_id_
- </select>
- <sql id="queryCloudTeacherActiveDetailSql">
- <where>
- cto.status_ != 0 AND cto.active_remark_ = '202109'
- <if test="organIds != null and organIds != ''">
- AND FIND_IN_SET(su.organ_id_,#{organIds})
- </if>
- <if test="search != null and search != ''">
- AND (su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR mg.id_ LIKE CONCAT('%',#{search},'%'))
- </if>
- <if test="chargeType != null">
- AND mg.charge_type_id_ = #{chargeType}
- </if>
- <if test="subjectId != null">
- AND st.subject_id_list_ = #{subjectId}
- </if>
- <if test="teacherId != null">
- AND st.teacher_id_ = #{teacherId}
- </if>
- <if test="tenantId != null">
- AND cto.tenant_id_ = #{tenantId}
- </if>
- <if test="remarkType != null and remarkType != ''">
- AND cto.remark_ = #{remarkType}
- </if>
- </where>
- </sql>
- </mapper>
|