<?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.nq.dao.UserRechargeMapper" >
|
<resultMap id="BaseResultMap" type="com.nq.pojo.UserRecharge" >
|
<id column="id" property="id" />
|
<result column="user_id" property="userId"/>
|
<result column="nick_name" property="nickName"/>
|
<result column="agent_id" property="agentId"/>
|
<result column="order_sn" property="orderSn"/>
|
<result column="pay_sn" property="paySn"/>
|
<result column="pay_channel" property="payChannel"/>
|
<result column="pay_amt" property="payAmt"/>
|
<result column="order_status" property="orderStatus"/>
|
<result column="order_desc" property="orderDesc"/>
|
<result column="add_time" property="addTime"/>
|
<result column="pay_time" property="payTime"/>
|
<result column="pay_id" property="payId"/>
|
<result column="img" property="img"/>
|
<result column="assets_type" property="assetsType"/>
|
</resultMap>
|
<sql id="Base_Column_List" >
|
id, user_id, nick_name, agent_id, order_sn, pay_sn, pay_channel, pay_amt, order_status,
|
order_desc, add_time, pay_time, pay_id,img
|
</sql>
|
<insert id="insert" parameterType="com.nq.pojo.UserRecharge" >
|
insert into user_recharge (id, user_id, nick_name,
|
agent_id, order_sn, pay_sn,
|
pay_channel, pay_amt, order_status,
|
order_desc, add_time, pay_time,pay_id,img
|
)
|
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{nickName,jdbcType=VARCHAR},
|
#{agentId,jdbcType=INTEGER}, #{orderSn,jdbcType=VARCHAR}, #{paySn,jdbcType=VARCHAR},
|
#{payChannel,jdbcType=VARCHAR}, #{payAmt,jdbcType=DECIMAL}, #{orderStatus,jdbcType=INTEGER},
|
#{orderDesc,jdbcType=VARCHAR}, #{addTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, #{payId,jdbcType=INTEGER}, #{img,jdbcType=VARCHAR}
|
)
|
</insert>
|
<insert id="insertSelective" parameterType="com.nq.pojo.UserRecharge" >
|
insert into user_recharge
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null" >
|
id,
|
</if>
|
<if test="userId != null" >
|
user_id,
|
</if>
|
<if test="nickName != null" >
|
nick_name,
|
</if>
|
<if test="agentId != null" >
|
agent_id,
|
</if>
|
<if test="orderSn != null" >
|
order_sn,
|
</if>
|
<if test="paySn != null" >
|
pay_sn,
|
</if>
|
<if test="payChannel != null" >
|
pay_channel,
|
</if>
|
<if test="payAmt != null" >
|
pay_amt,
|
</if>
|
<if test="orderStatus != null" >
|
order_status,
|
</if>
|
<if test="orderDesc != null" >
|
order_desc,
|
</if>
|
<if test="addTime != null" >
|
add_time,
|
</if>
|
<if test="payTime != null" >
|
pay_time,
|
</if>
|
<if test="payId != null" >
|
pay_id,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null" >
|
#{id,jdbcType=INTEGER},
|
</if>
|
<if test="userId != null" >
|
#{userId,jdbcType=INTEGER},
|
</if>
|
<if test="nickName != null" >
|
#{nickName,jdbcType=VARCHAR},
|
</if>
|
<if test="agentId != null" >
|
#{agentId,jdbcType=INTEGER},
|
</if>
|
<if test="orderSn != null" >
|
#{orderSn,jdbcType=VARCHAR},
|
</if>
|
<if test="paySn != null" >
|
#{paySn,jdbcType=VARCHAR},
|
</if>
|
<if test="payChannel != null" >
|
#{payChannel,jdbcType=VARCHAR},
|
</if>
|
<if test="payAmt != null" >
|
#{payAmt,jdbcType=DECIMAL},
|
</if>
|
<if test="orderStatus != null" >
|
#{orderStatus,jdbcType=INTEGER},
|
</if>
|
<if test="orderDesc != null" >
|
#{orderDesc,jdbcType=VARCHAR},
|
</if>
|
<if test="addTime != null" >
|
#{addTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="payTime != null" >
|
#{payTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="payId != null" >
|
#{payId,jdbcType=INTEGER},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.nq.pojo.UserRecharge" >
|
update user_recharge
|
<set >
|
<if test="userId != null" >
|
user_id = #{userId,jdbcType=INTEGER},
|
</if>
|
<if test="nickName != null" >
|
nick_name = #{nickName,jdbcType=VARCHAR},
|
</if>
|
<if test="agentId != null" >
|
agent_id = #{agentId,jdbcType=INTEGER},
|
</if>
|
<if test="orderSn != null" >
|
order_sn = #{orderSn,jdbcType=VARCHAR},
|
</if>
|
<if test="paySn != null" >
|
pay_sn = #{paySn,jdbcType=VARCHAR},
|
</if>
|
<if test="payChannel != null" >
|
pay_channel = #{payChannel,jdbcType=VARCHAR},
|
</if>
|
<if test="payAmt != null" >
|
pay_amt = #{payAmt,jdbcType=DECIMAL},
|
</if>
|
<if test="orderStatus != null" >
|
order_status = #{orderStatus,jdbcType=INTEGER},
|
</if>
|
<if test="orderDesc != null" >
|
order_desc = #{orderDesc,jdbcType=VARCHAR},
|
</if>
|
<if test="addTime != null" >
|
add_time = #{addTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="payTime != null" >
|
pay_time = #{payTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="com.nq.pojo.UserRecharge" >
|
update user_recharge
|
set user_id = #{userId,jdbcType=INTEGER},
|
nick_name = #{nickName,jdbcType=VARCHAR},
|
agent_id = #{agentId,jdbcType=INTEGER},
|
order_sn = #{orderSn,jdbcType=VARCHAR},
|
pay_sn = #{paySn,jdbcType=VARCHAR},
|
pay_channel = #{payChannel,jdbcType=VARCHAR},
|
pay_amt = #{payAmt,jdbcType=DECIMAL},
|
order_status = #{orderStatus,jdbcType=INTEGER},
|
order_desc = #{orderDesc,jdbcType=VARCHAR},
|
add_time = #{addTime,jdbcType=TIMESTAMP},
|
pay_time = #{payTime,jdbcType=TIMESTAMP}
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
|
|
|
|
|
<select id="checkInMoney" resultType="integer" parameterType="map">
|
SELECT COUNT(*) FROM user_recharge
|
WHERE user_id = #{userId}
|
and order_status = #{status}
|
and add_time > date_sub(now(), interval 1 hour)
|
</select>
|
|
|
<select id="findUserRechargeByOrderSn" parameterType="string" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM user_recharge
|
WHERE order_sn = #{orderSn}
|
</select>
|
|
|
<select id="findUserChargeList" resultMap="BaseResultMap" parameterType="map">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM user_recharge
|
<where>
|
user_id = #{uid}
|
<if test="payChannel != null and payChannel != '' ">
|
and pay_channel = #{payChannel}
|
</if>
|
<if test="orderStatus != null and orderStatus != '' ">
|
and order_status = #{orderStatus}
|
</if>
|
</where>
|
ORDER BY id DESC
|
</select>
|
|
|
|
<select id="listByAdmin" parameterType="map" resultType="com.nq.pojo.UserRecharge">
|
SELECT
|
s.id, s.user_id, s.nick_name, s.agent_id, s.order_sn, s.pay_sn, s.pay_channel,
|
s.pay_amt, s.order_status,s.order_desc,s.add_time,s.pay_time,s.pay_id,s.img
|
FROM user_recharge s
|
where 1=1
|
<if test="agentId != null and agentId != ''">
|
and ( agent_id = #{agentId}
|
or agent_id in (
|
select agent_user.id
|
FROM agent_user
|
where parent_id = ${agentId}
|
)
|
)
|
</if>
|
<if test="userId != null and agentId != ''">
|
and user_id = #{userId}
|
</if>
|
<if test="realName != null and realName != '' ">
|
and nick_name like CONCAT('%','${realName}','%')
|
</if>
|
<if test="state != null and agentId != ''">
|
and order_status = #{state}
|
</if>
|
|
<if test="begin_time != null and agentId != ''">
|
and pay_time <![CDATA[>=]]> #{begin_time}
|
</if>
|
<if test="end_time != null and agentId != ''">
|
and pay_time <![CDATA[<=]]> #{end_time}
|
</if>
|
ORDER BY s.id DESC
|
</select>
|
|
|
<delete id="deleteByUserId" parameterType="integer" >
|
DELETE FROM user_recharge WHERE user_id = #{userId}
|
</delete>
|
|
|
<select id="listByAgent" parameterType="map" resultMap="BaseResultMap">
|
SELECT
|
<include refid="Base_Column_List"/>
|
FROM user_recharge
|
<where>
|
agent_id = #{searchId}
|
<if test="realName != null and realName != '' ">
|
and nick_name like CONCAT('%','${realName}','%')
|
</if>
|
<if test="payChannel != null and payChannel != '' ">
|
and pay_channel = #{payChannel}
|
</if>
|
<if test="state != null">
|
and order_status = #{state}
|
</if>
|
</where>
|
ORDER BY id DESC
|
</select>
|
|
<select id="queryDayFrist" resultMap="BaseResultMap">
|
SELECT <include refid="Base_Column_List"/>
|
FROM user_recharge WHERE TO_DAYS(add_time) = TO_DAYS(NOW()) AND order_status = 1 GROUP BY user_id
|
</select>
|
|
|
<select id="queryDayFrist" resultMap="BaseResultMap" parameterType="integer">
|
SELECT <include refid="Base_Column_List"/>
|
FROM user_recharge WHERE TO_DAYS(add_time) = TO_DAYS(NOW()) AND order_status = 1 GROUP BY user_id AND agent_id = #{id}
|
</select>
|
|
<!--累计充值金额-->
|
<select id="CountChargeSumAmt" resultType="decimal" parameterType="integer">
|
SELECT sum(pay_amt) FROM user_recharge WHERE order_status = #{chargeState}
|
</select>
|
|
<!--累计充值金额-->
|
<select id="agentCountChargeSumAmt" resultType="decimal" parameterType="map">
|
SELECT sum(pay_amt) FROM user_recharge WHERE order_status = #{chargeState} and agent_id = #{agentId}
|
</select>
|
|
<!--今日充值金额-->
|
<select id="CountTotalRechargeAmountByTime" parameterType="integer" resultType="decimal">
|
select sum(IFNULL(pay_amt,0)) pay_amt from user_recharge where order_status = #{chargeState} and TO_DAYS(pay_time) = TO_DAYS(NOW())
|
</select>
|
|
<!--今日充值金额-->
|
<select id="CountTotalRechargeAmountByTime" parameterType="map" resultType="decimal">
|
select sum(IFNULL(pay_amt,0)) pay_amt from user_recharge where order_status = #{chargeState} and TO_DAYS(pay_time) = TO_DAYS(NOW()) and agent_id = #{agentId}
|
</select>
|
|
</mapper>
|