yujian
2019-08-12 14a3571e8cbd885d9d47ffdb4da14287d32a0718
队员列表 邀请码、微信绑定验证
1个文件已添加
9个文件已修改
1个文件已删除
884 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java 93 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteController.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java 372 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleExtraInfoMapper.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/ThreeSaleExtraInfo.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleExtraInfoMapper.xml 139 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleExtraInfoSerivceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleExtraInfoSerivce.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/VersionUtil.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -108,6 +108,7 @@
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.TimeUtil;
import com.yeshi.fanli.util.Utils;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
import com.yeshi.fanli.util.email.MailSenderUtil;
@@ -213,6 +214,8 @@
    @Resource
    private UserTaoLiJinDetailService userTaoLiJinDetailService;
    private static final String PASSWORD_MAX_ERROR = "password_max_error";
    private static final String EXTRACT_MIN_MONEY = "extract_min_money";
@@ -1694,6 +1697,7 @@
    }
    /**
     * 用户队员列表查询 1.5.3查询有效队员
     * 
@@ -1727,15 +1731,10 @@
                    bossData = new JSONObject();
                    UserInfo boss = threeSale.getBoss();
                    if (boss != null) {
                        bossData.put("bossId", boss.getId());
                        bossData.put("nickName", boss.getNickName());
                        bossData.put("portrait", boss.getPortrait());
                        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
                        if (userInfoExtra != null)
                            bossData.put("weiXin", userInfoExtra.getWeiXin());
                    }
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
                    Long createTime = threeSale.getCreateTime();
                    Date inviteTime = new Date(createTime);
@@ -1832,8 +1831,8 @@
            out.print(JsonUtil.loadFalseResult("统计失败"));
            e.printStackTrace();
        }
    }
    /**
     * 用户队员信息保存 1.4.1
@@ -1847,48 +1846,35 @@
     */
    @RequestMapping(value = "setextrainfo", method = RequestMethod.POST)
    public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String memoName, PrintWriter out) {
        try {
            List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null);
            if (listThreeSale == null || listThreeSale.size() == 0) {
                out.print(JsonUtil.loadFalseResult("该记录不存在"));
                return;
            }
            UserInfo worker = listThreeSale.get(0).getWorker();
            if (worker == null) {
                out.print(JsonUtil.loadFalseResult("该记录不存在"));
                return;
            }
            List<ThreeSaleExtraInfo> list = threeSaleExtraInfoSerivce.listbyBossIdAndWorkerId(uid, worker.getId());
            if (list == null || list.size() == 0) {
                ThreeSaleExtraInfo extraInfo = new ThreeSaleExtraInfo();
                extraInfo.setWorker(worker);
                extraInfo.setNickname(memoName);
                extraInfo.setCreateTime(new Date());
                extraInfo.setUpdateTime(new Date());
                UserInfo boss = new UserInfo(uid);
                extraInfo.setBoss(boss);
                threeSaleExtraInfoSerivce.insert(extraInfo);
            } else {
                ThreeSaleExtraInfo extraInfo = list.get(0);
                extraInfo.setNickname(memoName);
                extraInfo.setUpdateTime(new Date());
                threeSaleExtraInfoSerivce.updateByPrimaryKey(extraInfo);
            }
            out.print(JsonUtil.loadTrueResult("保存成功"));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("保存失败"));
            e.printStackTrace();
        List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null);
        if (listThreeSale == null || listThreeSale.size() == 0) {
            out.print(JsonUtil.loadFalseResult("该记录不存在"));
            return;
        }
        UserInfo worker = listThreeSale.get(0).getWorker();
        if (worker == null) {
            out.print(JsonUtil.loadFalseResult("该记录不存在"));
            return;
        }
        ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, worker.getId());
        if (extraInfo == null) {
            extraInfo = new ThreeSaleExtraInfo();
            extraInfo.setWorker(worker);
            extraInfo.setNickname(memoName);
            extraInfo.setCreateTime(new Date());
            extraInfo.setUpdateTime(new Date());
            extraInfo.setBoss(new UserInfo(uid));
            threeSaleExtraInfoSerivce.insertSelective(extraInfo);
        } else {
            ThreeSaleExtraInfo updateInfo = new ThreeSaleExtraInfo();
            updateInfo.setId(extraInfo.getId());
            updateInfo.setNickname(memoName);
            updateInfo.setUpdateTime(new Date());
            threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(updateInfo);
        }
        out.print(JsonUtil.loadTrueResult("保存成功"));
    }
    /**
@@ -2139,11 +2125,18 @@
                    userInfo.setRankIcon(null);
                }
                
                userInfo.setSex(userInfoExtra.getSex());
                userInfo.setWeiXin(userInfoExtra.getWeiXin());
                // 1.6.5 之后返回性别、微信号
                if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
                    if(userInfoExtra.getSex() != null)
                        userInfo.setSex(userInfoExtra.getSex());
                    if(!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
                        userInfo.setWeiXin(userInfoExtra.getWeiXin());
                }
            }
            // 1.6.5 之后返回 微信号提示
            if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion()))
                userInfo.setWeiXinTip(configService.get("添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。"));
            
            data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
            data.put("invitCode", invitCode); // 邀请码
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteController.java
File was deleted
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
New file
@@ -0,0 +1,372 @@
package com.yeshi.fanli.controller.client.v2;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
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.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.VersionUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("api/v2/invite")
public class InviteControllerV2 {
    @Resource
    private ConfigService configService;
    @Resource
    private PushService pushService;
    @Resource
    private UserSystemMsgService userSystemMsgService;
    @Resource
    private ThreeSaleSerivce threeSaleSerivce;
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
    /**
     * 邀请码验证
     * @param out
     */
    @RequestMapping(value = "verifyCode")
    public void verifyCode(AcceptData acceptData, Long uid, String inviteCode, PrintWriter out) {
        try {
            UserInfo userInfo = userInfoExtraService.getUserByInviteCode(inviteCode);
            JSONObject data = new JSONObject();
            data.put("nickName", userInfo.getNickName());
            data.put("portrait", userInfo.getPortrait());
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserInfoExtraException e) {
            out.print(JsonUtil.loadFalseResult(e.getMsg()));
        }
    }
    /**
     * 邀请码微信
     * @param out
     */
    @RequestMapping(value = "verifyWX")
    public void verifyWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
        try {
            UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, code);
            JSONObject data = new JSONObject();
            data.put("nickName", userInfo.getNickName());
            data.put("portrait", userInfo.getPortrait());
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserInfoExtraException e) {
            out.print(JsonUtil.loadFalseResult(e.getMsg()));
        }
    }
    /**
     * 用户队员列表查询 1.5.3查询有效队员
     *
     * @param acceptData
     * @param id
     * @param out
     */
    @RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
    public void getMyTeam(AcceptData acceptData, long page, long uid, int type, PrintWriter out) {
        if (type != 1 && type != 2) {
            out.print(JsonUtil.loadFalseResult("队员类型不正确"));
            return;
        }
        long count = 0;
        List<ThreeSale> listTeam = null;
        if (type == 1) {
            listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
            count = threeSaleSerivce.countFirstTeam(uid, 1);
        } else if (type == 2) {
            listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
            count = threeSaleSerivce.countSecondTeam(uid, 1);
        }
        // 组织数据
        JSONObject resultData = organizeTeam(count, listTeam, uid, type);
        resultData.put("helpLink", configService.get("team_help_url"));
        boolean hasCode = false;
        boolean bdWeiXin = false;
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null) {
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
                hasCode = true;
            if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
                bdWeiXin = true;
        }
        // 未激活邀请码
        if (!hasCode) {
            resultData.put("helpLinkActivate", configService.get("team_help_url"));
            resultData.put("tipCode", "激活邀请功能后才可以邀请队员,一级队员是由你直接邀请,二级队员是由你的一级队员邀请。\r\n邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
        }
        resultData.put("hasCode", hasCode);
        // 未添加微信号
        if (!bdWeiXin) {
            resultData.put("tipWeiXin", "添加微信号后,你的邀请人和一级队员可通过微信号与你建立联系;\r\n你也可以向邀请人学习或向一级队员教授赚钱技巧。");
        }
        resultData.put("bdWeiXin", bdWeiXin);
        // 安卓返回统计数据
        String platform = acceptData.getPlatform();
        if ("android".equalsIgnoreCase(platform)) {
            JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
            resultData.put("boss", bossData);
            resultData.put("firstTeam", threeSaleSerivce.countFirstTeam(uid, 1));
            resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
        }
        out.print(JsonUtil.loadTrueResult(resultData));
    }
    /**
     * 组织数据
     * @param count
     * @param list
     * @param uid
     * @param type
     * @return
     */
    private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type) {
        JSONObject result = new JSONObject();
        JSONArray resultArray = new JSONArray();
        Date todayTime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
        SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
        for (ThreeSale threeSale : list) {
            UserInfo worker = threeSale.getWorker();
            if (worker == null) {
                continue;
            }
            Long workerId = worker.getId();
            JSONObject object = new JSONObject();
            object.put("workerId", worker.getId());
            object.put("nickName", worker.getNickName());
            object.put("portrait", worker.getPortrait());
            object.put("inviteId", threeSale.getId());
            Date inviteTime = new Date(threeSale.getCreateTime());
            object.put("inviteTime", format.format(inviteTime) + " 加入");
            String fontColor1 = "#888888";
            JSONArray array = new JSONArray();
            if (threeSale.getState()) {
                Long lastLoginTime = worker.getLastLoginTime();
                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));
                } else {
                    // 往年
                    contentJson.put("content", "最近登录 " + format.format(lastLoginTime));
                }
                array.add(contentJson);
                // 一级队员 查询
                if(type == 1) {
                    String memoName = null;
                    ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
                    if (threeSaleExtraInfo != null) {
                        if (!StringUtil.isNullOrEmpty(threeSaleExtraInfo.getNickname())) {
                            memoName = threeSaleExtraInfo.getNickname();
                        }
                    }
                    object.put("memoName", memoName);
                    UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
                    if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
                        object.put("weiXin", userInfoExtra.getWeiXin());
                        object.put("weiXinState", 3);
                        object.put("weiXinTip", "添加TA的微信,你可教授TA如何通过板栗快省赚钱技巧。");
                    } else {
                        if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
                            object.put("weiXinState", 1);
                            object.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
                        } else {
                            object.put("weiXinState", 2);
                            object.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
                        }
                    }
                }
            }
            object.put("state", 1);
            object.put("recentMsg", array);
            resultArray.add(object);
        }
        result.put("count", count);
        result.put("list", resultArray);
        return result;
    }
    /**
     * 用户队员统计- IOS
     *
     * @param acceptData
     * @param id
     * @param out
     */
    @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
    public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
        JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
        JSONObject resultData = new JSONObject();
        resultData.put("boss", bossData);
        resultData.put("helpLink", configService.get("team_help_url"));
        resultData.put("firstTeam", threeSaleSerivce.countFirstTeam(uid, 1));
        resultData.put("firstTeamTotal", threeSaleSerivce.countFirstTeam(uid, null));
        resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
        resultData.put("secondTeamTotal", threeSaleSerivce.countSecondTeam(uid, null));
        out.print(JsonUtil.loadTrueResult(resultData));
    }
    /**
     * 上级信息组织
     * @param acceptData
     * @param uid
     * @param threeSale
     * @return
     */
    private JSONObject getBossInfo(AcceptData acceptData, long uid, ThreeSale threeSale) {
        JSONObject bossData = new JSONObject();
        if (threeSale != null && threeSale.getBoss() != null) {
            UserInfo boss = threeSale.getBoss();
            bossData.put("hasBoss", true);
            bossData.put("inviteId", threeSale.getId());
            bossData.put("nickName", boss.getNickName());
            bossData.put("portrait", boss.getPortrait());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
            Long createTime = threeSale.getCreateTime();
            Date inviteTime = new Date(createTime);
            if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
                UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
                if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
                    bossData.put("weiXin", userInfoExtra.getWeiXin());
                    bossData.put("weiXinState", 3);
                    bossData.put("weiXinTip", "添加TA的微信,你可向TA学习如何通过板栗快省赚钱。");
                } else {
                    if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
                        bossData.put("weiXinState", 1);
                        bossData.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
                    } else {
                        bossData.put("weiXinState", 2);
                        bossData.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
                    }
                }
                bossData.put("inviteTime", "你于 " + sdf.format(inviteTime) + "接受了TA的邀请");
            } else {
                bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
            }
        } else if(VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())){
            bossData.put("hasBoss", false);
            bossData.put("helpLink", configService.get("invite_code_hlep_link"));
            bossData.put("bossTip", "恭喜你,我们的优质用户;\r\n你并没有邀请人,但你的邀请激活功能是被默认开启的;\r\n你拥有独特的无邀请人激活码。");
        }
        return bossData;
    }
    /**
     * 站内信提醒队员添加微信号
     * @param acceptData
     * @param uid
     * @param inviteId
     * @param out
     */
    @RequestMapping(value = "remindTeam")
    public void remindTeam(AcceptData acceptData, Long uid, Long inviteId, PrintWriter out) {
        if (uid == null || inviteId == null) {
            out.print(JsonUtil.loadFalseResult("传递参数缺失"));
            return;
        }
        ThreeSale threeSale = threeSaleSerivce.selectByPrimaryKey(inviteId);
        if (threeSale == null) {
            out.print(JsonUtil.loadFalseResult("关系id不存在"));
            return;
        }
        Long remindId = null;
        if (uid.longValue() == threeSale.getWorker().getId().longValue()) {
            remindId = threeSale.getBoss().getId(); // 提醒上级
        } else if (uid.longValue() == threeSale.getBoss().getId().longValue()) {
            remindId = threeSale.getWorker().getId(); // 提醒下级
        }
        if (remindId == null) {
            out.print(JsonUtil.loadFalseResult("信息验证未通过"));
            return;
        }
        try {
            List<String> listIOS = new ArrayList<String>();
            List<String> listAndroid = new ArrayList<String>();
            pushService.pushZNX(remindId, "", "", listIOS, listAndroid);
            userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.question,
                    "", "", UserSystemMsg.TIME_TAG_EMERGENT, null);
            JSONObject data = new JSONObject();
            data.put("weiXinState", 2);
            data.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
            out.print(JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            out.print(JsonUtil.loadFalseResult("提醒失败"));
            return;
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleExtraInfoMapper.java
@@ -1,39 +1,27 @@
package com.yeshi.fanli.dao.mybatis;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
public interface ThreeSaleExtraInfoMapper {
    int deleteByPrimaryKey(Long id);
    int insert(ThreeSaleExtraInfo record);
    int insertSelective(ThreeSaleExtraInfo record);
    ThreeSaleExtraInfo selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(ThreeSaleExtraInfo record);
    int updateByPrimaryKey(ThreeSaleExtraInfo record);
    /**
     * 根据用户id、被邀请id 查询
     * @param bossId
     * @param workerId
     * @return
     */
    List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId);
    /**
     * 根据用户id、被邀请id删除
     * @param bossId
     * @param workerId
     * @return
     */
    int deleteByBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId);
package com.yeshi.fanli.dao.mybatis;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
public interface ThreeSaleExtraInfoMapper extends BaseMapper<ThreeSaleExtraInfo>{
    /**
     * 根据用户id、被邀请id 查询
     * @param bossId
     * @param workerId
     * @return
     */
    ThreeSaleExtraInfo getbyBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId);
    /**
     * 根据用户id、被邀请id删除
     * @param bossId
     * @param workerId
     * @return
     */
    int deleteByBossIdAndWorkerId(@Param("bossId") Long bossId, @Param("workerId") Long workerId);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/user/ThreeSaleExtraInfo.java
@@ -42,6 +42,14 @@
    @org.yeshi.utils.mybatis.Column(name = "tf_nickname")
    private String nickname; // 备注名
    
    @JoinColumn(name = "tf_remind_boss")
    @org.yeshi.utils.mybatis.Column(name = "tf_remind_boss")
    private Integer remindBoss; // 提示boss绑定微信   1 已提醒
    @JoinColumn(name = "tf_remind_worker")
    @org.yeshi.utils.mybatis.Column(name = "tf_remind_worker")
    private Integer remindWorker; // 提示worker绑定微信  1 已提醒
    @JoinColumn(name = "tf_createtime")
    @org.yeshi.utils.mybatis.Column(name = "tf_createtime")
    private Date createTime; // 创建时间
@@ -97,5 +105,22 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getRemindWorker() {
        return remindWorker;
    }
    public void setRemindWorker(Integer remindWorker) {
        this.remindWorker = remindWorker;
    }
    public Integer getRemindBoss() {
        return remindBoss;
    }
    public void setRemindBoss(Integer remindBoss) {
        this.remindBoss = remindBoss;
    }
    
}
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleExtraInfoMapper.xml
@@ -1,65 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.ThreeSaleExtraInfoMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">
    <id column="tf_id" property="id" jdbcType="BIGINT"/>
    <result column="tf_nickname" property="nickname" jdbcType="VARCHAR"/>
    <result column="tf_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="tf_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
      <association property="boss" column="tf_boss_id"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="tf_boss_id" property="id" jdbcType="BIGINT" />
    </association>
      <association property="worker" column="tf_worker_id"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="tf_worker_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">tf_id,tf_boss_id,tf_worker_id,tf_nickname,tf_createtime,tf_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_threesale_extra_info where tf_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_threesale_extra_info where tf_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threesale_extra_info (tf_id,tf_boss_id,tf_worker_id,tf_nickname,tf_createtime,tf_updatetime) values (#{id,jdbcType=BIGINT},#{boss.id,jdbcType=BIGINT},#{worker.id,jdbcType=BIGINT},#{nickname,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threesale_extra_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">tf_id,</if>
      <if test="boss != null">tf_boss_id,</if>
      <if test="worker != null">tf_worker_id,</if>
      <if test="nickname != null">tf_nickname,</if>
      <if test="createTime != null">tf_createtime,</if>
      <if test="updateTime != null">tf_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="boss != null">#{boss.id,jdbcType=BIGINT},</if>
      <if test="worker != null">#{worker.id,jdbcType=BIGINT},</if>
      <if test="nickname != null">#{nickname,jdbcType=VARCHAR},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">update yeshi_ec_threesale_extra_info set tf_boss_id = #{boss.id,jdbcType=BIGINT},tf_worker_id = #{worker.id,jdbcType=BIGINT},tf_nickname = #{nickname,jdbcType=VARCHAR},tf_createtime = #{createTime,jdbcType=TIMESTAMP},tf_updatetime = #{updateTime,jdbcType=TIMESTAMP} where tf_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">update yeshi_ec_threesale_extra_info
    <set>
      <if test="boss != null">tf_boss_id=#{boss.id,jdbcType=BIGINT},</if>
      <if test="worker != null">tf_worker_id=#{worker.id,jdbcType=BIGINT},</if>
      <if test="nickname != null">tf_nickname=#{nickname,jdbcType=VARCHAR},</if>
      <if test="createTime != null">tf_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">tf_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where tf_id = #{id,jdbcType=BIGINT}
  </update>
      <select id="listbyBossIdAndWorkerId"  resultMap="BaseResultMap">
        SELECT *  FROM `yeshi_ec_threesale_extra_info` t
        WHERE t.`tf_boss_id` = #{bossId}  AND t.`tf_worker_id`= #{workerId}
    </select>
    <delete id="deleteByBossIdAndWorkerId" parameterType="java.lang.Long">
         delete from yeshi_ec_threesale_extra_info
         WHERE `tf_boss_id` = #{bossId}  AND `tf_worker_id`= #{workerId}
    </delete>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.ThreeSaleExtraInfoMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">
    <id column="tf_id" property="id" jdbcType="BIGINT"/>
    <result column="tf_nickname" property="nickname" jdbcType="VARCHAR"/>
    <result column="tf_remind_boss" property="remindBoss" jdbcType="INTEGER"/>
    <result column="tf_remind_worker" property="remindWorker" jdbcType="INTEGER"/>
    <result column="tf_createtime" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="tf_updatetime" property="updateTime" jdbcType="TIMESTAMP"/>
    <association property="boss" column="tf_boss_id"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="tf_boss_id" property="id" jdbcType="BIGINT" />
    </association>
      <association property="worker" column="tf_worker_id"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="tf_worker_id" property="id" jdbcType="BIGINT" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">tf_id,tf_boss_id,tf_worker_id,tf_nickname,tf_remind_boss,tf_remind_worker,tf_createtime,tf_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_threesale_extra_info where tf_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_threesale_extra_info where tf_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threesale_extra_info (tf_id,tf_boss_id,tf_worker_id,tf_nickname,tf_remind_boss,tf_remind_worker,tf_createtime,tf_updatetime) values (#{id,jdbcType=BIGINT},#{boss.id,jdbcType=BIGINT},#{worker.id,jdbcType=BIGINT},#{nickname,jdbcType=VARCHAR},#{remindBoss,jdbcType=INTEGER},#{remindWorker,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_threesale_extra_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">tf_id,</if>
      <if test="boss != null">tf_boss_id,</if>
      <if test="worker != null">tf_worker_id,</if>
      <if test="nickname != null">tf_nickname,</if>
      <if test="remindBoss != null">tf_remind_boss,</if>
      <if test="remindWorker != null">tf_remind_worker,</if>
      <if test="createTime != null">tf_createtime,</if>
      <if test="updateTime != null">tf_updatetime,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="boss != null">#{boss.id,jdbcType=BIGINT},</if>
      <if test="worker != null">#{worker.id,jdbcType=BIGINT},</if>
      <if test="nickname != null">#{nickname,jdbcType=VARCHAR},</if>
      <if test="remindBoss != null">#{remindBoss,jdbcType=INTEGER},</if>
      <if test="remindWorker != null">#{remindWorker,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">update yeshi_ec_threesale_extra_info set tf_boss_id = #{boss.id,jdbcType=BIGINT},tf_worker_id = #{worker.id,jdbcType=BIGINT},tf_nickname = #{nickname,jdbcType=VARCHAR},tf_remind_boss = #{remindBoss,jdbcType=INTEGER},tf_remind_worker = #{remindWorker,jdbcType=INTEGER},tf_createtime = #{createTime,jdbcType=TIMESTAMP},tf_updatetime = #{updateTime,jdbcType=TIMESTAMP} where tf_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo">update yeshi_ec_threesale_extra_info
    <set>
      <if test="boss != null">tf_boss_id=#{boss.id,jdbcType=BIGINT},</if>
      <if test="worker != null">tf_worker_id=#{worker.id,jdbcType=BIGINT},</if>
      <if test="nickname != null">tf_nickname=#{nickname,jdbcType=VARCHAR},</if>
      <if test="remindBoss != null">tf_remind_boss=#{remindBoss,jdbcType=INTEGER},</if>
      <if test="remindWorker != null">tf_remind_worker=#{remindWorker,jdbcType=INTEGER},</if>
      <if test="createTime != null">tf_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">tf_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where tf_id = #{id,jdbcType=BIGINT}
  </update>
  <select id="getbyBossIdAndWorkerId"  resultMap="BaseResultMap">
    SELECT *  FROM `yeshi_ec_threesale_extra_info` t
    WHERE t.`tf_boss_id` = #{bossId}  AND t.`tf_worker_id`= #{workerId}
    LIMIT 1
  </select>
   <delete id="deleteByBossIdAndWorkerId" parameterType="java.lang.Long">
     delete from yeshi_ec_threesale_extra_info
     WHERE `tf_boss_id` = #{bossId}  AND `tf_worker_id`= #{workerId}
    </delete>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleExtraInfoSerivceImpl.java
@@ -1,7 +1,5 @@
package com.yeshi.fanli.service.impl.hongbao;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -48,8 +46,8 @@
    
    @Override
    public List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(Long bossId, Long workerId) {
        return threeSaleExtraInfoMapper.listbyBossIdAndWorkerId(bossId, workerId);
    public ThreeSaleExtraInfo getbyBossIdAndWorkerId(Long bossId, Long workerId) {
        return threeSaleExtraInfoMapper.getbyBossIdAndWorkerId(bossId, workerId);
    }
    
    @Override
@@ -58,6 +56,33 @@
    }
    
    
    @Override
    public boolean isRemindBoss(Long bossId, Long workerId) {
         ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoMapper.getbyBossIdAndWorkerId(bossId, workerId);
         if (extraInfo == null) {
             return false;
         }
         Integer remindBoss = extraInfo.getRemindBoss();
         if (remindBoss == null || remindBoss != 1) {
             return false;
         }
         return true;
    }
    @Override
    public boolean isRemindWorker(Long bossId, Long workerId) {
         ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoMapper.getbyBossIdAndWorkerId(bossId, workerId);
         if (extraInfo == null) {
             return false;
         }
         Integer remindWorker = extraInfo.getRemindWorker();
         if (remindWorker == null || remindWorker != 1) {
             return false;
         }
         return true;
    }
    
    
}
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/ThreeSaleSerivceImpl.java
@@ -18,10 +18,10 @@
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.exception.ThreeSaleException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleExtraInfoSerivce;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
import com.yeshi.fanli.service.inter.msg.MsgInviteDetailService;
import com.yeshi.fanli.service.inter.msg.UserInviteMsgNotificationService;
@@ -66,6 +66,10 @@
    
    @Resource
    private UserInfoExtraService userInfoExtraService;
    @Resource
    private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
    
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
@@ -345,7 +349,7 @@
    public List<ThreeSale> listbyIdAndBossId(Long id, Long uid, Integer expire) {
        return threeSaleMapper.listbyIdAndBossId(id, uid, expire);
    }
    @Override
    public JSONObject getMyFirstTeam(long start, int count, Long uid, Integer state) {
@@ -356,7 +360,7 @@
        long countTotal = threeSaleMapper.countFirstTeam(uid, state);
        return organizeTeam(countTotal, list, uid);
        return organizeTeam(countTotal, list);
    }
    @Override
