admin
2018-12-06 389d0c6d923532e3af63582e37946a5cda1fa90b
浏览记录调整
邀请更改
13个文件已修改
1527 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/RecommendController.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java 266 ●●●● 补丁 | 查看 | 原始文档 | 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 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml 491 ●●●● 补丁 | 查看 | 原始文档 | 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 193 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java 112 ●●●● 补丁 | 查看 | 原始文档 | 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 164 ●●●●● 补丁 | 查看 | 原始文档 | 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
@@ -26,23 +26,24 @@
    int updateByPrimaryKey(ThreeSale record);
    int effectThreeSale(Long workerUid);
    /**
     * 查询一度队员集合
     *
     * @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);
    long queryCountMyFirstTeamList(@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
@@ -50,127 +51,138 @@
     * @return
     */
    List<ThreeSale> queryMySecondTeamList(@Param("start") int start, @Param("count") int count,
            @Param("key") String key,@Param("bossId") Long bossId);
    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
     */
    int updateExpire(List<Long> list);
    /**
     * 一级查询
     * @param start
     * @param count
     * @param key
     * @param startTime
     * @param endTime
     * @return
     */
    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);
    /**
     * 二级查询
     * @param start
     * @param count
     * @param key
     * @param startTime
     * @param endTime
     * @return
     */
    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);
    /**
     * 上级查询
     * @param start
     * @param count
     * @param uid
     * @return
     */
    List<ThreeSale> listSuperiorQuery(@Param("start") long start, @Param("count") int count,
            @Param("state")Integer state, @Param("uid") Long uid);
    long countSuperiorQuery(@Param("state")Integer state, @Param("uid") Long uid);
    /**
     * 查询一级队员
     * @param paramLong
     * @param paramInt
     * @param paramLong1
     * @return
     */
    List<ThreeSale> listFirstTeam(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid);
            @Param("key") String key, @Param("bossId") Long bossId);
    /**
     * 统计一级队员
     * @param uid
     * @param state
     * @return
     */
    long countFirstTeam(@Param("uid") Long uid, @Param("state") Integer state);
    long queryCountMySecondTeamList(@Param("key") String key, @Param("bossId") Long bossId);
    /**
     * 查询二级队员
     * @param start
     * @param count
     * @param uid
     * @return
     */
    List<ThreeSale> listSecondTeam(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid);
    /**
     * 长时间未邀请成功用户
     *
     * @param daysNum
     * @return
     */
    List<Long> queryLongTimeFailed(@Param("daysNum") int daysNum);
    /**
     * 统计二级队员
     * @param uid
     * @param state
     * @return
     */
    long countSecondTeam(@Param("uid") Long uid, @Param("state") Integer state);
    /**
     * 长时间 邀请成功用户
     *
     * @param daysNum
     * @return
     */
    List<ThreeSale> queryLongTimeSuccess(@Param("daysNum") int daysNum);
    /**
     *
     * @param uid
     * @return
     */
    ThreeSale getMyBoss(@Param("uid") Long uid);
    /**
     * 根据id、uid查询
     * @param id
     * @param uid
     * @return
     */
    List<ThreeSale> listbyIdAndBossId(@Param("id")Long id, @Param("uid") Long uid, @Param("expire") Integer expire);
    /**
     * 设置对应邀请过期
     *
     * @param list
     * @return
     */
    int updateExpire(List<Long> list);
    /**
     * 一级查询
     *
     * @param start
     * @param count
     * @param key
     * @param startTime
     * @param endTime
     * @return
     */
    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);
    /**
     * 二级查询
     *
     * @param start
     * @param count
     * @param key
     * @param startTime
     * @param endTime
     * @return
     */
    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);
    /**
     * 上级查询
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    List<ThreeSale> listSuperiorQuery(@Param("start") long start, @Param("count") int count,
            @Param("state") Integer state, @Param("uid") Long uid);
    long countSuperiorQuery(@Param("state") Integer state, @Param("uid") Long uid);
    /**
     * 查询一级队员
     *
     * @param paramLong
     * @param paramInt
     * @param paramLong1
     * @return
     */
    List<ThreeSale> listFirstTeam(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid);
    /**
     * 统计一级队员
     *
     * @param uid
     * @param state
     * @return
     */
    long countFirstTeam(@Param("uid") Long uid, @Param("state") Integer state);
    /**
     * 查询二级队员
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    List<ThreeSale> listSecondTeam(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid);
    /**
     * 统计二级队员
     *
     * @param uid
     * @param state
     * @return
     */
    long countSecondTeam(@Param("uid") Long uid, @Param("state") Integer state);
    /**
     *
     * @param uid
     * @return
     */
    ThreeSale getMyBoss(@Param("uid") Long uid);
    /**
     * 根据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")
@@ -54,8 +57,8 @@
    @Column(name = "updateTime")
    private Long updateTime;
    @Transient
    @Transient
    private ThreeSaleExtraInfo threeSaleExtraInfo;
    public Long getId() {
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -5,22 +5,22 @@
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="state" property="state" jdbcType="BOOLEAN" />
        <result column="succeedTime" property="succeedTime" jdbcType="BIGINT" />
        <result column="createTime" property="createTime" jdbcType="BIGINT" />
        <result column="updateTime" property="updateTime" jdbcType="BIGINT" />
        <result column="expire" property="expire" jdbcType="INTEGER" />
        <association property="boss" column="boss_id"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
        <association property="worker" column="worker_id"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="worker_id" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="state" property="state" jdbcType="BOOLEAN" />
@@ -28,19 +28,20 @@
        <result column="createTime" property="createTime" jdbcType="BIGINT" />
        <result column="updateTime" property="updateTime" jdbcType="BIGINT" />
        <result column="expire" property="expire" jdbcType="INTEGER" />
        <association property="boss" column="boss_id"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
        <association property="worker" column="worker_id"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
        <association property="threeSaleExtraInfo" column="tf_id"
            resultMap="com.yeshi.fanli.dao.mybatis.ThreeSaleExtraInfoMapper.BaseResultMap" />
            resultMap="com.yeshi.fanli.dao.mybatis.ThreeSaleExtraInfoMapper.BaseResultMap" />
    </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"
@@ -129,269 +140,285 @@
    <update id="effectThreeSale" parameterType="java.lang.Long">
        update     yeshi_ec_threeSale t set t.state=1,
        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)
         <if test="key != null and key !='' ">
             and  yet.`worker_id` like '%${key}%'
         </if>
         ORDER BY yet.createtime DESC LIMIT ${start},${count}
    <!-- 查询一度队员集合 -->
    <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)
        <if test="key != null and key !='' ">
            and yet.`worker_id` like '%${key}%'
        </if>
        ORDER BY yet.createtime DESC LIMIT ${start},${count}
    </select>
    <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)
         <if test="key != null and key !='' ">
             and yet.`worker_id` like '%${key}%'
         </if>
    <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)
        <if test="key != null and key !='' ">
            and yet.`worker_id` like '%${key}%'
        </if>
    </select>
        <!-- 查询二度队员集合 -->
    <select id="queryMySecondTeamList"  resultMap="BaseResultMap">
        SELECT yet.* 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)
             <if test="key != null and key !='' ">
                 and  ts.`worker_id` like '%${key}%'
            </if>
              )A
         LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
    <!-- 查询二度队员集合 -->
    <select id="queryMySecondTeamList" resultMap="BaseResultMap">
        SELECT yet.* 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)
        <if test="key != null and key !='' ">
            and ts.`worker_id` like '%${key}%'
        </if>
        )A
        LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
        ORDER BY yet.`createtime` DESC LIMIT ${start},${count}
    </select>
    <select id="queryCountMySecondTeamList" resultType="java.lang.Long" >
          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)
             <if test="key != null and key !='' ">
                 and  ts.`worker_id` like '%${key}%'
            </if>
            )A
    <select id="queryCountMySecondTeamList" resultType="java.lang.Long">
        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)
        <if test="key != null and key !='' ">
            and ts.`worker_id` like '%${key}%'
        </if>
        )A
    </select>
    <select id="queryLongTimeFailed"  resultType="java.lang.Long">
     <!-- 长时间未邀请成功 -->
        SELECT h.`id` FROM `yeshi_ec_threesale` h
        WHERE h.`state` = 0  AND (h.expire = 0  OR  h.expire IS NULL)
    <select id="queryLongTimeFailed" resultType="java.lang.Long">
        <!-- 长时间未邀请成功 -->
        SELECT h.`id` FROM `yeshi_ec_threesale` h
        WHERE h.`state` = 0 AND (h.expire = 0 OR h.expire IS NULL)
        <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]>
    </select>
    <select id="queryLongTimeSuccess" resultMap="BaseResultMap">
     <!-- 长时间未邀请成功 -->
        SELECT * FROM `yeshi_ec_threesale` h
        WHERE h.`state` = 1 AND (h.expire = 0  OR  h.expire IS NULL)
        <!-- 长时间未邀请成功 -->
        SELECT * FROM `yeshi_ec_threesale` h
        WHERE h.`state` = 1 AND (h.expire = 0 OR h.expire IS NULL)
        <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]>
    </select>
    <update id="updateExpire" parameterType="java.lang.Long">
        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>
    <select id="listFirstTeamQuery"  resultMap="AllResultMap">
         SELECT    *  FROM `yeshi_ec_threesale`
         WHERE 1=1
          <if test="uid != null">
                  AND `boss_id` = #{uid}
          </if>
         <if test="state == 0">
                  AND `state` = 0  AND (expire = 0  OR  expire IS NULL)
          </if>
          <if test="state == 1">
                  AND `state` = 1
          </if>
          <if test="state ==2">
                AND `expire` = 1  <!-- 失效 -->
          </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>
          ORDER BY createTime DESC
          LIMIT ${start},${count}
    </select>
    <select id="countFirstTeamQuery"  resultType="java.lang.Long">
         SELECT count(id) FROM `yeshi_ec_threesale`
         WHERE 1=1
          <if test="uid != null">
                  AND `boss_id` = #{uid}
          </if>
         <if test="state == 0">
                  AND `state` = 0  AND (expire = 0  OR  expire IS NULL)
    <select id="listFirstTeamQuery" resultMap="AllResultMap">
        SELECT * FROM `yeshi_ec_threesale`
        WHERE 1=1
        <if test="uid != null">
            AND `boss_id` = #{uid}
        </if>
        <if test="state == 0">
            AND `state` = 0 AND (expire = 0 OR expire IS NULL)
        </if>
        <if test="state == 1">
                  AND `state` = 1
         </if>
          <if test="state ==2">
              AND `expire` = 1  <!-- 失效 -->
          </if>
          <if test="startTime != null and startTime !='' ">
            AND `state` = 1
        </if>
        <if test="state ==2">
            AND `expire` = 1  <!-- 失效 -->
        </if>
        <if test="startTime != null and startTime !='' ">
                <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
          </if>
          <if test="endTime != null and  endTime !=''">
        </if>
        <if test="endTime != null and  endTime !='' ">
                  <![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
          </if>
    </select>
    <select id="listSecondTeamQuery"  resultMap="AllResultMap">
        SELECT yet.* 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  1=1
               <if test="uid != null">
                      AND tf.`boss_id` = #{uid}
              </if>
               <if test="state == 0">
                      AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
              </if>
              <if test="state == 1">
                      AND ts.`state` = 1
              </if>
               <if test="state ==2">
                      AND ts.`expire` = 1  <!-- 失效 -->
              </if>
             <if test="startTime != null and startTime !='' ">
                    <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
              </if>
              <if test="endTime != null and  endTime !=''">
                      <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
              </if>
              )A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
        ORDER BY yet.`createtime` DESC
        </if>
        ORDER BY createTime DESC
        LIMIT ${start},${count}
    </select>
    <select id="countSecondTeamQuery" resultType="java.lang.Long" >
          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  1=1
               <if test="uid != null">
                      AND tf.`boss_id` = #{uid}
              </if>
              <if test="state == 0">
                      AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
              </if>
              <if test="state == 1">
                      AND ts.`state` = 1
              </if>
              <if test="state ==2">
                      AND ts.`expire` = 1  <!-- 失效 -->
              </if>
              <if test="startTime != null and startTime !='' ">
                    <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
              </if>
               <if test="endTime != null and endTime !=''">
                      <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
              </if>
            )A
    <select id="countFirstTeamQuery" resultType="java.lang.Long">
        SELECT count(id) FROM `yeshi_ec_threesale`
        WHERE 1=1
        <if test="uid != null">
            AND `boss_id` = #{uid}
        </if>
        <if test="state == 0">
            AND `state` = 0 AND (expire = 0 OR expire IS NULL)
        </if>
        <if test="state == 1">
            AND `state` = 1
        </if>
        <if test="state ==2">
            AND `expire` = 1  <!-- 失效 -->
        </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>
    </select>
    <select id="listSuperiorQuery"  resultMap="AllResultMap">
        SELECT * FROM `yeshi_ec_threesale` ts
        WHERE ts.`worker_id` = #{uid}
             <if test="state == 0">
                      AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
              </if>
              <if test="state == 1">
                      AND ts.`state` = 1
              </if>
            <if test="state ==2">
                  AND ts.`expire` = 1  <!-- 失效 -->
            </if>
        ORDER BY ts.`createtime` DESC
    <select id="listSecondTeamQuery" resultMap="AllResultMap">
        SELECT yet.* 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 1=1
        <if test="uid != null">
            AND tf.`boss_id` = #{uid}
        </if>
        <if test="state == 0">
            AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL)
        </if>
        <if test="state == 1">
            AND ts.`state` = 1
        </if>
        <if test="state ==2">
            AND ts.`expire` = 1  <!-- 失效 -->
        </if>
        <if test="startTime != null and startTime !='' ">
                    <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
        </if>
        <if test="endTime != null and  endTime !=''">
                      <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
        </if>
        )A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
        ORDER BY yet.`createtime` DESC
        LIMIT ${start},${count}
    </select>
    <select id="countSuperiorQuery" resultType="java.lang.Long" >
         SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts
        WHERE ts.`worker_id` = #{uid}
             <if test="state == 0">
                      AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
              </if>
              <if test="state == 1">
                      AND ts.`state` = 1
              </if>
            <if test="state ==2">
                  AND ts.`expire` = 1  <!-- 失效 -->
            </if>
    <select id="countSecondTeamQuery" resultType="java.lang.Long">
        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 1=1
        <if test="uid != null">
            AND tf.`boss_id` = #{uid}
        </if>
        <if test="state == 0">
            AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL)
        </if>
        <if test="state == 1">
            AND ts.`state` = 1
        </if>
        <if test="state ==2">
            AND ts.`expire` = 1  <!-- 失效 -->
        </if>
        <if test="startTime != null and startTime !='' ">
                    <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
        </if>
        <if test="endTime != null and endTime !=''">
                      <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
        </if>
        )A
    </select>
    <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`
        WHERE ts.`boss_id` =  #{uid}
    <select id="listSuperiorQuery" resultMap="AllResultMap">
        SELECT * FROM `yeshi_ec_threesale` ts
        WHERE ts.`worker_id` = #{uid}
        <if test="state == 0">
            AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL)
        </if>
        <if test="state == 1">
            AND ts.`state` = 1
        </if>
        <if test="state ==2">
            AND ts.`expire` = 1  <!-- 失效 -->
        </if>
        ORDER BY ts.`createtime` DESC
        LIMIT ${start},${count}
    </select>
    <select id="countSuperiorQuery" resultType="java.lang.Long">
        SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts
        WHERE ts.`worker_id` = #{uid}
        <if test="state == 0">
            AND ts.`state` = 0 AND (ts.expire = 0 OR ts.expire IS NULL)
        </if>
        <if test="state == 1">
            AND ts.`state` = 1
        </if>
        <if test="state ==2">
            AND ts.`expire` = 1  <!-- 失效 -->
        </if>
    </select>
    <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`
        WHERE ts.`boss_id` = #{uid}
        ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
        LIMIT ${start},${count}
    </select>
    <select id="countFirstTeam"  resultType="java.lang.Long">
         SELECT count(id) FROM `yeshi_ec_threesale`
         WHERE `boss_id` = #{uid}
         <if test="state != null">
              AND `state` = #{state}
    <select id="countFirstTeam" resultType="java.lang.Long">
        SELECT count(id) FROM `yeshi_ec_threesale`
        WHERE `boss_id` = #{uid}
        <if test="state != null">
            AND `state` = #{state}
        </if>
    </select>
    <select id="listSecondTeam"  resultMap="AllResultMap">
        SELECT yet.* 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  tf.`boss_id` = #{uid}
             ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
            LIMIT ${start},${count})A
    <select id="listSecondTeam" resultMap="AllResultMap">
        SELECT yet.* 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 tf.`boss_id` = #{uid}
        ORDER BY ts.state DESC, ts.expire, ts.createTime DESC
        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`
        LEFT JOIN `yeshi_ec_threesale_extra_info` ff
        ON yet.`boss_id` = ff.`tf_boss_id` AND yet.`worker_id` =
        ff.`tf_worker_id`
    </select>
    <select id="countSecondTeam" resultType="java.lang.Long" >
          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 tf.`boss_id` = #{uid}
            <if test="state != null">
                  AND ts.`state` = #{state}
            </if>
         )A
    <select id="countSecondTeam" resultType="java.lang.Long">
        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 tf.`boss_id` = #{uid}
        <if test="state != null">
            AND ts.`state` = #{state}
        </if>
        )A
    </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  <!-- 失效 -->
         </if>
        <if test="expire != null and expire == 1">
            AND `expire` = 1  <!-- 失效 -->
        </if>
    </select>
</mapper>
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;
@@ -52,12 +53,9 @@
    @Resource
    private UserInfoMapper userInfoMapper;
    @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) {
        ThreeSale threeSale = new ThreeSale();
        threeSale.setBoss(inviter);
        threeSale.setWorker(invitee);
        threeSale.setState(false);
        threeSale.setCreateTime(System.currentTimeMillis());
        dao.save(threeSale);
    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.setCreateTime(java.lang.System.currentTimeMillis());
            threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
            threeSale.setState(false);
            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);
@@ -279,44 +326,42 @@
    }
    @Override
    public List<ThreeSale> queryMyFirstTeamList(int start, int count, String key, Long bossId){
    public List<ThreeSale> queryMyFirstTeamList(int start, int count, String key, Long bossId) {
        return threeSaleMapper.queryMyFirstTeamList(start, count, key, bossId);
    }
    @Override
    public long queryCountMyFirstTeamList(String key, Long bossId){
    public long queryCountMyFirstTeamList(String key, Long bossId) {
        return threeSaleMapper.queryCountMyFirstTeamList(key, bossId);
    }
    @Override
    public List<ThreeSale> queryMySecondTeamList(int start, int count, String key, Long bossId){
    public List<ThreeSale> queryMySecondTeamList(int start, int count, String key, Long bossId) {
        return threeSaleMapper.queryMySecondTeamList(start, count, key, bossId);
    }
    @Override
    public long queryCountMySecondTeamList(String key, Long bossId){
    public long queryCountMySecondTeamList(String key, Long bossId) {
        return threeSaleMapper.queryCountMySecondTeamList(key, bossId);
    }
    @Override
    public int deleteByPrimaryKey(Long id){
    public int deleteByPrimaryKey(Long id) {
        return threeSaleMapper.deleteByPrimaryKey(id);
    }
    @Override
    public  List<Long> queryLongTimeFailed(int daysNum){
    public List<Long> queryLongTimeFailed(int daysNum) {
        return threeSaleMapper.queryLongTimeFailed(daysNum);
    }
    @Override
    public List<ThreeSale> queryLongTimeSuccess(int daysNum){
    public List<ThreeSale> queryLongTimeSuccess(int daysNum) {
        return threeSaleMapper.queryLongTimeSuccess(daysNum);
    }
    @Override
    public int updateExpire(List<Long> list){
    public int updateExpire(List<Long> list) {
        return threeSaleMapper.updateExpire(list);
    }
@@ -371,19 +416,17 @@
    public long countSecondTeam(Long uid, Integer state) {
        return threeSaleMapper.countSecondTeam(uid, state);
    }
    @Override
    public ThreeSale getMyBoss(Long uid) {
        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) {
        return threeSaleMapper.listbyIdAndBossId(id, uid, expire);
@@ -391,14 +434,14 @@
    @Override
    public JSONObject getMyFirstTeam(long start, int count, Long uid) {
        List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid);
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countFirstTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
@@ -408,36 +451,33 @@
        if (list == null) {
            list = new ArrayList<ThreeSale>();
        }
        long countTotal = threeSaleMapper.countSecondTeam(uid, null);
        return organizeTeam(countTotal, list);
    }
    public JSONObject organizeTeam(long count, List<ThreeSale> list) {
        JSONObject result = new JSONObject();
        JSONArray resultArray  = new JSONArray();
        for (ThreeSale threeSale: list) {
        JSONArray resultArray = new JSONArray();
        for (ThreeSale threeSale : list) {
            JSONObject object = new JSONObject();
            SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
            SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
            SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
            Date todayTime = new Date();
            // 邀请id
            object.put("inviteId", threeSale.getId());
            // 加入队列时间
            Long createTime = threeSale.getCreateTime();
            Date inviteTime = new Date(createTime);
            object.put("inviteTime", format.format(inviteTime) + " 加入");
            String memoName = "";
            ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
            if (threeSaleExtraInfo != null) {
@@ -446,11 +486,11 @@
                }
            }
            object.put("memoName", memoName);
            String nickName = "";
            String portrait = "";
            Long lastLoginTime = null;
            UserInfo worker = threeSale.getWorker();
            if (worker != null) {
                portrait = worker.getPortrait();
@@ -459,21 +499,21 @@
            }
            object.put("nickName", nickName);
            object.put("portrait", portrait);
            int state = 0;
            String fontColor1 = "#888888";
            String fontColor2 = "#F14242";
            JSONArray array  = new JSONArray();
            JSONArray array = new JSONArray();
            if (threeSale.getState()) {
                state = 1;
                if (lastLoginTime == null) {
                    lastLoginTime = threeSale.getCreateTime();
                }
                JSONObject contentJson = new JSONObject();
                contentJson.put("color", fontColor1);
                if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
                    // 本年
                    contentJson.put("content", "最近登陆 " + sdf.format(lastLoginTime));
@@ -481,10 +521,11 @@
                    // 往年
                    contentJson.put("content", "最近登陆 " + format.format(lastLoginTime));
                }
                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);
@@ -492,44 +533,48 @@
                array.add(contentJson);
            } else {
                state = 0;
                Calendar c = Calendar.getInstance();
                c.setTime(inviteTime);
                c.add(Calendar.DAY_OF_MONTH, 60);// 邀请不超过60天
                long days =  (c.getTimeInMillis() -todayTime.getTime()) / (1000*3600*24);
                long days = (c.getTimeInMillis() - todayTime.getTime()) / (1000 * 3600 * 24);
                if (days < 0) {
                    days = 0;
                }
                JSONObject contentJson1 = new JSONObject();
                contentJson1.put("color", fontColor1);
                contentJson1.put("content", "将于");
                JSONObject contentJson2 = new JSONObject();
                contentJson2.put("color", fontColor2);
                contentJson2.put("content", days+"天");
                contentJson2.put("content", days + "天");
                JSONObject contentJson3 = new JSONObject();
                contentJson3.put("color", fontColor1);
                contentJson3.put("content", "后脱离邀请关系");
                array.add(contentJson1);
                array.add(contentJson2);
                array.add(contentJson3);
            }
            object.put("state", state);
            object.put("recentMsg", array);
            resultArray.add(object);
        }
        result.put("count", count);
        result.put("result_list", resultArray);
        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 {
@@ -73,23 +75,21 @@
    @Resource
    private UserInfoMapper userInfoMapper;
    @Resource
    private BindingAccountMapper bindingAccountMapper;
    @Resource
    private PayInfoMapper payInfoMapper;
    @Resource
    private UserShareGoodsHistoryMapper userShareGoodsHistoryMapper;
    @Resource
    private ScanHistoryMapper scanHistoryMapper;
    @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;
                }
            }
        }
        return false;
        try {
            threeSaleSerivce.bind(find, inviter);
            return true;
        } catch (ThreeSaleException e) {
            e.printStackTrace();
            return false;
        }
    }
    @Transactional
@@ -552,7 +552,7 @@
                    List list = session
                            .createSQLQuery(
                                    "SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT t.* FROM `yeshi_ec_threesale` t  "
                                    + "WHERE t.`boss_id`=? AND (t.expire = 0  OR  t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
                                            + "WHERE t.`boss_id`=? AND (t.expire = 0  OR  t.expire IS NULL) ORDER BY t.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
                            .setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
                    return covertToInviteUserList(list);
                }
@@ -564,7 +564,7 @@
                    List list = session
                            .createSQLQuery(
                                    "SELECT u.id,u.`nick_name`,u.`portrait`,uu.state FROM (SELECT tt.* FROM `yeshi_ec_threesale` t  LEFT JOIN yeshi_ec_threesale tt ON tt.`boss_id`=t.`worker_id` "
                                    + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0  OR  tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
                                            + " WHERE t.`boss_id`=? AND tt.`id` IS NOT NULL AND (tt.expire = 0  OR  tt.expire IS NULL) ORDER BY tt.createTime DESC) uu LEFT JOIN yeshi_ec_user u ON u.`id`=uu.worker_id")
                            .setParameter(0, id).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
                    return covertToInviteUserList(list);
                }
@@ -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;
        }
@@ -638,37 +637,34 @@
        for (UserInfo userInfo : userList) {
            UserInfoAdmin userInfoAdmin = new UserInfoAdmin();
            Long lastLoginTime = userInfo.getLastLoginTime();
            if (lastLoginTime == null) {
                userInfo.setLastLoginTime(0L);
            }
            }
            userInfoAdmin.setUserInfo(userInfo);
            String wxName = userInfo.getWxName();
            if (StringUtil.isNullOrEmpty(wxName)) {
                userInfoAdmin.setWxNameState(1);
            } else {
                userInfoAdmin.setWxNameState(2);
            }
            String phone = userInfo.getPhone();
            if (StringUtil.isNullOrEmpty(phone)) {
                userInfoAdmin.setPhoneState(1);
            } else {
                userInfoAdmin.setPhoneState(2);
            }
            String tbName = userInfo.getTbName();
            if (StringUtil.isNullOrEmpty(tbName)) {
                userInfoAdmin.setTbNameState(1);
            } else {
                userInfoAdmin.setTbNameState(2);
            }
            Long uid = userInfo.getId();
@@ -682,7 +678,7 @@
                    userInfoAdmin.setAccountAlipay(bindingAccount.getAccount());
                    userInfoAdmin.setAccountName(bindingAccount.getName());
                    userInfoAdmin.setAccountBindId(bindingAccount.getId());
                } else if (type != null && type == 2) {
                    // 微信
                    userInfoAdmin.setAccountWX(bindingAccount.getAccount());
@@ -690,8 +686,7 @@
                    userInfoAdmin.setAccountBindIdWX(bindingAccount.getId());
                }
            }
            // 最后一次下单时间
            Long lastOrderTime = hongBaoService.getLastOrderTime(uid);
            if (lastOrderTime == null) {
@@ -699,8 +694,7 @@
            } else {
                userInfoAdmin.setLastOrderTime(lastOrderTime);
            }
            // 历史总订单
            long totalOrder = hongBaoService.countByUidSelf(uid, null, null);
            // 今日总订单
@@ -715,8 +709,8 @@
            // 支付宝账号 累计转账总金额
            double totalMoney = payInfoMapper.sumMoneyByUid(uid);
            userInfoAdmin.setTotalMoney(totalMoney);
            // 累计提现    (暂未计入微信)
            // 累计提现 (暂未计入微信)
            userInfoAdmin.setTotalExtract(totalMoney);
            // 未领取红包 待入账金额
@@ -726,22 +720,21 @@
            // 历史总收益
            double totalMoneyHistory = hongBaoService.countReceiveMoneysByUid(uid);
            userInfoAdmin.setTotalMoneyHistory(totalMoneyHistory);
            // 统计分享个数
            long countUserShares = userShareGoodsHistoryMapper.countUserShares(uid);
            userInfoAdmin.setCountUserShares(countUserShares);
            // 统计浏览足迹
            long countScanHistory = scanHistoryMapper.countUserScanHistory(uid);
            userInfoAdmin.setCountScanHistory(countScanHistory);
            // 一度队员数量
            int firstTeamCount = shareMapper.myFirstTeamCount(uid +"");
            int firstTeamCount = shareMapper.myFirstTeamCount(uid + "");
            userInfoAdmin.setCountLevelOne(firstTeamCount);
            // 二度队员数量
            int secondTeamCount = shareMapper.mySecondTeamCount(uid +"");
            int secondTeamCount = shareMapper.mySecondTeamCount(uid + "");
            userInfoAdmin.setCountLevelTwo(secondTeamCount);
            adminList.add(userInfoAdmin);
        }
@@ -754,7 +747,7 @@
    public long queryCount(String key, Integer userType, Integer days, String startTime, String endTime) {
        return userInfoMapper.queryCount(key, userType, days, startTime, endTime);
    }
    @Override
    public double querySumMoney(String key, Integer userType, Integer days, String startTime, String endTime) {
        return userInfoMapper.querySumMoney(key, userType, days, startTime, endTime);
@@ -764,12 +757,12 @@
    public UserInfo selectByPKey(Long id) {
        return userInfoMapper.selectByPKey(id);
    }
    @Override
    public int updateByPrimaryKeySelective(UserInfo record) {
        return userInfoMapper.updateByPrimaryKeySelective(record);
    }
    @Override
    @Transactional
    public void deleteBindInfo(UserInfo user, int type) {
@@ -798,10 +791,9 @@
        userInfoMapper.updateByPrimaryKeySelective(user);
    }
    @Override
    public List<Long> longTimeNoLogin(int daysNum, List<Long> list ) {
    public List<Long> longTimeNoLogin(int daysNum, List<Long> list) {
        return userInfoMapper.longTimeNoLogin(daysNum, 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);
@@ -50,12 +51,12 @@
    // 获取最近有效的分销列表
    List<ThreeSale> getLastestThreeSaleList(int i, String key);
    //邀请关系
    // 邀请关系
    int getLastestThreeSaleCount(String key);
    /**
     * 查询一度队员集合
     *
     * @param start
     * @param count
     * @param key
@@ -68,6 +69,7 @@
    /**
     * 查询二度队员集合
     *
     * @param start
     * @param count
     * @param key
@@ -80,78 +82,81 @@
    /**
     * 删除邀请关系id
     *
     * @param id
     * @return
     */
    public int deleteByPrimaryKey(Long id);
    /**
     *  长时间未邀请成功用户
     * 长时间未邀请成功用户
     *
     * @param daysNum
     * @return
     */
    public List<Long> queryLongTimeFailed(int daysNum);
     /**
     * 长时间 邀请成功用户
     * @param daysNum
     * @return
     */
    /**
     * 长时间 邀请成功用户
     *
     * @param daysNum
     * @return
     */
    public List<ThreeSale> queryLongTimeSuccess(int daysNum);
    /**
     * 设置对应邀请过期
     *
     * @param list
     * @return
     */
    public int updateExpire(List<Long> list);
     /**
     * 一级查询
     * @param start
     * @param count
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state,
             String startTime, String endTime);
    /**
     * 一级查询
     *
     * @param start
     * @param count
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    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
     * @param startTime
     * @param endTime
     * @return
     */
    public List<ThreeSale> listSecondTeamQuery(long start, int count, Long uid, Integer state,
            String startTime,String endTime);
    /**
     * 二级查询
     *
     * @param start
     * @param count
     * @param uid
     * @param startTime
     * @param endTime
     * @return
     */
    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
     * @return
     */
    /**
     * 上级查询
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    public List<ThreeSale> listSuperiorQuery(long start, int count, Integer state, Long uid);
    public long countSuperiorQuery(Integer state, Long uid);
    /**
     * app端一级查询1.4.1
     *
     * @param start
     * @param count
     * @param uid
@@ -161,66 +166,81 @@
    /**
     * 统计所有一级队员
     *
     * @param uid
     * @param state  状态,值 为空时则统计所有
     * @param state
     *            状态,值 为空时则统计所有
     * @return
     */
    public long countFirstTeam(Long uid, Integer state);
    /**
     * app端二级查询1.4.1
     * @param start
     * @param count
     * @param uid
     * @return
     */
    /**
     * app端二级查询1.4.1
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid);
    /**
        * 统计二级队员
        * @param uid
        * @param state  状态,值 为空时则统计所有
        * @return
        */
     * 统计二级队员
     *
     * @param uid
     * @param state
     *            状态,值 为空时则统计所有
     * @return
     */
    public long countSecondTeam(Long uid, Integer state);
    /**
     * 前端查询一级队员
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    public JSONObject getMyFirstTeam(long start, int count, Long uid);
    /**
     * 前端查询二级队员
     *
     * @param start
     * @param count
     * @param uid
     * @return
     */
    public JSONObject getMySecondTeam(long start, int count, Long uid);
    /**
     * 获取上级
     * @param uid
     * @return
     */
     * 获取上级
     *
     * @param uid
     * @return
     */
    public ThreeSale getMyBoss(Long uid);
    public ThreeSale selectByPrimaryKey(Long id);
    /**
     * 查询队员记录  id+uid
     * 查询队员记录 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);
}