| | |
| | | package com.yeshi.fanli.service.impl.user.invite;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.user.invite.TeamDailyRecordDao;
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException;
|
| | | 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.vo.order.OrderRankingVO;
|
| | |
|
| | | @Service
|
| | | public class TeamDailyRecordServiceImpl implements TeamDailyRecordService {
|
| | |
|
| | | @Resource
|
| | | private TeamDailyRecordDao teamDailyRecordDao;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | |
| | | @Override
|
| | | public void save(TeamDailyRecord record) throws TeamDailyRecordException {
|
| | | if (record == null || record.getCountDay() == null || record.getUid() == null) {
|
| | | throw new TeamDailyRecordException(1, "数据不完整");
|
| | | }
|
| | | |
| | | // 创建id
|
| | | String gernalTime = TimeUtil.getGernalTime(record.getCountDay().getTime());
|
| | | String id = StringUtil.Md5(record.getUid() + "#" + gernalTime);
|
| | | |
| | | // id
|
| | | record.setId(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
|
| | | public String createId(Long uid, Date date) {
|
| | | String gernalTime = TimeUtil.getGernalTime(date.getTime());
|
| | | return StringUtil.Md5(uid + "#" + gernalTime);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public TeamDailyRecord getById(String id) {
|
| | | return teamDailyRecordDao.get(id);
|
| | | }
|
| | | |
| | | @Override
|
| | | 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);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<OrderRankingVO> getRankingByFirstNum(Long uid, Date minDay, Date maxDay) {
|
| | | return teamDailyRecordDao.getRankingByFirstNum(uid, minDay, maxDay);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.user.invite; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.user.invite.TeamDailyRecordDao; |
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord; |
| | | import com.yeshi.fanli.exception.user.TeamDailyRecordException; |
| | | 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 org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.vo.order.OrderRankingVO; |
| | | |
| | | @Service |
| | | public class TeamDailyRecordServiceImpl implements TeamDailyRecordService { |
| | | |
| | | @Resource |
| | | private TeamDailyRecordDao teamDailyRecordDao; |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | |
| | | @Override |
| | | public void save(TeamDailyRecord record) throws TeamDailyRecordException { |
| | | if (record == null || record.getCountDay() == null || record.getUid() == null) { |
| | | throw new TeamDailyRecordException(1, "数据不完整"); |
| | | } |
| | | |
| | | // 创建id |
| | | String gernalTime = TimeUtil.getGernalTime(record.getCountDay().getTime()); |
| | | String id = StringUtil.Md5(record.getUid() + "#" + gernalTime); |
| | | |
| | | // id |
| | | record.setId(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.setFirstNum(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 |
| | | public String createId(Long uid, Date date) { |
| | | String gernalTime = TimeUtil.getGernalTime(date.getTime()); |
| | | return StringUtil.Md5(uid + "#" + gernalTime); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public TeamDailyRecord getById(String id) { |
| | | return teamDailyRecordDao.get(id); |
| | | } |
| | | |
| | | @Override |
| | | 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); |
| | | } |
| | | |
| | | @Override |
| | | public List<OrderRankingVO> getRankingByFirstNum(Long uid, Date minDay, Date maxDay) { |
| | | return teamDailyRecordDao.getRankingByFirstNum(uid, minDay, maxDay); |
| | | } |
| | | } |