yujian
2019-07-30 969ac5f2ef08e2cd662853d9b771c9663c5d2c70
分享商品更改缓存简版商品
15个文件已修改
1547 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 39 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/share/ShareGoodsRecordDTO.java 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml 1206 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/CommonGoodsUtil.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/user/UserInfoVO.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -71,6 +71,7 @@
import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
import com.yeshi.fanli.util.factory.MonitorFactory;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
@@ -538,25 +539,28 @@
            return;
        }
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goodsId + "");
//        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
//                Constant.systemCommonConfig.getShareGoodsPagePathJD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
//                goodsId + "");
        // 券短连接
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        String couponUrl = null;
        JDCouponInfo couponInfo = jdGoods.getCouponInfo();
        if (couponInfo != null) {
            couponUrl = couponInfo.getLink();
        }
        String materialId = "https://item.jd.com/" + goodsId + ".html";
        String jumpLink = JDApiUtil.convertShortLink(materialId, couponUrl, JDApiUtil.POSITION_SHARE + "", uid+ "");
        ShareInfoVO shareInfo = new ShareInfoVO();
        shareInfo.setClickUrl(url);
        shareInfo.setClickUrl(jumpLink);
        shareInfo.setRule(configService.get("share_rule_link_jd"));
        shareInfo.setPictUrl(jdGoods.getPicUrl());
        
        String shareText = "";
        boolean hasCoupon = false;
        // 分享模板
        JDCouponInfo couponInfo = jdGoods.getCouponInfo();
        ShareGoodsTextTemplate textTemplate = shareGoodsTextTemplateService.getShareGoodsTextTemplate(uid);
        if (couponInfo == null) { // 无券模板
            if (textTemplate != null) 
@@ -572,7 +576,7 @@
            if (StringUtil.isNullOrEmpty(shareText))
                shareText = configService.get("goods_share_text_coupon_jd");
        }
        shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, shortLink, hasCoupon);
        shareText = shareGoodsTextTemplateService.createContentByTemplateJD(shareText, uid, jdGoods, jumpLink, hasCoupon);
        shareInfo.setShareText(shareText);
        String descText = shareText.replace(jdGoods.getSkuName(), "").trim();
@@ -649,17 +653,14 @@
            return;
        }
        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
                goodsId + "");
//        String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
//                Constant.systemCommonConfig.getShareGoodsPagePathPDD(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
//                goodsId + "");
        String shortLink = HttpUtil.getShortLink(url);
        if (!StringUtil.isNullOrEmpty(shortLink)) {
            url = shortLink;
        }
        String jumpLink = PinDuoDuoApiUtil.convert(goodsId, PinDuoDuoApiUtil.PID_SHARE + "", uid + "");
        
        ShareInfoVO shareInfo = new ShareInfoVO();
        shareInfo.setClickUrl(url);
        shareInfo.setClickUrl(jumpLink);
        shareInfo.setRule(configService.get("share_rule_link_pdd"));
        shareInfo.setPictUrl(goods.getGoodsImageUrl());
@@ -685,7 +686,7 @@
        String token = PinDuoDuoApiUtil.createGenerate(goodsId);
                
        // 生成分享内容
        String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, shortLink,
        String shareText = shareGoodsTextTemplateService.createContentByTemplatePDD(template, uid, goods, jumpLink,
                        hasCoupon, token);
        shareInfo.setShareText(shareText);
fanli/src/main/java/com/yeshi/fanli/dto/share/ShareGoodsRecordDTO.java
@@ -3,7 +3,7 @@
import java.util.List;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.goods.CommonGoods;
public class ShareGoodsRecordDTO {
    
@@ -15,7 +15,7 @@
    private ShareSourceTypeEnum source;
    private Long auctionId;
    private Integer goodsType;
    private List<TaoBaoGoodsBrief> listGoodsBrief;
    private List<CommonGoods> listGoods;
    private List<Long> listId;
    
