| | |
| | | private UserInfoRegisterService userInfoRegisterService;
|
| | |
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public long countNewUser(Integer isToday, Integer isMonth) {
|
| | | return userInfoMapper.countNewUser(isToday, isMonth);
|
| | |
| | | @Override
|
| | | public List<CountUserInfo> getNewUserData(Date startTime, Date endTime, String channel) {
|
| | | // 重新查询统计今日以及空缺
|
| | | initChannelUserCount();
|
| | |
|
| | | return countUserInfoDao.query(CountUserEnum.newUser, startTime, endTime, channel);
|
| | | }
|
| | |
|
| | | // 初始化统计
|
| | | @Override
|
| | | public void initChannelUserCount() {
|
| | | CountUserInfo lastRecord = countUserInfoDao.getMaxDate(CountUserEnum.newUser);
|
| | | Date lastDay = null;
|
| | | if (lastRecord != null && lastRecord.getDay() != null) {
|
| | | lastDay = lastRecord.getDay();
|
| | | }
|
| | | try {
|
| | | if (lastDay == null) {
|
| | | lastDay = TimeUtil.parse("2017-05-14");
|
| | | }
|
| | |
|
| | | Date today = new Date();
|
| | | int betweenDays = DateUtil.daysBetween2(lastDay, today);
|
| | | // 统计今日之前的
|
| | | if (betweenDays > 0) {
|
| | | for (int i = 0; i <= betweenDays; i++) {
|
| | | addRecordCount(DateUtil.plusDay(i, lastDay));
|
| | | }
|
| | | }
|
| | | // 重新统计今日
|
| | | addRecordCount(TimeUtil.getGernalTime(today.getTime()));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private void addRecordCount(String preDay) throws Exception {
|
| | | ChannelEnum[] channels = ChannelEnum.values();
|
| | | for (int i = 0; i < channels.length; i++) {
|
| | | Integer count = userInfoRegisterService.countByChannelAndDay(channels[i].getVlaue(), preDay);
|
| | | if (count == null) {
|
| | | count = 0;
|
| | | }
|
| | | CountUserInfo record = new CountUserInfo();
|
| | | record.setNum(count);
|
| | | record.setChannel(channels[i].name());
|
| | | record.setId(StringUtil.Md5(preDay + channels[i].name() + CountUserEnum.newUser.name()));
|
| | | record.setDay(TimeUtil.parse(preDay));
|
| | | record.setType(CountUserEnum.newUser);
|
| | | countUserInfoDao.save(record);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | | for (int m = 0; m <listRegister.size(); m ++) {
|
| | | boolean reduce = false;
|
| | | Long uid = listRegister.get(m).getId();
|
| | | String vlaue = listRegister.get(m).getChannel().getVlaue();
|
| | | String vlaue = listRegister.get(m).getChannel();
|
| | |
|
| | | for (int n = 0; n <listOrder.size(); n ++) {
|
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == listOrder.get(n).getUid()) {
|
| | |
| | | for (int m = 0; m <listRegister.size(); m ++) {
|
| | | boolean reduce = false;
|
| | | Long uid = listRegister.get(m).getId();
|
| | | String vlaue = listRegister.get(m).getChannel().getVlaue();
|
| | | String vlaue = listRegister.get(m).getChannel();
|
| | |
|
| | | for (int n = 0; n <listOrder.size(); n ++) {
|
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == listOrder.get(n).getUid()) {
|
| | |
| | |
|
| | | @Override
|
| | | public List<CountOrderInfo> counOrderLastNum(Date startTime, Date endTime) {
|
| | | // 重新查询统计今日以及空缺
|
| | | initOrderLastNum();
|
| | |
|
| | | return countOrderInfoDao.query(CountOrderEnum.lastNum, startTime, endTime);
|
| | | }
|
| | |
|
| | | // 初始化统计
|
| | | private void initOrderLastNum() {
|
| | | try {
|
| | | CountOrderInfo lastRecord = countOrderInfoDao.getMaxDate(CountOrderEnum.lastNum);
|
| | | Date lastDay = null;
|
| | | if (lastRecord != null && lastRecord.getDay() != null) {
|
| | | lastDay = lastRecord.getDay();
|
| | | }
|
| | |
|
| | | if (lastDay == null) {
|
| | | lastDay = TimeUtil.parse("2019-01-01");
|
| | | }
|
| | |
|
| | | Date today = new Date();
|
| | | int betweenDays = DateUtil.daysBetween2(lastDay, today);
|
| | | if (betweenDays > 0) {
|
| | | for (int i = 0; i <= betweenDays; i++) {
|
| | | addRecordOrderLastNum(DateUtil.plusDay(i, lastDay));
|
| | | }
|
| | | } else {
|
| | | // 重新统计昨日
|
| | | addRecordOrderLastNum(DateUtil.reduceDay2(1, lastDay));
|
| | | // 重新统计今日
|
| | | addRecordOrderLastNum(TimeUtil.getGernalTime(today.getTime()));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private void addRecordOrderLastNum(String preDay) throws Exception {
|
| | | Integer num = lostOrderService.countLostOrderNum(preDay);
|
| | | if (num == null)
|
| | | num = 0;
|
| | | CountOrderInfo record = new CountOrderInfo();
|
| | | record.setNum(num);
|
| | | record.setDay(TimeUtil.parse(preDay));
|
| | | record.setType(CountOrderEnum.lastNum.name());
|
| | | record.setId(StringUtil.Md5(preDay + CountOrderEnum.lastNum.name()));
|
| | | countOrderInfoDao.save(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CountOrderInfo> counOrderLastMoney(Date startTime, Date endTime) {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<CountOrderInfo> countOrderType(Integer state, Date startTime, Date endTime) {
|
| | | // 重新查询统计今日以及空缺
|
| | | initOrderTypeCount();
|
| | |
|
| | | return countOrderInfoDao.query(CountOrderEnum.orderType, startTime, endTime, state);
|
| | | }
|
| | |
|
| | | // 初始化统计
|
| | | private void initOrderTypeCount() {
|
| | | try {
|
| | | CountOrderInfo lastRecord = countOrderInfoDao.getMaxDate(CountOrderEnum.orderType);
|
| | | Date lastDay = null;
|
| | | if (lastRecord != null && lastRecord.getDay() != null) {
|
| | | lastDay = lastRecord.getDay();
|
| | | }
|
| | |
|
| | | if (lastDay == null) {
|
| | | lastDay = TimeUtil.parse("2018-01-01");
|
| | | }
|
| | |
|
| | | Date today = new Date();
|
| | | int betweenDays = DateUtil.daysBetween2(lastDay, today);
|
| | | if (betweenDays > 0) {
|
| | | for (int i = 0; i <= betweenDays; i++) {
|
| | | addRecordOrderTypeCount(DateUtil.plusDay(i, lastDay));
|
| | | }
|
| | | } else {
|
| | | // 重新统计昨日
|
| | | addRecordOrderTypeCount(DateUtil.reduceDay2(1, lastDay));
|
| | | // 重新统计今日
|
| | | addRecordOrderTypeCount(TimeUtil.getGernalTime(today.getTime()));
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private void addRecordOrderTypeCount(String preDay) throws Exception {
|
| | | for (int i = 1; i < 4; i++) {
|
| | | Integer count = hongBaoV2CountService.countOrderByTypeAndDate(i, preDay);
|
| | | if (count == null)
|
| | | count = 0;
|
| | | CountOrderInfo record = new CountOrderInfo();
|
| | | record.setNum(count);
|
| | | record.setState(i);
|
| | | record.setDay(TimeUtil.parse(preDay));
|
| | | record.setType(CountOrderEnum.orderType.name());
|
| | | record.setId(StringUtil.Md5(preDay + CountOrderEnum.orderType.name()));
|
| | | countOrderInfoDao.save(record);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CountUserInfo> countUserDownOrderByChannelAndToday(String channel, Date startTime, Date endTime) {
|
| | |
| | | for (int m = 0; m <listRegister.size(); m ++) {
|
| | | boolean reduce = false;
|
| | | Long uid = listRegister.get(m).getId();
|
| | | String vlaue = listRegister.get(m).getChannel().getVlaue();
|
| | | String vlaue = listRegister.get(m).getChannel();
|
| | |
|
| | | for (int n = 0; n <listOrder.size(); n ++) {
|
| | | if (channelVlaue.equalsIgnoreCase(vlaue) && uid.longValue() == listOrder.get(n).getUid()) {
|