<?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.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper">
|
<resultMap id="BaseResultMap"
|
type="com.yeshi.fanli.entity.order.InviteOrderSubsidy">
|
<id column="os_id" property="id" jdbcType="BIGINT" />
|
<result column="os_uid" property="uid" jdbcType="BIGINT" />
|
<result column="os_money" property="money" jdbcType="DECIMAL" />
|
<result column="os_order_no" property="orderNo" jdbcType="VARCHAR" />
|
<result column="os_source_type" property="sourceType" jdbcType="INTEGER" />
|
<result column="os_state" property="state" jdbcType="INTEGER" />
|
<result column="os_create_time" property="createTime" jdbcType="TIMESTAMP" />
|
<result column="os_update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
<result column="os_original_money" property="originalMoney"
|
jdbcType="DECIMAL" />
|
<result column="os_pre_get_time" property="preGetTime"
|
jdbcType="TIMESTAMP" />
|
<result column="os_get_time" property="getTime" jdbcType="TIMESTAMP" />
|
<result column="os_level" property="level" jdbcType="INTEGER" />
|
<result column="os_valid_time" property="validTime" jdbcType="TIMESTAMP" />
|
<result column="os_invalid_time" property="inValidTime"
|
jdbcType="TIMESTAMP" />
|
</resultMap>
|
<sql id="Base_Column_List">os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money,os_pre_get_time,os_get_time,os_level,os_valid_time,os_invalid_time
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT}
|
</select>
|
<select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_invite_order_subsidy where os_id = #{0} for update
|
</select>
|
<select id="listByOrderNoAndType" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND
|
os_source_type = #{type}
|
</select>
|
|
<select id="listByOrderNoAndTypeAndUid" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_invite_order_subsidy where os_order_no = #{orderNo} AND
|
os_source_type = #{type} and os_uid=#{uid}
|
</select>
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_invite_order_subsidy where os_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy"
|
useGeneratedKeys="true" keyProperty="id">insert into
|
yeshi_ec_invite_order_subsidy
|
(os_id,os_uid,os_money,os_order_no,os_source_type,os_state,os_create_time,os_update_time,os_original_money,os_pre_get_time,os_get_time,os_level,os_valid_time,os_invalid_time)
|
values
|
(#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{orderNo,jdbcType=VARCHAR},#{sourceType,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{originalMoney,jdbcType=DECIMAL},#{preGetTime,jdbcType=TIMESTAMP},#{getTime,jdbcType=TIMESTAMP},#{level,jdbcType=INTEGER},#{validTime,jdbcType=TIMESTAMP},#{inValidTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_invite_order_subsidy
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">os_id,</if>
|
<if test="uid != null">os_uid,</if>
|
<if test="money != null">os_money,</if>
|
<if test="orderNo != null">os_order_no,</if>
|
<if test="sourceType != null">os_source_type,</if>
|
<if test="state != null">os_state,</if>
|
<if test="createTime != null">os_create_time,</if>
|
<if test="updateTime != null">os_update_time,</if>
|
<if test="originalMoney != null">os_original_money,</if>
|
<if test="preGetTime != null">os_pre_get_time,</if>
|
<if test="getTime != null">os_get_time,</if>
|
<if test="level != null">os_level,</if>
|
<if test="validTime != null">os_valid_time,</if>
|
<if test="inValidTime != null">os_invalid_time,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="uid != null">#{uid,jdbcType=BIGINT},</if>
|
<if test="money != null">#{money,jdbcType=DECIMAL},</if>
|
<if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
|
<if test="sourceType != null">#{sourceType,jdbcType=INTEGER},</if>
|
<if test="state != null">#{state,jdbcType=INTEGER},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
|
<if test="originalMoney != null">#{originalMoney,jdbcType=DECIMAL},</if>
|
<if test="preGetTime != null">#{preGetTime,jdbcType=TIMESTAMP},</if>
|
<if test="getTime != null">#{getTime,jdbcType=TIMESTAMP},</if>
|
<if test="level != null">#{level,jdbcType=INTEGER}</if>
|
<if test="validTime != null">#{validTime,jdbcType=TIMESTAMP}</if>
|
<if test="inValidTime != null">#{inValidTime,jdbcType=TIMESTAMP}</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">update
|
yeshi_ec_invite_order_subsidy set os_uid =
|
#{uid,jdbcType=BIGINT},os_money =
|
#{money,jdbcType=DECIMAL},os_order_no =
|
#{orderNo,jdbcType=VARCHAR},os_source_type =
|
#{sourceType,jdbcType=INTEGER},os_state =
|
#{state,jdbcType=INTEGER},os_create_time =
|
#{createTime,jdbcType=TIMESTAMP},os_update_time =
|
#{updateTime,jdbcType=TIMESTAMP} ,os_original_money
|
=#{originalMoney,jdbcType=DECIMAL} ,os_pre_get_time
|
=#{preGetTime,jdbcType=TIMESTAMP} ,os_get_time
|
=#{getTime,jdbcType=TIMESTAMP} ,os_level =#{level,jdbcType=INTEGER}
|
,os_valid_time =#{validTime,jdbcType=TIMESTAMP} ,os_invalid_time
|
=#{inValidTime,jdbcType=TIMESTAMP} where os_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.order.InviteOrderSubsidy">
|
update yeshi_ec_invite_order_subsidy
|
<set>
|
<if test="uid != null">os_uid=#{uid,jdbcType=BIGINT},</if>
|
<if test="money != null">os_money=#{money,jdbcType=DECIMAL},</if>
|
<if test="orderNo != null">os_order_no=#{orderNo,jdbcType=VARCHAR},</if>
|
<if test="sourceType != null">os_source_type=#{sourceType,jdbcType=INTEGER},</if>
|
<if test="state != null">os_state=#{state,jdbcType=INTEGER},</if>
|
<if test="createTime != null">os_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="updateTime != null">os_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
|
<if test="originalMoney !=null">os_original_money =#{originalMoney,jdbcType=DECIMAL},
|
</if>
|
<if test="preGetTime !=null">os_pre_get_time =#{preGetTime,jdbcType=TIMESTAMP},</if>
|
<if test="getTime !=null">os_get_time =#{getTime,jdbcType=TIMESTAMP},</if>
|
<if test="level !=null">os_level =#{level,jdbcType=INTEGER},</if>
|
<if test="validTime !=null">os_valid_time =#{validTime,jdbcType=TIMESTAMP},</if>
|
<if test="inValidTime !=null">os_invalid_time =#{inValidTime,jdbcType=TIMESTAMP},</if>
|
</set>
|
where os_id = #{id,jdbcType=BIGINT}
|
</update>
|
<select id="getByOrderNoAndType" resultMap="BaseResultMap">SELECT * FROM
|
yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND os_order_no =
|
#{orderNo} AND os_source_type = #{type} LIMIT 1
|
</select>
|
<select id="getByOrderNoAndTypeForUpdate" resultMap="BaseResultMap">SELECT *
|
FROM yeshi_ec_invite_order_subsidy WHERE os_uid = #{uid} AND
|
os_order_no = #{orderNo} AND os_source_type = #{type} for update
|
</select>
|
<select id="countByOrderNoAndType" resultType="java.lang.Long">SELECT count(*)
|
FROM yeshi_ec_invite_order_subsidy WHERE os_order_no = #{orderNo} AND
|
os_source_type = #{type}
|
</select>
|
|
|
<select id="sumValidMoneyByUidAndDate" resultType="BigDecimal">
|
SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
|
WHERE
|
d.`os_uid` = #{uid} AND (d.`os_state` = 1 OR d.`os_state` = 3)
|
<if test="level != null">
|
AND d.os_level = #{level}
|
</if>
|
<if test="day == 1"> <!-- 今天 -->
|
AND TO_DAYS(d.`os_valid_time`) = TO_DAYS(NOW())
|
</if>
|
<if test="day == 2"> <!-- 昨天 -->
|
AND TO_DAYS(NOW()) - TO_DAYS(d.`os_valid_time`) = 1
|
</if>
|
<if test="day == 3"> <!-- 本月 -->
|
AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') =
|
DATE_FORMAT(CURDATE(),'%Y%m')
|
</if>
|
<if test="day == 4"> <!-- 上月 -->
|
AND
|
PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`,
|
'%Y%m')) = 1
|
</if>
|
</select>
|
|
|
<select id="sumMoneyByUidAndDateAndState" resultType="BigDecimal">
|
SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
|
WHERE
|
d.`os_uid` = #{uid} AND d.`os_state` = #{state}
|
<if test="level != null">
|
AND d.os_level = #{level}
|
</if>
|
<if test="day == 1"> <!-- 今天 -->
|
AND TO_DAYS(d.`os_valid_time`) = TO_DAYS(NOW())
|
</if>
|
<if test="day == 2"> <!-- 昨天 -->
|
AND TO_DAYS(NOW()) - TO_DAYS(d.`os_valid_time`) = 1
|
</if>
|
<if test="day == 3"> <!-- 本月 -->
|
AND DATE_FORMAT(d.`os_valid_time`,'%Y%m') =
|
DATE_FORMAT(CURDATE(),'%Y%m')
|
</if>
|
<if test="day == 4"> <!-- 上月 -->
|
AND
|
PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%m'),DATE_FORMAT(d.`os_valid_time`,
|
'%Y%m')) = 1
|
</if>
|
</select>
|
|
|
<select id="sumRecievedMoneyByUid" resultType="BigDecimal">
|
SELECT SUM(d.`os_money`) FROM yeshi_ec_invite_order_subsidy d
|
WHERE
|
d.`os_uid` = #{uid} AND d.`os_state` = 3
|
<if test="level != null">
|
AND d.os_level = #{level}
|
</if>
|
</select>
|
|
</mapper>
|