<?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.dsh.course.mapper.TCoursePackagePaymentMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.dsh.course.entity.TCoursePackagePayment">
|
<id column="id" property="id" />
|
<result column="appUserId" property="appUserId" />
|
<result column="studentId" property="studentId" />
|
<result column="coursePackageId" property="coursePackageId" />
|
<result column="payType" property="payType" />
|
<result column="classHours" property="classHours" />
|
<result column="cashPayment" property="cashPayment" />
|
<result column="playPaiCoin" property="playPaiCoin" />
|
<result column="totalClassHours" property="totalClassHours" />
|
<result column="laveClassHours" property="laveClassHours" />
|
<result column="absencesNumber" property="absencesNumber" />
|
<result column="payUserType" property="payUserType" />
|
<result column="payStatus" property="payStatus" />
|
<result column="orderNumber" property="orderNumber" />
|
<result column="payUserId" property="payUserId" />
|
<result column="status" property="status" />
|
<result column="withdrawalTime" property="withdrawalTime" />
|
<result column="certificate" property="certificate" />
|
<result column="state" property="state" />
|
<result column="insertTime" property="insertTime" />
|
</resultMap>
|
<update id="updateUseTime">
|
update t_course_package_payment
|
set useTime = #{date}
|
where id = #{id}
|
</update>
|
<update id="updateHoursById">
|
update t_course_package_payment set totalClassHours =totalClassHours +#{i},classHours =classHours+#{i},laveClassHours =laveClassHours+#{i} where id =#{id}
|
</update>
|
|
<select id="queryCountNumber" resultType="int">
|
SELECT
|
count( 1 ) AS num
|
FROM (
|
SELECT studentId FROM t_course_package_payment WHERE payStatus = 2 AND state = 1 and coursePackageId = #{coursePackageId} GROUP BY studentId
|
) AS aa
|
</select>
|
|
<select id="getCoursePackagePaymentByCode" resultType="com.dsh.course.entity.TCoursePackagePayment">
|
select * from t_course_package_payment where 1=1
|
<if test="code != null">
|
and `code` = #{code}
|
</if>
|
</select>
|
|
<select id="billingDataRequestVo" resultType="com.dsh.course.model.BillingRequest">
|
SELECT DATE_FORMAT(insertTime, '%m-%d %H:%i')as `time`,IFNULL(playPaiCoin, cashPayment) AS amount
|
from t_course_package_payment
|
where payStatus = 2 and state = 1 and payType in (1,2)
|
<if test="null != monthStart and '' != monthStart and null != monthEnd and '' != monthEnd">
|
and DATE_FORMAT(insertTime, '%Y-%m-%d %H:%i:%s') between #{monthStart} and #{monthEnd}
|
</if>
|
<if test="null != appUserId and '' != appUserId ">
|
and appUserId = #{appUserId}
|
</if>
|
</select>
|
|
|
|
<select id="queryRegistrationRecord" resultType="map">
|
select
|
CAST(id AS CHAR(20)) as id,
|
appUserId,
|
studentId,
|
DATE_FORMAT(insertTime, '%Y-%m-%d %H:%i') as insertTime,
|
totalClassHours,
|
laveClassHours,
|
absencesNumber,
|
`status`
|
from t_course_package_payment where payStatus = 2 and state = 1
|
<if test="null != coursePackageId">
|
and coursePackageId = #{coursePackageId}
|
</if>
|
<if test="null != userIds">
|
and appUserId in
|
<foreach collection="userIds" item="item" index="index" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != studentIds">
|
and studentId in
|
<foreach collection="studentIds" item="item" index="index" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
order by
|
CASE
|
WHEN laveClassHours < 3 THEN 0
|
ELSE 1
|
END, insertTime DESC
|
</select>
|
|
|
<select id="queryWalkInStudentList" resultType="map">
|
select
|
CAST(id AS CHAR(20)) as id,
|
appUserId,
|
studentId
|
from t_course_package_payment where payStatus = 2 and state = 1
|
<if test="null != coursePackageId">
|
and coursePackageId = #{coursePackageId}
|
</if>
|
<if test="null != coursePackagePaymentId">
|
and id not in
|
<foreach collection="coursePackagePaymentId" item="item" index="index" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != userIds">
|
and appUserId in
|
<foreach collection="userIds" item="item" index="index" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="null != studentIds">
|
and studentId in
|
<foreach collection="studentIds" item="item" index="index" separator="," open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
order by insertTime desc
|
</select>
|
<select id="getStudentIds" resultType="java.lang.Integer">
|
SELECT studentId
|
FROM t_course_package_payment
|
WHERE appUserId = #{appId} AND id != #{id} and coursePackageId=#{classId}
|
|
|
</select>
|
<select id="getStudentTotal" resultType="map">
|
SELECT * from(
|
SELECT studentId, totalClassHours, name as courseName, laveClassHours,cashPayment as cashPayment,hasHours,appUserId,insertTime
|
,coursePackageId
|
FROM (
|
SELECT studentId, totalClassHours, name, laveClassHours,cashPayment, (totalClassHours - laveClassHours) AS hasHours,py.appUserId,py.insertTime
|
,coursePackageId
|
FROM t_course_package_payment py
|
LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
|
UNION ALL
|
SELECT studentId, SUM(totalClassHours) AS totalClassHours,'总计' as name, SUM(laveClassHours) AS laveClassHours, SUM(cashPayment) AS cashPayment,
|
(SUM(totalClassHours) - SUM(laveClassHours)) AS hasHours,py.appUserId,py.insertTime,py.coursePackageId
|
FROM t_course_package_payment py
|
LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
|
GROUP BY studentId
|
ORDER BY studentId, length(name) desc ,totalClassHours
|
) subquery
|
) a
|
<where>
|
<if test="null != start and '' != start and null != end and '' != end">
|
a.insertTime between #{start} and #{end}
|
</if>
|
<if test="coursePackageIds != null and coursePackageIds.size()>0">
|
AND a.coursePackageId IN
|
<foreach collection="coursePackageIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
|
</select>
|
<select id="pacQueryDto" resultType="map">
|
|
SELECT
|
coursePackageId,
|
SUM( cashPayment ) AS cashPayment,
|
SUM( totalClassHours ) AS totalClassHours,
|
SUM( totalClassHours - laveClassHours ) AS hasHours,
|
ROUND( SUM(( totalClassHours - laveClassHours ) * ( cashPayment / totalClassHours )), 2 ) AS lavePay,
|
cp.`name` ,
|
cp.province,
|
cp.city,
|
cp.storeId,cp.cityCode,cp.provinceCode,py.insertTime
|
FROM
|
t_course_package_payment py
|
LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
|
<where>
|
<if test="storeIds != null and storeIds.size()>0">
|
AND cp.id IN
|
<foreach collection="storeIds" separator="," item="id" open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
<if test="null != start and '' != start and null != end and '' != end">
|
py.insertTime between #{start} and #{end}
|
</if>
|
<if test="null != cityCode and '' != cityCode">
|
and cityCode =#{cityCode}
|
</if>
|
|
<if test="null != provinceCode and '' != provinceCode">
|
and provinceCode =#{provinceCode}
|
</if>
|
|
<if test="null != name and '' != name">
|
and name like CONCAT('%', #{name}, '%')
|
</if>
|
|
|
</where>
|
GROUP BY
|
coursePackageId
|
|
|
|
|
</select>
|
|
<select id="listOne" resultType="com.dsh.course.entity.TCoursePackagePayment">
|
select * from t_course_package_payment where appUserId in <foreach collection="ids" separator="," open="(" item="id" close=")">#{id}</foreach>
|
</select>
|
<select id="queryStore" resultType="java.lang.Integer">
|
SELECT
|
tc.storeId
|
FROM
|
t_payment_competition pc
|
LEFT JOIN t_competition tc on pc.competitionId = tc.id
|
WHERE pc.code=#{code}
|
</select>
|
|
<update id="updateBytime">
|
update t_course_package_payment
|
set laveClassHours = #{coursePackagePayment.laveClassHours},absencesNumber=#{coursePackagePayment.absencesNumber}
|
where id = #{coursePackagePayment.id}
|
</update>
|
</mapper>
|