Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
manager
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
reyun
manager
Commits
8b085178
Commit
8b085178
authored
Oct 21, 2020
by
lzxry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流量同步bug
parent
b8ceff10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
12 deletions
+36
-12
TkioFlow.java
src/main/java/common/model/TkioFlow.java
+11
-1
TkioFlowRepository.java
src/main/java/common/repository/TkioFlowRepository.java
+1
-2
TrackingFlowTask.java
src/main/java/track/task/TrackingFlowTask.java
+24
-9
No files found.
src/main/java/common/model/TkioFlow.java
View file @
8b085178
package
common
.
model
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
/**
...
...
@@ -10,8 +11,9 @@ import javax.persistence.Id;
*/
@Entity
public
class
TkioFlow
{
@Id
@GeneratedValue
private
Long
id
;
private
String
ds
;
private
String
email
;
private
String
contractCode
;
...
...
@@ -57,4 +59,12 @@ public class TkioFlow {
public
void
setCostFlow
(
Long
costFlow
)
{
this
.
costFlow
=
costFlow
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
}
src/main/java/common/repository/TkioFlowRepository.java
View file @
8b085178
...
...
@@ -7,12 +7,11 @@ import org.springframework.data.jpa.repository.Query;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
public
interface
TkioFlowRepository
extends
JpaRepository
<
TkioFlow
,
Long
>
{
@Query
(
value
=
"select sum(flow) from tkio_flow where email = ?1 and contract_code = ?2"
,
nativeQuery
=
true
)
Long
sumFlowByEmailAndContractCode
(
String
email
,
String
contractCode
);
BigDecimal
sumFlowByEmailAndContractCode
(
String
email
,
String
contractCode
);
@Transactional
@Modifying
...
...
src/main/java/track/task/TrackingFlowTask.java
View file @
8b085178
...
...
@@ -16,6 +16,7 @@ import tkio.repository.AppRepository;
import
tkio.service.AccountFlowRestrictService
;
import
util.DateUtil
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
...
...
@@ -92,6 +93,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
contracts
.
get
(
0
));
if
(
tkioFlow
!=
null
)
{
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
else
{
//多个合同
...
...
@@ -125,10 +127,14 @@ public class TrackingFlowTask {
if
(
tkioFlow
!=
null
&&
i
<
contractsArray
.
length
-
1
&&
tkioFlow
.
getCostFlow
()
!=
null
&&
tkioFlow
.
getCostFlow
()
>
0L
)
{
//处理成本流量,如果超出了,依次算在下一个合同上
clickNum
=
BigInteger
.
valueOf
(
tkioFlow
.
getCostFlow
());
tkioFlow
.
setCostFlow
(
null
);
tkioFlowList
.
add
(
tkioFlow
);
if
(
tkioFlow
.
getFlow
()>
0
){
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
else
{
if
(
tkioFlow
!=
null
)
{
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
break
;
}
...
...
@@ -156,6 +162,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
contractsArray
[
j
]);
if
(
tkioFlow
!=
null
)
{
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
break
;
}
...
...
@@ -164,6 +171,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
correlationContract
.
get
(
0
));
if
(
tkioFlow
!=
null
)
{
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
...
...
@@ -172,7 +180,7 @@ public class TrackingFlowTask {
}
}
if
(
tkioFlowList
.
size
()
>
0
)
{
tkioFlowRepository
.
save
(
tkioFlowList
);
//
tkioFlowRepository.save(tkioFlowList);
}
calculationFlow
.
setStatus
(
2
);
calculationFlowRepository
.
save
(
calculationFlow
);
...
...
@@ -211,6 +219,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
contracts
.
get
(
0
));
if
(
tkioFlow
!=
null
){
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
else
{
//多个合同
//看昨日被哪几个合同包含了
...
...
@@ -240,13 +249,17 @@ public class TrackingFlowTask {
for
(
int
i
=
0
;
i
<
contractsArray
.
length
;
i
++)
{
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
contractsArray
[
i
]);
if
(
tkioFlow
!=
null
&&
i
<
contractsArray
.
length
-
1
&&
tkioFlow
.
getCostFlow
()>
0L
){
//处理成本流量,如果超出了,依次算在下一个合同上
if
(
tkioFlow
!=
null
&&
i
<
contractsArray
.
length
-
1
&&
tkioFlow
.
getCostFlow
()
!=
null
&&
tkioFlow
.
getCostFlow
()
>
0L
){
//处理成本流量,如果超出了,依次算在下一个合同上
clickNum
=
BigInteger
.
valueOf
(
tkioFlow
.
getCostFlow
());
tkioFlow
.
setCostFlow
(
null
);
tkioFlowList
.
add
(
tkioFlow
);
if
(
tkioFlow
.
getFlow
()>
0
)
{
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
else
{
if
(
tkioFlow
!=
null
){
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
break
;
}
...
...
@@ -274,6 +287,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
contractsArray
[
j
]);
if
(
tkioFlow
!=
null
){
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
break
;
}
...
...
@@ -285,6 +299,7 @@ public class TrackingFlowTask {
TkioFlow
tkioFlow
=
getTkioFlow
(
clickNum
,
yesterday
,
correlationContract
.
get
(
0
));
if
(
tkioFlow
!=
null
){
tkioFlowList
.
add
(
tkioFlow
);
tkioFlowRepository
.
save
(
tkioFlow
);
}
}
...
...
@@ -296,7 +311,7 @@ public class TrackingFlowTask {
}
if
(
tkioFlowList
.
size
()>
0
){
tkioFlowRepository
.
save
(
tkioFlowList
);
//
tkioFlowRepository.save(tkioFlowList);
}
}
...
...
@@ -334,13 +349,13 @@ public class TrackingFlowTask {
tkioFlow
.
setCostFlow
(
clickNum
.
longValue
());
}
else
{
//查看历史总消耗流量是否超出
Long
totalFlow
=
tkioFlowRepository
.
sumFlowByEmailAndContractCode
(
contract
.
getEmail
(),
contract
.
getContractCode
());
BigDecimal
totalFlow
=
tkioFlowRepository
.
sumFlowByEmailAndContractCode
(
contract
.
getEmail
(),
contract
.
getContractCode
());
if
(
totalFlow
!=
null
){
Double
contractTrackFlow
=
contract
.
getTrackFlow
()
*
4
;
if
(
contractTrackFlow
.
longValue
()-
totalFlow
-
clickNum
.
longValue
()>=
0
){
Double
contractTrackFlow
=
contract
.
getTrackFlow
()
*
10000
;
if
(
contractTrackFlow
.
longValue
()-
totalFlow
.
longValue
()
-
clickNum
.
longValue
()>=
0
){
tkioFlow
.
setFlow
(
clickNum
.
longValue
());
}
else
{
tkioFlow
.
setFlow
(
contractTrackFlow
.
longValue
()
-
totalFlow
);
tkioFlow
.
setFlow
(
contractTrackFlow
.
longValue
()
-
totalFlow
.
longValue
()
);
tkioFlow
.
setCostFlow
(
clickNum
.
longValue
()-
tkioFlow
.
getFlow
());
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment