Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
Project
Project
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
licc
data-server
Commits
7f6c80fc
Commit
7f6c80fc
authored
Mar 11, 2021
by
m1991
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
4181aec1
53caafc8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
182 additions
and
43 deletions
+182
-43
IpUtil.java
...ommon/src/main/java/cn/wisenergy/common/utils/IpUtil.java
+54
-0
OrderMapper.java
...mapper/src/main/java/cn/wisenergy/mapper/OrderMapper.java
+7
-0
OrderMapper.xml
wisenergy-mapper/src/main/resources/mapper/OrderMapper.xml
+13
-0
AccountService.java
...rc/main/java/cn/wisenergy/service/app/AccountService.java
+1
-3
MonthTaskService.java
.../main/java/cn/wisenergy/service/app/MonthTaskService.java
+1
-3
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+3
-1
MonthTaskServiceImpl.java
...a/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
+37
-35
XxlJobConfig.java
...n/src/main/java/cn/wisenergy/web/config/XxlJobConfig.java
+65
-0
application.yml
wisenergy-web-admin/src/main/resources/application.yml
+1
-1
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/IpUtil.java
0 → 100644
View file @
7f6c80fc
package
cn
.
wisenergy
.
common
.
utils
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.UnknownHostException
;
import
java.util.Enumeration
;
public
class
IpUtil
{
/**
* 正确的IP拿法,即优先拿site-local地址
*
* @return
* @throws UnknownHostException
*/
public
static
InetAddress
getLocalHostLANAddress
()
throws
UnknownHostException
{
try
{
InetAddress
candidateAddress
=
null
;
// 遍历所有的网络接口
for
(
Enumeration
<
NetworkInterface
>
ifaces
=
NetworkInterface
.
getNetworkInterfaces
();
ifaces
.
hasMoreElements
();
)
{
NetworkInterface
iface
=
ifaces
.
nextElement
();
// 在所有的接口下再遍历IP
for
(
Enumeration
<
InetAddress
>
inetAddrs
=
iface
.
getInetAddresses
();
inetAddrs
.
hasMoreElements
();
)
{
InetAddress
inetAddr
=
inetAddrs
.
nextElement
();
if
(!
inetAddr
.
isLoopbackAddress
())
{
// 排除loopback类型地址
if
(
inetAddr
.
isSiteLocalAddress
())
{
// 如果是site-local地址,就是它了
return
inetAddr
;
}
else
if
(
candidateAddress
==
null
)
{
// site-local类型的地址未被发现,先记录候选地址
candidateAddress
=
inetAddr
;
}
}
}
}
if
(
candidateAddress
!=
null
)
{
return
candidateAddress
;
}
// 如果没有发现 non-loopback地址.只能用最次选的方案
InetAddress
jdkSuppliedAddress
=
InetAddress
.
getLocalHost
();
if
(
jdkSuppliedAddress
==
null
)
{
throw
new
UnknownHostException
(
"The JDK InetAddress.getLocalHost() method unexpectedly returned null."
);
}
return
jdkSuppliedAddress
;
}
catch
(
Exception
e
)
{
UnknownHostException
unknownHostException
=
new
UnknownHostException
(
"Failed to determine LAN address: "
+
e
);
unknownHostException
.
initCause
(
e
);
throw
unknownHostException
;
}
}
}
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/OrderMapper.java
View file @
7f6c80fc
...
...
@@ -49,4 +49,11 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
* @return 订单列表
*/
List
<
OrderInfo
>
getListBySuccessTime
(
@Param
(
"successTime"
)
Date
successTime
);
/**
* 更据创建订单时间获取订单列表
* @param createTime 创建订单时间
* @return 订单列表
*/
List
<
OrderInfo
>
getByCreateTime
(
@Param
(
"createTime"
)
Date
createTime
);
}
wisenergy-mapper/src/main/resources/mapper/OrderMapper.xml
View file @
7f6c80fc
...
...
@@ -140,4 +140,17 @@
</where>
</select>
<select
id=
"getByCreateTime"
resultType=
"cn.wisenergy.model.app.OrderInfo"
>
SELECT
<include
refid=
"cols_all"
/>
from
<include
refid=
"table"
/>
<where>
<if
test=
"successTime != null "
>
YEAR(create_time) = YEAR(#{successTime})
AND MONTH(create_time) = MONTH(#{successTime})
</if>
</where>
</select>
</mapper>
\ No newline at end of file
wisenergy-service/src/main/java/cn/wisenergy/service/app/AccountService.java
View file @
7f6c80fc
...
...
@@ -29,11 +29,9 @@ public interface AccountService {
/**
* 收益和业绩统计(月度肥料 -日)
*
* @param list 订单信息
* @return true or false
*/
R
<
Boolean
>
performanceCount
(
List
<
OrderInfo
>
list
);
R
<
Boolean
>
performanceCount
();
/**
* 获取用户的商机信息
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/MonthTaskService.java
View file @
7f6c80fc
...
...
@@ -21,11 +21,9 @@ public interface MonthTaskService {
/**
* 收益和业绩统计(月度肥料)-月任务
*
* @param list 订单信息
* @return true or false
*/
R
<
Boolean
>
performanceCount
(
List
<
OrderInfo
>
list
);
R
<
Boolean
>
performanceCount
();
/**
* 进步奖收益统计(最大进步奖) -月任务
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
7f6c80fc
...
...
@@ -113,7 +113,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
}
@Override
public
R
<
Boolean
>
performanceCount
(
List
<
OrderInfo
>
list
)
{
public
R
<
Boolean
>
performanceCount
()
{
//获取本月订单
List
<
OrderInfo
>
list
=
orderMapper
.
getByCreateTime
(
new
Date
());
log
.
info
(
"shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}"
,
list
.
size
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
R
.
ok
(
0
,
true
);
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
View file @
7f6c80fc
...
...
@@ -76,7 +76,10 @@ public class MonthTaskServiceImpl implements MonthTaskService {
}
@Override
public
R
<
Boolean
>
performanceCount
(
List
<
OrderInfo
>
list
)
{
public
R
<
Boolean
>
performanceCount
()
{
//获取上月订单
Date
lastMonth
=
DateUtil
.
getLastMonth
(
new
Date
());
List
<
OrderInfo
>
list
=
orderMapper
.
getByCreateTime
(
lastMonth
);
log
.
info
(
"shop-mall[]AccountServiceImpl[]performanceCount[]input.param.list:{}"
,
list
.
size
());
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
R
.
ok
(
0
,
true
);
...
...
@@ -99,47 +102,46 @@ public class MonthTaskServiceImpl implements MonthTaskService {
for
(
OrderInfo
orderInfo
:
list
)
{
long
createTime
=
orderInfo
.
getCreated
().
getTime
();
long
time
=
System
.
currentTimeMillis
();
if
(
createTime
<=
time
)
{
//获取用户信息
User
user
=
usersMapper
.
selectById
(
orderInfo
.
getBuyerId
());
if
(
null
==
user
)
{
continue
;
}
List
<
TeamPerformance
>
teamPerformances
=
new
ArrayList
<>();
//获取用户信息
User
user
=
usersMapper
.
selectById
(
orderInfo
.
getBuyerId
());
if
(
null
==
user
)
{
continue
;
}
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
continue
;
}
List
<
TeamPerformance
>
teamPerformances
=
new
ArrayList
<>();
//1、统计当前用户月度业绩
BigDecimal
userCount
=
teamPerformance
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
teamPerformance
.
setMonthTeamPerformance
(
userCount
);
teamPerformances
.
add
(
teamPerformance
);
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
continue
;
}
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List
<
User
>
userList
=
accountService
.
getByList
(
user
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
continue
;
}
//1、统计当前用户月度业绩
BigDecimal
userCount
=
teamPerformance
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
teamPerformance
.
setMonthTeamPerformance
(
userCount
);
teamPerformances
.
add
(
teamPerformance
);
//3、统计当前用户上级月度绩效
for
(
User
userInfo
:
userList
)
{
TeamPerformance
team
=
teamPerformanceMapper
.
getByUserIdAndTime
(
userInfo
.
getUserId
(),
yearMonth
);
if
(
null
==
team
)
{
continue
;
}
//1)、统计当前用户月度绩效
BigDecimal
monthCount
=
team
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
team
.
setMonthTeamPerformance
(
monthCount
);
teamPerformances
.
add
(
team
);
}
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List
<
User
>
userList
=
accountService
.
getByList
(
user
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
continue
;
}
//4、更新账户月度绩效
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
//3、统计当前用户上级月度绩效
for
(
User
userInfo
:
userList
)
{
TeamPerformance
team
=
teamPerformanceMapper
.
getByUserIdAndTime
(
userInfo
.
getUserId
(),
yearMonth
);
if
(
null
==
team
)
{
continue
;
}
//1)、统计当前用户月度绩效
BigDecimal
monthCount
=
team
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
team
.
setMonthTeamPerformance
(
monthCount
);
teamPerformances
.
add
(
team
);
}
//4、更新账户月度绩效
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
}
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/config/XxlJobConfig.java
0 → 100644
View file @
7f6c80fc
package
cn
.
wisenergy
.
web
.
config
;
import
cn.wisenergy.common.utils.IpUtil
;
import
com.xxl.job.core.executor.impl.XxlJobSpringExecutor
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.net.UnknownHostException
;
@Configuration
public
class
XxlJobConfig
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
XxlJobConfig
.
class
);
@Value
(
"${xxl.job.admin.addresses}"
)
private
String
adminAddresses
;
@Value
(
"${xxl.job.accessToken}"
)
private
String
accessToken
;
@Value
(
"${xxl.job.executor.appname}"
)
private
String
appname
;
@Value
(
"${xxl.job.executor.address}"
)
private
String
address
;
@Value
(
"${xxl.job.executor.ip}"
)
private
String
ip
;
@Value
(
"${xxl.job.executor.port}"
)
private
int
port
;
@Value
(
"${xxl.job.executor.logpath}"
)
private
String
logPath
;
@Value
(
"${xxl.job.executor.logretentiondays}"
)
private
int
logRetentionDays
;
@Bean
public
XxlJobSpringExecutor
xxlJobExecutor
()
{
LOGGER
.
info
(
">>>>>>>>>>> xxl-job config init."
);
XxlJobSpringExecutor
xxlJobSpringExecutor
=
new
XxlJobSpringExecutor
();
xxlJobSpringExecutor
.
setAdminAddresses
(
adminAddresses
);
xxlJobSpringExecutor
.
setAppname
(
appname
);
xxlJobSpringExecutor
.
setAddress
(
address
);
String
ip
=
null
;
try
{
ip
=
IpUtil
.
getLocalHostLANAddress
().
getHostAddress
();
}
catch
(
UnknownHostException
e
)
{
LOGGER
.
error
(
"UnknownHostException "
,
e
);
}
LOGGER
.
info
(
"XxlJobSpringExecutor ip:"
+
ip
);
xxlJobSpringExecutor
.
setIp
(
ip
);
xxlJobSpringExecutor
.
setIp
(
ip
);
xxlJobSpringExecutor
.
setPort
(
port
);
xxlJobSpringExecutor
.
setAccessToken
(
accessToken
);
xxlJobSpringExecutor
.
setLogPath
(
logPath
);
xxlJobSpringExecutor
.
setLogRetentionDays
(
logRetentionDays
);
return
xxlJobSpringExecutor
;
}
}
wisenergy-web-admin/src/main/resources/application.yml
View file @
7f6c80fc
...
...
@@ -60,7 +60,7 @@ xxl:
executor
:
address
:
appname
:
shop-mall
ip
:
172.24.252.165
ip
:
logpath
:
/var/logs/xxl-job/jobhandler
logretentiondays
:
30
port
:
9999
\ No newline at end of file
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