<?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.share.ShareMapper">
|
|
<resultMap id="BaseResultMap"
|
type="com.yeshi.fanli.entity.taobao.ShareTaoPassword">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="auctionId" property="auctionId" jdbcType="BIGINT" />
|
<result column="pid" property="pid" jdbcType="VARCHAR" />
|
<result column="taoToken" property="taoToken" jdbcType="VARCHAR" />
|
<result column="couponLink" property="couponLink" jdbcType="VARCHAR" />
|
<result column="clickUrl" property="clickUrl" jdbcType="VARCHAR" />
|
<result column="createTime" property="createTime" jdbcType="DATE" />
|
</resultMap>
|
|
<!-- 图片的返回实体 -->
|
<resultMap id="ImgResultMap" type="com.yeshi.fanli.entity.bus.invite.SpreadImg">
|
<id column="id" property="id" jdbcType="BIGINT" />
|
<result column="url" property="url" jdbcType="VARCHAR" />
|
<result column="createtime" property="createtime" jdbcType="DATE" />
|
</resultMap>
|
|
<!-- 根据uid查询是否存在pid与其绑定 -->
|
<select id="idBind" resultType="String">
|
select yepu.pid from
|
yeshi_ec_pid_user yepu where yepu.uid = #{uid}
|
</select>
|
|
<!-- 随机获得一个pid -->
|
<select id="getRandomPid" resultType="String">
|
SELECT yep.`pid` FROM
|
`yeshi_ec_pid` yep WHERE yep.`used` = '0' ORDER BY RAND() LIMIT 1;
|
</select>
|
|
<!-- 修改该pid的used为1 -->
|
<update id="updatePidUsed">
|
UPDATE
|
`yeshi_ec_pid` yep
|
SET
|
yep.`used` = '1'
|
WHERE
|
yep.`pid` = #{pid}
|
</update>
|
|
<!-- 插入数据到 yeshi_ec_share_tao_password -->
|
<insert id="insertShareTaoPassword" parameterType="com.yeshi.fanli.entity.taobao.ShareTaoPassword"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_share_tao_password
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="auctionId != null">auctionId,</if>
|
<if test="pid != null">pid,</if>
|
<if test="taoToken != null">taoToken,</if>
|
<if test="couponLink != null">couponLink,</if>
|
<if test="clickUrl != null">clickUrl,</if>
|
<if test="createTime != null">createTime,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="auctionId != null">#{auctionId,jdbcType=BIGINT},</if>
|
<if test="pid != null">#{pid,jdbcType=VARCHAR},</if>
|
<if test="taoToken != null">#{taoToken,jdbcType=VARCHAR},</if>
|
<if test="couponLink != null">#{couponLink,jdbcType=VARCHAR},</if>
|
<if test="clickUrl != null">#{clickUrl,jdbcType=VARCHAR},</if>
|
<if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
|
<!-- 添加绑定操作 -->
|
<insert id="insertPidUser" parameterType="com.yeshi.fanli.entity.taobao.PidUser"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_pid_user
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="uid != null">uid,</if>
|
<if test="pid != null">pid,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="uid != null">#{uid,jdbcType=BIGINT},</if>
|
<if test="pid != null">#{pid,jdbcType=VARCHAR},</if>
|
</trim>
|
</insert>
|
|
<!-- 根据auctionId和pid查看是否存在数据 -->
|
<select id="getAunctionPidCount" resultType="Integer">
|
SELECT
|
COUNT(1)
|
FROM
|
`yeshi_ec_share_tao_password` yestp
|
WHERE
|
yestp.`auctionId` =
|
#{auctionId}
|
AND
|
yestp.`pid` = #{pid};
|
</select>
|
|
<!-- 获取创建时间 -->
|
<select id="getShareTaoPassword" resultMap="BaseResultMap">
|
SELECT
|
*
|
FROM
|
`yeshi_ec_share_tao_password` yestp
|
WHERE
|
yestp.`auctionId` =
|
#{auctionId}
|
AND
|
yestp.`pid` = #{pid};
|
</select>
|
|
<!-- 时间大于一个月 更新数据 -->
|
<update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.ShareTaoPassword">
|
update yeshi_ec_share_tao_password
|
<set>
|
<if test="auctionId != null">
|
auctionId = #{auctionId,jdbcType=BIGINT},
|
</if>
|
<if test="pid != null">
|
pid = #{pid,jdbcType=VARCHAR},
|
</if>
|
<if test="taoToken != null">
|
taoToken = #{taoToken,jdbcType=VARCHAR},
|
</if>
|
<if test="couponLink != null">
|
couponLink = #{couponLink,jdbcType=VARCHAR},
|
</if>
|
<if test="clickUrl != null">
|
clickUrl = #{clickUrl,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<!-- 查询我的一级队员 -->
|
<select id="myFirstTeamCount" resultType="Integer">
|
SELECT
|
count(yet.`worker_id`)
|
FROM
|
`yeshi_ec_threesale` yet
|
WHERE
|
yet.`boss_id` =
|
#{uid}
|
AND
|
yet.`state` = '1'
|
</select>
|
|
<!-- 查询我的二级队员 -->
|
<select id="mySecondTeamCount" resultType="Integer">
|
SELECT
|
count(yet.`worker_id`)
|
FROM
|
`yeshi_ec_threesale` yet
|
WHERE
|
yet.`boss_id` =
|
ANY(
|
SELECT
|
yet.`worker_id`
|
FROM
|
`yeshi_ec_threesale` yet
|
WHERE
|
yet.`boss_id` = #{uid}
|
AND
|
yet.`state` = '1'
|
)
|
AND
|
yet.`state` = '1';
|
</select>
|
|
<!-- 查询我的今日收益 -->
|
<select id="getMoneyToday" resultType="java.math.BigDecimal">
|
SELECT
|
SUM(yeh.`hb_money`)
|
FROM
|
`yeshi_ec_hongbao_v2` yeh
|
WHERE
|
(yeh.`hb_state` = '1' OR yeh.`hb_state`
|
= '2' OR yeh.`hb_state` = '3')
|
AND
|
(yeh.`hb_type` = '6' OR yeh.`hb_type`
|
= '7' OR yeh.`hb_type` = '20' OR yeh.`hb_type` = '21' OR yeh.`hb_type`
|
= '22')
|
AND
|
yeh.`hb_uid` = #{uid}
|
AND
|
FROM_UNIXTIME(UNIX_TIMESTAMP(yeh.hb_create_time),'%Y-%m-%d') =
|
FROM_UNIXTIME(UNIX_TIMESTAMP(),'%Y-%m-%d');
|
</select>
|
|
<!-- 查询我的本月预估收益 -->
|
<select id="getMoneyMonth" resultType="java.math.BigDecimal">
|
SELECT
|
SUM(yeh.`hb_money`)
|
FROM
|
`yeshi_ec_hongbao_v2` yeh
|
WHERE
|
(yeh.`hb_state` = '1' OR
|
yeh.`hb_state` = '2' OR yeh.`hb_state` = '3')
|
AND
|
(yeh.`hb_type` = '6'
|
OR yeh.`hb_type` = '7' OR yeh.`hb_type` = '20' OR yeh.`hb_type` = '21'
|
OR yeh.`hb_type` = '22')
|
AND
|
yeh.`hb_uid` = #{uid}
|
AND
|
FROM_UNIXTIME(UNIX_TIMESTAMP(yeh.hb_create_time),'%Y-%m') =
|
FROM_UNIXTIME(UNIX_TIMESTAMP(),'%Y-%m');
|
</select>
|
|
|
<!-- 查询我的上月预估收益 -->
|
<select id="getMoneyLastMonth" resultType="java.math.BigDecimal">
|
SELECT
|
SUM(h.`hb_money`) FROM yeshi_ec_hongbao_v2 h WHERE h.`hb_uid`=#{0}
|
AND (h.`hb_state`=1 OR h.`hb_state`=2 OR h.`hb_state`=3) AND
|
(h.`hb_type`=6 OR h.`hb_type`=7 OR h.`hb_type`=20 OR h.`hb_type`=21 OR
|
h.`hb_type`=22 ) AND h.`hb_pre_get_time` IS NOT NULL AND
|
DATE_FORMAT(h.`hb_pre_get_time`,'%Y-%m')=DATE_FORMAT(NOW(),'%Y-%m');
|
</select>
|
|
|
|
|
|
<!-- 邀请图片count -->
|
<select id="spreadImgCount" resultType="Integer">
|
SELECT COUNT(*) FROM
|
`yeshi_ec_spread_img` yesi WHERE 1 = 1;
|
</select>
|
|
<!-- 分页查询邀请图片 -->
|
<select id="spreadImgList" resultMap="ImgResultMap">
|
SELECT * FROM
|
`yeshi_ec_spread_img`;
|
</select>
|
|
<!-- 添加邀请好友图片 -->
|
<insert id="addInviteFriendImg" parameterType="com.yeshi.fanli.entity.bus.invite.SpreadImg"
|
useGeneratedKeys="true" keyProperty="id">
|
insert into yeshi_ec_share_tao_password
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="url != null">url,</if>
|
<if test="createtime != null">createtime,</if>
|
</trim>
|
values
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="url != null">#{url,jdbcType=VARCHAR},</if>
|
<if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
|
</trim>
|
</insert>
|
|
<!-- 根据uid查询用户头像 -->
|
<select id="getPortrait" resultType="String">
|
SELECT yeu.`portrait` FROM
|
yeshi_ec_user yeu WHERE yeu.`id` = #{uid};
|
</select>
|
|
<!-- 获取分享赚count -->
|
<select id="getCount" resultType="Integer">
|
SELECT COUNT(1) FROM
|
`yeshi_ec_hongbao` yeh WHERE yeh.`type` = '20' AND yeh.`uid` = #{uid};
|
</select>
|
|
<!-- 获取邀请赚count -->
|
<select id="getInviteCount" resultType="Integer">
|
SELECT
|
COUNT(1)
|
FROM
|
`yeshi_ec_hongbao` yeh
|
WHERE
|
(yeh.`type` = '6' OR yeh.`type` = '7')
|
AND
|
yeh.`uid` = #{uid};
|
</select>
|
|
<!-- 随机增加榜单igd_money -->
|
<update id="updateInviteRank">
|
UPDATE
|
`yeshi_ec_invite_getmoney_demo` igt
|
SET
|
igt.`igd_money` = igt.`igd_money` + #{bigDecimalMoney}
|
</update>
|
|
|
<!-- 查询所有用户分享赚列表总数 -->
|
<select id="getShareMoneyCount" resultType="Integer">
|
SELECT COUNT(1) FROM
|
`yeshi_ec_pid_order`;
|
</select>
|
|
<!-- 查询系统内所设定的背景图片 -->
|
<select id="systemSpreadImgList" resultType="String">
|
SELECT si.`si_url`
|
FROM `yeshi_ec_spread_img` si;
|
</select>
|
|
<!-- 查询板块栏目数量 -->
|
<select id="getCounts" resultType="Integer">
|
SELECT counts FROM
|
`yeshi_ec_recommend_section` WHERE id = #{key};
|
</select>
|
|
<!-- 查询活动规则 -->
|
<select id="getActivityRules" resultType="String">
|
SELECT yesc.`value`
|
FROM `yeshi_ec_system_clientparams` yesc WHERE yesc.`key` = #{key};
|
</select>
|
|
<!-- 修改活动规则 -->
|
<update id="editActivityRules">
|
UPDATE `yeshi_ec_system_clientparams` yesc SET
|
yesc.`value` = #{value} WHERE yesc.`key` = #{key};
|
</update>
|
|
|
</mapper>
|