You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
291 lines
9.8 KiB
291 lines
9.8 KiB
<?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.example.demo.mapper.DetailYMapper" >
|
|
<select id="select" resultType="com.example.demo.domain.entity.DetailY">
|
|
SELECT
|
|
username,
|
|
name,
|
|
detail_y.jwcode,
|
|
area,
|
|
detail_y.update_type,
|
|
detail_y.create_time,
|
|
detail_y.consume_platform,
|
|
detail_y.free_coin,
|
|
detail_y.recharge_coin,
|
|
detail_y.task_coin,
|
|
detail_y.product_name,
|
|
(detail_y.recharge_coin + detail_y.free_coin + detail_y.task_coin) AS gold
|
|
FROM
|
|
detail_y
|
|
<where>
|
|
|
|
<if test="num!=null and num.length > 0">
|
|
and recharge_coin NOT LIKE '-%'
|
|
AND free_coin NOT LIKE '-%'
|
|
AND task_coin NOT LIKE '-%'
|
|
</if>
|
|
<!-- 动态条件 -->
|
|
<if test="jwcode != null and jwcode.length > 0">
|
|
AND detail_y.jwcode = #{jwcode}
|
|
</if>
|
|
|
|
<if test="updateTypes != null">
|
|
AND update_type IN
|
|
<foreach collection="updateTypes" item="updateTypes" open="(" separator="," close=")">
|
|
#{updateTypes}
|
|
</foreach>
|
|
</if>
|
|
<if test="startDate != null and endDate != null">
|
|
AND detail_y.create_time BETWEEN #{startDate} AND #{endDate}
|
|
</if>
|
|
<if test="consumePlatform != null and consumePlatform.length > 0">
|
|
AND consume_platform = #{consumePlatform}
|
|
</if>
|
|
<if test="area != null and area.length > 0">
|
|
AND area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<!-- 优先使用前端传入的排序参数 -->
|
|
<when test="sortField != null and sortField.length >0 or sortOrder != null and sortOrder.length >0">
|
|
ORDER BY ${sortField} ${sortOrder}
|
|
</when>
|
|
<!-- 默认排序 -->
|
|
<otherwise>
|
|
ORDER BY detaily_id DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="select1" resultType="com.example.demo.domain.entity.DetailY">
|
|
SELECT
|
|
username,
|
|
name,
|
|
detail_y.jwcode,
|
|
area,
|
|
detail_y.update_type,
|
|
detail_y.create_time,
|
|
detail_y.consume_platform,
|
|
detail_y.free_coin,
|
|
detail_y.recharge_coin,
|
|
detail_y.task_coin,
|
|
detail_y.product_name,
|
|
(detail_y.recharge_coin + detail_y.free_coin + detail_y.task_coin) AS gold
|
|
FROM
|
|
detail_y
|
|
<where>
|
|
<if test="num!=null and num.length > 0">
|
|
AND (recharge_coin LIKE '-%'
|
|
OR free_coin LIKE '-%'
|
|
OR task_coin LIKE '-%')
|
|
</if>
|
|
<!-- 动态条件 -->
|
|
<if test="jwcode != null and jwcode.length > 0">
|
|
AND detail_y.jwcode = #{jwcode}
|
|
</if>
|
|
|
|
<if test="updateTypes != null">
|
|
AND update_type IN
|
|
<foreach collection="updateTypes" item="updateTypes" open="(" separator="," close=")">
|
|
#{updateTypes}
|
|
</foreach>
|
|
</if>
|
|
<if test="startDate != null and endDate != null">
|
|
AND detail_y.create_time BETWEEN #{startDate} AND #{endDate}
|
|
</if>
|
|
<if test="consumePlatform != null and consumePlatform.length > 0">
|
|
AND consume_platform = #{consumePlatform}
|
|
</if>
|
|
<if test="area != null and area.length > 0">
|
|
AND area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
<choose>
|
|
<!-- 优先使用前端传入的排序参数 -->
|
|
<when test="sortField != null and sortField.length >0 or sortOrder != null and sortOrder.length >0">
|
|
ORDER BY ${sortField} ${sortOrder}
|
|
</when>
|
|
<!-- 默认排序 -->
|
|
<otherwise>
|
|
ORDER BY detaily_id DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
|
|
<select id="getgold" resultType="com.example.demo.domain.vo.DetailYgold">
|
|
select
|
|
sum(recharge_coin) as SumbuyJb,
|
|
sum(task_coin) as SumcoreJb,
|
|
sum(free_coin) as SumfreeJb
|
|
from detail_y
|
|
group by jwcode
|
|
</select>
|
|
<select id="getDetailY" resultType="com.example.demo.domain.vo.SumDetailY">
|
|
SELECT
|
|
case when update_type = 0 then '充值'
|
|
when update_type = 1 then '消费'
|
|
when update_type = 2 then '退款'
|
|
when update_type = 3 THEN '其他'
|
|
else '未知'
|
|
end as types,
|
|
sum(recharge_coin) as SumR,
|
|
sum(task_coin) as SumT,
|
|
sum(free_coin) as SumF
|
|
FROM
|
|
detail_y
|
|
<where>
|
|
<if test="jwcode != null and jwcode.length > 0">
|
|
AND detail_y.jwcode = #{jwcode}
|
|
</if>
|
|
|
|
<if test="updateTypes != null">
|
|
AND update_type IN
|
|
<foreach collection="updateTypes" item="updateTypes" open="(" separator="," close=")">
|
|
#{updateTypes}
|
|
</foreach>
|
|
</if>
|
|
<if test="startDate != null and endDate != null">
|
|
AND detail_y.create_time BETWEEN #{startDate} AND #{endDate}
|
|
</if>
|
|
<if test="consumePlatform != null and consumePlatform.length > 0">
|
|
AND consume_platform = #{consumePlatform}
|
|
</if>
|
|
<if test="area != null and area.length > 0">
|
|
AND area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
types;
|
|
</select>
|
|
<select id="getarea" resultType="java.lang.String">
|
|
SELECT DISTINCT area FROM detail_y WHERE area IS NOT NULL
|
|
</select>
|
|
<select id="selectgold" resultType="com.example.demo.domain.vo.DetailYgold">
|
|
SELECT
|
|
`user`.name,
|
|
`user`.area,
|
|
user_gold.buy_jb,
|
|
user_gold.core_jb,
|
|
user_gold.free_12,
|
|
user_gold.free_6,
|
|
user_gold.jwcode,
|
|
SUM(CASE WHEN detail_y.update_type = 0 THEN detail_y.recharge_coin ELSE 0 END) AS Rcoin,
|
|
SUM(CASE WHEN detail_y.update_type = 1 THEN detail_y.recharge_coin + detail_y.free_coin + detail_y.task_coin ELSE 0 END) AS Scoin
|
|
FROM
|
|
detail_y
|
|
LEFT JOIN
|
|
user_gold ON detail_y.jwcode = user_gold.jwcode
|
|
LEFT JOIN
|
|
`user` ON detail_y.jwcode = `user`.jwcode
|
|
<where>
|
|
<if test='jwcode != null and jwcode.length > 0'>
|
|
AND detail_y.jwcode = #{jwcode}
|
|
</if>
|
|
<if test='area != null and area.length > 0'>
|
|
AND `user`.area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND `user`.area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
GROUP BY
|
|
user_gold.jwcode
|
|
<choose>
|
|
<when test="sortField != null and sortField.length >0 or sortOrder != null and sortOrder.length >0">
|
|
ORDER BY ${sortField} ${sortOrder}
|
|
</when>
|
|
<otherwise>
|
|
ORDER BY Rcoin DESC
|
|
</otherwise>
|
|
</choose>
|
|
</select>
|
|
|
|
<select id="getCount" resultType="com.example.demo.domain.entity.DetailY">
|
|
SELECT
|
|
SUM(`buy_jb`) AS sumR,
|
|
SUM(`core_jb`) AS sumT,
|
|
SUM(`free_6`)+SUM(`free_12`) AS sumF
|
|
FROM
|
|
`user_gold`
|
|
left join `user` on `user`.jwcode=`user_gold`.jwcode
|
|
<where>
|
|
<if test='jwcode != null and jwcode.length > 0'>
|
|
AND user_gold.jwcode = #{jwcode}
|
|
</if>
|
|
<if test='area != null and area.length > 0'>
|
|
AND area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="searchAll" resultType="com.example.demo.domain.entity.UserDetailExport">
|
|
SELECT
|
|
d.detaily_id,
|
|
u.name,
|
|
d.jwcode,
|
|
u.area,
|
|
d.consume_platform,
|
|
d.update_type,
|
|
d.recharge_coin,
|
|
d.task_coin,
|
|
d.free_coin,
|
|
d.create_admin,
|
|
d.create_time,
|
|
(d.recharge_coin+d.task_coin+d.free_coin) AS gold
|
|
FROM
|
|
detail_y d
|
|
LEFT JOIN
|
|
user u ON d.jwcode = u.jwcode
|
|
<where>
|
|
<if test="updateType != null">
|
|
AND d.update_type = #{updateType}
|
|
</if>
|
|
<if test="jwcode != null">
|
|
AND d.jwcode = #{jwcode}
|
|
</if>
|
|
<if test="area != null">
|
|
AND u.area = #{area}
|
|
</if>
|
|
<if test="areas != null">
|
|
AND u.area IN
|
|
<foreach collection="areas" item="areas" open="(" separator="," close=")">
|
|
#{areas}
|
|
</foreach>
|
|
</if>
|
|
<if test="startDate != null and endDate != null">
|
|
AND d.create_time BETWEEN #{startDate} AND #{endDate}
|
|
</if>
|
|
</where>
|
|
ORDER BY
|
|
d.detaily_id DESC
|
|
</select>
|
|
</mapper>
|