admin
2018-12-06 389d0c6d923532e3af63582e37946a5cda1fa90b
浏览记录调整
邀请更改
13个文件已修改
581 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/goods/ScanHistoryV2Mapper.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/ThreeSale.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml 59 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/goods/ScanHistoryV2Mapper.xml 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonGoodsService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ScanHistoryV2Service.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java
@@ -5,7 +5,6 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -45,11 +44,11 @@
import com.yeshi.fanli.entity.common.JumpDetail;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.goods.CommonGoods;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.entity.taobao.ClientTBPid;
import com.yeshi.fanli.entity.taobao.PidUser;
import com.yeshi.fanli.entity.taobao.ScanHistory;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TBPid;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
@@ -58,6 +57,8 @@
import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
import com.yeshi.fanli.exception.goods.CommonGoodsException;
import com.yeshi.fanli.exception.goods.ScanHistoryException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.log.LogHelper;
@@ -71,6 +72,7 @@
import com.yeshi.fanli.service.inter.goods.HonestService;
import com.yeshi.fanli.service.inter.goods.RecommendBannerService;
import com.yeshi.fanli.service.inter.goods.RecommendSectionGoodsService;
import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerService;
import com.yeshi.fanli.service.inter.goods.SuperRecommendBannerV2Service;
import com.yeshi.fanli.service.inter.goods.SuperRecommendSectionService;
@@ -86,7 +88,6 @@
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
import com.yeshi.fanli.service.inter.user.ScanHistoryService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
import com.yeshi.fanli.service.inter.user.ShareManageService;
import com.yeshi.fanli.service.inter.user.TBPidService;
@@ -132,7 +133,7 @@
    private OrderService orderService;
    @Resource
    private ScanHistoryService scanHistoryService;
    private ScanHistoryV2Service scanHistoryV2Service;
    @Resource
    private ShareManageService shareManageService;
@@ -739,16 +740,9 @@
            ThreadUtil.run(new Runnable() {
                public void run() {
                    // 添加浏览记录
                    ScanHistory sh = TaoBaoUtil.getScanHistory(tbb);
                    sh.setDevice(acceptData.getDevice());
                    sh.setSystem(systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
                    sh.setCreatetime(new Date());
                    if (uid != null && !uid.equals("")) {
                        sh.setUid(Long.parseLong(uid));
                    }
                    try {
                        scanHistoryService.addScanHistory(sh);
                        scanHistoryV2Service.addScanHistory(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid),
                                acceptData.getDevice(), tbb);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
@@ -1051,25 +1045,17 @@
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                ScanHistory sh = TaoBaoUtil.getScanHistory(goodsInfo);
                sh.setId(0);
                sh.setDevice(acceptData.getDevice());
                sh.setSystem(systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
                sh.setCreatetime(new Date());
                if (!StringUtil.isNullOrEmpty(tempUid)) {
                    sh.setUid(Long.parseLong(tempUid));
                }
                try {
                    scanHistoryService.addScanHistory(sh);
                } catch (Exception e) {
                    scanHistoryV2Service.addScanHistory(
                            StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(),
                            goodsInfo);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                } catch (CommonGoodsException e) {
                    e.printStackTrace();
                } catch (ScanHistoryException e) {
                    e.printStackTrace();
                }
                // try {
                // taoBaoGoodsBriefService.updateTBGoodsWithNewInfo(goodsInfo);
                // } catch (Exception e) {
                //
                // }
            }
        });
    }
@@ -1296,13 +1282,10 @@
            out.print(JsonUtil.loadFalseResult(1, "不存在该系统"));
            return;
        }
        boolean b = NumberUtil.isNumeric(uid);
        long id = 0;
        if (b) {
            id = Long.parseLong(uid);
        }
        List<ScanHistory> list = scanHistoryService.getScanHistory(sys.getId(), acceptData.getDevice(), page, 20, id);
        long count = scanHistoryService.getScanHistoryCount(sys.getId(), acceptData.getDevice(), id);
        List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid(
                StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(), page, 20);
        long count = scanHistoryV2Service.getCountByDeviceOrUid(
                StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice());
        JSONObject data = new JSONObject();
        data.put("count", count);
        JSONArray array = new JSONArray();
@@ -1311,10 +1294,10 @@
            Map<String, String> map = hongBaoManageService.convertMap();
            String proportion = map.get("hongbao_goods_proportion");
            String fcRate = map.get("hongbao_fc_ratio");
            for (ScanHistory sh : list) {
                sh.setSalesCount(TaoBaoUtil.getSaleCount(sh.getBiz30day()));
                array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.getTaoBaoGoodsBrief(sh),
                        proportion, fcRate, "")));
            for (ScanHistoryV2 sh : list) {
                TaoBaoGoodsBrief goods = TaoBaoUtil.convert(sh.getCommonGoods());
                goods.setId(sh.getId());
                array.add(gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goods, proportion, fcRate, "")));
            }
        }
        data.put("data", array);
