| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.invite.ThreeSaleDetailDao;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail;
|
| | | import com.yeshi.fanli.exception.ParamsException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | |
|
| | | @Service
|
| | | public class ThreeSaleDetailSerivceImpl implements ThreeSaleDetailService {
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleDetailDao threeSaleDetailDao;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Override
|
| | | public void addThreeSaleDetail(ThreeSaleDetail detail) throws ParamsException {
|
| | | if (detail.getBossUid() == null || detail.getWorkerUid() == null || detail.getLevel() == null
|
| | | || detail.getCreateTime() == null) {
|
| | | throw new ParamsException(1, "参数不完整");
|
| | | }
|
| | | String id = detail.getBossUid() + "#" + detail.getWorkerUid();
|
| | | detail.setId(id);
|
| | | // 根据主键查询
|
| | | ThreeSaleDetail old = threeSaleDetailDao.get(id);
|
| | | // if (old == null)
|
| | | threeSaleDetailDao.save(detail);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSaleDetail> listByBossUidAndLevel(Long bossUid, int level, int page, int pageSize) {
|
| | | return threeSaleDetailDao.listByBossUidAndLevel(bossUid, level, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByBossUidAndLevel(Long bossUid, int level) {
|
| | | return threeSaleDetailDao.countByBossUidAndLevel(bossUid, level);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSaleDetail> listByBossUidAndMinLevel(Long bossUid, int minLevel, int page, int pageSize) {
|
| | | return threeSaleDetailDao.listByBossUidAndMinLevel(bossUid, minLevel, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByBossUidAndMinLevel(Long bossUid, int minLevel) {
|
| | | return threeSaleDetailDao.countByBossUidAndMinLevel(bossUid, minLevel);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public long countByBossUidAndMaxLevel(Long bossUid, int minLevel) {
|
| | | return threeSaleDetailDao.countByBossUidAndMaxLevel(bossUid, minLevel);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public void addByWorkerUid(Long workerUid) {
|
| | | List<ThreeSale> list = threeSaleSerivce.getMyBossDeepList(workerUid, 100);
|
| | | LogHelper.teamInfo(String.format("邀请详细信息: 用户ID:%s 上级数量:%s", workerUid + "", list.size()));
|
| | | int level = 0;
|
| | | long createTime = 0L;
|
| | | if (list.size() > 0) {
|
| | | if (list.get(0).getSucceedTime() != null)
|
| | | createTime = list.get(0).getSucceedTime();
|
| | | else
|
| | | createTime = list.get(0).getCreateTime();
|
| | | }
|
| | | for (ThreeSale tts : list) {
|
| | | level++;
|
| | | ThreeSaleDetail detail = new ThreeSaleDetail();
|
| | | detail.setBossUid(tts.getBoss().getId());
|
| | | detail.setLevel(level);
|
| | | detail.setWorkerUid(workerUid);
|
| | | detail.setCreateTime(new Date(createTime));
|
| | | try {
|
| | | if (tts.getState())
|
| | | addThreeSaleDetail(detail);
|
| | | } catch (ParamsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<ThreeSaleDetail> listByWorkerUid(Long uid) {
|
| | | return threeSaleDetailDao.listByWorkerUid(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ThreeSaleDetail getByBossUidAndWorkerUid(Long bossUid, Long workerUid) {
|
| | | String id = bossUid + "#" + workerUid;
|
| | | return threeSaleDetailDao.get(id);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.user.invite; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.user.invite.ThreeSaleDetailDao; |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale; |
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleDetail; |
| | | import com.yeshi.fanli.exception.ParamsException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; |
| | | |
| | | @Service |
| | | public class ThreeSaleDetailSerivceImpl implements ThreeSaleDetailService { |
| | | |
| | | @Resource |
| | | private ThreeSaleDetailDao threeSaleDetailDao; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | @Override |
| | | public void addThreeSaleDetail(ThreeSaleDetail detail) throws ParamsException { |
| | | if (detail.getBossUid() == null || detail.getWorkerUid() == null || detail.getLevel() == null |
| | | || detail.getCreateTime() == null) { |
| | | throw new ParamsException(1, "参数不完整"); |
| | | } |
| | | String id = detail.getBossUid() + "#" + detail.getWorkerUid(); |
| | | detail.setId(id); |
| | | // 根据主键查询 |
| | | ThreeSaleDetail old = threeSaleDetailDao.get(id); |
| | | // if (old == null) |
| | | threeSaleDetailDao.save(detail); |
| | | } |
| | | |
| | | @Override |
| | | public List<ThreeSaleDetail> listByBossUidAndLevel(Long bossUid, int level, int page, int pageSize) { |
| | | return threeSaleDetailDao.listByBossUidAndLevel(bossUid, level, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countByBossUidAndLevel(Long bossUid, int level) { |
| | | return threeSaleDetailDao.countByBossUidAndLevel(bossUid, level); |
| | | } |
| | | |
| | | @Override |
| | | public List<ThreeSaleDetail> listByBossUidAndMinLevel(Long bossUid, int minLevel, int page, int pageSize) { |
| | | return threeSaleDetailDao.listByBossUidAndMinLevel(bossUid, minLevel, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countByBossUidAndMinLevel(Long bossUid, int minLevel) { |
| | | return threeSaleDetailDao.countByBossUidAndMinLevel(bossUid, minLevel); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long countByBossUidAndMaxLevel(Long bossUid, int minLevel) { |
| | | return threeSaleDetailDao.countByBossUidAndMaxLevel(bossUid, minLevel); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void addByWorkerUid(Long workerUid) { |
| | | List<ThreeSale> list = threeSaleSerivce.getMyBossDeepList(workerUid, 100); |
| | | LogHelper.teamInfo(String.format("邀请详细信息: 用户ID:%s 上级数量:%s", workerUid + "", list.size())); |
| | | int level = 0; |
| | | long createTime = 0L; |
| | | if (list.size() > 0) { |
| | | if (list.get(0).getSucceedTime() != null) |
| | | createTime = list.get(0).getSucceedTime(); |
| | | else |
| | | createTime = list.get(0).getCreateTime(); |
| | | } |
| | | for (ThreeSale tts : list) { |
| | | level++; |
| | | ThreeSaleDetail detail = new ThreeSaleDetail(); |
| | | detail.setBossUid(tts.getBoss().getId()); |
| | | detail.setLevel(level); |
| | | detail.setWorkerUid(workerUid); |
| | | detail.setCreateTime(new Date(createTime)); |
| | | try { |
| | | if (tts.getState()) |
| | | addThreeSaleDetail(detail); |
| | | } catch (ParamsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ThreeSaleDetail> listByWorkerUid(Long uid) { |
| | | return threeSaleDetailDao.listByWorkerUid(uid); |
| | | } |
| | | |
| | | @Override |
| | | public ThreeSaleDetail getByBossUidAndWorkerUid(Long bossUid, Long workerUid) { |
| | | String id = bossUid + "#" + workerUid; |
| | | return threeSaleDetailDao.get(id); |
| | | } |
| | | } |