123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653 |
- <?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="member_rank_setting_id_" property="memberRankSettingId"/>
- <result column="student_id_" property="studentId"/>
- <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="level_" property="level"/>
- <result column="time_" property="time"/>
- <result column="amount_" property="amount"/>
- <result column="operating_amount_" property="operatingAmount"/>
- <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="platform_order_id_" property="platformOrderId"/>
- <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" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
- <result column="level_" property="cloudTeacherOrder.level"/>
- <result column="time_" property="cloudTeacherOrder.time"/>
- <result column="amount_" property="cloudTeacherOrder.amount"/>
- <result column="operating_amount_" property="cloudTeacherOrder.operatingAmount"/>
- <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="platform_order_id_" property="cloudTeacherOrder.platformOrderId"/>
- <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="intro_" property="memberRankSetting.intro"/>
- <result column="music_group_id_" property="studentPaymentOrder.musicGroupId"/>
- </resultMap>
- <select id="get" resultMap="CloudTeacherOrder">
- select * from cloud_teacher_order where id_ = #{id}
- </select>
- <delete id="delete">
- 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">
- INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_, operating_amount_, refund_amount_, status_,
- order_id_,platform_order_id_,start_time_,end_time_,remark_, create_time_, update_time_,music_group_id_,active_remark_,tenant_id_,member_rank_setting_id_)
- VALUES (#{organId},#{studentId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{level}, #{time}, #{amount}, #{operatingAmount}, #{refundAmount},
- #{status},#{orderId},#{platformOrderId},#{startTime},#{endTime}, #{remark}, NOW(), NOW(),#{musicGroupId},#{activeRemark},#{tenantId},#{memberRankSettingId})
- </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,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
- </if>
- <if test="level != null">
- level_ = #{level},
- </if>
- <if test="time != null">
- time_ = #{time},
- </if>
- <if test="amount != null">
- amount_ = #{amount},
- </if>
- <if test="operatingAmount != null">
- operating_amount_ = #{operatingAmount},
- </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="platformOrderId != null">
- platform_order_id_ = #{platformOrderId},
- </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="findByPlatformOrderId" resultMap="CloudTeacherOrder">
- select * from cloud_teacher_order cto
- left join sys_user su on cto.student_id_ = su.id_
- where cto.platform_order_id_ = #{platformOrderId} and su.del_flag_ = '0'
- </select>
- <resultMap type="com.ym.mec.biz.dal.dto.Mapper" id="mapper">
- <result column="userId" property="key"/>
- <result column="phone" property="value"/>
- </resultMap>
- <select id="findUserNameByOrderId" resultMap="mapper">
- select su.id_ as userId, su.phone_ as phone from cloud_teacher_order cto
- left join sys_user su on cto.student_id_ = su.id_
- where platform_order_id_ = #{platformOrderId} and su.del_flag_ = '0'
- </select>
- <update id="updateOrderStatusOK">
- update cloud_teacher_order set status_ = 2,
- `start_time_` = CURRENT_DATE(),
- `end_time_` = case
- when type_ = 1 then concat(date_add(CURRENT_DATE(), interval `time_` day) , ' 00:00:00')
- when type_ = 2 then concat(date_add(CURRENT_DATE(), interval `time_` month) , ' 00:00:00')
- when type_ = 3 then concat(date_add(CURRENT_DATE(), interval `time_` * 3 month) , ' 00:00:00')
- when type_ = 4 then concat(date_add(CURRENT_DATE(), interval `time_` * 6 month) , ' 00:00:00')
- when type_ = 5 then concat(date_add(CURRENT_DATE(), interval `time_` year) , ' 00:00:00')
- end
- where platform_order_id_ = #{platformOrderId}
- </update>
- <update id="updateOrderId">
- update cloud_teacher_order
- set platform_order_id_ = #{platformOrderId} , pay_amount_ = #{amount}
- where id_ = #{cloudTeacherOrderId}
- </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 status != ''">
- and FIND_IN_SET(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 status != ''">
- and FIND_IN_SET(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="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_,mrs.intro_
- 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>
- 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="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 case when mg.course_view_type_ = 2 then '会员收费' when mg.course_view_type_ = 3 then '免费' else '课程收费' end) charge_type_name_,
- sj.name_ subject_name_,st.current_grade_num_,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 student st ON st.user_id_ = cto.student_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>
- <resultMap id="cloudTeacherStudent" type="com.ym.mec.biz.dal.entity.CloudTeacherStudent">
- <result property="type" column="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
- </resultMap>
- <!-- 查询激活或未激活记录 -->
- <select id="queryInactive" resultMap="cloudTeacherStudent">
- select
- cto.id_ as cloudTeacherOrderId,
- cto.student_id_ as studentId,
- cto.type_ as type,
- case cto.type_
- WHEN 'DAY' THEN '天'
- WHEN 'MONTH' THEN '月'
- WHEN 'QUARTERLY' THEN '季'
- WHEN 'YEAR_HALF' THEN '半年'
- WHEN 'YEAR' THEN '年' ELSE ''
- end as typeName,
- cto.time_ as time,
- sj.id_ as subject,
- sj.name_ as subjectName,
- cto.tenant_id_ as tenantId,
- u.username_ as name,
- u.phone_ as phone
- ,cto.status_ as status
- ,cto.operator_ as operator
- ,cto.operate_time_ as operateTime
- ,cto.cancel_reason_ as cancelReason
- ,cto.organ_id_ organId
- ,cto.create_time_ createTime
- ,cto.level_ memberRankId
- from cloud_teacher_order cto
- left join student s on cto.student_id_ = s.user_id_
- left join sys_user u on cto.student_id_ = u.id_
- left join subject sj on s.subject_id_list_ = sj.id_
- <if test="musicGroupId != null and musicGroupId != ''">
- left join student_registration sr ON cto.student_id_ = sr.user_id_
- </if>
- <where>
- FIND_IN_SET(cto.status_,#{status}) AND cto.tenant_id_ = #{tenantId}
- <if test="organIds != null and organIds != ''">
- AND FIND_IN_SET(u.organ_id_ , #{organIds})
- </if>
- <if test="musicGroupId != null and musicGroupId != ''">
- AND sr.music_group_id_ = #{musicGroupId}
- </if>
- <if test="memberRankId != null">
- AND cto.level_ = #{memberRankId}
- </if>
- <if test="queryCondition != null and queryCondition != ''">
- AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
- </if>
- <if test="subjectId">
- AND (s.subject_id_list_ = #{subjectId})
- </if>
- <if test="operatorName != null and operatorName.trim() != ''">
- AND cto.operator_ in (
- select id_ from sys_user where real_name_ like concat('%',#{operatorName},'%')
- union select -1 from sys_user
- )
- </if>
- <if test="operateStartTime != null">
- AND cto.operate_time_ >= #{operateStartTime}
- </if>
- <if test="operateEndTime != null">
- AND #{operateEndTime} >= cto.operate_time_
- </if>
- </where>
- ORDER BY cto.id_ DESC
- <include refid="global.limit"/>
- </select>
- <select id="findInactiveCount" resultType="java.lang.Integer">
- select count(1) from cloud_teacher_order cto
- left join student s on cto.student_id_ = s.user_id_
- left join sys_user u on cto.student_id_ = u.id_
- left join subject sj on s.subject_id_list_ = sj.id_
- <if test="musicGroupId != null and musicGroupId != ''">
- left join student_registration sr ON cto.student_id_ = sr.user_id_
- </if>
- <where>
- FIND_IN_SET(cto.status_,#{status}) AND cto.tenant_id_ = #{tenantId}
- <if test="organIds != null and organIds != ''">
- AND FIND_IN_SET(u.organ_id_ , #{organIds})
- </if>
- <if test="musicGroupId != null and musicGroupId != ''">
- AND sr.music_group_id_ = #{musicGroupId}
- </if>
- <if test="memberRankId != null">
- AND cto.level_ = #{memberRankId}
- </if>
- <if test="queryCondition != null and queryCondition != ''">
- AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
- </if>
- <if test="subjectId">
- AND (s.subject_id_list_ = #{subjectId})
- </if>
- <if test="operatorName != null and operatorName.trim() != ''">
- AND cto.operator_ in (
- select id_ from sys_user where real_name_ like concat('%',#{operatorName},'%')
- union select -1 from sys_user
- )
- </if>
- <if test="operateStartTime != null">
- AND cto.operate_time_ >= #{operateStartTime}
- </if>
- <if test="operateEndTime != null">
- AND #{operateEndTime} >= cto.operate_time_
- </if>
- </where>
- </select>
- <!-- 查询订单记录 -->
- <select id="findRecordCount" resultType="java.lang.Integer">
- SELECT count(1) FROM tenant_order_record tor
- LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
- LEFT JOIN student s ON cto.student_id_ = s.user_id_
- LEFT JOIN sys_user u ON cto.student_id_ = u.id_
- <where>
- cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
- <if test="queryCondition != null and queryCondition != ''">
- AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND tor.order_no_ LIKE CONCAT('%', #{orderNo}, '%')
- </if>
- <if test="memberRankId != null">
- AND cto.level_ = #{memberRankId}
- </if>
- <if test="startTime != null">
- <![CDATA[ AND tor.created_time_ >= #{startTime} ]]>
- </if>
- <if test="endTime != null">
- <![CDATA[ AND tor.created_time_ <= #{endTime} ]]>
- </if>
- </where>
- </select>
- <select id="queryRecord" resultMap="cloudTeacherStudent">
- SELECT
- cto.id_ AS cloudTeacherOrderId,
- cto.student_id_ AS studentId,
- cto.type_ AS type,
- CASE cto.type_ WHEN 'DAY' THEN '天'
- WHEN 'MONTH' THEN '月'
- WHEN 'QUARTERLY' THEN '季'
- WHEN 'YEAR_HALF' THEN '半年'
- WHEN 'YEAR' THEN '年' ELSE ''
- END AS typeName,
- cto.time_ AS time,
- u.tenant_id_ AS tenantId,
- u.username_ AS name,
- u.phone_ AS phone,
- tor.order_no_ as orderNo,
- tor.trans_no_ as transNo,
- tor.created_time_ as orderTime,
- cto.pay_amount_ as amount,
- cto.level_ as memberRankId
- FROM tenant_order_record tor
- LEFT JOIN cloud_teacher_order cto ON tor.id_ = cto.platform_order_id_
- LEFT JOIN student s ON cto.student_id_ = s.user_id_
- LEFT JOIN sys_user u ON cto.student_id_ = u.id_
- <where>
- cto.tenant_id_ = #{tenantId} AND tor.order_type_ = 'CLOUD_TEACHER' AND tor.order_state_ = 1
- <if test="queryCondition != null and queryCondition != ''">
- AND (u.username_ LIKE CONCAT('%', #{queryCondition}, '%') or u.phone_ = #{queryCondition} or u.id_ = #{queryCondition})
- </if>
- <if test="orderNo != null and orderNo != ''">
- AND tor.order_no_ LIKE CONCAT('%', #{orderNo}, '%')
- </if>
- <if test="memberRankId != null">
- AND cto.level_ = #{memberRankId}
- </if>
- <if test="startTime != null">
- <![CDATA[ AND tor.created_time_ >= #{startTime} ]]>
- </if>
- <if test="endTime != null">
- <![CDATA[ AND tor.created_time_ <= #{endTime} ]]>
- </if>
- </where>
- <include refid="global.limit"/>
- </select>
- <select id="checkOrdered" resultType="java.lang.Integer">
- select count(1) from cloud_teacher_order where id_ in (${cloudTeacherStudentIds}) and status_ = 2 and platform_order_id_ is not null
- </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="subjectId != null">
- AND st.subject_id_list_ = #{subjectId}
- </if>
- <if test="tenantId != null">
- AND cto.tenant_id_ = #{tenantId}
- </if>
- <if test="remarkType != null and remarkType != ''">
- AND cto.remark_ = #{remarkType}
- </if>
- </where>
- </sql>
- <insert id="batchInsert">
- INSERT INTO cloud_teacher_order (organ_id_,student_id_, type_, level_, time_, amount_,status_,
- remark_,create_time_, update_time_,tenant_id_)
- VALUES
- <foreach collection="userIds" item="userId" separator=",">
- (#{bean.organId},#{userId},#{bean.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{bean.level},
- #{bean.time}, #{bean.amount},#{bean.status},#{bean.remark},NOW(),NOW(),#{bean.tenantId})
- </foreach>
- </insert>
-
- <select id="queryByUserIdAndStatus" resultMap="CloudTeacherOrder">
- select cto.* from cloud_teacher_order cto where cto.student_id_ = #{userId} and cto.status_ = #{status}
- </select>
- <select id="getWaitActivateMap" resultType="java.util.Map">
- select cto.organ_id_ 'key',COUNT(DISTINCT cto.student_id_) 'value' from cloud_teacher_order cto
- left join student s ON s.user_id_ = cto.student_id_
- left join student_registration sr ON sr.user_id_ = cto.student_id_
- left join music_group mg ON mg.id_ = sr.music_group_id_
- where cto.status_ = 1 AND (s.membership_end_time_ < NOW() OR s.membership_end_time_ IS NULL)
- AND sr.music_group_status_ = 'NORMAL' AND mg.status_ IN ('PROGRESS','PAUSE')
- <if test="organIds != null and organIds.size > 0">
- AND cto.organ_id_ IN
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
- #{organId}
- </foreach>
- </if>
- group by cto.organ_id_
- </select>
- <select id="sumPersonIncome" resultType="java.util.Map">
- select organ_id_ 'key',SUM(amount_) 'value' from cloud_teacher_order cto
- where cto.music_group_id_ IS NULL
- AND DATE_FORMAT(create_time_, '%Y-%m') = #{month} AND cto.status_ IN (1,2) AND amount_ > 0 group by organ_id_
- </select>
- <select id="sumPersonalCloudAmount" resultType="java.util.Map">
- select cto.organ_id_ 'key',TRUNCATE(SUM(operating_amount_ / (TIMESTAMPDIFF(DAY,cto.start_time_,cto.end_time_) + 1) *
- (TIMESTAMPDIFF(DAY,CASE WHEN start_time_ < #{firstDay} THEN #{firstDay} ELSE DATE_FORMAT(start_time_,'%Y-%m-%d') END,
- CASE WHEN DATE_FORMAT(end_time_,'%Y-%m') > #{month} THEN #{lastDay} ELSE DATE_FORMAT(end_time_,'%Y-%m-%d') END) + 1)),2) 'value'
- from cloud_teacher_order cto
- where operating_amount_ = 480 AND music_group_id_ IS NOT NULL AND #{month} BETWEEN DATE_FORMAT(start_time_,'%Y-%m') AND DATE_FORMAT(end_time_,'%Y-%m')
- AND cto.settlement_report_flag_ = 0 AND cto.status_ = 2
- group by cto.organ_id_;
- </select>
- <select id="sumGroupCloudAmount" resultType="java.util.Map">
- select cto.organ_id_ 'key',TRUNCATE(SUM(operating_amount_ / (TIMESTAMPDIFF(DAY,cto.start_time_,cto.end_time_) + 1) *
- (TIMESTAMPDIFF(DAY,CASE WHEN start_time_ < #{firstDay} THEN #{firstDay} ELSE DATE_FORMAT(start_time_,'%Y-%m-%d') END,
- CASE WHEN DATE_FORMAT(end_time_,'%Y-%m') > #{month} THEN #{lastDay} ELSE DATE_FORMAT(end_time_,'%Y-%m-%d') END) + 1)),2) 'value'
- from cloud_teacher_order cto
- where operating_amount_ > 0 AND operating_amount_ != 480 AND #{month} BETWEEN DATE_FORMAT(start_time_,'%Y-%m') AND DATE_FORMAT(end_time_,'%Y-%m')
- AND cto.settlement_report_flag_ = 0 AND cto.status_ = 2
- group by cto.organ_id_
- </select>
- <update id="cancelInactiveCloudTeacher">
- update cloud_teacher_order
- set operator_ = #{operator}, status_=4 ,cancel_reason_=#{cancelReason},operate_time_=#{operateTime}
- where id_ in
- <foreach collection="idList" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- and status_ = 1 and tenant_id_ = #{tenantId}
- </update>
- <select id="queryCloudTeacherOrderByIds" resultMap="CloudTeacherOrder">
- select t.* from cloud_teacher_order t
- where t.id_ in
- <foreach collection="ids" item="item" close=")" open="(" separator=",">
- #{item}
- </foreach>
- </select>
- <select id="exportCloudCoachActivationDetails" resultType="com.ym.mec.biz.dal.dto.CloudCoachActivationDetailsDto">
- select o.name_ organName,cto.amount_ amount,cto.student_id_ studentId,cto.start_time_ createTime,su.username_ studentName,
- CASE WHEN cto.type_ = 'MONTH' THEN CONCAT(cto.time_,'月')
- WHEN cto.type_ = 'YEAR' THEN CONCAT(cto.time_ * 12,'月')
- WHEN cto.type_ = 'YEAR_HALF' THEN CONCAT(cto.time_ * 6,'月')
- WHEN cto.type_ = 'QUARTERLY' THEN CONCAT(cto.time_ * 3,'月')
- ELSE CONCAT(cto.time_,'天') END AS time
- from cloud_teacher_order cto
- left join organization o ON o.id_ = cto.organ_id_
- left join sys_user su ON su.id_ = cto.student_id_
- where cto.status_ = 2
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(cto.organ_id_,#{organId})
- </if>
- <if test="month != null and month != ''">
- AND DATE_FORMAT(cto.start_time_,'%Y-%m') = #{month}
- </if>
- ORDER BY o.id_ DESC,cto.start_time_ DESC
- </select>
- <select id="exportMusicGroupNoCourse"
- resultType="com.ym.mec.biz.dal.dto.ExportWrapper$ExportMusicGroupNoCourseDto">
- select o.name_ organName,mg.name_ musicGroupName,mg.id_ musicGroupId,mgpscd.user_id_ studentId,su.username_ studentName,
- sum(CASE WHEN mgpscd.course_type_ = 'CLASSROOM' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS classroom,
- sum(CASE WHEN mgpscd.course_type_ = 'COMPREHENSIVE' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS comprehensive,
- sum(CASE WHEN mgpscd.course_type_ = 'HIGH' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS high,
- sum(CASE WHEN mgpscd.course_type_ = 'HIGH_ONLINE' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS highOnline,
- sum(CASE WHEN mgpscd.course_type_ = 'MIX' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS mix,
- sum(CASE WHEN mgpscd.course_type_ = 'SINGLE' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS single,
- sum(CASE WHEN mgpscd.course_type_ = 'TRAINING_MIX' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS trainingMix,
- sum(CASE WHEN mgpscd.course_type_ = 'TRAINING_SINGLE' THEN mgpscd.sub_course_minutes_ ELSE 0 END) AS trainingSingle
- from music_group mg
- left join music_group_payment_calender mgpc ON mgpc.music_group_id_ = mg.id_
- left join music_group_payment_student_course_detail mgpscd ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
- left join organization o ON o.id_ = mg.organ_id_
- left join sys_user su ON su.id_ = mgpscd.user_id_
- left join student_registration sr ON sr.user_id_ = mgpscd.user_id_ AND sr.music_group_id_ = mgpc.music_group_id_
- where mg.status_ = 'PROGRESS' AND sr.music_group_status_ = 'NORMAL' AND mgpscd.sub_course_minutes_ > 0
- <if test="organId != null and organId != ''">
- AND FIND_IN_SET(mg.organ_id_,#{organId})
- </if>
- group by mgpscd.music_group_id_,mgpscd.user_id_ order by mg.organ_id_,mg.id_
- </select>
- <select id="countByMemberRankSettingId" resultType="int">
- select count(1) from cloud_teacher_order where level_ in
- <foreach collection="memberRankSettingId" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </select>
- <select id="queryByUserIds" resultType="com.ym.mec.biz.dal.entity.CloudTeacherOrder">
- select * from cloud_teacher_order where student_id_ in
- <foreach collection="userIds" item="userId" separator="," open="(" close=")">
- #{userId}
- </foreach>
- <if test="status != null">
- and status_ = #{status}
- <if test="status == 2">
- and end_time_ >= NOW()
- </if>
- </if>
- </select>
- <select id="getActivationVipIds" resultType="java.lang.Integer">
- select distinct member_rank_id_ from student_member_time where student_id_ = #{studentId} and end_time_ >=now()
- </select>
- </mapper>
|