@@ -1331,18 +1314,16 @@
            return;
        }
        long id = 0;
        if (NumberUtil.isNumeric(uid)) {
            id = Long.parseLong(uid);
        }
        if ("0".equals(type)) {
            String[] idStr = ids.split(",");
            for (String auctionIdStr : idStr) {
                scanHistoryService.deleteScanHistory(acceptData.getDevice(), sys, Long.parseLong(auctionIdStr), id);
                scanHistoryV2Service.deleteByAuctionIdAndDeviceOrUid(
                        StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid), acceptData.getDevice(),
                        Long.parseLong(auctionIdStr));
            }
        } else {
            scanHistoryService.deleteScanHistory(acceptData.getDevice(), sys, id);
            scanHistoryV2Service.deleteByDeviceOrUid(StringUtil.isNullOrEmpty(uid) ? null : Long.parseLong(uid),
                    acceptData.getDevice());
        }
        out.print(JsonUtil.loadTrueResult(""));
@@ -1991,16 +1972,10 @@
        ThreadUtil.run(new Runnable() {
            public void run() {
                // 添加浏览记录
                ScanHistory sh = TaoBaoUtil.getScanHistory(goodsInfo);
                sh.setId(0);
                sh.setDevice(acceptData.getDevice());
                sh.setSystem(systemService.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
                sh.setCreatetime(new Date());
                if (!StringUtil.isNullOrEmpty(tempUid)) {
                    sh.setUid(Long.parseLong(tempUid));
                }
                try {
                    scanHistoryService.addScanHistory(sh);
                    scanHistoryV2Service.addScanHistory(
                            StringUtil.isNullOrEmpty(tempUid) ? null : Long.parseLong(tempUid), acceptData.getDevice(),
                            goodsInfo);
                } catch (Exception e) {
                    e.printStackTrace();
                }
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java
@@ -29,20 +29,21 @@
    
    /**
     * 查询一度队员集合
     *
     * @param start
     * @param count
     * @param key
     * @param uid
     * @return
     */
    List<ThreeSale> queryMyFirstTeamList(@Param("start") int start, @Param("count") int count,
            @Param("key") String key,@Param("bossId") Long bossId);
    List<ThreeSale> queryMyFirstTeamList(@Param("start") int start, @Param("count") int count, @Param("key") String key,
            @Param("bossId") Long bossId);
    
    long queryCountMyFirstTeamList(@Param("key") String key,@Param("bossId") Long bossId);
    
    /**
     * 查询二度队员集合
     *
     * @param start
     * @param count
     * @param key
@@ -54,25 +55,25 @@
    
    long queryCountMySecondTeamList(@Param("key") String key,@Param("bossId") Long bossId);
    
    /**
     * 长时间未邀请成功用户
     *
     * @param daysNum
     * @return
     */
    List<Long> queryLongTimeFailed(@Param("daysNum") int daysNum);
    
    /**
     * 长时间 邀请成功用户
     *
     * @param daysNum
     * @return
     */
    List<ThreeSale> queryLongTimeSuccess(@Param("daysNum") int daysNum);
    
    /**
     * 设置对应邀请过期
     *
     * @param list
     * @return
     */
@@ -80,6 +81,7 @@
    
    /**
     * 一级查询
     *
     * @param start
     * @param count
     * @param key
@@ -90,12 +92,12 @@
    List<ThreeSale> listFirstTeamQuery(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid, 
            @Param("state")Integer state, @Param("startTime") String startTime, @Param("endTime") String endTime);
    
    long countFirstTeamQuery(@Param("uid") Long uid, @Param("state")Integer state, @Param("startTime") String startTime,
            @Param("endTime") String endTime);
    long countFirstTeamQuery(@Param("uid") Long uid, @Param("state") Integer state,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    
    /**
     * 二级查询
     *
     * @param start
     * @param count
     * @param key
@@ -106,13 +108,12 @@
    List<ThreeSale> listSecondTeamQuery(@Param("start")long start, @Param("count")int count, @Param("uid")Long uid, 
            @Param("state")Integer state, @Param("startTime")String startTime, @Param("endTime")String endTime);
    
    long countSecondTeamQuery(@Param("uid")Long uid, @Param("state")Integer state, @Param("startTime")String startTime,
            @Param("endTime") String endTime);
    long countSecondTeamQuery(@Param("uid") Long uid, @Param("state") Integer state,
            @Param("startTime") String startTime, @Param("endTime") String endTime);
    
    /**
     * 上级查询
     *
     * @param start
     * @param count
     * @param uid
@@ -123,9 +124,9 @@
    
    long countSuperiorQuery(@Param("state")Integer state, @Param("uid") Long uid);
    
    /**
     * 查询一级队员
     *
     * @param paramLong
     * @param paramInt
     * @param paramLong1
@@ -135,6 +136,7 @@
    /**
     * 统计一级队员
     *
     * @param uid
     * @param state
     * @return
@@ -143,6 +145,7 @@
    /**
     * 查询二级队员
     *
     * @param start
     * @param count
     * @param uid
@@ -152,6 +155,7 @@
    /**
     * 统计二级队员
     *
     * @param uid
     * @param state
     * @return
@@ -167,10 +171,18 @@
    
    /**
     * 根据id、uid查询
     *
     * @param id
     * @param uid
     * @return
     */
    List<ThreeSale> listbyIdAndBossId(@Param("id")Long id, @Param("uid") Long uid, @Param("expire") Integer expire);
    
    /**
     * 根据邀请者ID查询关系
     *
     * @param workerId
     * @return
     */
    List<ThreeSale> listByWorkerId(Long workerId);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/goods/ScanHistoryV2Mapper.java
@@ -1,8 +1,54 @@
package com.yeshi.fanli.dao.mybatis.goods;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
public interface ScanHistoryV2Mapper extends BaseMapper<ScanHistoryV2> {
    /**
     * 根据UID或者设备号获取浏览记录
     *
     * @param uid
     * @param device
     * @param start
     * @param count
     * @return
     */
    List<ScanHistoryV2> selectByDeviceOrUid(@Param("uid") Long uid, @Param("device") String device,
            @Param("start") long start, @Param("count") int count);
    /**
     * 根据UID或者设备号获取浏览记录条数
     *
     * @param uid
     * @param device
     * @return
     */
    Long selectCountByDeviceOrUid(@Param("uid") Long uid, @Param("device") String device);
    /**
     * 根据设备或用户ID删除
     *
     * @param uid
     * @param device
     * @return
     */
    int deleteByDeviceOrUid(@Param("uid") Long uid, @Param("device") String device);
    /**
     * 根据设备或用户ID与商品信息检索
     *
     * @param uid
     * @param device
     * @param goodsId
     * @param goodsType
     * @return
     */
    List<ScanHistoryV2> selectByDeviceOrUidAndGoodsIdAndGoodsType(@Param("uid") Long uid,
            @Param("device") String device, @Param("goodsId") long goodsId, @Param("goodsType") int goodsType);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/ThreeSale.java
@@ -24,6 +24,9 @@
@org.yeshi.utils.mybatis.Table("yeshi_ec_threeSale")
public class ThreeSale {
    public static int EXPIRE_NORMAL = 0;// 正常状态
    public static int EXPIRE_OUTOFDATE = 1;// 过期状态
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -40,7 +40,8 @@
            
    </resultMap>
    
    <sql id="Base_Column_List">id,boss_id,worker_id,state,expire,succeedTime,createTime,updateTime</sql>
    <sql id="Base_Column_List">id,boss_id,worker_id,state,expire,succeedTime,createTime,updateTime
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
@@ -69,13 +70,23 @@
    <!-- 根据邀请者ID查询关系 -->
    <select id="listByWorkerId" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_threeSale s where worker_id = #{0}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_threeSale where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threeSale
        (id,boss_id,worker_id,state,expire,succeedTime,createTime,updateTime) values
        (id,boss_id,worker_id,state,expire,succeedTime,createTime,updateTime)
        values
        (#{id,jdbcType=BIGINT},#{boss.id,jdbcType=BIGINT},#{worker.id,jdbcType=BIGINT},#{state,jdbcType=BOOLEAN},#{expire,jdbcType=INTEGER},#{succeedTime,jdbcType=BIGINT},#{createTime,jdbcType=BIGINT},#{updateTime,jdbcType=BIGINT})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSale"
@@ -132,13 +143,15 @@
        update     yeshi_ec_threeSale t set t.state=1, 
        t.succeedTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>,
        t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>
        where t.state=0 and t.worker_id=#{0}  AND (t.expire = 0  OR  t.expire IS NULL)
        where t.state=0 and t.worker_id=#{0} AND (t.expire = 0 OR t.expire IS
        NULL)
    </update>
        <!-- 查询一度队员集合 -->
    <select id="queryMyFirstTeamList"  resultMap="BaseResultMap">
         SELECT    *  FROM `yeshi_ec_threesale` yet
         WHERE  yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0  OR  yet.expire IS NULL)
        WHERE yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0
        OR yet.expire IS NULL)
         <if test="key != null and key !='' ">
             and  yet.`worker_id` like '%${key}%'
         </if>
@@ -147,7 +160,8 @@
    
    <select id="queryCountMyFirstTeamList"  resultType="java.lang.Long">
         SELECT    count(yet.id)  FROM `yeshi_ec_threesale` yet
         WHERE  yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0  OR  yet.expire IS NULL)
        WHERE yet.`state` = '1' AND yet.`boss_id` = #{bossId} AND (yet.expire = 0
        OR yet.expire IS NULL)
         <if test="key != null and key !='' ">
             and yet.`worker_id` like '%${key}%'
         </if>
@@ -157,9 +171,11 @@
        <!-- 查询二度队员集合 -->
    <select id="queryMySecondTeamList"  resultMap="BaseResultMap">
        SELECT yet.* FROM  (
            SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
        SELECT DISTINCT(ts.`id`) AS id FROM
        `yeshi_ec_threesale` ts
                 LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
             WHERE  ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0  OR  ts.expire IS NULL)
        WHERE ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0 OR
        ts.expire IS NULL)
             <if test="key != null and key !='' ">
                 and  ts.`worker_id` like '%${key}%'
            </if>
@@ -172,7 +188,8 @@
          SELECT COUNT(A.id) FROM (
                SELECT  DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts 
                 LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
               WHERE ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0  OR  ts.expire IS NULL)
        WHERE ts.`state` = '1' AND tf.`boss_id`=#{bossId} AND (ts.expire = 0 OR
        ts.expire IS NULL)
             <if test="key != null and key !='' ">
                 and  ts.`worker_id` like '%${key}%'
            </if>