@@ -368,10 +372,10 @@
        long countTotal = threeSaleMapper.countSecondTeam(uid, state);
        return organizeTeam(countTotal, list, uid);
        return organizeTeam(countTotal, list);
    }
    public JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid) {
    public JSONObject organizeTeam(long count, List<ThreeSale> list) {
        JSONObject result = new JSONObject();
@@ -413,7 +417,6 @@
                lastLoginTime = worker.getLastLoginTime();
                nickName = worker.getNickName();
            }
            object.put("workerId", workerId);
            object.put("nickName", nickName);
            object.put("portrait", portrait);
@@ -438,15 +441,8 @@
                    // 往年
                    contentJson.put("content", "最近登录 " + format.format(lastLoginTime));
                }
                array.add(contentJson);
                if (workerId != null) {
                    UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
                    if (userInfoExtra != null)
                        object.put("weiXin", userInfoExtra.getWeiXin());
                }
            } else if (threeSale.getExpire() != null
                    && (threeSale.getExpire() == 1 || threeSale.getExpire().equals(1))) {
@@ -490,18 +486,13 @@
            resultArray.add(object);
        }
        boolean bdWeiXin = false;
        UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
        if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
            bdWeiXin = true;
        result.put("bdWeiXin", bdWeiXin);
        result.put("count", count);
        result.put("result_list", resultArray);
        return result;
    }
    @Override
    public List<ThreeSale> listByWorkerId(Long workerId) {
        return threeSaleMapper.listByWorkerId(workerId);
@@ -714,5 +705,16 @@
    public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime){
        return threeSaleMapper.getSuccessByDate(bossId, minTime, maxTime);
    }
    @Override
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid, Integer state) {
        return threeSaleMapper.listFirstTeam(start, count, uid, state);
    }
    @Override
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state) {
        return threeSaleMapper.listSecondTeam(start, count, uid, state);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleExtraInfoSerivce.java
@@ -1,7 +1,5 @@
package com.yeshi.fanli.service.inter.hongbao;
import java.util.List;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
public interface ThreeSaleExtraInfoSerivce {
@@ -23,7 +21,7 @@
     * @param workerId
     * @return
     */
    public List<ThreeSaleExtraInfo> listbyBossIdAndWorkerId(Long bossId, Long workerId);
    public ThreeSaleExtraInfo getbyBossIdAndWorkerId(Long bossId, Long workerId);
    /**
     * 根据用户id、被邀请id删除
@@ -32,4 +30,20 @@
     * @return
     */
    public int deleteByBossIdAndWorkerId(Long bossId, Long workerId);
    /**
     * 是否已提醒boss
     * @param bossId
     * @param workerId
     * @return
     */
    public boolean isRemindBoss(Long bossId, Long workerId);
    /**
     * 是否已提醒下级
     * @param bossId
     * @param workerId
     * @return
     */
    public boolean isRemindWorker(Long bossId, Long workerId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/hongbao/ThreeSaleSerivce.java
@@ -2,11 +2,11 @@
import java.util.List;
import net.sf.json.JSONObject;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.exception.ThreeSaleException;
import net.sf.json.JSONObject;
public interface ThreeSaleSerivce {
@@ -262,4 +262,24 @@
     */
    public List<ThreeSale> getSuccessByDate(Long bossId, Long minTime, Long maxTime);
    /**
     * 一级队员
     * @param start
     * @param count
     * @param uid
     * @param state
     * @return
     */
    public List<ThreeSale> listFirstTeam(long start, int count, Long uid, Integer state);
    /**
     * 二级队员
     * @param start
     * @param count
     * @param uid
     * @param state
     * @return
     */
    public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state);
}
fanli/src/main/java/com/yeshi/fanli/util/VersionUtil.java
@@ -42,6 +42,15 @@
        else
            return false;
    }
    public static boolean greaterThan_1_6_5(String platform, String versionCode) {
        if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 47))
                || (("ios".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) >= 59)))
            return true;
        else
            return false;
    }
    public static boolean smallerThan_1_5_1(String platform, String versionCode) {
        if ((("android".equalsIgnoreCase(platform) && Integer.parseInt(versionCode) < 36))