From 7e37f77192fa701e309fa04f821aa5fd5259ca33 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 01 四月 2020 09:28:31 +0800
Subject: [PATCH] 队员列表
---
fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java | 99 ++++++++++++++++++++++++++++++++++++-------------
1 files changed, 73 insertions(+), 26 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java
index 945b907..34434e2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/count/DailyCountUserServiceImpl.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.count;
import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -126,7 +127,11 @@
} else {
lastDate = TimeUtil.parse("2017-05-06");
}
-
+ long min = DateUtil.dateDiffMin(lastDate, new Date());
+ if (min <= 10) { // 10鍒嗛挓浠ュ唴涓嶇粺璁�
+ return;
+ }
+
Date today = new Date();
int betweenDays = DateUtil.daysBetween2(lastDate, today);
for (int i = 0; i <= betweenDays; i++) {
@@ -174,12 +179,11 @@
ChannelEnum[] channels = ChannelEnum.values();
for (int i = 0; i < channels.length; i++) {
Long count = userInfoRegisterService.countByChannelAndDay(channels[i].getVlaue(), preDay);
- BigDecimal total = new BigDecimal(0);
- if (count != null) {
- total = new BigDecimal(total.toString());
+ if (count == null) {
+ count = 0L;
}
DailyCountUser obj = new DailyCountUser();
- obj.setTotal(total);
+ obj.setTotal(BigDecimal.valueOf(count));
obj.setType(typeEnum);
obj.setChannel(channels[i].name());
obj.setUpdateDate(new Date());
@@ -197,27 +201,30 @@
*/
private void addNewUserDownOrderDay(String preDay, DailyCountUserEnum typeEnum) throws Exception {
// 缁熻褰撴棩鏈夋晥璁㈠崟
- List<CountOrderDTO> listOrder = commonOrderCountService.countValidOrderByDay(preDay);
+ List<Long> listOrder = commonOrderCountService.getUidByValidOrderByDay(preDay);
+
+ // 鏌ヨ褰撴棩鏂版敞鍐岀敤鎴�
+ List<UserInfoRegister> listRegister = userInfoRegisterService.listByDay(preDay);
ChannelEnum[] channels = ChannelEnum.values();
for (int i = 0; i < channels.length; i++) {
+ long totalDay = 0;
+ long totalValid = 0;
+ String channelName = channels[i].getVlaue();
- long totalUser = 0;
- long totalUserDown = 0;
- if (listOrder != null && listOrder.size() > 0) {
- // 鏌ヨ璇ユ笭閬撳綋鏃ユ敞鍐岀敤鎴�
- List<UserInfoRegister> listRegister = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay);
- if (listRegister != null && listRegister.size() > 0) {
- totalUser = listRegister.size();
+ if (listOrder != null && listOrder.size() > 0 && listRegister != null && listRegister.size() > 0) {
+ for (UserInfoRegister register: listRegister) {
+ String channel = register.getChannel();
+ if (channelName.equalsIgnoreCase(channel)) {
+ totalDay ++ ;
+ }
- // 寰幆缁熻鏄惁瀛樺湪鐢ㄦ埛涓嬪崟
- for (UserInfoRegister userInfoRegister: listRegister) {
- Long id = userInfoRegister.getId();
- for (CountOrderDTO dto: listOrder) {
- if (dto.getUid() != null && dto.getUid().longValue() == id.longValue()) {
- totalUserDown ++;
- break;
- }
+ Long id = register.getId();
+ // 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁浠婃棩涓嬪崟
+ for (Long uid: listOrder) {
+ if (uid.longValue() == id.longValue()) {
+ totalValid ++;
+ break;
}
}
}
@@ -225,13 +232,17 @@
// 璁$畻姣斾緥锛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁�
BigDecimal total = new BigDecimal(0);
- if (totalUser > 0 && totalUserDown > 0) {
- total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalUserDown),BigDecimal.valueOf(totalUser));
+ if (totalDay > 0 && totalValid > 0) {
+ total = MoneyBigDecimalUtil.div(BigDecimal.valueOf(totalValid),BigDecimal.valueOf(totalDay));
total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100));
}
DailyCountUser obj = new DailyCountUser();
obj.setTotal(total);
+ obj.setRate(true);
+ obj.setTotalDay(BigDecimal.valueOf(totalDay));
+ obj.setTotalValid(BigDecimal.valueOf(totalValid));
+
obj.setType(typeEnum);
obj.setChannel(channels[i].name());
obj.setUpdateDate(new Date());
@@ -257,20 +268,50 @@
long totalUser = 0;
long totalWeek = 0;
long totalWeek3 = 0;
+
+ List<Long> listUid = new ArrayList<Long>();
+
// 鏌ヨ浠婃棩鏂板鐢ㄦ埛
List<UserInfoRegister> list = userInfoRegisterService.listByChannelAndDay(channels[i].getVlaue(), preDay);
+
+
if (list != null && list.size() > 0) {
+ System.out.println("***********************" +list.size());
totalUser = list.size();
for (UserInfoRegister user : list) {
- Integer total = commonOrderCountService.countOderByUidAndDate(limitDay, user.getId());
- if (total != null && total > 0) {
- totalWeek ++;
+ listUid.add(user.getId());
+ }
+ }
+
+ if (listUid.size() > 0) {
+ List<Long> listUidDown = commonOrderCountService.getDownOrderUserByListUidAndDate(limitDay, listUid);
+ if (listUidDown != null && listUidDown.size() > 0) {
+ System.out.println("***********************" +listUidDown.size());
+ for (Long uid: listUid) {
+ int total = 0;
+ for (Long id: listUidDown) {
+ if (uid.longValue() == id.longValue()) {
+ total ++;
+ }
+ }
+
+ if (total > 0) {
+ System.out.println("-----------------------------------------------------");
+ totalWeek ++;
+ System.out.println(totalWeek);
+ System.out.println("-----------------------------------------------------");
+ }
+
if (total >= 3) {
+ System.out.println("-----------------------------------------------------");
totalWeek3 ++;
+ System.out.println(totalWeek3);
+ System.out.println("-----------------------------------------------------");
}
}
}
}
+
// 璁$畻姣斾緥锛氬綋鍛� 涓嬪崟鐢ㄦ埛鏁�/鏂板鐢ㄦ埛鏁�
BigDecimal total = new BigDecimal(0);
@@ -279,6 +320,9 @@
total = MoneyBigDecimalUtil.mul(total, BigDecimal.valueOf(100));
}
DailyCountUser obj = new DailyCountUser();
+ obj.setRate(true);
+ obj.setTotalDay(BigDecimal.valueOf(totalUser));
+ obj.setTotalValid(BigDecimal.valueOf(totalWeek));
obj.setTotal(total);
obj.setType(DailyCountUserEnum.newUserDownOrderWeek);
obj.setChannel(channels[i].name());
@@ -295,6 +339,9 @@
total3 = MoneyBigDecimalUtil.mul(total3, BigDecimal.valueOf(100));
}
DailyCountUser obj3 = new DailyCountUser();
+ obj3.setRate(true);
+ obj3.setTotalDay(BigDecimal.valueOf(totalUser));
+ obj3.setTotalValid(BigDecimal.valueOf(totalWeek3));
obj3.setTotal(total3);
obj3.setType(DailyCountUserEnum.newUserDownOrderWeek3);
obj3.setChannel(channels[i].name());
--
Gitblit v1.8.0