@@ -199,7 +216,8 @@
        update
        yeshi_ec_threeSale t
        set t.expire = 1, t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]>
        where  t.`id` IN <foreach item="item" collection="list" open="(" separator=","
        where t.`id` IN
        <foreach item="item" collection="list" open="(" separator=","
            close=")">#{item}</foreach>
    </update>
    
@@ -254,7 +272,8 @@
    
    <select id="listSecondTeamQuery"  resultMap="AllResultMap">
        SELECT yet.* FROM  (
            SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
        SELECT DISTINCT(ts.`id`) AS id FROM
        `yeshi_ec_threesale` ts
                 LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
             WHERE  1=1
               <if test="uid != null">
@@ -341,7 +360,8 @@
    <select id="listFirstTeam"  resultMap="AllResultMap">
        SELECT    *  FROM `yeshi_ec_threesale`  ts
        LEFT JOIN `yeshi_ec_threesale_extra_info` ff 
        ON ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id` = ff.`tf_worker_id`
        ON ts.`boss_id` = ff.`tf_boss_id` AND ts.`worker_id` =
        ff.`tf_worker_id`
        WHERE ts.`boss_id` =  #{uid}
        ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
        LIMIT ${start},${count}
@@ -358,14 +378,17 @@
    
    <select id="listSecondTeam"  resultMap="AllResultMap">
        SELECT yet.* FROM  (
            SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts
        SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale`
        ts
             LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
             WHERE  tf.`boss_id` = #{uid} 
             ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
            LIMIT ${start},${count})A
        LIMIT
        ${start},${count})A
        LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
        LEFT JOIN `yeshi_ec_threesale_extra_info` ff 
        ON yet.`boss_id` = ff.`tf_boss_id` AND yet.`worker_id` = ff.`tf_worker_id`
        ON yet.`boss_id` = ff.`tf_boss_id` AND yet.`worker_id` =
        ff.`tf_worker_id`
        
    </select>
    
