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.

98 lines
4.1 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.GoldDetailMapper">
<insert id="insertExportRecord" useGeneratedKeys="true" keyProperty="recordId.id">
insert into export (account,type,state,url,file_name,data_num)
values(#{account},#{type},#{state},#{url},#{fileName},#{dataNum})
</insert>
<select id="getGoldDetail" resultType="com.example.demo.domain.vo.GoldDetail">
select `user`.name, `user`.jwcode, `user`.market, `ugr`.pay_platform, `ugr`.type, `ugr`.sum_gold, `ugr`.permanent_gold, `ugr`.free_june, `ugr`.free_december, `ugr`.task_gold, `admin`.admin_name, `ugr`.audit_time
from user_gold_record ugr
left join `user` on `user`.jwcode = `ugr`.jwcode
left join `admin` on `admin`.id = `ugr`.admin_id
<where>
<if test="jwcode != null">
and `ugr`.jwcode = #{jwcode}
</if>
<if test="payPlatform != null and payPlatform.length > 0">
and `ugr`.pay_platform = #{payPlatform}
</if>
<if test="type != null">
and `ugr`.type = #{type}
</if>
<if test="market != null and market.length > 0">
and `user`.market = #{market}
</if>
<if test="startTime != null and endTime != null">
and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime}
</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 audit_time DESC
</otherwise>
</choose>
</select>
<select id="getTotal" resultType="com.example.demo.domain.vo.Total">
select sum(sum_gold) as Goldtotal, sum(permanent_gold) as permanentGold, sum(free_june+free_december) as freeGold, sum(task_gold) as taskGold
from user_gold_record
<where>
<if test="jwcode != null">
and `ugr`.jwcode = #{jwcode}
</if>
<if test="payPlatform != null and payPlatform.length > 0">
and `ugr`.pay_platform = #{payPlatform}
</if>
<if test="type != null">
and `ugr`.type = #{type}
</if>
<if test="market != null and market.length > 0">
and `user`.market = #{market}
</if>
<if test="startTime != null and endTime != null">
and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime}
</if>
</where>
</select>
<select id="getGold" resultType="com.example.demo.domain.entity.User">
select * from user
<where>
<if test="jwcode != null">
and jwcode = #{jwcode}
</if>
<if test="market != null and market.length > 0">
and market = #{market}
</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 create_time DESC
</otherwise>
</choose>
</select>
<select id="GoldTotal" resultType="com.example.demo.domain.vo.Total">
select
sum(current_permanent_gold) as permanentGold,
sum(current_free_june + current_free_december) as freeGold,
sum(current_task_gold) as taskGold,
sum(current_permanent_gold) + sum(current_free_june + current_free_december) + sum(current_task_gold) as Goldtotal
from `user`
<where>
<if test="jwcode != null ">
and jwcode = #{jwcode}
</if>
<if test="market != null and market.length > 0">
and market = #{market}
</if>
</where>
</select>
</mapper>