| | |
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.invite.TeamDailyRecordDao;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamDailyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | |
|
| | | @Service
|
| | | public class TeamDailyRecordServiceImpl implements TeamDailyRecordService {
|
| | |
| | |
|
| | | // id
|
| | | record.setId(id);
|
| | | TeamDailyRecord teamDaily = teamDailyRecordDao.getById(id);
|
| | | TeamDailyRecord teamDaily = teamDailyRecordDao.get(id);
|
| | | if (teamDaily != null) {
|
| | | teamDailyRecordDao.updateSelective(record);
|
| | | } else {
|
| | | record.setCountDay(new Date(TimeUtil.convertDateToTemp(gernalTime)));
|
| | | SimpleDateFormat formatMonth = new SimpleDateFormat("yyyy-MM");
|
| | | record.setYearMonth(formatMonth.format(record.getCountDay()));
|
| | | |
| | | // 初始化数据
|
| | | initData(record);
|
| | | record.setUpdateTime(new Date());
|
| | | teamDailyRecordDao.save(record);
|
| | | }
|
| | | }
|
| | |
|
| | | private void initData(TeamDailyRecord record) {
|
| | | if (record.getFirstNum() == null) |
| | | record.setFirstDaRen(0);
|
| | | if (record.getSecondNum() == null) |
| | | record.setSecondNum(0);
|
| | | if (record.getBeyondNum() == null) |
| | | record.setBeyondNum(0);
|
| | | |
| | | if (record.getFirstDaRen() == null) |
| | | record.setFirstDaRen(0);
|
| | | if (record.getSecondDaRen() == null)
|
| | | record.setSecondDaRen(0); |
| | | if (record.getBeyondDaRen() == null)
|
| | | record.setBeyondDaRen(0);
|
| | | |
| | | if (record.getFirstHighVIP() == null)
|
| | | record.setFirstHighVIP(0);
|
| | | if (record.getSecondHighVIP() == null)
|
| | | record.setSecondHighVIP(0);
|
| | | if (record.getBeyondHighVIP() == null)
|
| | | record.setBeyondHighVIP(0);
|
| | | |
| | | if (record.getFirstSuperVIP() == null)
|
| | | record.setFirstSuperVIP(0);
|
| | | if (record.getSecondSuperVIP() == null)
|
| | | record.setSecondSuperVIP(0);
|
| | | if (record.getBeyondSuperVIP() == null)
|
| | | record.setBeyondSuperVIP(0);
|
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | public void addDailyRecord(Long uid) {
|
| | | // 重新统计队员等级数量
|
| | | recountRecord(uid);
|
| | |
|
| | | // 统计上级队员数量
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(uid);
|
| | | if (threeSale != null) {
|
| | | recountRecord(threeSale.getBoss().getId());
|
| | | }
|
| | | public String createId(Long uid, Date date) {
|
| | | String gernalTime = TimeUtil.getGernalTime(date.getTime());
|
| | | return StringUtil.Md5(uid + "#" + gernalTime);
|
| | | }
|
| | |
|
| | | private void recountRecord(Long uid) {
|
| | | try {
|
| | | // 直接粉丝
|
| | | int firstCount = (int) threeSaleSerivce.countFirstTeamByDate(uid, 1);
|
| | | // 间接粉丝
|
| | | int secondCount = (int) threeSaleSerivce.countSecondTeamByDate(uid, 1);
|
| | |
|
| | | int secondBeyond = 0;
|
| | | |
| | | |
| | | } catch (Exception e) {
|
| | | e.getSuppressed();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> getbyUid(Long uid) {
|
| | | return teamDailyRecordDao.getbyUid(uid);
|
| | | public TeamDailyRecord getById(String id) {
|
| | | return teamDailyRecordDao.get(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<TeamDailyRecord> getbyUid(Long uid, Date minTime) {
|
| | | return teamDailyRecordDao.getbyUid(uid, minTime);
|
| | | public List<TeamDailyRecord> getByUid(Long uid) {
|
| | | return teamDailyRecordDao.getByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> listByUid(Long uid, Date minTime, Date maxTime) {
|
| | | return teamDailyRecordDao.listByUid(uid, minTime, maxTime);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> sumGroupByYearMonth(Long uid, Date minTime, Date maxTime) {
|
| | | return teamDailyRecordDao.sumGroupByYearMonth(uid, minTime, maxTime);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> sumTeamNumGroupByCountDay(Long uid, Date minDay, Date maxDay) {
|
| | | return teamDailyRecordDao.sumTeamNumGroupByCountDay(uid, minDay, maxDay);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> sumTeamNumGroupByYearMonth(Long uid, Date minDay, Date maxDay) {
|
| | | return teamDailyRecordDao.sumTeamNumGroupByYearMonth(uid, minDay, maxDay);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<TeamDailyRecord> sumTeamNumGroupByUid(Long uid, Date minDay, Date maxDay) {
|
| | | return teamDailyRecordDao.sumTeamNumGroupByUid(uid, minDay, maxDay);
|
| | | }
|
| | |
|
| | | }
|