| | |
| | | <mapper namespace="com.dsh.activity.mapper.PayHuiminMapper"> |
| | | |
| | | |
| | | <select id="selectSalesDetailPage" resultType="com.dsh.activity.model.response.SalesDetailVO"> |
| | | SELECT |
| | | tph.id, |
| | | thc.huiMinName, |
| | | thc.huiMinType, |
| | | thc.salesMoney, |
| | | thc.operatorId, |
| | | thc.storeId, |
| | | tph.appUserId, |
| | | tph.paymentTime, |
| | | thc.endTime, |
| | | tph.studentId, |
| | | tph.status, |
| | | CASE |
| | | WHEN tph.id IS NULL THEN NULL |
| | | ELSE COALESCE(COUNT(thr.id), 0) |
| | | END AS useTimes |
| | | FROM |
| | | t_pay_huimin tph |
| | | LEFT JOIN t_huimin_card thc ON tph.cardId = thc.id |
| | | LEFT JOIN t_huimin_record thr ON tph.appUserId= thr.appUserId AND tph.cardId= thr.huiminCardId |
| | | <where> |
| | | tph.id IS NOT NULL |
| | | <if test="query.huiMinName !=null and query.huiMinName != ''"> |
| | | AND thc.huiMinName LIKE CONCAT('%',#{query.huiMinName},'%') |
| | | </if> |
| | | <if test="query.huiMinType !=null and query.huiMinType != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.operatorId !=null and query.operatorId != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.appUserIds != null and query.appUserIds.size()>0"> |
| | | AND tph.appUserId IN |
| | | <foreach collection="query.appUserIds" item="appUserId" open="(" separator="," close=")"> |
| | | #{appUserId} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.paymentTimeStart != null and query.paymentTimeEnd!=null"> |
| | | AND tph.paymentTime BETWEEN #{query.paymentTimeStart} AND #{query.paymentTimeEnd} |
| | | </if> |
| | | <if test="query.endTimeStart != null and query.endTimeEnd!=null"> |
| | | AND tph.endTime BETWEEN #{query.endTimeStart} AND #{query.endTimeEnd} |
| | | </if> |
| | | <if test="query.status!=null and query.status !=''"> |
| | | <choose> |
| | | <when test="query.status == 1"> |
| | | AND tph.status = 2 |
| | | </when> |
| | | <when test="query.status == 2"> |
| | | AND tph.status = 3 |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | </where> |
| | | ORDER BY tph.insertTime DESC |
| | | </select> |
| | | <select id="getStaticsData" resultType="java.util.Map" |
| | | parameterType="com.dsh.activity.entity.HuiminPayQuery"> |
| | | SELECT |
| | | COALESCE(SUM( tph.salesMoney),0) AS totalAmount, |
| | | COALESCE(SUM(CASE WHEN refundStatus IN (2, 3) THEN tph.salesMoney ELSE 0 END),0) AS refundAmount |
| | | FROM t_pay_huimin tph |
| | | LEFT JOIN t_huimin_card thc ON tph.cardId = thc.id |
| | | <where> |
| | | tph.id IS NOT NULL |
| | | <if test="query.huiMinName !=null and query.huiMinName != ''"> |
| | | AND thc.huiMinName LIKE CONCAT('%',#{query.huiMinName},'%') |
| | | </if> |
| | | <if test="query.huiMinType !=null and query.huiMinType != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.operatorId !=null and query.operatorId != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.appUserIds != null and query.appUserIds.size()>0"> |
| | | AND tph.appUserId IN |
| | | <foreach collection="query.appUserIds" item="appUserId" open="(" separator="," close=")"> |
| | | #{appUserId} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.paymentTimeStart != null and query.paymentTimeEnd!=null"> |
| | | AND tph.paymentTime BETWEEN #{query.paymentTimeStart} AND #{query.paymentTimeEnd} |
| | | </if> |
| | | <if test="query.endTimeStart != null and query.endTimeEnd!=null"> |
| | | AND tph.endTime BETWEEN #{query.endTimeStart} AND #{query.endTimeEnd} |
| | | </if> |
| | | <if test="query.status!=null and query.status !=''"> |
| | | <choose> |
| | | <when test="query.status == 1"> |
| | | AND tph.status = 2 |
| | | </when> |
| | | <when test="query.status == 2"> |
| | | AND tph.status = 3 |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="exportData" resultType="com.dsh.activity.model.response.SalesDetailVO" |
| | | parameterType="com.dsh.activity.entity.HuiminPayQuery"> |
| | | SELECT |
| | | tph.id, |
| | | thc.huiMinName, |
| | | thc.huiMinType, |
| | | thc.salesMoney, |
| | | thc.operatorId, |
| | | thc.storeId, |
| | | tph.appUserId, |
| | | tph.paymentTime, |
| | | thc.endTime, |
| | | tph.studentId, |
| | | tph.status, |
| | | CASE |
| | | WHEN tph.id IS NULL THEN NULL |
| | | ELSE COALESCE(COUNT(thr.id), 0) |
| | | END AS useTimes |
| | | FROM |
| | | t_pay_huimin tph |
| | | LEFT JOIN t_huimin_card thc ON tph.cardId = thc.id |
| | | LEFT JOIN t_huimin_record thr ON tph.appUserId= thr.appUserId AND tph.cardId= thr.huiminCardId |
| | | <where> |
| | | tph.id IS NOT NULL |
| | | <if test="query.huiMinName !=null and query.huiMinName != ''"> |
| | | AND thc.huiMinName LIKE CONCAT('%',#{query.huiMinName},'%') |
| | | </if> |
| | | <if test="query.huiMinType !=null and query.huiMinType != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.operatorId !=null and query.operatorId != ''"> |
| | | AND thc.huiMinType = #{query.huiMinType} |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.useId !=null and query.useId != ''"> |
| | | AND FIND_IN_SET(#{query.useId},thc.useIds) |
| | | </if> |
| | | <if test="query.appUserIds != null and query.appUserIds.size()>0"> |
| | | AND tph.appUserId IN |
| | | <foreach collection="query.appUserIds" item="appUserId" open="(" separator="," close=")"> |
| | | #{appUserId} |
| | | </foreach> |
| | | </if> |
| | | <if test="query.paymentTimeStart != null and query.paymentTimeEnd!=null"> |
| | | AND tph.paymentTime BETWEEN #{query.paymentTimeStart} AND #{query.paymentTimeEnd} |
| | | </if> |
| | | <if test="query.endTimeStart != null and query.endTimeEnd!=null"> |
| | | AND tph.endTime BETWEEN #{query.endTimeStart} AND #{query.endTimeEnd} |
| | | </if> |
| | | <if test="query.status!=null and query.status !=''"> |
| | | <choose> |
| | | <when test="query.status == 1"> |
| | | AND tph.status = 2 |
| | | </when> |
| | | <when test="query.status == 2"> |
| | | AND tph.status = 3 |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | </where> |
| | | ORDER BY tph.insertTime DESC |
| | | </select> |
| | | </mapper> |