    public Long getUid() {
@@ -30,16 +30,8 @@
        return shareId;
    }
    public void setShareId(Long shareId) {
    public void setShareId(Long shareId) {
        this.shareId = shareId;
    }
    public List<TaoBaoGoodsBrief> getListGoodsBrief() {
        return listGoodsBrief;
    }
    public void setListGoodsBrief(List<TaoBaoGoodsBrief> listGoodsBrief) {
        this.listGoodsBrief = listGoodsBrief;
    }
    public String getRedisKey() {
@@ -98,4 +90,12 @@
        this.goodsType = goodsType;
    }
    public List<CommonGoods> getListGoods() {
        return listGoods;
    }
    public void setListGoods(List<CommonGoods> listGoods) {
        this.listGoods = listGoods;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml
@@ -1,602 +1,604 @@
<?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.UserInfoMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserInfo">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="identifycode" property="openid" jdbcType="VARCHAR" />
        <result column="login_type" property="loginType" jdbcType="INTEGER" />
        <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
        <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="tbName" property="tbName" jdbcType="VARCHAR" />
        <result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
        <result column="wxName" property="wxName" jdbcType="VARCHAR" />
        <result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
        <result column="portrait" property="portrait" jdbcType="VARCHAR" />
        <result column="createtime" property="createtime" jdbcType="BIGINT" />
        <result column="last_logintime" property="lastLoginTime"
            jdbcType="BIGINT" />
        <result column="loginip" property="lastLoginIp" jdbcType="VARCHAR" />
        <result column="tuiguang_code" property="tuiGuangCode"
            jdbcType="VARCHAR" />
        <result column="appid" property="appId" jdbcType="VARCHAR" />
        <result column="my_hongBao" property="myHongBao" jdbcType="DECIMAL" />
        <result column="pay_password" property="payPassword" jdbcType="VARCHAR" />
        <result column="rank" property="rank" jdbcType="INTEGER" />
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <!-- <association property="system" column="sid" resultMap="com.yeshi.fanli.dao.mybatis.SystemMapper.BaseResultMap"
            /> -->
    </resultMap>
    <resultMap id="BaseResultMapVO" type="com.yeshi.fanli.vo.user.UserInfoVO">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="identifycode" property="openid" jdbcType="VARCHAR" />
        <result column="login_type" property="loginType" jdbcType="INTEGER" />
        <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
        <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="tbName" property="tbName" jdbcType="VARCHAR" />
        <result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
        <result column="wxName" property="wxName" jdbcType="VARCHAR" />
        <result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
        <result column="portrait" property="portrait" jdbcType="VARCHAR" />
        <result column="createtime" property="createtime" jdbcType="BIGINT" />
        <result column="last_logintime" property="lastLoginTime"
            jdbcType="BIGINT" />
        <result column="loginip" property="lastLoginIp" jdbcType="VARCHAR" />
        <result column="tuiguang_code" property="tuiGuangCode"
            jdbcType="VARCHAR" />
        <result column="appid" property="appId" jdbcType="VARCHAR" />
        <result column="my_hongBao" property="myHongBao" jdbcType="DECIMAL" />
        <result column="pay_password" property="payPassword" jdbcType="VARCHAR" />
        <result column="rank" property="rank" jdbcType="INTEGER" />
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="ur_id" property="rankId" jdbcType="BIGINT" />
        <result column="ur_name" property="rankName"    jdbcType="VARCHAR" />
        <result column="ur_picture" property="rankPicture"    jdbcType="VARCHAR" />
        <result column="totalOrder" property="totalOrder"    jdbcType="BIGINT" />
        <result column="monthOrder" property="monthOrder"    jdbcType="BIGINT" />
        <result column="taoBaoUid" property="taoBaoUid"    jdbcType="VARCHAR" />
        <result column="wxUnionIdInvalid" property="wxUnionIdInvalid"    jdbcType="VARCHAR" />
        <result column="taobaoUidInvalid" property="taobaoUidInvalid"    jdbcType="VARCHAR" />
        <result column="phoneInvalid" property="phoneInvalid"    jdbcType="VARCHAR" />
        <result column="alipayAccountInvalid" property="alipayAccountInvalid"    jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT} and `state`=0
    </select>
    <select id="selectByPKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT} for update
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user
        (id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc)
        values
        (#{id,jdbcType=BIGINT},#{openid,jdbcType=VARCHAR},#{loginType,jdbcType=INTEGER},#{wxOpenId,jdbcType=VARCHAR},#{wxUnionId,jdbcType=VARCHAR},#{nickName,jdbcType=VARCHAR},#{tbName,jdbcType=VARCHAR},#{tbPic,jdbcType=VARCHAR},#{wxName,jdbcType=VARCHAR},#{wxPic,jdbcType=VARCHAR},#{portrait,jdbcType=VARCHAR},#{createtime,jdbcType=BIGINT},#{lastLoginTime,jdbcType=BIGINT},#{lastLoginIp,jdbcType=VARCHAR},#{tuiGuangCode,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},#{myHongBao,jdbcType=DECIMAL},#{payPassword,jdbcType=VARCHAR},#{system.id,jdbcType=BIGINT},#{rank,jdbcType=INTEGER},#{phone,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{stateDesc,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="openid != null">identifycode,</if>
            <if test="loginType != null">login_type,</if>
            <if test="wxOpenId != null">wx_open_id,</if>
            <if test="wxUnionId != null">wx_union_id,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="tbName != null">tbName,</if>
            <if test="tbPic != null">tbPic,</if>
            <if test="wxName != null">wxName,</if>
            <if test="wxPic != null">wxPic,</if>
            <if test="portrait != null">portrait,</if>
            <if test="createtime != null">createtime,</if>
            <if test="lastLoginTime != null">last_logintime,</if>
            <if test="lastLoginIp != null">loginip,</if>
            <if test="tuiGuangCode != null">tuiguang_code,</if>
            <if test="appId != null">appid,</if>
            <if test="myHongBao != null">my_hongBao,</if>
            <if test="payPassword != null">pay_password,</if>
            <if test="system != null">sid,</if>
            <if test="rank != null">rank,</if>
            <if test="phone != null">phone,</if>
            <if test="state != null">state,</if>
            <if test="stateDesc != null">state_desc,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="openid != null">#{openid,jdbcType=VARCHAR},</if>
            <if test="loginType != null">#{loginType,jdbcType=INTEGER},</if>
            <if test="wxOpenId != null">#{wxOpenId,jdbcType=VARCHAR},</if>
            <if test="wxUnionId != null">#{wxUnionId,jdbcType=VARCHAR},</if>
            <if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if>
            <if test="tbName != null">#{tbName,jdbcType=VARCHAR},</if>
            <if test="tbPic != null">#{tbPic,jdbcType=VARCHAR},</if>
            <if test="wxName != null">#{wxName,jdbcType=VARCHAR},</if>
            <if test="wxPic != null">#{wxPic,jdbcType=VARCHAR},</if>
            <if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if>
            <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
            <if test="lastLoginTime != null">#{lastLoginTime,jdbcType=BIGINT},</if>
            <if test="lastLoginIp != null">#{lastLoginIp,jdbcType=VARCHAR},</if>
            <if test="tuiGuangCode != null">#{tuiGuangCode,jdbcType=VARCHAR},</if>
            <if test="appId != null">#{appId,jdbcType=VARCHAR},</if>
            <if test="myHongBao != null">#{myHongBao,jdbcType=DECIMAL},</if>
            <if test="payPassword != null">#{payPassword,jdbcType=VARCHAR},</if>
            <if test="system != null">#{system.id,jdbcType=BIGINT},</if>
            <if test="rank != null">#{rank,jdbcType=INTEGER},</if>
            <if test="phone != null">#{phone,jdbcType=VARCHAR},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">update
        yeshi_ec_user set identifycode = #{openid,jdbcType=VARCHAR},login_type
        = #{loginType,jdbcType=INTEGER},wx_open_id =
        #{wxOpenId,jdbcType=VARCHAR},wx_union_id =
        #{wxUnionId,jdbcType=VARCHAR},nick_name =
        #{nickName,jdbcType=VARCHAR},tbName = #{tbName,jdbcType=VARCHAR},tbPic
        = #{tbPic,jdbcType=VARCHAR},wxName = #{wxName,jdbcType=VARCHAR},wxPic
        = #{wxPic,jdbcType=VARCHAR},portrait =
        #{portrait,jdbcType=VARCHAR},createtime =
        #{createtime,jdbcType=BIGINT},last_logintime =
        #{lastLoginTime,jdbcType=BIGINT},loginip =
        #{lastLoginIp,jdbcType=VARCHAR},tuiguang_code =
        #{tuiGuangCode,jdbcType=VARCHAR},appid =
        #{appId,jdbcType=VARCHAR},my_hongBao =
        #{myHongBao,jdbcType=DECIMAL},pay_password =
        #{payPassword,jdbcType=VARCHAR},sid =
        #{system.id,jdbcType=BIGINT},rank = #{rank,jdbcType=INTEGER} ,phone
        =#{phone,jdbcType=VARCHAR} ,state =#{state,jdbcType=INTEGER}
        ,state_desc =#{stateDesc,jdbcType=VARCHAR} where id =
        #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">
        update yeshi_ec_user
        <set>
            <if test="openid != null">identifycode=#{openid,jdbcType=VARCHAR},</if>
            <if test="loginType != null">login_type=#{loginType,jdbcType=INTEGER},</if>
            <if test="wxOpenId != null">wx_open_id=#{wxOpenId,jdbcType=VARCHAR},</if>
            <if test="wxUnionId != null">wx_union_id=#{wxUnionId,jdbcType=VARCHAR},</if>
            <if test="nickName != null">nick_name=#{nickName,jdbcType=VARCHAR},</if>
            <if test="tbName != null">tbName=#{tbName,jdbcType=VARCHAR},</if>
            <if test="tbPic != null">tbPic=#{tbPic,jdbcType=VARCHAR},</if>
            <if test="wxName != null">wxName=#{wxName,jdbcType=VARCHAR},</if>
            <if test="wxPic != null">wxPic=#{wxPic,jdbcType=VARCHAR},</if>
            <if test="portrait != null">portrait=#{portrait,jdbcType=VARCHAR},</if>
            <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
            <if test="lastLoginTime != null">last_logintime=#{lastLoginTime,jdbcType=BIGINT},</if>
            <if test="lastLoginIp != null">loginip=#{lastLoginIp,jdbcType=VARCHAR},</if>
            <if test="tuiGuangCode != null">tuiguang_code=#{tuiGuangCode,jdbcType=VARCHAR},</if>
            <if test="appId != null">appid=#{appId,jdbcType=VARCHAR},</if>
            <if test="myHongBao != null">my_hongBao=#{myHongBao,jdbcType=DECIMAL},</if>
            <if test="payPassword != null">pay_password=#{payPassword,jdbcType=VARCHAR},</if>
            <if test="system != null">sid=#{system.id,jdbcType=BIGINT},</if>
            <if test="rank != null">rank=#{rank,jdbcType=INTEGER},</if>
            <if test="phone !=null">phone =#{phone,jdbcType=VARCHAR},</if>
            <if test="state !=null">state =#{state,jdbcType=INTEGER},</if>
            <if test="stateDesc !=null">state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="subHongBaoByUid">update yeshi_ec_user set my_hongBao=
        my_hongBao-#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
    </update>
    <update id="addHongBaoByUid">update yeshi_ec_user set my_hongBao=
        my_hongBao+#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
    </update>
    <!-- 清除手势密码 -->
    <delete id="cleanPassword">DELETE FROM `yeshi_ec_extract_record` WHERE uid =
        #{id};
    </delete>
    <!-- 查询新人红包 -->
    <select id="getNewPeopleHB" resultType="BigDecimal">SELECT sum(hb.`money`)
        FROM `yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id} AND hb.`type` = '4';
    </select>
    <!-- 查询我的红包 -->
    <select id="getMyHB" resultType="BigDecimal">SELECT SUM(hb.`money`) FROM
        `yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id};
    </select>
    <!-- 根据AppId与微信unionID获取用户 -->
    <select id="listByAppIdAndWXUnionId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and wx_union_id=#{unionId}
    </select>
    <!-- 根据AppId与淘宝OpenId获取用户 -->
    <select id="listByAppIdAndTaoBaoOpenId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and identifycode=#{openId}
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="listByAppIdAndPhone" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and phone=#{phone}
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByPhone" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where phone=#{phone} AND state = 0
        LIMIT 1
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByWXUnionId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where wx_union_id=#{unionId} AND state = 0
        LIMIT 1
    </select>
    <select id="getMaxUid" resultType="java.lang.Long">select max(id) from
        yeshi_ec_user
    </select>
    <!-- 两个账号的业务融合 -->
    <select id="connectUser" >
     call procedure_connect_user(#{mainUid},#{lessUid})
    </select>
    <select id="query"  resultMap="BaseResultMapVO">
           SELECT *
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1 )AS totalOrder <!-- 累计订单 -->
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1
                   AND DATE_FORMAT(hb.`hb_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m'))AS monthOrder <!-- 累计本月订单 -->
        ,(SELECT COUNT(tr.`id`) FROM `yeshi_ec_threesale` tr  <!-- 队员 -->
             WHERE  tr.`boss_id`=u.id AND tr.state = 1) AS totalPlayers
           FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
               LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
        <if test="userState == 2">
               LEFT JOIN
                (SELECT A.uid AS buid,MAX(A.f_wxUnionId) AS wxUnionIdInvalid ,MAX(A.f_taobaoUid) AS taobaoUidInvalid,MAX(A.f_phone) AS phoneInvalid,MAX(A.f_alipayAccount) AS alipayAccountInvalid FROM
                    (SELECT u.`id`AS uid,b.account AS alipayAccount,b.name AS alipayAccountName,fu.* FROM yeshi_ec_user u
                LEFT JOIN yeshi_ec_binding_account b ON b.`uid` = u.`id`
                LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
                LEFT JOIN (SELECT fc.fuc_effective,IF(fc.`fuc_type` = 'wxUnionId',fc.`fuc_identify_code`,NULL)AS f_wxUnionId,
                    IF(fc.`fuc_type` = 'taobaoUid',fc.`fuc_identify_code`,NULL)AS f_taobaoUid,
                    IF(fc.`fuc_type` = 'phone',fc.`fuc_identify_code`,NULL)AS f_phone,
                    IF(fc.`fuc_type` = 'alipayAccount',fc.`fuc_identify_code`,NULL)AS f_alipayAccount
                FROM yeshi_ec_forbidden_user_identify_code fc WHERE fc.fuc_effective = 1 )fu ON (fu.f_wxUnionId = u.`wx_union_id` OR fu.f_taobaoUid = tb.`uiet_taobao_uid` OR fu.f_phone = u.`phone` OR fu.f_alipayAccount = b.`account`)
                WHERE u.`state` =2
            )A GROUP BY A.uid) B ON u.id= B.buid
           </if>
           where 1=1
               <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
               <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
               </if>
               <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
               </if>
                  <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
               </if>
               <if test="days != null">
                    <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
            </if>
               <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
              ORDER BY
              <if test="orderField == 1">
                  totalOrder,
              </if>
              <if test="orderField == 2">
                  totalOrder DESC,
              </if>
              <if test="orderField == 3">
                  monthOrder,
              </if>
              <if test="orderField == 4">
                  monthOrder DESC,
              </if>
              <if test="orderField == 5">
                  totalPlayers,
              </if>
              <if test="orderField == 6">
                  totalPlayers DESC,
              </if>
              u.createtime DESC
              LIMIT ${start},${count}
    </select>
    <select id="queryCount" resultType="java.lang.Long">
           SELECT IFNULL(count(u.id),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
           where 1=1
                <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
                <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
                </if>
                <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
                </if>
                   <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
                </if>
                <if test="days != null">  <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
             </if>
             <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
    </select>
    <select id="querySumMoney" resultType="java.lang.Double">
           SELECT COALESCE(sum(u.my_hongBao),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
           where <![CDATA[ 1>0 ]]>
                <if test="key != null and key !='' ">
                   AND    (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%'  OR u.`wxName` LIKE '%${key}%'
                   OR u.`nick_name` LIKE '%${key}%'  OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
                </if>
                <if test="startTime != null and startTime !='' ">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
                </if>
                <if test="endTime != null and endTime !=''">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}'  ]]>
                </if>
                   <if test="userType != null">
                   AND u.rank = #{userType}
                </if>
                  <if test="days != null">
                <!--  时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
            </if>
    </select>
    <select id="countNewUser" resultType="java.lang.Long">
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user`
           WHERE 1=1
                <if test="isToday != null and isToday == 1">
                AND TO_DAYS(FROM_UNIXTIME(createtime/1000)) = TO_DAYS(NOW())
            </if>
            <if test="isMonth != null and isMonth == 1">
                AND DATE_FORMAT( FROM_UNIXTIME(createtime/1000), '%Y%m' ) = DATE_FORMAT(CURDATE() , '%Y%m' )
            </if>
    </select>
    <select id="countRank" resultType="java.lang.Long">
       <!--  等级统计 -->
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user` WHERE rank = #{rank}
    </select>
    <select id="countAllMoney" resultType="java.math.BigDecimal">
       <!--  金额统计 -->
           SELECT CAST(SUM(my_hongBao)AS DECIMAL(19,2)) FROM `yeshi_ec_user`
           WHERE 1=1
               <if test="minMoney != null">
              AND <![CDATA[ my_hongBao >= #{minMoney}]]>
            </if>
    </select>
    <select id="countShareAndInviteMoney" resultMap="BaseResultMap">
        SELECT IFNULL(SUM(h.`money`),0),h.`uid` FROM `yeshi_ec_hongbao` h
        WHERE  DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )= '2018-08-02'
        <![CDATA[AND h.state <>4]]>
         AND ( h.`type` =5 OR  h.`type` =6 OR h.`type` =7 OR  h.`type` =20 OR h.`type` =21 OR h.`type` =22 )
        GROUP BY h.`uid`
        ORDER BY SUM(h.`money`) DESC
         LIMIT ${start},${count}
    </select>
    <select id="longTimeNoLogin"  resultType="java.lang.Long">
        SELECT u.`id` FROM `yeshi_ec_user` u
        WHERE  u.`id` IN <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
        AND <![CDATA[ (DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`last_logintime`/1000))
            OR (u.`last_logintime` IS NULL
                AND DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`createTime`/1000)))) ]]>
    </select>
    <select id="countLoseUser" resultType="java.lang.Long">
        SELECT  COUNT(DISTINCT t.`id` ) FROM `yeshi_ec_user` t
        LEFT JOIN `yeshi_ec_user_money_detail` d ON d.`umd_uid` = t.`id`
        WHERE DATE_SUB(CURDATE(), INTERVAL ${num} DAY)<![CDATA[> ]]> DATE(FROM_UNIXTIME( t.`last_logintime`/1000))
               AND DATE_SUB(CURDATE(), INTERVAL ${num} DAY) <![CDATA[> ]]> DATE(d.`umd_createtime`)
    </select>
    <select id="countHasOrderUser" resultType="java.lang.Long">
        SELECT COUNT(DISTINCT h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE (h.`hb_type`=1 or  h.`hb_type`=2 or h.`hb_type`= 20)
    </select>
    <select id="countNewUserByDate" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT h.`id`) AS showValue,
            <if test="type == 1">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM yeshi_ec_user h
            <if test="channel != null and  channel != 'all' ">
                left join (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`)a ON h.`id`=a.uid
            </if>
        WHERE 1=1
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
        </if>
        ORDER BY h.`createtime`
    </select>
    <select id="getTodayHasOrder" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM  yeshi_ec_user u
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id`
        WHERE (h.`hb_type`=1 OR h.`hb_type`=20)
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <!-- 当日下单 -->
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = DATE_FORMAT(h.hb_create_time,'%Y-%m-%d')
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="getWeekHasOrder" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT hb.uid) AS showValue,FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
        FROM (SELECT COUNT(v2.`hb_id`) AS num,v2.hb_uid  AS uid
              FROM yeshi_ec_hongbao_v2 v2
              WHERE   (v2.`hb_type`=1 OR v2.`hb_type`=20)
                  AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ >= ]]>'${startTime}'
                 AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
              GROUP BY v2.hb_uid HAVING num >= ${orderNum})hb
        LEFT JOIN yeshi_ec_user u  ON u.id = hb.uid
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '${startTime}'
            <if test="channel != null and  channel != 'all' ">
               AND a.uid is not null
            </if>
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        ORDER BY u.`createtime`
    </select>
    <select id="getInfoByPhoneOrInviteCode" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_user u
        LEFT JOIN yeshi_ec_user_info_extra uf ON uf.`uie_uid` = u.`id`
        WHERE uf.`uie_invite_code` IS NOT NULL
              AND (u.`phone` =#{phone} OR uf.`uie_invite_code` = #{inviteCode})
        LIMIT 1
    </select>
</mapper>
<?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.UserInfoMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.UserInfo">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="identifycode" property="openid" jdbcType="VARCHAR" />
        <result column="login_type" property="loginType" jdbcType="INTEGER" />
        <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
        <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="tbName" property="tbName" jdbcType="VARCHAR" />
        <result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
        <result column="wxName" property="wxName" jdbcType="VARCHAR" />
        <result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
        <result column="portrait" property="portrait" jdbcType="VARCHAR" />
        <result column="createtime" property="createtime" jdbcType="BIGINT" />
        <result column="last_logintime" property="lastLoginTime"
            jdbcType="BIGINT" />
        <result column="loginip" property="lastLoginIp" jdbcType="VARCHAR" />
        <result column="tuiguang_code" property="tuiGuangCode"
            jdbcType="VARCHAR" />
        <result column="appid" property="appId" jdbcType="VARCHAR" />
        <result column="my_hongBao" property="myHongBao" jdbcType="DECIMAL" />
        <result column="pay_password" property="payPassword" jdbcType="VARCHAR" />
        <result column="rank" property="rank" jdbcType="INTEGER" />
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <!-- <association property="system" column="sid" resultMap="com.yeshi.fanli.dao.mybatis.SystemMapper.BaseResultMap"
            /> -->
    </resultMap>
    <resultMap id="BaseResultMapVO" type="com.yeshi.fanli.vo.user.UserInfoVO">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="identifycode" property="openid" jdbcType="VARCHAR" />
        <result column="login_type" property="loginType" jdbcType="INTEGER" />
        <result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR" />
        <result column="wx_union_id" property="wxUnionId" jdbcType="VARCHAR" />
        <result column="nick_name" property="nickName" jdbcType="VARCHAR" />
        <result column="uiet_taobao_nick_name" property="tbName" jdbcType="VARCHAR" />
        <result column="tbPic" property="tbPic" jdbcType="VARCHAR" />
        <result column="wxName" property="wxName" jdbcType="VARCHAR" />
        <result column="wxPic" property="wxPic" jdbcType="VARCHAR" />
        <result column="portrait" property="portrait" jdbcType="VARCHAR" />
        <result column="createtime" property="createtime" jdbcType="BIGINT" />
        <result column="last_logintime" property="lastLoginTime"
            jdbcType="BIGINT" />
        <result column="loginip" property="lastLoginIp" jdbcType="VARCHAR" />
        <result column="tuiguang_code" property="tuiGuangCode"
            jdbcType="VARCHAR" />
        <result column="appid" property="appId" jdbcType="VARCHAR" />
        <result column="my_hongBao" property="myHongBao" jdbcType="DECIMAL" />
        <result column="pay_password" property="payPassword" jdbcType="VARCHAR" />
        <result column="rank" property="rank" jdbcType="INTEGER" />
        <result column="phone" property="phone" jdbcType="VARCHAR" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="ur_id" property="rankId" jdbcType="BIGINT" />
        <result column="ur_name" property="rankName"    jdbcType="VARCHAR" />
        <result column="ur_picture" property="rankPicture"    jdbcType="VARCHAR" />
        <result column="totalOrder" property="totalOrder"    jdbcType="BIGINT" />
        <result column="monthOrder" property="monthOrder"    jdbcType="BIGINT" />
        <result column="uiet_special_id" property="tbSpecialId"    jdbcType="VARCHAR" />
        <result column="uiet_relation_id" property="tbRelationId"    jdbcType="VARCHAR" />
        <result column="uiet_taobao_uid" property="taoBaoUid"    jdbcType="VARCHAR" />
        <result column="wxUnionIdInvalid" property="wxUnionIdInvalid"    jdbcType="VARCHAR" />
        <result column="taobaoUidInvalid" property="taobaoUidInvalid"    jdbcType="VARCHAR" />
        <result column="phoneInvalid" property="phoneInvalid"    jdbcType="VARCHAR" />
        <result column="alipayAccountInvalid" property="alipayAccountInvalid"    jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT} and `state`=0
    </select>
    <select id="selectByPKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where id = #{id,jdbcType=BIGINT} for update
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_user where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user
        (id,identifycode,login_type,wx_open_id,wx_union_id,nick_name,tbName,tbPic,wxName,wxPic,portrait,createtime,last_logintime,loginip,tuiguang_code,appid,my_hongBao,pay_password,sid,rank,phone,state,state_desc)
        values
        (#{id,jdbcType=BIGINT},#{openid,jdbcType=VARCHAR},#{loginType,jdbcType=INTEGER},#{wxOpenId,jdbcType=VARCHAR},#{wxUnionId,jdbcType=VARCHAR},#{nickName,jdbcType=VARCHAR},#{tbName,jdbcType=VARCHAR},#{tbPic,jdbcType=VARCHAR},#{wxName,jdbcType=VARCHAR},#{wxPic,jdbcType=VARCHAR},#{portrait,jdbcType=VARCHAR},#{createtime,jdbcType=BIGINT},#{lastLoginTime,jdbcType=BIGINT},#{lastLoginIp,jdbcType=VARCHAR},#{tuiGuangCode,jdbcType=VARCHAR},#{appId,jdbcType=VARCHAR},#{myHongBao,jdbcType=DECIMAL},#{payPassword,jdbcType=VARCHAR},#{system.id,jdbcType=BIGINT},#{rank,jdbcType=INTEGER},#{phone,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{stateDesc,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="openid != null">identifycode,</if>
            <if test="loginType != null">login_type,</if>
            <if test="wxOpenId != null">wx_open_id,</if>
            <if test="wxUnionId != null">wx_union_id,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="tbName != null">tbName,</if>
            <if test="tbPic != null">tbPic,</if>
            <if test="wxName != null">wxName,</if>
            <if test="wxPic != null">wxPic,</if>
            <if test="portrait != null">portrait,</if>
            <if test="createtime != null">createtime,</if>
            <if test="lastLoginTime != null">last_logintime,</if>
            <if test="lastLoginIp != null">loginip,</if>
            <if test="tuiGuangCode != null">tuiguang_code,</if>
            <if test="appId != null">appid,</if>
            <if test="myHongBao != null">my_hongBao,</if>
            <if test="payPassword != null">pay_password,</if>
            <if test="system != null">sid,</if>
            <if test="rank != null">rank,</if>
            <if test="phone != null">phone,</if>
            <if test="state != null">state,</if>
            <if test="stateDesc != null">state_desc,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="openid != null">#{openid,jdbcType=VARCHAR},</if>
            <if test="loginType != null">#{loginType,jdbcType=INTEGER},</if>
            <if test="wxOpenId != null">#{wxOpenId,jdbcType=VARCHAR},</if>
            <if test="wxUnionId != null">#{wxUnionId,jdbcType=VARCHAR},</if>
            <if test="nickName != null">#{nickName,jdbcType=VARCHAR},</if>
            <if test="tbName != null">#{tbName,jdbcType=VARCHAR},</if>
            <if test="tbPic != null">#{tbPic,jdbcType=VARCHAR},</if>
            <if test="wxName != null">#{wxName,jdbcType=VARCHAR},</if>
            <if test="wxPic != null">#{wxPic,jdbcType=VARCHAR},</if>
            <if test="portrait != null">#{portrait,jdbcType=VARCHAR},</if>
            <if test="createtime != null">#{createtime,jdbcType=BIGINT},</if>
            <if test="lastLoginTime != null">#{lastLoginTime,jdbcType=BIGINT},</if>
            <if test="lastLoginIp != null">#{lastLoginIp,jdbcType=VARCHAR},</if>
            <if test="tuiGuangCode != null">#{tuiGuangCode,jdbcType=VARCHAR},</if>
            <if test="appId != null">#{appId,jdbcType=VARCHAR},</if>
            <if test="myHongBao != null">#{myHongBao,jdbcType=DECIMAL},</if>
            <if test="payPassword != null">#{payPassword,jdbcType=VARCHAR},</if>
            <if test="system != null">#{system.id,jdbcType=BIGINT},</if>
            <if test="rank != null">#{rank,jdbcType=INTEGER},</if>
            <if test="phone != null">#{phone,jdbcType=VARCHAR},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">update
        yeshi_ec_user set identifycode = #{openid,jdbcType=VARCHAR},login_type
        = #{loginType,jdbcType=INTEGER},wx_open_id =
        #{wxOpenId,jdbcType=VARCHAR},wx_union_id =
        #{wxUnionId,jdbcType=VARCHAR},nick_name =
        #{nickName,jdbcType=VARCHAR},tbName = #{tbName,jdbcType=VARCHAR},tbPic
        = #{tbPic,jdbcType=VARCHAR},wxName = #{wxName,jdbcType=VARCHAR},wxPic
        = #{wxPic,jdbcType=VARCHAR},portrait =
        #{portrait,jdbcType=VARCHAR},createtime =
        #{createtime,jdbcType=BIGINT},last_logintime =
        #{lastLoginTime,jdbcType=BIGINT},loginip =
        #{lastLoginIp,jdbcType=VARCHAR},tuiguang_code =
        #{tuiGuangCode,jdbcType=VARCHAR},appid =
        #{appId,jdbcType=VARCHAR},my_hongBao =
        #{myHongBao,jdbcType=DECIMAL},pay_password =
        #{payPassword,jdbcType=VARCHAR},sid =
        #{system.id,jdbcType=BIGINT},rank = #{rank,jdbcType=INTEGER} ,phone
        =#{phone,jdbcType=VARCHAR} ,state =#{state,jdbcType=INTEGER}
        ,state_desc =#{stateDesc,jdbcType=VARCHAR} where id =
        #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.UserInfo">
        update yeshi_ec_user
        <set>
            <if test="openid != null">identifycode=#{openid,jdbcType=VARCHAR},</if>
            <if test="loginType != null">login_type=#{loginType,jdbcType=INTEGER},</if>
            <if test="wxOpenId != null">wx_open_id=#{wxOpenId,jdbcType=VARCHAR},</if>
            <if test="wxUnionId != null">wx_union_id=#{wxUnionId,jdbcType=VARCHAR},</if>
            <if test="nickName != null">nick_name=#{nickName,jdbcType=VARCHAR},</if>
            <if test="tbName != null">tbName=#{tbName,jdbcType=VARCHAR},</if>
            <if test="tbPic != null">tbPic=#{tbPic,jdbcType=VARCHAR},</if>
            <if test="wxName != null">wxName=#{wxName,jdbcType=VARCHAR},</if>
            <if test="wxPic != null">wxPic=#{wxPic,jdbcType=VARCHAR},</if>
            <if test="portrait != null">portrait=#{portrait,jdbcType=VARCHAR},</if>
            <if test="createtime != null">createtime=#{createtime,jdbcType=BIGINT},</if>
            <if test="lastLoginTime != null">last_logintime=#{lastLoginTime,jdbcType=BIGINT},</if>
            <if test="lastLoginIp != null">loginip=#{lastLoginIp,jdbcType=VARCHAR},</if>
            <if test="tuiGuangCode != null">tuiguang_code=#{tuiGuangCode,jdbcType=VARCHAR},</if>
            <if test="appId != null">appid=#{appId,jdbcType=VARCHAR},</if>
            <if test="myHongBao != null">my_hongBao=#{myHongBao,jdbcType=DECIMAL},</if>
            <if test="payPassword != null">pay_password=#{payPassword,jdbcType=VARCHAR},</if>
            <if test="system != null">sid=#{system.id,jdbcType=BIGINT},</if>
            <if test="rank != null">rank=#{rank,jdbcType=INTEGER},</if>
            <if test="phone !=null">phone =#{phone,jdbcType=VARCHAR},</if>
            <if test="state !=null">state =#{state,jdbcType=INTEGER},</if>
            <if test="stateDesc !=null">state_desc =#{stateDesc,jdbcType=VARCHAR},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="subHongBaoByUid">update yeshi_ec_user set my_hongBao=
        my_hongBao-#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
    </update>
    <update id="addHongBaoByUid">update yeshi_ec_user set my_hongBao=
        my_hongBao+#{money,jdbcType=DECIMAL} where id = #{uid,jdbcType=BIGINT}
    </update>
    <!-- 清除手势密码 -->
    <delete id="cleanPassword">DELETE FROM `yeshi_ec_extract_record` WHERE uid =
        #{id};
    </delete>
    <!-- 查询新人红包 -->
    <select id="getNewPeopleHB" resultType="BigDecimal">SELECT sum(hb.`money`)
        FROM `yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id} AND hb.`type` = '4';
    </select>
    <!-- 查询我的红包 -->
    <select id="getMyHB" resultType="BigDecimal">SELECT SUM(hb.`money`) FROM
        `yeshi_ec_hongbao` hb WHERE hb.`uid` = #{id};
    </select>
    <!-- 根据AppId与微信unionID获取用户 -->
    <select id="listByAppIdAndWXUnionId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and wx_union_id=#{unionId}
    </select>
    <!-- 根据AppId与淘宝OpenId获取用户 -->
    <select id="listByAppIdAndTaoBaoOpenId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and identifycode=#{openId}
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="listByAppIdAndPhone" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_user where appid=#{appId} and phone=#{phone}
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByPhone" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where phone=#{phone} AND state = 0
        LIMIT 1
    </select>
    <!-- 根据AppId与电话号码获取用户 -->
    <select id="getEffectiveUserInfoByWXUnionId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_user
        where wx_union_id=#{unionId} AND state = 0
        LIMIT 1
    </select>
    <select id="getMaxUid" resultType="java.lang.Long">select max(id) from
        yeshi_ec_user
    </select>
    <!-- 两个账号的业务融合 -->
    <select id="connectUser" >
     call procedure_connect_user(#{mainUid},#{lessUid})
    </select>
    <select id="query"  resultMap="BaseResultMapVO">
           SELECT *
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1 )AS totalOrder <!-- 累计订单 -->
           ,(SELECT COUNT(hb.hb_id) FROM `yeshi_ec_hongbao_v2` hb
                   WHERE hb.hb_uid = u.id AND hb.hb_type = 1
                   AND DATE_FORMAT(hb.`hb_create_time`,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m'))AS monthOrder <!-- 累计本月订单 -->
        ,(SELECT COUNT(tr.`id`) FROM `yeshi_ec_threesale` tr  <!-- 队员 -->
             WHERE  tr.`boss_id`=u.id AND tr.state = 1) AS totalPlayers
           FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
               LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
        <if test="userState == 2">
               LEFT JOIN
                (SELECT A.uid AS buid,MAX(A.f_wxUnionId) AS wxUnionIdInvalid ,MAX(A.f_taobaoUid) AS taobaoUidInvalid,MAX(A.f_phone) AS phoneInvalid,MAX(A.f_alipayAccount) AS alipayAccountInvalid FROM
                    (SELECT u.`id`AS uid,b.account AS alipayAccount,b.name AS alipayAccountName,fu.* FROM yeshi_ec_user u
                LEFT JOIN yeshi_ec_binding_account b ON b.`uid` = u.`id`
                LEFT JOIN yeshi_ec_user_info_extra_taobao tb ON  tb.`uiet_uid` = u.id
                LEFT JOIN (SELECT fc.fuc_effective,IF(fc.`fuc_type` = 'wxUnionId',fc.`fuc_identify_code`,NULL)AS f_wxUnionId,
                    IF(fc.`fuc_type` = 'taobaoUid',fc.`fuc_identify_code`,NULL)AS f_taobaoUid,
                    IF(fc.`fuc_type` = 'phone',fc.`fuc_identify_code`,NULL)AS f_phone,
                    IF(fc.`fuc_type` = 'alipayAccount',fc.`fuc_identify_code`,NULL)AS f_alipayAccount
                FROM yeshi_ec_forbidden_user_identify_code fc WHERE fc.fuc_effective = 1 )fu ON (fu.f_wxUnionId = u.`wx_union_id` OR fu.f_taobaoUid = tb.`uiet_taobao_uid` OR fu.f_phone = u.`phone` OR fu.f_alipayAccount = b.`account`)
                WHERE u.`state` =2
            )A GROUP BY A.uid) B ON u.id= B.buid
           </if>
           where 1=1
               <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
               <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
               </if>
               <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
               </if>
                  <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
               </if>
               <if test="days != null">
                    <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
            </if>
               <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
              ORDER BY
              <if test="orderField == 1">
                  totalOrder,
              </if>
              <if test="orderField == 2">
                  totalOrder DESC,
              </if>
              <if test="orderField == 3">
                  monthOrder,
              </if>
              <if test="orderField == 4">
                  monthOrder DESC,
              </if>
              <if test="orderField == 5">
                  totalPlayers,
              </if>
              <if test="orderField == 6">
                  totalPlayers DESC,
              </if>
              u.createtime DESC
              LIMIT ${start},${count}
    </select>
    <select id="queryCount" resultType="java.lang.Long">
           SELECT IFNULL(count(u.id),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
               LEFT JOIN yeshi_ec_user_info_extra  ext ON u.`id` = ext.uie_uid
               LEFT JOIN yeshi_ec_user_rank rak ON rak.ur_id = ext.uie_rank_id
           where 1=1
                <if test="userState == 1">
                   AND u.`state` <![CDATA[<>]]> 2 <!--  正常用户 -->
               </if>
               <if test="userState == 2">
                    AND u.`state` =2   <!-- 封禁用户 -->
               </if>
                <if test="startTime != null and startTime !='' ">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[>=]]> DATE_FORMAT(#{startTime},'%Y%m%d')
                </if>
                <if test="endTime != null and endTime !=''">
                   AND DATE_FORMAT(FROM_UNIXTIME(u.createtime/1000),'%Y%m%d')<![CDATA[<=]]> DATE_FORMAT(#{endTime},'%Y%m%d')
                </if>
                   <if test="userRank != null">
                   AND rak.ur_name = #{userRank}
                </if>
                <if test="days != null">  <!--  注册时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(u.createtime/1000)]]>
             </if>
             <if test="key != null and key !='' ">
                   <if test="keyType == 1">
                       AND    u.id  = #{key}
                   </if>
                   <if test="keyType == 2">
                       AND    u.`nick_name` LIKE '%${key}%'
                   </if>
                   <if test="keyType == 3">
                       AND    u.`phone` = #{key}
                   </if>
                   <if test="keyType == 4">
                       AND    b.`account` = #{key}
                   </if>
               </if>
    </select>
    <select id="querySumMoney" resultType="java.lang.Double">
           SELECT COALESCE(sum(u.my_hongBao),0) FROM yeshi_ec_user u
               LEFT JOIN yeshi_ec_binding_account  b ON u.`id` = b.`uid`
           where <![CDATA[ 1>0 ]]>
                <if test="key != null and key !='' ">
                   AND    (u.id LIKE '%${key}%' OR u.`phone` LIKE '%${key}%'  OR u.`wxName` LIKE '%${key}%'
                   OR u.`nick_name` LIKE '%${key}%'  OR u.`tbName` LIKE '%${key}%' OR b.`account` LIKE '%${key}%')
                </if>
                <if test="startTime != null and startTime !='' ">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) >= '${startTime}' ]]>
                </if>
                <if test="endTime != null and endTime !=''">
                   <![CDATA[ AND FROM_UNIXTIME(createtime/1000) < '${endTime}'  ]]>
                </if>
                   <if test="userType != null">
                   AND u.rank = #{userType}
                </if>
                  <if test="days != null">
                <!--  时间   -->
                    AND <![CDATA[DATE_SUB(CURDATE(), INTERVAL ${days} DAY) <= FROM_UNIXTIME(createtime/1000)]]>
            </if>
    </select>
    <select id="countNewUser" resultType="java.lang.Long">
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user`
           WHERE 1=1
                <if test="isToday != null and isToday == 1">
                AND TO_DAYS(FROM_UNIXTIME(createtime/1000)) = TO_DAYS(NOW())
            </if>
            <if test="isMonth != null and isMonth == 1">
                AND DATE_FORMAT( FROM_UNIXTIME(createtime/1000), '%Y%m' ) = DATE_FORMAT(CURDATE() , '%Y%m' )
            </if>
    </select>
    <select id="countRank" resultType="java.lang.Long">
       <!--  等级统计 -->
           SELECT COALESCE(count(id),0) FROM `yeshi_ec_user` WHERE rank = #{rank}
    </select>
    <select id="countAllMoney" resultType="java.math.BigDecimal">
       <!--  金额统计 -->
           SELECT CAST(SUM(my_hongBao)AS DECIMAL(19,2)) FROM `yeshi_ec_user`
           WHERE 1=1
               <if test="minMoney != null">
              AND <![CDATA[ my_hongBao >= #{minMoney}]]>
            </if>
    </select>
    <select id="countShareAndInviteMoney" resultMap="BaseResultMap">
        SELECT IFNULL(SUM(h.`money`),0),h.`uid` FROM `yeshi_ec_hongbao` h
        WHERE  DATE_FORMAT(FROM_UNIXTIME(h.`createtime`/1000), '%Y-%m-%d' )= '2018-08-02'
        <![CDATA[AND h.state <>4]]>
         AND ( h.`type` =5 OR  h.`type` =6 OR h.`type` =7 OR  h.`type` =20 OR h.`type` =21 OR h.`type` =22 )
        GROUP BY h.`uid`
        ORDER BY SUM(h.`money`) DESC
         LIMIT ${start},${count}
    </select>
    <select id="longTimeNoLogin"  resultType="java.lang.Long">
        SELECT u.`id` FROM `yeshi_ec_user` u
        WHERE  u.`id` IN <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
        AND <![CDATA[ (DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`last_logintime`/1000))
            OR (u.`last_logintime` IS NULL
                AND DATE_SUB(CURDATE(), INTERVAL ${daysNum} DAY) > DATE(FROM_UNIXTIME(u.`createTime`/1000)))) ]]>
    </select>
    <select id="countLoseUser" resultType="java.lang.Long">
        SELECT  COUNT(DISTINCT t.`id` ) FROM `yeshi_ec_user` t
        LEFT JOIN `yeshi_ec_user_money_detail` d ON d.`umd_uid` = t.`id`
        WHERE DATE_SUB(CURDATE(), INTERVAL ${num} DAY)<![CDATA[> ]]> DATE(FROM_UNIXTIME( t.`last_logintime`/1000))
               AND DATE_SUB(CURDATE(), INTERVAL ${num} DAY) <![CDATA[> ]]> DATE(d.`umd_createtime`)
    </select>
    <select id="countHasOrderUser" resultType="java.lang.Long">
        SELECT COUNT(DISTINCT h.`hb_uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE (h.`hb_type`=1 or  h.`hb_type`=2 or h.`hb_type`= 20)
    </select>
    <select id="countNewUserByDate" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT h.`id`) AS showValue,
            <if test="type == 1">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM yeshi_ec_user h
            <if test="channel != null and  channel != 'all' ">
                left join (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`)a ON h.`id`=a.uid
            </if>
        WHERE 1=1
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
        </if>
        ORDER BY h.`createtime`
    </select>
    <select id="getTodayHasOrder" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM  yeshi_ec_user u
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id`
        WHERE (h.`hb_type`=1 OR h.`hb_type`=20)
            <if test="channel != null and  channel != 'all' ">
                AND a.uid is not null
            </if>
            <!-- 当日下单 -->
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = DATE_FORMAT(h.hb_create_time,'%Y-%m-%d')
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="getWeekHasOrder" resultType="java.util.HashMap">
        SELECT COUNT(DISTINCT hb.uid) AS showValue,FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
        FROM (SELECT COUNT(v2.`hb_id`) AS num,v2.hb_uid  AS uid
              FROM yeshi_ec_hongbao_v2 v2
              WHERE   (v2.`hb_type`=1 OR v2.`hb_type`=20)
                  AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ >= ]]>'${startTime}'
                 AND DATE_FORMAT(v2.`hb_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
              GROUP BY v2.hb_uid HAVING num >= ${orderNum})hb
        LEFT JOIN yeshi_ec_user u  ON u.id = hb.uid
        <if test="channel != null and channel != 'all' ">
            LEFT JOIN  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON u.`id`=a.uid
        </if>
        WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '${startTime}'
            <if test="channel != null and  channel != 'all' ">
               AND a.uid is not null
            </if>
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        ORDER BY u.`createtime`
    </select>
    <select id="getInfoByPhoneOrInviteCode" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_user u
        LEFT JOIN yeshi_ec_user_info_extra uf ON uf.`uie_uid` = u.`id`
        WHERE uf.`uie_invite_code` IS NOT NULL
              AND (u.`phone` =#{phone} OR uf.`uie_invite_code` = #{inviteCode})
        LIMIT 1
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -298,9 +298,7 @@
                    }
                    // 实付款
                    commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement);
                    listOrderGoods.add(commonGoodsVO);
                    Integer orderType = order.getOrderType();
                    if (orderType == null) {
                        String shopType = commonGoodsVO.getShopType();
@@ -309,14 +307,8 @@
                        } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
                            order.setOrderType(2);
                        } 
                        if (Constant.SOURCE_TYPE_JD == sourceType2) {
                            order.setOrderType(3);
                        } else if (Constant.SOURCE_TYPE_PDD == sourceType2) {
                            order.setOrderType(4);
                        }
                    }
                    listOrderGoods.add(commonGoodsVO);
                    break;
                }
            }
@@ -341,6 +333,18 @@
            if (settleTime != null) {
                order.setReceiveTime("收货时间:" + format.format(settleTime));
            }
            Integer sourceType2 = order.getSourceType();
            if (sourceType2 == Constant.SOURCE_TYPE_TAOBAO) {
                Integer orderType = order.getOrderType();
                if (orderType == null) {
                     order.setOrderType(1);
                }
            } else if (sourceType2 == Constant.SOURCE_TYPE_JD) {
                 order.setOrderType(3);
            }  else if (sourceType2 == Constant.SOURCE_TYPE_PDD) {
                 order.setOrderType(4);
            }
            /* 订单状态 转换处理 */
            String orderStateContent = "";
fanli/src/main/java/com/yeshi/fanli/service/impl/pdd/PDDGoodsServiceImpl.java
@@ -151,7 +151,7 @@
    @Override
    @Cacheable(value = "pddSpecialCache", key = "'getIndexPDDGoods-'+#page")
    public PDDGoodsResult getIndexPDDGoods(int page) {
        return PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page-1, Constant.PAGE_SIZE, 1);
        return PinDuoDuoApiUtil.getTopList(PinDuoDuoApiUtil.PID_FANLI, page, Constant.PAGE_SIZE, 1);
    }
    
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -32,6 +32,7 @@
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.util.CommonGoodsUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
@@ -403,7 +404,6 @@
            throw new UserGoodsStorageException(1, "选品库商品不存在");
        }
        
        List<UserGoodsStorage> listResult = new ArrayList<UserGoodsStorage>();
        // 还原顺序 用于制图
        for (Long sid: listStorageID) {
@@ -417,30 +417,24 @@
        }
        
        BigDecimal totalMoney = new BigDecimal(0.00);
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        
        Integer goodsType = null;
        BigDecimal rate = hongBaoManageService.getShareRate();
        for (UserGoodsStorage userGoodsStorage: listResult) {
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            if (goodsType == null) {
                goodsType = commonGoods.getGoodsType();
            }
            TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
            listGoodsBrief.add(goodsBrief);
            BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, rate);
            BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
            listCommonGoods.add(commonGoods);
        }
        
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listGoodsBrief, listStorageID);
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods, listStorageID);
        FileUploadResult uploadResult = new FileUploadResult();
        uploadResult.setUrl(shareRecord.getSharePictureUrl());
        
        JSONObject data = new JSONObject();
        data.put("revenue", listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney);
        data.put("revenue", listCommonGoods.size() + "个商品预估分享奖金:¥"+totalMoney);
        data.put("shareId", shareRecord.getRedisKey());
        data.put("shareImg", uploadResult);
        
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -726,17 +726,23 @@
            userInfoVO.setLastLoginTime(null);
        }
        /*
         * 显示用户微信 淘宝 老版本存在 String wxUnionId = userInfoVO.getWxUnionId(); if
         * (wxUnionId == null || wxUnionId.trim().length() == 0) {
         * userInfoVO.setWxName(null); }
         *
         * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null
         * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
         */
         //显示用户微信 淘宝 老版本存在
         String wxUnionId = userInfoVO.getWxUnionId();
         if (wxUnionId == null || wxUnionId.trim().length() == 0) {
             userInfoVO.setWxName(null);
         }
         // 是否绑定支付宝(购买 +  分享权限)
         String taoBaoUid = userInfoVO.getTaoBaoUid();
         String tbSpecialId = userInfoVO.getTbSpecialId();
         String tbRelationId = userInfoVO.getTbRelationId();
         if (StringUtil.isNullOrEmpty(taoBaoUid) || StringUtil.isNullOrEmpty(tbSpecialId) || StringUtil.isNullOrEmpty(tbRelationId)) {
             userInfoVO.setTbName(null);
             userInfoVO.setTaoBaoUid(null);
         }
        Long uid = userInfoVO.getId();
        /* 绑定收款账号信息 */
        List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
        if (account != null && account.size() > 0) {
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -326,16 +326,14 @@
     * @param listGoods
     */
    @Transactional
    public void multipleGoodsShareRecord(Long shareId, List<TaoBaoGoodsBrief> listGoods)
    public void multipleGoodsShareRecord(Long shareId, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
        // 分享记录
        Date date = new Date();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
        for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
            CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
            commonGoods.setState(taoBaoGoodsBrief.getState());
        for (CommonGoods commonGoods : listGoods) {
            try {
                CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
@@ -690,18 +688,24 @@
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoodsBrief(listGoodsBrief);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.storage);
@@ -715,9 +719,9 @@
    }
    
    @Override
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief, List<Long> listStorageID)
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listGoods, List<Long> listStorageID)
            throws UserShareGoodsRecordException {
        if (uid == null || uid <= 0 || listGoodsBrief == null || listGoodsBrief.size() == 0) {
        if (uid == null || uid <= 0 || listGoods == null || listGoods.size() == 0) {
            throw new UserShareGoodsRecordException(1, "传递参数不正确");
        }
        // 插入记录
@@ -725,7 +729,7 @@
        record.setUid(uid);
        record.setShareState(0); // 初始未分享
        record.setSource(ShareSourceTypeEnum.storage);
        record.setPicture(listGoodsBrief.get(0).getPictUrl()); // 取一个商品图片作为主图
        record.setPicture(listGoods.get(0).getPicture()); // 取一个商品图片作为主图
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
@@ -733,14 +737,14 @@
        // 分享链接
        String shareUrl = getShareUrlV2(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoods);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListId(listStorageID);
        recordDTO.setListGoodsBrief(listGoodsBrief);
        recordDTO.setListGoods(listGoods);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.storage);
@@ -770,16 +774,21 @@
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
        // 分享二维码链接
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listGoodsBrief);
        FileUploadResult uploadResult = drawingSharePicture(uid, id, shareUrl, listCommonGoods);
        ShareGoodsRecordDTO recordDTO = new ShareGoodsRecordDTO();
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setListGoodsBrief(listGoodsBrief);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setSharePictureUrl(uploadResult.getUrl());
        recordDTO.setSource(ShareSourceTypeEnum.activity);
@@ -808,6 +817,11 @@
        record.setCreateTime(new Date());
        userShareGoodsRecordMapper.insertSelective(record);
        List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
        for (TaoBaoGoodsBrief goodsBrief: listGoodsBrief) {
            listCommonGoods.add(CommonGoodsFactory.create(goodsBrief));
        }
        Long id = record.getId();
        // 分享链接
        String shareUrl = getShareUrl(record);
@@ -816,7 +830,7 @@
        recordDTO.setUid(uid);
        recordDTO.setShareId(id);
        recordDTO.setShareUrl(shareUrl);
        recordDTO.setListGoodsBrief(listGoodsBrief);
        recordDTO.setListGoods(listCommonGoods);
        recordDTO.setSource(ShareSourceTypeEnum.activity);
        // 缓存分享商品信息
@@ -857,7 +871,7 @@
            updateByPrimaryKeySelective(shareRecord);
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
        } else if (ShareSourceTypeEnum.storage.equals(source)) {
            // 分享库分享
@@ -868,7 +882,7 @@
            updateByPrimaryKeySelective(shareRecord);
            // 保存商品信息
            multipleGoodsShareRecord(shareId, recordDTO.getListGoodsBrief());
            multipleGoodsShareRecord(shareId, recordDTO.getListGoods());
            
            // 更新选品库商品状态 为已分享
            List<Long> listId = recordDTO.getListId();
@@ -938,7 +952,7 @@
     * @return
     * @throws UserShareGoodsRecordException
     */
    public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<TaoBaoGoodsBrief> listGoods)
    public FileUploadResult drawingSharePicture(Long uid, Long shareId, String url, List<CommonGoods> listGoods)
            throws UserShareGoodsRecordException {
        InputStream erCodeInputStream = null;
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java
@@ -5,6 +5,7 @@
import com.yeshi.fanli.dto.share.ShareGoodsRecordDTO;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
@@ -143,7 +144,7 @@
    public List<UserShareGoodsGroup> listByRecordId(Long shareId);
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<TaoBaoGoodsBrief> listGoodsBrief,
    public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listCommonGoods,
            List<Long> listStorageID) throws UserShareGoodsRecordException;
    
}
fanli/src/main/java/com/yeshi/fanli/util/CommonGoodsUtil.java
@@ -58,4 +58,28 @@
        }
        return BigDecimalUtil.getWithNoZera(money);
    }
    /**
     * 计算商品券后价,没有券则返回原价
     *
     * @param goodsBrief
     * @return
     */
    public static BigDecimal getAfterUseCouplePrice(CommonGoods goods) {
        if (StringUtil.isNullOrEmpty(goods.getCouponInfo()) || "无".equals(goods.getCouponInfo())) {
            return goods.getPrice();
        } else {
            List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goods.getCouponInfo());
            BigDecimal startFee = list.get(0);
            BigDecimal couponAccount = list.get(1);
            if (startFee.compareTo(goods.getPrice()) <= 0
                    && goods.getPrice().compareTo(couponAccount) > 0) {
                BigDecimal finalPrice = goods.getPrice().subtract(couponAccount);
                return finalPrice;
            } else {// 不能用券
                return goods.getPrice();
            }
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/util/ImageUtil.java
@@ -33,6 +33,7 @@
import org.yeshi.utils.entity.DateInfo;
import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
@@ -763,7 +764,7 @@
     * @return
     */
    public static InputStream drawGoodsSharePicture(InputStream qrcodeStream, InputStream portrait,
            List<TaoBaoGoodsBrief> goodsList) {
            List<CommonGoods> goodsList) {
        String fontPath = "/usr/share/fonts/PingFang_Medium.ttf";
        String os = System.getProperty("os.name");
@@ -809,8 +810,8 @@
        try {
            // 画第一张
            for (int i = 0; i < goodsList.size(); i++) {
                TaoBaoGoodsBrief goods = goodsList.get(i);
                BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
                CommonGoods goods = goodsList.get(i);
                BigDecimal couplePrice = CommonGoodsUtil.getAfterUseCouplePrice(goods);
                // 第一张图需要有价格信息
                if (i == 0) {
                    int topX = 50;
@@ -820,7 +821,7 @@
                    // 画大图 起始点坐标为(50,50)
                    int widht = 650;
                    int height = 650;
                    InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPictUrl().replace("_.webp", "").replace("_220x220", ""));
                    InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPicture().replace("_.webp", "").replace("_220x220", ""));
                    BufferedImage picImage = ImageIO.read(goodsPicture);
                    picImage = ImageUtil.zoomInImage(picImage, widht, height);
                    g2d.drawImage(picImage, topX, topX, null);
@@ -909,7 +910,7 @@
                    // 画大图
                    InputStream goodsPicture = TaoBaoHttpUtil
                            .getAsInputStream(goods.getPictUrl().replace("_.webp", ""));
                            .getAsInputStream(goods.getPicture().replace("_.webp", ""));
                    BufferedImage picImage = ImageIO.read(goodsPicture);
                    picImage = ImageUtil.zoomInImage(picImage, 315, 315);
                    g2d.drawImage(picImage, topX, topY, null);
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -318,6 +318,20 @@
    
    private static JDGoods parseJDGoods(JSONObject json) {
        JDGoods goods = new JDGoods();
        // 佣金信息
        Object commission = json.get("commissionInfo");
        JSONObject commissionJson = JSONObject.fromObject(commission);
        BigDecimal commissionShare = new BigDecimal(commissionJson.optString("commissionShare"));
        if (commissionShare.compareTo(new BigDecimal(0)) > 0) {
            JDCommissionInfo commissionInfo = new JDCommissionInfo();
            commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
            commissionInfo.setCommissionShare(commissionShare);
            goods.setCommissionInfo(commissionInfo);
        } else {
            return null;
        }
        goods.setComments(json.optLong("comments"));
        goods.setBrandCode(json.optString("brandCode"));
        goods.setBrandName(json.optString("brandName"));
@@ -356,14 +370,6 @@
        categoryInfo.setCid3Name(categoryJson.optString("cid3Name"));
        goods.setCategoryInfo(categoryInfo);
        
        // 佣金信息
        Object commission = json.get("commissionInfo");
        JSONObject commissionJson = JSONObject.fromObject(commission);
        JDCommissionInfo commissionInfo = new JDCommissionInfo();
        commissionInfo.setCommission(new BigDecimal(commissionJson.optString("commission")));
        commissionInfo.setCommissionShare(new BigDecimal(commissionJson.optString("commissionShare")));
        goods.setCommissionInfo(commissionInfo);
        
        // 图片信息
        List<String> imageList = new ArrayList<String>();
@@ -468,7 +474,6 @@
        if (resultJson.optInt("code") == 0) {
            result = resultJson.optString("result");
            resultJson = JSONObject.fromObject(result);
            System.out.println(resultJson);
            JSONArray array = resultJson.optJSONArray("data");
            if (array != null)
                for (int i = 0; i < array.size(); i++) {
@@ -482,7 +487,21 @@
    private static JDGoods parseSimpleJDGoods(JSONObject json) {
        JDGoods goods = new JDGoods();
        goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
                ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
        BigDecimal commisionRatioWl = new BigDecimal(json.optString("commisionRatioWl"));
        if (commisionRatioWl.compareTo(new BigDecimal(0)) > 0) {
            JDCommissionInfo commissionInfo = new JDCommissionInfo();
            commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
            commissionInfo.setCommission(MoneyBigDecimalUtil
                    .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
            goods.setCommissionInfo(commissionInfo);
        } else {
            return null;
        }
        JDCategoryInfo categoryInfo = new JDCategoryInfo();
        categoryInfo.setCid1(json.optLong("cid1"));
        categoryInfo.setCid1Name(json.optString("cid1Name"));
@@ -493,21 +512,12 @@
        goods.setCategoryInfo(categoryInfo);
        goods.setComments(null);
        goods.setPrice(StringUtil.isNullOrEmpty(json.optString("wlUnitPrice"))
                ? new BigDecimal(json.optString("unitPrice")) : new BigDecimal(json.optString("wlUnitPrice")));
        JDCommissionInfo commissionInfo = new JDCommissionInfo();
        commissionInfo.setCommissionShare(new BigDecimal(json.optString("commisionRatioWl")));
        commissionInfo.setCommission(MoneyBigDecimalUtil
                .div(goods.getPrice().multiply(commissionInfo.getCommissionShare()), new BigDecimal(100)));
        String isFreeShipping = json.optString("isFreeShipping");
        if (!StringUtil.isNullOrEmpty(isFreeShipping)) {
            goods.setIsFreeShipping(Integer.parseInt(isFreeShipping));
        }
        
        goods.setCommissionInfo(commissionInfo);
        goods.setCouponInfo(null);
        goods.setGoodCommentsShare(null);
        List<String> imageList = new ArrayList<>();
fanli/src/main/java/com/yeshi/fanli/util/jd/JDUtil.java
@@ -184,7 +184,10 @@
                    JSONArray array = json.optJSONObject("data").optJSONArray("unionGoods");
                    if (array != null) {
                        for (int i = 0; i < array.size(); i++) {
                            goodsList.add(parseGoods(array.optJSONArray(i).optJSONObject(0).toString()));
                            JDGoods parseGoods = parseGoods(array.optJSONArray(i).optJSONObject(0).toString());
                            if (parseGoods != null) {
                                goodsList.add(parseGoods);
                            }
                        }
                    }
                }
@@ -240,7 +243,10 @@
                    JSONArray array = json.optJSONObject("data").optJSONArray("unionRecommendGoods");
                    if (array != null) {
                        for (int i = 0; i < array.size(); i++) {
                            goodsList.add(parseGoods(array.optJSONArray(i).optJSONObject(0).toString()));
                            JDGoods parseGoods = parseGoods(array.optJSONArray(i).optJSONObject(0).toString());
                            if (parseGoods != null) {
                                goodsList.add(parseGoods);
                            }
                        }
                    }
                }
@@ -264,12 +270,23 @@
        return null;
    }
    private static JDGoods parseGoods(String data) {
        JDGoods goods = new JDGoods();
        JSONObject json = JSONObject.fromObject(data);
        BigDecimal wlCommissionRatio = new BigDecimal(json.optString("wlCommissionRatio"));
        if (wlCommissionRatio.compareTo(new BigDecimal(0)) > 0) {
            JDCommissionInfo commission = new JDCommissionInfo();
            commission.setCommission(new BigDecimal(json.optString("wlCommission")));
            commission.setCommissionShare(wlCommissionRatio);
            goods.setCommissionInfo(commission);
        } else {
            return null; // 过滤无返利商品
        }
        goods.setSkuId(json.optLong("skuId"));
        goods.setSkuName(json.optString("skuName"));
        
        JDShopInfo shopInfo = new JDShopInfo();
        shopInfo.setShopId(json.optInt("shopId"));
@@ -286,10 +303,7 @@
        
        goods.setMaterialUrl("https://item.jd.com/"+ json.optLong("skuId") +".html");
        goods.setPicUrl("http://img14.360buyimg.com/n1/" + json.optString("materialUrl"));
        JDCommissionInfo commission = new JDCommissionInfo();
        commission.setCommission(new BigDecimal(json.optString("wlCommission")));
        commission.setCommissionShare(new BigDecimal(json.optString("wlCommissionRatio")));
        goods.setCommissionInfo(commission);
        goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
        // 团购信息
@@ -301,16 +315,20 @@
        } 
        
        
        // 券信息
        BigDecimal finalPrice = new BigDecimal(json.optString("finalPrice"));
        if (finalPrice != null && json.optString("hasCoupon") != null && json.optInt("hasCoupon") == 1
                && json.optInt("couponRemainCnt") > 0) {
            JDCouponInfo coupon = new JDCouponInfo();
            coupon.setDiscount(new BigDecimal(json.optString("couponDiscount")));
            coupon.setQuota(new BigDecimal(json.optString("couponQuota")));
            coupon.setLink("https:" + json.optString("couponLink"));
            goods.setCouponInfo(coupon);
        }
        String finalPrice = json.optString("finalPrice");
        if (!StringUtil.isNullOrEmpty(finalPrice)) {
            // 券信息
            BigDecimal finalPriceDecimal = new BigDecimal(json.optString("finalPrice"));
            if (finalPriceDecimal != null && json.optString("hasCoupon") != null && json.optInt("hasCoupon") == 1
                    && json.optInt("couponRemainCnt") > 0) {
                JDCouponInfo coupon = new JDCouponInfo();
                coupon.setDiscount(new BigDecimal(json.optString("couponDiscount")));
                coupon.setQuota(new BigDecimal(json.optString("couponQuota")));
                coupon.setLink("https:" + json.optString("couponLink"));
                goods.setCouponInfo(coupon);
            }
        }
        
        return goods;
    }
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -178,7 +178,7 @@
    public static PDDGoodsResult getTopList(String pid, Integer page, Integer pageSize, Integer sortType) {
        Map<String, String> map = new HashMap<>();
        map.put("type", "pdd.ddk.top.goods.list.query");
        map.put("offset", (page == null? 0: page) +"");
        map.put("offset", (page == null? 0: (page-1) * Constant.PAGE_SIZE) +"");
        map.put("limit", (pageSize == null? Constant.PAGE_SIZE : pageSize) +"");
        
        if (!StringUtil.isNullOrEmpty(pid))
@@ -195,7 +195,8 @@
        
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
        int totalCount = root.optInt("total");
        //int totalCount = root.optInt("total");
        int totalCount = 400; // 默认设置成400
        return new PDDGoodsResult(totalCount, goodsList);
    }
fanli/src/main/java/com/yeshi/fanli/vo/user/UserInfoVO.java
@@ -78,6 +78,11 @@
    private String phoneInvalid; // 手机号
    private String alipayAccountInvalid; // 支付宝账号
    private String tbSpecialId;
    private String tbRelationId;
    public String getRankId() {
        return rankId;
@@ -318,5 +323,21 @@
    public void setAlipayAccountInvalid(String alipayAccountInvalid) {
        this.alipayAccountInvalid = alipayAccountInvalid;
    }
    public String getTbSpecialId() {
        return tbSpecialId;
    }
    public void setTbSpecialId(String tbSpecialId) {
        this.tbSpecialId = tbSpecialId;
    }
    public String getTbRelationId() {
        return tbRelationId;
    }
    public void setTbRelationId(String tbRelationId) {
        this.tbRelationId = tbRelationId;
    }
    
}