240 lines
8.4 KiB
XML
240 lines
8.4 KiB
XML
|
|
<?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="UserOwnLesson">
|
||
|
|
|
||
|
|
<insert id="insertUserOwnLesson" parameterType="UserOwnLesson">
|
||
|
|
INSERT INTO UserOwnLesson ( uid, goodsId, startTime, endTime,
|
||
|
|
status , areaid )
|
||
|
|
Values ( #{uid}, #{goodsId}, #{startTime}, #{endTime},
|
||
|
|
#{status} , #{areaid} )
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUserOwnLesson" parameterType="UserOwnLesson">
|
||
|
|
UPDATE UserOwnLesson
|
||
|
|
SET uid = #{uid}, goodsId = #{goodsId}, startTime = #{startTime},
|
||
|
|
endTime = #{endTime}, status = #{status} , areaid = #{areaid}
|
||
|
|
where uid=#{uid}
|
||
|
|
and goodsId=#{goodsId}
|
||
|
|
and areaid = #{areaid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonByKey" parameterType="java.util.Map" resultType="UserOwnLesson">
|
||
|
|
SELECT uid , goodsId , startTime , endTime , status , areaid
|
||
|
|
FROM UserOwnLesson
|
||
|
|
WHERE uid=#{uid}
|
||
|
|
and goodsId=#{goodsId}
|
||
|
|
and areaid = #{areaid}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="insertUserOwnLessonBatch" parameterType="java.util.List">
|
||
|
|
INSERT INTO UserOwnLesson ( uid, goodsId, startTime, endTime,
|
||
|
|
status , areaid )
|
||
|
|
Values
|
||
|
|
<foreach collection="list" index="index" item="item" separator=",">
|
||
|
|
( #{item.uid}, #{item.goodsId},
|
||
|
|
#{item.startTime}, #{item.endTime},
|
||
|
|
#{item.status} , #{item.areaid} )
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<insert id="sendUserOwnLessonsToClass" parameterType="java.util.Map">
|
||
|
|
INSERT INTO UserOwnLesson ( uid, goodsId, startTime, endTime,
|
||
|
|
status , areaid )
|
||
|
|
SELECT studentId , #{goodsId} , #{startTime}, #{endTime} , 1 , #{areaid}
|
||
|
|
FROM StudentOwnClass
|
||
|
|
WHERE classesId = #{classesId}
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<insert id="sendUserOwnLessonsToUser" parameterType="java.util.Map">
|
||
|
|
INSERT INTO UserOwnLesson ( uid, goodsId, startTime, endTime,
|
||
|
|
status , areaid )
|
||
|
|
SELECT #{userId} , #{goodsId} , #{startTime}, #{endTime} , 1 , #{areaid}
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonByUid" parameterType="java.util.Map" resultType="UserOwnLessonDto">
|
||
|
|
SELECT uid,g.goodsname, g.goodsid , g.price , startTime,
|
||
|
|
endTime, u.status, areaid
|
||
|
|
FROM UserOwnLesson u inner join goods g on g.goodsid = u.goodsid
|
||
|
|
where uid = #{uid} and u.areaId=#{areaId}
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonCountByUid" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
select count(*) from UserOwnLesson where uid = #{uid} and areaId=#{areaId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonCountByUidForEffect" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
select count(*) from cs_lesson as cl inner join lesson as l1 on cl.unitid = l1.lessonid and l1.lessontype = 'U' and l1.status = 1 inner join lesson as l2 on l1.parentid = l2.lessonid and l2.lessontype= 'B' and l2.status = 1 inner join lesson as l3 on l2.parentid = l3.lessonid inner join goodsownpackage as g on g.lessonid = l2.lessonid inner join userownlesson as ul on ul.goodsid= g.goodsid where ul.status =1 and ul.areaid= #{areaId} and ul.uid = #{uid} and ul.endtime > CURRENT_TIMESTAMP
|
||
|
|
<if test="exincluedBookIds!=null">
|
||
|
|
and l2.lessonid not in
|
||
|
|
<foreach collection="exincluedBookIds" index="index" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getLastLessonByUid" parameterType="java.util.Map" resultType="UserOwnLesson">
|
||
|
|
select u.uid , u.goodsid , u.starttime , u.endtime,
|
||
|
|
u.status , u.areaid
|
||
|
|
from userownlesson u
|
||
|
|
inner join goods g
|
||
|
|
on u.goodsid = g.goodsid
|
||
|
|
where g.isrecomm = 0 and u.uid = #{uid} and u.areaid = #{areaid}
|
||
|
|
order by u.starttime desc limit 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getExpireLessonByUid" parameterType="java.util.Map" resultType="String">
|
||
|
|
select max(endTime )
|
||
|
|
from userownlesson u
|
||
|
|
inner join goods g
|
||
|
|
on u.goodsid = g.goodsid and g.isrecomm = 0
|
||
|
|
where uid = #{uid} and u.areaId=#{areaId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getEarliestLessonByUid" parameterType="java.util.Map" resultType="String">
|
||
|
|
select min(startTime )
|
||
|
|
from userownlesson u
|
||
|
|
inner join goods g
|
||
|
|
on u.goodsid = g.goodsid and g.isrecomm = 0
|
||
|
|
where uid = #{uid} and u.areaId=#{areaId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getFreeRecommGoods" parameterType="long" resultType="Integer">
|
||
|
|
select u.goodsid
|
||
|
|
from userownlesson u
|
||
|
|
inner join goods g
|
||
|
|
on u.goodsid = g.goodsid
|
||
|
|
where u.uid = #{uid} and g.price = 0 and g.isrecomm = 1
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMinTimeByGoodsIdByClassesId" parameterType="java.util.HashMap" resultType="java.util.Date">
|
||
|
|
select min(u.endTime)
|
||
|
|
from userownlesson u
|
||
|
|
inner join studentownclass s
|
||
|
|
on u.uid = s.studentid and s.status =1
|
||
|
|
and s.classesid = #{classesId}
|
||
|
|
where u.goodsId = #{goodsId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMinTimeByGoodsIdBystudentIds" parameterType="java.util.HashMap" resultType="java.util.Date">
|
||
|
|
select min(endTime)
|
||
|
|
from userownlesson
|
||
|
|
where goodsId = #{goodsId} and uid in
|
||
|
|
<foreach collection="studentIds" item="item" separator="," close=")" open="(">
|
||
|
|
|
||
|
|
#{item}
|
||
|
|
|
||
|
|
</foreach>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonByGoodsIdByUids" parameterType="java.util.Map" resultType="UserOwnLesson">
|
||
|
|
select uid , goodsid , starttime , endtime, status , areaid
|
||
|
|
from userownlesson
|
||
|
|
where goodsid = #{goodsId} and uid in
|
||
|
|
<foreach collection="studentIds" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUserOwnLessonByGoodsIdByClassesIds" parameterType="java.util.Map" resultType="UserOwnLesson">
|
||
|
|
select uid , goodsid , starttime , endtime, u.status , u.areaid
|
||
|
|
from userownlesson u
|
||
|
|
inner join studentownclass s
|
||
|
|
on u.uid = s.studentid and s.status = 1
|
||
|
|
inner join classes c
|
||
|
|
on c.classesid = s.classesid and c.classtype = 1 and c.status = 1
|
||
|
|
where goodsid = #{goodsId} and c.classesid in
|
||
|
|
<foreach collection="classesIds" item="item" separator="," close=")" open="(">
|
||
|
|
|
||
|
|
#{item}
|
||
|
|
|
||
|
|
</foreach>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getMinTimeByGoodsIdByClassesIds" parameterType="java.util.HashMap" resultType="java.util.Date">
|
||
|
|
select min(u.endTime)
|
||
|
|
from userownlesson u
|
||
|
|
inner join studentownclass s
|
||
|
|
on u.uid = s.studentid and s.status = 1
|
||
|
|
inner join classes c
|
||
|
|
on c.classesid = s.classesid and c.classtype = 1 and c.status = 1
|
||
|
|
where goodsid = #{goodsId} and c.classesid in
|
||
|
|
<foreach collection="classesIds" item="item" separator="," close=")" open="(">
|
||
|
|
|
||
|
|
#{item}
|
||
|
|
|
||
|
|
</foreach>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getBaseGoodsByUid" parameterType="java.util.Map" resultType="UserOwnLessonDto">
|
||
|
|
SELECT uid,g.goodsname, g.goodsid , g.price , startTime,
|
||
|
|
endTime, u.status, areaid
|
||
|
|
FROM UserOwnLesson u
|
||
|
|
INNER JOIN goods g
|
||
|
|
ON g.goodsid = u.goodsid
|
||
|
|
WHERE uid = #{uid} and u.areaid=#{areaId}
|
||
|
|
AND ( ( g.isrecomm = 0 ) OR ( g.isrecomm = 0 AND price = 0 ) )
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<update id="resetUserOwnlessonTimes" parameterType="java.util.Map">
|
||
|
|
UPDATE UserOwnLesson
|
||
|
|
set startTime = #{startTime} , endTime = #{endTime}
|
||
|
|
WHERE uid = #{uid}
|
||
|
|
AND
|
||
|
|
goodsId > 0
|
||
|
|
|
||
|
|
AND goodsId in ( select goodsId from Goods
|
||
|
|
where ( isrecomm = 0 )
|
||
|
|
or ( isrecomm = 1 and price =0 ) )
|
||
|
|
</update>
|
||
|
|
|
||
|
|
|
||
|
|
<update id="resetUserOwnlessonEndTime" parameterType="java.util.Map">
|
||
|
|
UPDATE UserOwnLesson
|
||
|
|
set endTime = #{endTime}
|
||
|
|
WHERE uid = #{uid}
|
||
|
|
AND goodsid in (SELECT g.goodsid FROM goods g
|
||
|
|
WHERE (g.isrecomm > 0 AND g.price = 0)
|
||
|
|
OR g.isrecomm = 0)
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<update id="resetUserOwnlessonEndTimeByYears" parameterType="java.util.Map">
|
||
|
|
|
||
|
|
UPDATE UserOwnLesson
|
||
|
|
set endTime = ( endTime - interval '${refundYears} year')
|
||
|
|
WHERE uid = #{uid} AND goodsid in (SELECT g.goodsid FROM goods g
|
||
|
|
WHERE (g.isrecomm > 0 AND g.price = 0)
|
||
|
|
OR g.isrecomm = 0)
|
||
|
|
|
||
|
|
</update>
|
||
|
|
<delete id="deleteUserOwnLessonByUidAndGoodsIds" parameterType="java.util.Map" >
|
||
|
|
delete from userownlesson where uid=#{uid} and
|
||
|
|
goodsId in
|
||
|
|
<foreach collection="goodsIds" item="item" separator="," close=")" open="(">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|