@@ -381,13 +404,17 @@
    </select>
    
    <select id="getMyBoss" resultMap="AllResultMap">
        select <include refid="Base_Column_List" /> from yeshi_ec_threeSale where
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_threeSale where
        state = 1 and worker_id=#{uid}
    </select>
    
    
    <select id="listbyIdAndBossId" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" /> FROM yeshi_ec_threeSale
        SELECT
        <include refid="Base_Column_List" />
        FROM yeshi_ec_threeSale
        WHERE id = #{id} AND boss_id=#{uid}
         <if test="expire != null and expire == 1">
              AND `expire` = 1  <!-- 失效 -->
fanli/src/main/java/com/yeshi/fanli/mapping/goods/ScanHistoryV2Mapper.xml
@@ -26,9 +26,64 @@
        <include refid="Base_Column_List" />
        from yeshi_ec_scanhistory_v2 where s_id = #{id,jdbcType=BIGINT}
    </select>
    <!-- 根据UID或者设备号获取浏览记录 -->
    <select id="selectByDeviceOrUid" resultMap="BaseResultMap">
        SELECT s.*,MAX(s.`s_id`) AS orderid FROM yeshi_ec_scanhistory_v2 s
        WHERE
        <trim prefix="(" suffix=")" suffixOverrides="or">
            <if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
            <if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
        </trim>
        GROUP BY s.`s_common_goods_id` ORDER BY orderid DESC limit
        #{start},#{count}
    </select>
    <!-- 根据UID或者设备号获取浏览记录条数 -->
    <select id="selectCountByDeviceOrUid" resultType="java.lang.Long">
        SELECT count(s.`s_id`) FROM yeshi_ec_scanhistory_v2 s
        WHERE
        <trim prefix="(" suffix=")" suffixOverrides="or">
            <if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
            <if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
        </trim>
        GROUP BY s.`s_common_goods_id`
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_scanhistory_v2 where s_id = #{id,jdbcType=BIGINT}
    </delete>
    <!-- 根据设备或用户ID删除 -->
    <delete id="deleteByDeviceOrUid">
        delete from
        yeshi_ec_scanhistory_v2 where
        <trim prefix="(" suffix=")" suffixOverrides="or">
            <if test="uid != null"> `s_uid`=#{uid,jdbcType=BIGINT} or</if>
            <if test="device != null">`s_device`=#{device,jdbcType=VARCHAR} or</if>
        </trim>
    </delete>
    <!-- 根据设备或用户ID与商品信息检索 -->
    <select id="selectByDeviceOrUidAndGoodsIdAndGoodsType"
        resultMap="BaseResultMap">
        SELECT s.* FROM yeshi_ec_scanhistory_v2 s left join
        yeshi_ec_common_goods g on g.cg_id=s.s_common_goods_id
        WHERE
        <trim prefix="(" suffix=")" suffixOverrides="or">
            <if test="uid != null"> s.`s_uid`=#{uid,jdbcType=BIGINT} or</if>
            <if test="device != null">s.`s_device`=#{device,jdbcType=VARCHAR} or</if>
        </trim>
        and g.cg_goods_id=#{goodsId} and g.cg_goods_type=#{goodsType}
    </select>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.goods.ScanHistoryV2"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_scanhistory_v2
