| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | return threeSaleMapper.countSuperiorQuery(state, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listFirstTeam(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listFirstTeam(start, count, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countFirstTeam(Long uid, Integer state) {
|
| | | return threeSaleMapper.countFirstTeam(uid, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSale> listSecondTeam(long start, int count, Long uid) {
|
| | | return threeSaleMapper.listSecondTeam(start, count, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countSecondTeam(Long uid, Integer state) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public JSONObject getMyFirstTeam(long start, int count, Long uid) {
|
| | | public JSONObject getMyFirstTeam(long start, int count, Long uid, Integer state) {
|
| | |
|
| | | List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid);
|
| | | List<ThreeSale> list = threeSaleMapper.listFirstTeam(start, count, uid, state);
|
| | | if (list == null) {
|
| | | list = new ArrayList<ThreeSale>();
|
| | | }
|
| | |
|
| | | long countTotal = threeSaleMapper.countFirstTeam(uid, null);
|
| | | long countTotal = threeSaleMapper.countFirstTeam(uid, state);
|
| | |
|
| | | return organizeTeam(countTotal, list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public JSONObject getMySecondTeam(long start, int count, Long uid) {
|
| | | List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid);
|
| | | public JSONObject getMySecondTeam(long start, int count, Long uid, Integer state) {
|
| | | List<ThreeSale> list = threeSaleMapper.listSecondTeam(start, count, uid, state);
|
| | | if (list == null) {
|
| | | list = new ArrayList<ThreeSale>();
|
| | | }
|
| | |
|
| | | long countTotal = threeSaleMapper.countSecondTeam(uid, null);
|
| | | long countTotal = threeSaleMapper.countSecondTeam(uid, state);
|
| | |
|
| | | return organizeTeam(countTotal, list);
|
| | | }
|
| | |
| | | @Transactional
|
| | | public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException {
|
| | |
|
| | | if (invitee == null || inviter == null)
|
| | | if (invitee == null || inviter == null) |
| | | throw new ThreeSaleException(1, "用户信息为空");
|
| | |
|
| | | |
| | | // 获取有效的邀请关系
|
| | | ThreeSale threeSale = threeSaleMapper.getRelationshipByBossIdAndWorkerId(inviter.getId(), invitee.getId());
|
| | |
|
| | |
| | | threeSale.setCreateTime(java.lang.System.currentTimeMillis());
|
| | | threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.insertSelective(threeSale);
|
| | |
|
| | | }
|
| | |
|
| | | List<ThreeSale> listExpire = threeSaleMapper.getExpireRecord(inviter.getId(), invitee.getId());
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void bindRelationshipByWX(UserInfo invitee, Long inviterId, ThreeSale threeSaleOld) throws ThreeSaleException {
|
| | |
|
| | | if (invitee == null || (inviterId == null && threeSaleOld == null))
|
| | | throw new ThreeSaleException(1, "用户信息为空");
|
| | | |
| | | ThreeSale threeSale = null;
|
| | | if (inviterId != null ) {
|
| | | // 新建立确定关系
|
| | | threeSale = new ThreeSale();
|
| | | threeSale.setBoss(new UserInfo(inviterId));
|
| | | threeSale.setWorker(invitee);
|
| | | threeSale.setState(true);
|
| | | threeSale.setExpire(ThreeSale.EXPIRE_NORMAL);
|
| | | threeSale.setSucceedTime(java.lang.System.currentTimeMillis());
|
| | | threeSale.setCreateTime(java.lang.System.currentTimeMillis());
|
| | | threeSale.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.insertSelective(threeSale);
|
| | | |
| | | // 邀请关系失效 1.5.3 之前失效
|
| | | if (threeSaleOld != null) {
|
| | | ThreeSale three = new ThreeSale();
|
| | | three.setId(threeSaleOld.getId());
|
| | | three.setExpire(ThreeSale.EXPIRE_OUTOFDATE);
|
| | | three.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.updateByPrimaryKeySelective(three);
|
| | | }
|
| | | } else if (threeSaleOld != null && inviterId == null) {
|
| | | // 1.5.3 之前生效
|
| | | threeSaleOld.setState(true);
|
| | | threeSaleOld.setExpire(ThreeSale.EXPIRE_NORMAL);
|
| | | threeSaleOld.setSucceedTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleOld.setUpdateTime(java.lang.System.currentTimeMillis());
|
| | | threeSaleMapper.updateByPrimaryKeySelective(threeSaleOld);
|
| | | |
| | | threeSale = threeSaleOld;
|
| | | }
|
| | |
|
| | | if (threeSale == null) {
|
| | | throw new ThreeSaleException(1, "关系绑定失败");
|
| | | }
|
| | | |
| | | UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
|
| | | threeSale.setBoss(boss);
|
| | | |
| | | |
| | | // 添加到队列
|
| | | ThreeSaleCMQManager.getInstance().addThreeSaleMsg(threeSale);
|
| | | // 邀请消息
|
| | | userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
|
| | | }
|
| | | |
| | | /**
|
| | | * 根据邀请者查询关系
|
| | | * |
| | | * @param workerId
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public ThreeSale getByWorkerId(Long workerId) {
|
| | | return threeSaleMapper.getByWorkerId(workerId);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public long countSuccessFirstTeam(Long uid) {
|
| | | return threeSaleMapper.countFirstTeam(uid, 1);
|
| | | }
|