<?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.PidOrderMapper">
|
<resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.taobao.PidOrder">
|
<id column="po_id" property="id" jdbcType="BIGINT" />
|
<result column="po_order_createtime" property="orderCreateTime"
|
jdbcType="TIMESTAMP" />
|
<result column="po_goods_title" property="goodsTitle" jdbcType="VARCHAR" />
|
<result column="po_auction_id" property="auctionId" jdbcType="BIGINT" />
|
<result column="po_goods_num" property="goodsNum" jdbcType="INTEGER" />
|
<result column="po_price" property="price" jdbcType="DECIMAL" />
|
<result column="po_state" property="state" jdbcType="VARCHAR" />
|
<result column="po_order_type" property="orderType" jdbcType="VARCHAR" />
|
<result column="po_rate" property="rate" jdbcType="DECIMAL" />
|
<result column="po_pay_money" property="payMoney" jdbcType="DECIMAL" />
|
<result column="po_pre_money" property="preMoney" jdbcType="DECIMAL" />
|
<result column="po_final_money" property="finalMoney" jdbcType="DECIMAL" />
|
<result column="po_balance_time" property="balanceTime"
|
jdbcType="TIMESTAMP" />
|
<result column="po_order_id" property="orderId" jdbcType="VARCHAR" />
|
<result column="po_type_name" property="typeName" jdbcType="VARCHAR" />
|
<result column="po_src_media_id" property="srcMediaId"
|
jdbcType="VARCHAR" />
|
<result column="po_adzone_id" property="adzoneId" jdbcType="VARCHAR" />
|
<result column="po_createtime" property="createTime" jdbcType="TIMESTAMP" />
|
<result column="po_order_update_time" property="orderUpdateTime"
|
jdbcType="TIMESTAMP" />
|
<result column="po_local_update_time" property="localUpdateTime"
|
jdbcType="TIMESTAMP" />
|
<result column="po_account_balance" property="accountBalance"
|
jdbcType="BOOLEAN" />
|
<result column="po_account_balance_time" property="accountBalanceTime"
|
jdbcType="TIMESTAMP" />
|
<result column="po_beizhu" property="beizhu" jdbcType="VARCHAR" />
|
<association property="userInfo" column="po_uid"
|
javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
|
<id column="po_uid" property="id" jdbcType="BIGINT" />
|
</association>
|
<association property="hongBao" column="po_hongbao_id"
|
javaType="com.yeshi.fanli.entity.bus.user.HongBao">
|
<id column="po_hongbao_id" property="id" jdbcType="BIGINT" />
|
</association>
|
|
</resultMap>
|
<sql id="Base_Column_List">po_id,po_order_createtime,po_goods_title,po_auction_id,po_goods_num,po_price,po_state,po_order_type,po_rate,po_pay_money,po_pre_money,po_final_money,po_balance_time,po_order_id,po_type_name,po_src_media_id,po_adzone_id,po_createtime,po_uid
|
,po_order_update_time,po_local_update_time,po_account_balance,po_account_balance_time,po_beizhu,po_hongbao_id
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_id = #{id,jdbcType=BIGINT}
|
</select>
|
|
|
<select id="selectByUid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_uid = #{0}
|
</select>
|
|
<select id="getPidOrderListbyStateAndMaxTime" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order p WHERE p.`po_state`=#{state} AND
|
UNIX_TIMESTAMP(p.`po_createtime`)*1000
|
<![CDATA[
|
<
|
]]>
|
#{maxTime}
|
</select>
|
|
|
|
|
<select id="getPidOrderListByOrderId" resultMap="BaseResultMap"
|
parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_order_id = #{0} for update
|
</select>
|
<select id="getCanBalanceList" resultMap="BaseResultMap"
|
parameterType="java.lang.Integer">SELECT * FROM `yeshi_ec_pid_order` p WHERE
|
p.`po_state`='订单结算' AND p.`po_account_balance`=0 AND
|
(((FROM_UNIXTIME(UNIX_TIMESTAMP(),'%Y'))*12+FROM_UNIXTIME(UNIX_TIMESTAMP(),'%c')-((FROM_UNIXTIME(UNIX_TIMESTAMP(p.`po_balance_time`),'%Y'))*12+FROM_UNIXTIME(UNIX_TIMESTAMP(p.`po_balance_time`),'%c')))>1)
|
AND FROM_UNIXTIME(UNIX_TIMESTAMP(p.`po_balance_time`),'%e') >=25
|
limit #{0}
|
</select>
|
|
|
<select id="getUidCanBalanceList" resultType="java.lang.Long">
|
<![CDATA[
|
SELECT * FROM (SELECT DISTINCT(h.uid) FROM (SELECT h.* FROM yeshi_ec_hongbao h WHERE (h.`state`=1 OR h.`state`=2) AND (h.`type`=21 OR h.`type`=22) AND h.`order_id` IS NOT NULL AND ( h.`pre_get_time`>0 AND h.`pre_get_time`<UNIX_TIMESTAMP()*1000) ) h
|
LEFT JOIN yeshi_ec_pid_order p ON h.`order_id`=p.`po_order_id` WHERE h.`order_id` IS NOT NULL AND p.`po_state`='订单结算' AND p.`po_id` IS NOT NULL
|
) a UNION ALL (
|
SELECT DISTINCT(h.`uid`) FROM yeshi_ec_pid_order p LEFT JOIN
|
yeshi_ec_hongbao h ON p.`po_hongbao_id`=h.`id` WHERE p.po_state='订单结算'
|
|
AND (h.`state`=1 OR h.`state`=2) AND h.`pre_get_time` <
|
UNIX_TIMESTAMP()*1000
|
]]>
|
)
|
</select>
|
|
|
<select id="getCanBalanceListByUid" resultMap="BaseResultMap"
|
parameterType="java.lang.Long">
|
SELECT
|
<include refid="Base_Column_List" />
|
FROM yeshi_ec_pid_order p LEFT JOIN
|
yeshi_ec_hongbao h ON
|
p.`po_hongbao_id`=h.`id` WHERE p.po_state='订单结算' and h.uid=#{0}
|
<![CDATA[
|
AND (h.`state`=1 OR h.`state`=2) AND h.`pre_get_time` <
|
UNIX_TIMESTAMP()*1000;
|
]]>
|
</select>
|
|
|
|
|
|
<select id="getPidOrderListCanUpdate" resultMap="BaseResultMap"
|
parameterType="java.lang.Integer">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_local_update_time is null or <![CDATA[
|
po_local_update_time<po_order_update_time order by po_order_id
|
]]>
|
limit #{0}
|
</select>
|
<select id="getPidOrderListCanUpdateByOrderId" resultMap="BaseResultMap"
|
parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_order_id=#{0} and
|
(po_local_update_time is null or <![CDATA[
|
po_local_update_time<po_order_update_time
|
]]>
|
)
|
</select>
|
<select id="selectByState" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from yeshi_ec_pid_order where po_state=#{state} limit #{count}
|
</select>
|
|
|
<select id="getPidOrderNormalCount" resultType="java.lang.Long">
|
select
|
count(*)
|
from yeshi_ec_pid_order where po_state!='订单失效' and
|
po_order_createtime>=#{startTime,jdbcType=TIMESTAMP} and <![CDATA[ po_order_createtime<=]]>
|
#{endTime,jdbcType=TIMESTAMP}
|
</select>
|
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
|
yeshi_ec_pid_order where po_id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.PidOrder"
|
useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_pid_order
|
(po_id,po_order_createtime,po_goods_title,po_auction_id,po_goods_num,po_price,po_state,po_order_type,po_rate,po_pay_money,po_pre_money,po_final_money,po_balance_time,po_order_id,po_type_name,po_src_media_id,po_adzone_id,po_createtime,po_uid,po_order_update_time,po_local_update_time,po_account_balance,po_account_balance_time,po_beizhu,po_hongbao_id)
|
values
|
(#{id,jdbcType=BIGINT},#{orderCreateTime,jdbcType=TIMESTAMP},#{goodsTitle,jdbcType=VARCHAR},#{auctionId,jdbcType=BIGINT},#{goodsNum,jdbcType=INTEGER},#{price,jdbcType=DECIMAL},#{state,jdbcType=VARCHAR},#{orderType,jdbcType=VARCHAR},#{rate,jdbcType=DECIMAL},#{payMoney,jdbcType=DECIMAL},#{preMoney,jdbcType=DECIMAL},#{finalMoney,jdbcType=DECIMAL},#{balanceTime,jdbcType=TIMESTAMP},#{orderId,jdbcType=VARCHAR},#{typeName,jdbcType=VARCHAR},#{srcMediaId,jdbcType=VARCHAR},#{adzoneId,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{userInfo.id,jdbcType=BIGINT},#{orderUpdateTime,jdbcType=TIMESTAMP},#{localUpdateTime,jdbcType=TIMESTAMP},#{accountBalance,jdbcType=BOOLEAN},#{accountBalanceTime,jdbcType=TIMESTAMP},#{beizhu,jdbcType=VARCHAR},#{hongBao.id,jdbcType=BIGINT})
|
</insert>
|
<insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.PidOrder"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_pid_order
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">po_id,</if>
|
<if test="orderCreateTime != null">po_order_createtime,</if>
|
<if test="goodsTitle != null">po_goods_title,</if>
|
<if test="auctionId != null">po_auction_id,</if>
|
<if test="goodsNum != null">po_goods_num,</if>
|
<if test="price != null">po_price,</if>
|
<if test="state != null">po_state,</if>
|
<if test="orderType != null">po_order_type,</if>
|
<if test="rate != null">po_rate,</if>
|
<if test="payMoney != null">po_pay_money,</if>
|
<if test="preMoney != null">po_pre_money,</if>
|
<if test="finalMoney != null">po_final_money,</if>
|
<if test="balanceTime != null">po_balance_time,</if>
|
<if test="orderId != null">po_order_id,</if>
|
<if test="typeName != null">po_type_name,</if>
|
<if test="srcMediaId != null">po_src_media_id,</if>
|
<if test="adzoneId != null">po_adzone_id,</if>
|
<if test="createTime != null">po_createtime,</if>
|
<if test="userInfo != null">po_uid,</if>
|
<if test="orderUpdateTime != null">po_order_update_time,</if>
|
<if test="localUpdateTime != null">po_local_update_time,</if>
|
<if test="accountBalance != null">po_account_balance,</if>
|
<if test="accountBalanceTime != null">po_account_balance_time,</if>
|
<if test="beizhu != null">po_beizhu,</if>
|
<if test="hongBao != null">po_hongbao_id,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">#{id,jdbcType=BIGINT},</if>
|
<if test="orderCreateTime != null">#{orderCreateTime,jdbcType=TIMESTAMP},</if>
|
<if test="goodsTitle != null">#{goodsTitle,jdbcType=VARCHAR},</if>
|
<if test="auctionId != null">#{auctionId,jdbcType=BIGINT},</if>
|
<if test="goodsNum != null">#{goodsNum,jdbcType=INTEGER},</if>
|
<if test="price != null">#{price,jdbcType=DECIMAL},</if>
|
<if test="state != null">#{state,jdbcType=VARCHAR},</if>
|
<if test="orderType != null">#{orderType,jdbcType=VARCHAR},</if>
|
<if test="rate != null">#{rate,jdbcType=DECIMAL},</if>
|
<if test="payMoney != null">#{payMoney,jdbcType=DECIMAL},</if>
|
<if test="preMoney != null">#{preMoney,jdbcType=DECIMAL},</if>
|
<if test="finalMoney != null">#{finalMoney,jdbcType=DECIMAL},</if>
|
<if test="balanceTime != null">#{balanceTime,jdbcType=TIMESTAMP},</if>
|
<if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
|
<if test="typeName != null">#{typeName,jdbcType=VARCHAR},</if>
|
<if test="srcMediaId != null">#{srcMediaId,jdbcType=VARCHAR},</if>
|
<if test="adzoneId != null">#{adzoneId,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT}</if>
|
<if test="orderUpdateTime != null">#{orderUpdateTime,jdbcType=TIMESTAMP}</if>
|
<if test="localUpdateTime != null">#{localUpdateTime,jdbcType=TIMESTAMP}</if>
|
<if test="accountBalance != null">#{accountBalance,jdbcType=BOOLEAN}</if>
|
<if test="accountBalanceTime != null">#{accountBalanceTime,jdbcType=TIMESTAMP}</if>
|
<if test="beizhu != null">#{beizhu,jdbcType=VARCHAR}</if>
|
<if test="hongBao != null">#{hongBao.id,jdbcType=BIGINT}</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.taobao.PidOrder">update
|
yeshi_ec_pid_order set po_order_createtime =
|
#{orderCreateTime,jdbcType=TIMESTAMP},po_goods_title =
|
#{goodsTitle,jdbcType=VARCHAR},po_auction_id =
|
#{auctionId,jdbcType=BIGINT},po_goods_num =
|
#{goodsNum,jdbcType=INTEGER},po_price =
|
#{price,jdbcType=DECIMAL},po_state =
|
#{state,jdbcType=VARCHAR},po_order_type =
|
#{orderType,jdbcType=VARCHAR},po_rate =
|
#{rate,jdbcType=DECIMAL},po_pay_money =
|
#{payMoney,jdbcType=DECIMAL},po_pre_money =
|
#{preMoney,jdbcType=DECIMAL},po_final_money =
|
#{finalMoney,jdbcType=DECIMAL},po_balance_time =
|
#{balanceTime,jdbcType=TIMESTAMP},po_order_id =
|
#{orderId,jdbcType=VARCHAR},po_type_name =
|
#{typeName,jdbcType=VARCHAR},po_src_media_id =
|
#{srcMediaId,jdbcType=VARCHAR},po_adzone_id =
|
#{adzoneId,jdbcType=VARCHAR},po_createtime =
|
#{createTime,jdbcType=TIMESTAMP} ,po_uid =
|
#{userInfo.id,jdbcType=BIGINT} ,po_order_update_time =
|
#{orderUpdateTime,jdbcType=TIMESTAMP} ,po_local_update_time =
|
#{localUpdateTime,jdbcType=TIMESTAMP} ,po_account_balance
|
=#{accountBalance,jdbcType=BOOLEAN} ,po_account_balance_time
|
=#{accountBalanceTime,jdbcType=TIMESTAMP} ,po_beizhu
|
=#{beizhu,jdbcType=VARCHAR} ,po_hongbao_id
|
=#{hongBao.id,jdbcType=BIGINT}
|
where po_id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.PidOrder">
|
update yeshi_ec_pid_order
|
<set>
|
<if test="orderCreateTime != null">po_order_createtime=#{orderCreateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="goodsTitle != null">po_goods_title=#{goodsTitle,jdbcType=VARCHAR},</if>
|
<if test="auctionId != null">po_auction_id=#{auctionId,jdbcType=BIGINT},</if>
|
<if test="goodsNum != null">po_goods_num=#{goodsNum,jdbcType=INTEGER},</if>
|
<if test="price != null">po_price=#{price,jdbcType=DECIMAL},</if>
|
<if test="state != null">po_state=#{state,jdbcType=VARCHAR},</if>
|
<if test="orderType != null">po_order_type=#{orderType,jdbcType=VARCHAR},</if>
|
<if test="rate != null">po_rate=#{rate,jdbcType=DECIMAL},</if>
|
<if test="payMoney != null">po_pay_money=#{payMoney,jdbcType=DECIMAL},</if>
|
<if test="preMoney != null">po_pre_money=#{preMoney,jdbcType=DECIMAL},</if>
|
<if test="finalMoney != null">po_final_money=#{finalMoney,jdbcType=DECIMAL},</if>
|
<if test="balanceTime != null">po_balance_time=#{balanceTime,jdbcType=TIMESTAMP},</if>
|
<if test="orderId != null">po_order_id=#{orderId,jdbcType=VARCHAR},</if>
|
<if test="typeName != null">po_type_name=#{typeName,jdbcType=VARCHAR},</if>
|
<if test="srcMediaId != null">po_src_media_id=#{srcMediaId,jdbcType=VARCHAR},</if>
|
<if test="adzoneId != null">po_adzone_id=#{adzoneId,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">po_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
|
<if test="id !=null">po_id =#{id,jdbcType=BIGINT},</if>
|
<if test="userInfo !=null">po_uid =#{userInfo.id,jdbcType=BIGINT},</if>
|
<if test="orderUpdateTime !=null">po_order_update_time
|
=#{orderUpdateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="localUpdateTime !=null">po_local_update_time
|
=#{localUpdateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="accountBalance !=null">po_account_balance =#{accountBalance,jdbcType=BOOLEAN},
|
</if>
|
<if test="accountBalanceTime !=null">po_account_balance_time
|
=#{accountBalanceTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="beizhu !=null">po_beizhu =#{beizhu,jdbcType=VARCHAR},</if>
|
<if test="hongBao !=null">po_hongbao_id =#{hongBao.id,jdbcType=BIGINT},</if>
|
</set>
|
where po_id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<!-- 根据红包id查询PidOrder -->
|
<select id="getPidOrderByHongBaoId" resultMap="BaseResultMap">
|
SELECT * FROM
|
`yeshi_ec_pid_order` po WHERE po.`po_hongbao_id` = #{hongBaoId};
|
</select>
|
</mapper>
|