@@ -36,6 +91,7 @@
        values
        (#{id,jdbcType=BIGINT},#{device,jdbcType=VARCHAR},#{userInfo.id,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.goods.ScanHistoryV2"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_scanhistory_v2
@@ -70,7 +126,8 @@
        <set>
            <if test="device != null">s_device=#{device,jdbcType=VARCHAR},</if>
            <if test="userInfo != null">s_uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="commonGoods != null">s_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if>
            <if test="commonGoods != null">s_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},
            </if>
            <if test="createTime != null">s_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">s_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java
@@ -65,6 +65,23 @@
        commonGoodsMapper.insertSelective(commonGoods);
        return commonGoods;
    }
    @Override
    public CommonGoods addCommonGoods(CommonGoods commonGoods) throws CommonGoodsException {
        filterCommonGoods(commonGoods);
        CommonGoods goods = commonGoodsMapper.selectByGoodsIdAndGoodsType(commonGoods.getGoodsId(),
                commonGoods.getGoodsType());
        if (goods != null) {
            commonGoods.setId(goods.getId());
            return commonGoods;
        }
        commonGoods.setCreateTime(new Date());
        commonGoods.setUpdateTime(new Date());
        commonGoodsMapper.insertSelective(commonGoods);
        return commonGoods;
    }
    @Override
    public void updateCommonGoods(CommonGoods commonGoods) throws CommonGoodsException {
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ScanHistoryV2ServiceImpl.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.goods;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -54,11 +55,44 @@
        if (history.getUserInfo() == null && StringUtil.isNullOrEmpty(history.getDevice()))
            throw new ScanHistoryException(1, "设备或用户信息缺失");
        CommonGoods commonGoods = commonGoodsService.addOrUpdateCommonGoods(history.getCommonGoods());
        CommonGoods commonGoods = commonGoodsService.addCommonGoods(history.getCommonGoods());
        if (commonGoods == null)
            throw new CommonGoodsException(2, "商品信息不完整");
        history.setCommonGoods(commonGoods);
        scanHistoryV2Mapper.insertSelective(history);
    }
    @Override
    public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return null;
        return scanHistoryV2Mapper.selectByDeviceOrUid(uid, device, (page - 1) * pageSize, pageSize);
    }
    @Override
    public long getCountByDeviceOrUid(Long uid, String device) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return 0;
        Long count = scanHistoryV2Mapper.selectCountByDeviceOrUid(uid, device);
        return count == null ? 0 : count;
    }
    @Override
    public void deleteByDeviceOrUid(Long uid, String device) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return;
        scanHistoryV2Mapper.deleteByDeviceOrUid(uid, device);
    }
    @Override
    public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, Long auctionId) {
        if (uid == null && StringUtil.isNullOrEmpty(device))
            return;
        List<ScanHistoryV2> list = scanHistoryV2Mapper.selectByDeviceOrUidAndGoodsIdAndGoodsType(uid, device, auctionId,
                CommonGoods.GOODS_TYPE_TB);
        if (list != null)
            for (ScanHistoryV2 sv : list)
                scanHistoryV2Mapper.deleteByPrimaryKey(sv.getId());
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -28,6 +28,7 @@
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.ThreeSaleException;
import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
@@ -55,9 +56,6 @@
    
    @Resource
    private ThreeSaleMapper threeSaleMapper;
    public UserInfo getBoss(final long uid) {
        return (UserInfo) dao.excute(new HibernateCallback<UserInfo>() {
@@ -92,18 +90,67 @@
    }
    @Transactional
    public void bind(UserInfo invitee, UserInfo inviter) {
    public void bind(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
        if (invitee == null || inviter == null)
            throw new ThreeSaleException(1, "用户信息为空");
        if (invitee.getId() == null)// 该用户还不存在
        {
            // 保存用户
            UserInfo inviteeUser = userInfoService.addUser(invitee, Constant.APPID);
            if (inviteeUser == null)
                throw new ThreeSaleException(2, "创建用户失败");
            // 保存关系
        ThreeSale threeSale = new ThreeSale();
        threeSale.setBoss(inviter);
        threeSale.setWorker(invitee);
            threeSale.setCreateTime(java.lang.System.currentTimeMillis());
            threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
        threeSale.setState(false);
        threeSale.setCreateTime(System.currentTimeMillis());
        dao.save(threeSale);
            threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
            threeSale.setWorker(inviteeUser);
            threeSaleMapper.insertSelective(threeSale);
        } else {// 是已经存在的用户
            // 用户已经存在我们的用户库中
            if (invitee.getLastLoginTime() == null || invitee.getLastLoginTime() == 0L) {
                // 用户未登录
                int outOfDateCount = 0;// 过期数量
                // 查询邀请关系
                List<ThreeSale> list = listByWorkerId(invitee.getId());
                if (list != null && list.size() > 0) {
                    for (ThreeSale ts : list) {
                        if (!ts.getState() && ts.getExpire() == ThreeSale.EXPIRE_OUTOFDATE) {
                            outOfDateCount++;
                        }
                    }
                    // 全部是失效状态
                    if (outOfDateCount == list.size()) {
                        // 可以确定关系
                        ThreeSale threeSale = new ThreeSale();
                        threeSale.setBoss(inviter);
                        threeSale.setCreateTime(java.lang.System.currentTimeMillis());
                        threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
                        threeSale.setState(false);
                        threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
                        threeSale.setWorker(invitee);
                        threeSaleMapper.insertSelective(threeSale);
                        // threeSaleSerivce.bind(invitee, inviter);
                    } else {
                        // 还存在有效的邀请,则不做处理
                    }
                } else {
                    // 用户未登录,又不存在邀请关系,不做处理
                }
            } else {
                // 已经登录,不做处理
            }
        }
    }
    @Transactional
    public void effective(UserInfo invitee) {
        List<ThreeSale> list = dao.list("from ThreeSale ts where ts.worker.id = ? ",
        List<ThreeSale> list = dao.list("from ThreeSale ts where ts.worker.id = ? and ts.state=0 and ts.expire=0",
                new Serializable[] { invitee.getId() });
        if (list.size() > 0) {
            ThreeSale threeSale = list.get(0);
@@ -298,7 +345,6 @@
        return threeSaleMapper.queryCountMySecondTeamList(key, bossId);
    }
    
    @Override
    public int deleteByPrimaryKey(Long id){
        return threeSaleMapper.deleteByPrimaryKey(id);
@@ -308,7 +354,6 @@
    public  List<Long> queryLongTimeFailed(int daysNum){
        return threeSaleMapper.queryLongTimeFailed(daysNum);
    }
    
    @Override
    public List<ThreeSale> queryLongTimeSuccess(int daysNum){
@@ -377,12 +422,10 @@
        return threeSaleMapper.getMyBoss(uid);
    }
    
    @Override
    public ThreeSale selectByPrimaryKey(Long id) {
        return threeSaleMapper.selectByPrimaryKey(id);
    }
    
    @Override
    public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire) {
@@ -414,8 +457,6 @@
        return organizeTeam(countTotal, list);
    }
    public JSONObject organizeTeam(long count, List<ThreeSale> list) {
        
        JSONObject result = new JSONObject();
@@ -436,7 +477,6 @@
            Long createTime = threeSale.getCreateTime();
            Date inviteTime = new Date(createTime);
            object.put("inviteTime", format.format(inviteTime) + " 加入");
            
            String memoName = "";
            ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
@@ -484,7 +524,8 @@
                
                array.add(contentJson);
                
            } else if ( threeSale.getExpire()!= null && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) {
            } else if (threeSale.getExpire() != null
                    && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) {
                state = 2;
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
@@ -496,7 +537,6 @@
                Calendar c = Calendar.getInstance();
                c.setTime(inviteTime);
                c.add(Calendar.DAY_OF_MONTH, 60);// 邀请不超过60天
                
                long days =  (c.getTimeInMillis() -todayTime.getTime()) / (1000*3600*24);
                if (days < 0) {
@@ -532,4 +572,9 @@
        return result;
    }
    
    @Override
    public List<ThreeSale> listByWorkerId(Long workerId) {
        return threeSaleMapper.listByWorkerId(workerId);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -22,6 +22,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.NumberUtil;
import org.yeshi.utils.tencentcloud.COSManager;
import com.google.gson.Gson;
import com.yeshi.fanli.dao.mybatis.BindingAccountMapper;
@@ -34,9 +37,11 @@
import com.yeshi.fanli.entity.admin.UserInfoAdmin;
import com.yeshi.fanli.entity.bus.user.BindingAccount;
import com.yeshi.fanli.entity.bus.user.InviteUser;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.WeiXinUser;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.exception.ThreeSaleException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
@@ -49,9 +54,6 @@
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.wx.WXLoginUtil;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.NumberUtil;
import org.yeshi.utils.tencentcloud.COSManager;
@Service
public class UserInfoServiceImpl implements UserInfoService {
@@ -88,8 +90,6 @@
    
    @Resource
    private ShareMapper shareMapper;
    public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
        List<UserInfo> list = null;
@@ -420,13 +420,15 @@
        }
        String wxUnionId = weiXinUser.getUnionid();
        UserInfo find = getUserByLoginTypeAndOpenId(Constant.WEIXIN, wxUnionId, Constant.APPID);
        if (find == null) {
            find = new UserInfo();
            find.setAppId(Constant.APPID);
            find.setWxUnionId(weiXinUser.getUnionid());
            String wxHeadImg = COSManager.getInstance().uploadFile(
                    HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
                    Constant.WXHEADURL + UUID.randomUUID().toString()).getUrl();
            String wxHeadImg = COSManager.getInstance()
                    .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
                            Constant.WXHEADURL + UUID.randomUUID().toString())
                    .getUrl();
            find.setPortrait(wxHeadImg);
            find.setWxPic(wxHeadImg);
            find.setNickName(weiXinUser.getNickname());
@@ -437,17 +439,15 @@
            System system = new System(Constant.FANLI);
            system.setPlatform(1);
            find.setSystem(system);
            UserInfo addUser = null;
            synchronized (UserInfo.class) {
                addUser = addUser(find, Constant.APPID);
                if (addUser != null && addUser.getId() > 1) {
                    threeSaleSerivce.bind(find, inviter);
                    return true;
                }
            }
        }
        try {
            threeSaleSerivce.bind(find, inviter);
            return true;
        } catch (ThreeSaleException e) {
            e.printStackTrace();
        return false;
        }
    }
    @Transactional
@@ -598,8 +598,8 @@
    @Override
    public long getFriendsListCount(long id, int type) {
        if (type == 1)
            return userInfoDao
                    .getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t  WHERE t.`boss_id`=  " + id +" AND (t.expire = 0  OR  t.expire IS NULL)");
            return userInfoDao.getCountSQL("SELECT COUNT(t.`id`) FROM `yeshi_ec_threesale` t  WHERE t.`boss_id`=  " + id
                    + " AND (t.expire = 0  OR  t.expire IS NULL)");
        else
            return userInfoDao.getCountSQL(
                    "SELECT COUNT(tt.id) FROM `yeshi_ec_threesale` t  LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id`  WHERE t.`boss_id`="
@@ -622,15 +622,14 @@
        return UserUtil.filterForClientUser(user);
    }
    @Override
    public List<UserInfoAdmin> query(long start, int count, String key, Integer userType,
            Integer days, String startTime, String endTime, Integer orderField,Integer orderMode) {
    public List<UserInfoAdmin> query(long start, int count, String key, Integer userType, Integer days,
            String startTime, String endTime, Integer orderField, Integer orderMode) {
        List<UserInfoAdmin> adminList = new ArrayList<UserInfoAdmin>();
        List<UserInfo> userList = userInfoMapper.query(start, count, key, userType, days,
                startTime, endTime, orderField,orderMode);
        List<UserInfo> userList = userInfoMapper.query(start, count, key, userType, days, startTime, endTime,
                orderField, orderMode);
        if (userList == null || userList.size() == 0) {
            return null;
        }
@@ -643,7 +642,6 @@
            if (lastLoginTime == null) {
                userInfo.setLastLoginTime(0L);
            } 
            
            userInfoAdmin.setUserInfo(userInfo);
            
@@ -668,8 +666,6 @@
                userInfoAdmin.setTbNameState(2);
            }
            
            Long uid = userInfo.getId();
            /* 绑定账号信息 */
@@ -691,7 +687,6 @@
                }
            }
            
            // 最后一次下单时间
            Long lastOrderTime = hongBaoService.getLastOrderTime(uid);
            if (lastOrderTime == null) {
@@ -699,7 +694,6 @@
            } else {
                userInfoAdmin.setLastOrderTime(lastOrderTime);
            }
            
            // 历史总订单
            long totalOrder = hongBaoService.countByUidSelf(uid, null, null);
@@ -726,7 +720,6 @@
            // 历史总收益
            double totalMoneyHistory = hongBaoService.countReceiveMoneysByUid(uid);
            userInfoAdmin.setTotalMoneyHistory(totalMoneyHistory);
            
            // 统计分享个数
            long countUserShares = userShareGoodsHistoryMapper.countUserShares(uid);
@@ -798,7 +791,6 @@
        userInfoMapper.updateByPrimaryKeySelective(user);
    }
    
    @Override
    public List<Long> longTimeNoLogin(int daysNum, List<Long> list ) {
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/CommonGoodsService.java
@@ -19,6 +19,16 @@
     * @throws CommonGoodsException
     */
    public CommonGoods addOrUpdateCommonGoods(CommonGoods commonGoods) throws CommonGoodsException;
    /**
     * 添加商品(无就添加,有则返回)
     *
     * @param commonGoods
     * @return
     * @throws CommonGoodsException
     */
    public CommonGoods addCommonGoods(CommonGoods commonGoods) throws CommonGoodsException;
    /**
     * 更新商品信息
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/ScanHistoryV2Service.java
@@ -1,5 +1,7 @@
package com.yeshi.fanli.service.inter.goods;
import java.util.List;
import com.yeshi.fanli.entity.goods.ScanHistoryV2;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.exception.goods.CommonGoodsException;
@@ -24,4 +26,41 @@
     * @throws ScanHistoryException
     */
    public void addScanHistory(ScanHistoryV2 history) throws CommonGoodsException, ScanHistoryException;
    /**
     * 根据设备或者用户ID获取浏览记录
     *
     * @param uid
     * @param device
     * @param page
     * @param pageSize
     * @return
     */
    public List<ScanHistoryV2> getScanHistoryByDeviceOrUid(Long uid, String device, int page, int pageSize);
    /**
     * 根据设备或者用户ID获取浏览记录数量
     *
     * @param uid
     * @param device
     * @return
     */
    public long getCountByDeviceOrUid(Long uid, String device);
    /**
     * 根据用户或者设备删除浏览记录
     *
     * @param uid
     * @param device
     */
    public void deleteByDeviceOrUid(Long uid, String device);
    /**
     * 根据用户或者设备和淘宝商品ID删除浏览记录
     *
     * @param uid
     * @param device
     * @param auctionId
     */
    public void deleteByAuctionIdAndDeviceOrUid(Long uid, String device, Long auctionId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java
@@ -6,6 +6,7 @@
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.ThreeSaleException;
public interface ThreeSaleSerivce {
@@ -20,7 +21,7 @@
    int findInviteCount(long id);
    void bind(UserInfo invitee, UserInfo inviter);
    void bind(UserInfo invitee, UserInfo inviter) throws ThreeSaleException;
    void effective(UserInfo find);
@@ -53,9 +54,9 @@
    //邀请关系
    int getLastestThreeSaleCount(String key);
    /**
     * 查询一度队员集合
     *
     * @param start
     * @param count
     * @param key
@@ -68,6 +69,7 @@
    /**
     * 查询二度队员集合
     *
     * @param start
     * @param count
     * @param key
@@ -80,31 +82,31 @@
    /**
     * 删除邀请关系id
     *
     * @param id
     * @return
     */
    public int deleteByPrimaryKey(Long id);
    /**
     *  长时间未邀请成功用户
     *
     * @param daysNum
     * @return
     */
    public List<Long> queryLongTimeFailed(int daysNum);
     /**
     * 长时间 邀请成功用户
     *
     * @param daysNum
     * @return
     */
    public List<ThreeSale> queryLongTimeSuccess(int daysNum);
    /**
     * 设置对应邀请过期
     *
     * @param list
     * @return
     */
@@ -112,6 +114,7 @@
     /**
     * 一级查询
     *
     * @param start
     * @param count
     * @param uid
@@ -119,13 +122,14 @@
     * @param endTime
     * @return
     */
    public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state,
             String startTime, String endTime);
    public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime,
            String endTime);
        
    public long countFirstTeamQuery(Long uid, Integer state, String startTime, String endTime);
      /**
     * 二级查询
     *
     * @param start
     * @param count
     * @param uid
@@ -133,14 +137,14 @@
     * @param endTime
     * @return
     */
    public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state,
            String startTime,String endTime);
    public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state, String startTime,
            String endTime);
    
    public long countSecondTeamQuery(Long uid, Integer state, String startTime, String endTime);
    
      /**
     * 上级查询
     *
     * @param start
     * @param count
     * @param uid
@@ -152,6 +156,7 @@
    /**
     * app端一级查询1.4.1
     *
     * @param start
     * @param count
     * @param uid
@@ -161,15 +166,17 @@
    /**
     * 统计所有一级队员
     *
     * @param uid
     * @param state  状态,值 为空时则统计所有
     * @param state
     *            状态,值 为空时则统计所有
     * @return
     */
    public long countFirstTeam(Long uid, Integer state);
    
    /**
     * app端二级查询1.4.1
     *
     * @param start
     * @param count
     * @param uid
@@ -179,15 +186,17 @@
    /**
        * 统计二级队员
     *
        * @param uid
        * @param state  状态,值 为空时则统计所有
     * @param state
     *            状态,值 为空时则统计所有
        * @return
        */
    public long countSecondTeam(Long uid, Integer state);
    
    /**
     * 前端查询一级队员
     *
     * @param start
     * @param count
     * @param uid
@@ -195,9 +204,9 @@
     */
    public JSONObject getMyFirstTeam(long start, int count, Long uid);
    
    /**
     * 前端查询二级队员
     *
     * @param start
     * @param count
     * @param uid
@@ -207,6 +216,7 @@
    
    /**
     * 获取上级
     *
     * @param uid
     * @return
     */
@@ -216,11 +226,21 @@
    /**
     * 查询队员记录  id+uid
     *
     * @param id
     * @param uid
     * @param expire 是否失效状态
     * @param expire
     *            是否失效状态
     * @return
     */
    public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire);
    /**
     * 根据邀请者查询关系
     *
     * @param workerId
     * @return
     */
    public List<ThreeSale> listByWorkerId(Long workerId);
}