Commit 644c0f5f by kangxiaoshan

月流量报表

parent 1a41f230
......@@ -12,6 +12,7 @@ import javax.persistence.Id;
@Entity
public class TkioFlowHistory {
@Id
@GeneratedValue
private Long id;
private String ds;
private String email;
......@@ -23,10 +24,8 @@ public class TkioFlowHistory {
private String nextCode;
private Integer firstRecode;
public TkioFlowHistory() {
}
public TkioFlowHistory(TkioFlow flow) {
......
......@@ -1564,7 +1564,6 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
public boolean checkLateContract(DateTime dateTime, DateTime creatTime) {
int aferDays = dateTime.monthOfYear().get() == 12 ? 29 : 9;
return dateTime.dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(creatTime);
}
private int getDayRange(DateTime range1, DateTime range2) {
......
......@@ -91,6 +91,8 @@ public class TrackingFlowTask {
}
private void calculationFlowByAccount(CalculationFlow calculationFlow, String email) {
System.out.println(email + " 账号正在处理流量");
try {
Account account = accountRepository.findByEmail(email);
List<Account> accountList = accountRepository.findByRootParent(account.getRootParent());
......@@ -261,7 +263,6 @@ public class TrackingFlowTask {
skip = false;
}
TkioFlow tkioFlow = getTkioFlow(clickFlow, yesterday, sortedContract.get(i), true);
Long costFlow = tkioFlow.getCostFlow() == null ? 0L : tkioFlow.getCostFlow();
TkioFlowHistory flowHistory = new TkioFlowHistory(tkioFlow);
......@@ -281,42 +282,44 @@ public class TrackingFlowTask {
Contract next = sortedContract.get(i + 1);
if (DateTime.parse(next.getStartDate()).isBefore(DateTime.parse(yesterday))
|| DateTime.parse(next.getStartDate()).isEqual(DateTime.parse(yesterday))) {
// 生效
if (DateTime.parse(next.getStartDate()).monthOfYear().get() != new DateTime(next.getCreateTime()).monthOfYear().get()
&& new DateTime(next.getCreateTime()).dayOfMonth().get() > 10) {
if (laterRecodeContract(DateTime.parse(next.getStartDate()), new DateTime(next.getCreateTime()))) {
//生效且晚录
if (DateTime.parse(yesterday).isBefore(new DateTime(next.getCreateTime()).dayOfMonth().withMinimumValue())) {
//下一合同录入月1号之前的超出流量计入上分合同
flowHistory.setNextCode(next.getContractCode());//标记用于那份合同的调整流量 (该字段不为空的合同外流量之和为该字段对应合同的调整流量)
tkioFlowHistoryRepository.save(flowHistory);
break;
} else {
//下一合同录入月1号及之后的超出流量计入自己
clickFlow = new BigInteger(costFlow.toString());
fistRecode = true;//首次记录流量 (用于标记调整流量 归属在 合同所在月份中的第一个开始月份)
continue;
}
} else {
//2、生效且非晚录合同 超出流量计入下一合同
//2、生效且非晚录合同 超出流量计入下一合同
clickFlow = new BigInteger(costFlow.toString());
fistRecode = true;
continue;
}
}
//3、未生效或晚录合同 则关联流量信息到当前合同
if (DateTime.parse(yesterday).monthOfYear().get() == DateTime.parse(next.getStartDate()).monthOfYear().get()) {
//生效当月 超出的流量关联到 该合同
clickFlow = new BigInteger(costFlow.toString());
fistRecode = true;
continue;
} else {
//生效当月之前 超出的流量计入上一合同
flowHistory.setNextCode(next.getContractCode());//标记用于那份合同的调整流量
//未生效 超出的流量计入自己
tkioFlowHistoryRepository.save(flowHistory);
break;
}
break;
} else {
//无下一份合同 则关联流量信息到当前合同内
//无下一份合同 超出的流量计入自己
tkioFlowHistoryRepository.save(flowHistory);
}
}
return clickFlow;
}
public void task() {
List<String> emails = contractRepository.findDistinctEmailByPlatform("tkio");
List<String> emails = contractRepository.findDistinctEmailByPlatform("tkio");
List<TkioFlow> tkioFlowList = new ArrayList<>();
String yesterday = DateUtil.getBeforeDays(1);//昨日
logger.info("昨日流量同步:" + yesterday);
......@@ -516,6 +519,11 @@ public class TrackingFlowTask {
return sortedContract;
}
public boolean laterRecodeContract(DateTime startTime, DateTime creatTime) {
int aferDays = startTime.monthOfYear().get() == 12 ? 29 : 9;
return startTime.dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(creatTime);
}
public static void main(String[] args) throws ParseException {
String ago = "2020-10-01";
int between = DateUtil.daysBetween(ago, DateUtil.getBeforeDays(1)) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment