<?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.panzhihua.service_community.dao.ComActUserWalletTradeMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActUserWalletTradeDO">
|
<id column="id" property="id" />
|
<result column="user_id" property="userId" />
|
<result column="community_id" property="communityId" />
|
<result column="service_id" property="serviceId" />
|
<result column="amount" property="amount" />
|
<result column="type" property="type" />
|
<result column="remark" property="remark" />
|
<result column="create_at" property="createAt" />
|
<result column="create_by" property="createBy" />
|
<result column="wallet_id" property="walletId" />
|
<result column="change_type" property="changeType" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, user_id, community_id, service_id, amount, type, remark, create_at, create_by, wallet_id, change_type
|
</sql>
|
|
<select id="getUserWalletTradeList" resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeVO"
|
parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeDTO">
|
SELECT
|
cauwt.id,
|
ca.`name` AS communityName,
|
cauwt.type,
|
cauwt.remark,
|
cauwt.change_type,
|
cauwt.amount,
|
cauwt.create_at
|
FROM
|
com_act_user_wallet_trade AS cauwt
|
LEFT JOIN com_act AS ca ON ca.community_id = cauwt.community_id
|
where cauwt.community_id = ${walletTradeDTO.communityId}
|
and cauwt.user_id = #{walletTradeDTO.userId}
|
|
order by cauwt.create_at desc
|
</select>
|
|
<select id="getUserWalletTradeAdmin" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO"
|
resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeAdminVO">
|
SELECT
|
cauwt.id,
|
su.user_id,
|
cauwt.amount,
|
cauwt.service_id,
|
cauwt.remark,
|
cauwt.type,
|
su.`name` AS userName,
|
su.nick_name,
|
cauwt.change_type,
|
su.phone,
|
cauwt.create_at,
|
su1.`name` AS operationUserName
|
FROM
|
com_act_user_wallet_trade AS cauwt
|
LEFT JOIN sys_user AS su ON su.user_id = cauwt.user_id
|
LEFT JOIN sys_user AS su1 ON su1.user_id = cauwt.create_by
|
<where>
|
<if test="walletTradeDTO.communityId != null">
|
and cauwt.community_id = ${walletTradeDTO.communityId}
|
</if>
|
<if test="walletTradeDTO.userId != null">
|
and cauwt.user_id = #{walletTradeDTO.userId}
|
</if>
|
<if test="walletTradeDTO.type != null">
|
and cauwt.type = #{walletTradeDTO.type}
|
</if>
|
<if test="walletTradeDTO.changeType != null">
|
and cauwt.change_type = #{walletTradeDTO.changeType}
|
</if>
|
<if test="walletTradeDTO.name != null and walletTradeDTO.name != """>
|
AND (su.nick_name like concat (#{walletTradeDTO.name},'%') or su.name like concat (#{walletTradeDTO.name},'%'))
|
</if>
|
<if test="walletTradeDTO.phone != null and walletTradeDTO.phone != """>
|
AND su.phone like concat (#{walletTradeDTO.phone},'%')
|
</if>
|
<if test="walletTradeDTO.startTime != null and walletTradeDTO.startTime != """>
|
AND cauwt.create_at <![CDATA[>=]]> #{walletTradeDTO.startTime}
|
</if>
|
<if test="walletTradeDTO.endTime != null and walletTradeDTO.endTime != """>
|
AND cauwt.create_at <![CDATA[<=]]> #{walletTradeDTO.endTime}
|
</if>
|
<if test="walletTradeDTO.keyWord != null and walletTradeDTO.keyWord != """>
|
AND (su.phone like concat (#{walletTradeDTO.keyWord},'%') or su.name like concat (#{walletTradeDTO.keyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.expenditureKeyWord != null and walletTradeDTO.expenditureKeyWord != """>
|
AND (cauwt.remark like concat (#{walletTradeDTO.expenditureKeyWord},'%') or su1.name like concat (#{walletTradeDTO.expenditureKeyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.remark != null and walletTradeDTO.remark != """>
|
AND cauwt.remark like concat (#{walletTradeDTO.remark},'%')
|
</if>
|
</where>
|
<if test="walletTradeDTO.sort == null">
|
order by cauwt.create_at desc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 1">
|
order by cauwt.amount asc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 2">
|
order by cauwt.amount desc
|
</if>
|
|
</select>
|
|
<select id="getTradeUserTotalWalletTradeAdmin" resultType="java.math.BigDecimal"
|
parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO">
|
SELECT
|
sum(cauwt.amount)
|
FROM
|
com_act_user_wallet_trade AS cauwt
|
LEFT JOIN sys_user AS su ON su.user_id = cauwt.user_id
|
LEFT JOIN sys_user AS su1 ON su1.user_id = cauwt.create_by
|
<where>
|
<if test="walletTradeDTO.communityId != null">
|
and cauwt.community_id = ${walletTradeDTO.communityId}
|
</if>
|
<if test="walletTradeDTO.userId != null">
|
and cauwt.user_id = #{walletTradeDTO.userId}
|
</if>
|
<if test="walletTradeDTO.type != null">
|
and cauwt.type = #{walletTradeDTO.type}
|
</if>
|
<if test="walletTradeDTO.changeType != null">
|
and cauwt.change_type = #{walletTradeDTO.changeType}
|
</if>
|
<if test="walletTradeDTO.keyWord != null and walletTradeDTO.keyWord != """>
|
AND (su.phone like concat (#{walletTradeDTO.keyWord},'%') or su.name like concat (#{walletTradeDTO.keyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.expenditureKeyWord != null and walletTradeDTO.expenditureKeyWord != """>
|
AND (cauwt.remark like concat (#{walletTradeDTO.expenditureKeyWord},'%') or su1.name like concat (#{walletTradeDTO.expenditureKeyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.phone != null and walletTradeDTO.phone != """>
|
AND su.phone like concat (#{walletTradeDTO.phone},'%')
|
</if>
|
<if test="walletTradeDTO.remark != null and walletTradeDTO.remark != """>
|
AND cauwt.remark like concat (#{walletTradeDTO.remark},'%')
|
</if>
|
<if test="walletTradeDTO.startTime != null and walletTradeDTO.startTime != """>
|
AND cauwt.create_at <![CDATA[>=]]> #{walletTradeDTO.startTime}
|
</if>
|
<if test="walletTradeDTO.endTime != null and walletTradeDTO.endTime != """>
|
AND cauwt.create_at <![CDATA[<=]]> #{walletTradeDTO.endTime}
|
</if>
|
</where>
|
|
<if test="walletTradeDTO.sort == null">
|
order by cauwt.create_at desc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 1">
|
order by cauwt.amount asc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 2">
|
order by cauwt.amount desc
|
</if>
|
</select>
|
|
<select id="getTradeUserTotalWalletTradeExportAdmin" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO"
|
resultType="com.panzhihua.common.model.vos.community.ComActUserWalletTradeExcelVO">
|
SELECT
|
cauwt.amount,su1.`name` as userName,su1.phone,cauwt.create_at,su.`name` as createBy
|
FROM
|
com_act_user_wallet_trade AS cauwt
|
LEFT JOIN sys_user AS su ON su.user_id = cauwt.create_by
|
LEFT JOIN sys_user AS su1 ON su1.user_id = cauwt.user_id
|
<where>
|
<if test="walletTradeDTO.communityId != null">
|
and cauwt.community_id = ${walletTradeDTO.communityId}
|
</if>
|
<if test="walletTradeDTO.userId != null">
|
and cauwt.user_id = #{walletTradeDTO.userId}
|
</if>
|
<if test="walletTradeDTO.type != null">
|
and cauwt.type = #{walletTradeDTO.type}
|
</if>
|
<if test="walletTradeDTO.changeType != null">
|
and cauwt.change_type = #{walletTradeDTO.changeType}
|
</if>
|
<if test="walletTradeDTO.keyWord != null and walletTradeDTO.keyWord != """>
|
AND (su.phone like concat (#{walletTradeDTO.keyWord},'%') or su.name like concat (#{walletTradeDTO.keyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.startTime != null and walletTradeDTO.startTime != """>
|
AND cauwt.create_at <![CDATA[>=]]> #{walletTradeDTO.startTime}
|
</if>
|
<if test="walletTradeDTO.endTime != null and walletTradeDTO.endTime != """>
|
AND cauwt.create_at <![CDATA[<=]]> #{walletTradeDTO.endTime}
|
</if>
|
<if test="walletTradeDTO.tradeIds != null and walletTradeDTO.tradeIds.size > 0">
|
AND cauwt.id in
|
<foreach collection='walletTradeDTO.tradeIds' item='id' index='index' open='(' close=')' separator=',' >
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
|
<if test="walletTradeDTO.sort == null">
|
order by cauwt.create_at desc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 1">
|
order by cauwt.amount asc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 2">
|
order by cauwt.amount desc
|
</if>
|
|
</select>
|
|
<select id="getTradeUserTotalJLWalletTradeExportAdmin" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO"
|
resultType="com.panzhihua.common.model.vos.community.ComActUserWalletTradeRewardExcelVO">
|
SELECT
|
cauwt.amount,su1.`name` as userName,su1.phone,cauwt.create_at,su.`name` as createBy,cauwt.type,cauwt.remark
|
FROM
|
com_act_user_wallet_trade AS cauwt
|
LEFT JOIN sys_user AS su ON su.user_id = cauwt.create_by
|
LEFT JOIN sys_user AS su1 ON su1.user_id = cauwt.user_id
|
<where>
|
<if test="walletTradeDTO.communityId != null">
|
and cauwt.community_id = ${walletTradeDTO.communityId}
|
</if>
|
<if test="walletTradeDTO.userId != null">
|
and cauwt.user_id = #{walletTradeDTO.userId}
|
</if>
|
<if test="walletTradeDTO.type != null">
|
and cauwt.type = #{walletTradeDTO.type}
|
</if>
|
<if test="walletTradeDTO.changeType != null">
|
and cauwt.change_type = #{walletTradeDTO.changeType}
|
</if>
|
<if test="walletTradeDTO.keyWord != null and walletTradeDTO.keyWord != """>
|
AND (su.phone like concat (#{walletTradeDTO.keyWord},'%') or su.name like concat (#{walletTradeDTO.keyWord},'%'))
|
</if>
|
<if test="walletTradeDTO.startTime != null and walletTradeDTO.startTime != """>
|
AND cauwt.create_at <![CDATA[>=]]> #{walletTradeDTO.startTime}
|
</if>
|
<if test="walletTradeDTO.endTime != null and walletTradeDTO.endTime != """>
|
AND cauwt.create_at <![CDATA[<=]]> #{walletTradeDTO.endTime}
|
</if>
|
<if test="walletTradeDTO.tradeIds != null and walletTradeDTO.tradeIds.size > 0">
|
AND cauwt.id in
|
<foreach collection='walletTradeDTO.tradeIds' item='id' index='index' open='(' close=')' separator=',' >
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
|
<if test="walletTradeDTO.sort == null">
|
order by cauwt.create_at desc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 1">
|
order by cauwt.amount asc
|
</if>
|
<if test="walletTradeDTO.sort != null and walletTradeDTO.sort == 2">
|
order by cauwt.amount desc
|
</if>
|
|
</select>
|
|
<select id="getTradeUserStatisticsAdmin" parameterType="com.panzhihua.common.model.dtos.community.wallet.PageComActWalletTradeAdminDTO"
|
resultType="com.panzhihua.common.model.vos.community.wallet.ComActWalletTradeStatisticsAdminVO">
|
SELECT
|
sum( amount ) as dayTotal,
|
(select sum(amount) from com_act_user_wallet_trade where community_id = ${walletTradeDTO.communityId} and change_type = #{walletTradeDTO.changeType} and create_at between timestamp(DATE_ADD(curdate(),interval -day(curdate())+1 day)) and now()) as monthTotal,
|
(select sum(amount) from com_act_user_wallet_trade where community_id = ${walletTradeDTO.communityId} and change_type = #{walletTradeDTO.changeType}) as total
|
FROM
|
com_act_user_wallet_trade
|
where community_id = ${walletTradeDTO.communityId} and change_type = #{walletTradeDTO.changeType}
|
and create_at between timestamp(date_add(curdate(), interval - 0 day)) and now()
|
</select>
|
</mapper>
|