Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
Overview
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
huluobin
gogirl-miniapp-backend
Commits
90402558
Commit
90402558
authored
Mar 11, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 更新
parent
3b60457e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
69 deletions
+23
-69
CustomerBalanceRecordMapper.java
...ure/mapper/user/customer/CustomerBalanceRecordMapper.java
+2
-1
Schedule.java
...ain/java/com/gogirl/infrastructure/schedule/Schedule.java
+13
-10
CustomerBalanceRecordMapper.xml
...ain/resources/mapper/user/CustomerBalanceRecordMapper.xml
+1
-1
Test.java
src/test/java/com/gogirl/Test.java
+0
-57
ScheduleTest.java
...java/com/gogirl/infrastructure/schedule/ScheduleTest.java
+7
-0
No files found.
src/main/java/com/gogirl/infrastructure/mapper/user/customer/CustomerBalanceRecordMapper.java
View file @
90402558
...
...
@@ -7,6 +7,7 @@ import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.time.LocalDate
;
import
java.util.List
;
...
...
@@ -20,7 +21,7 @@ public interface CustomerBalanceRecordMapper extends BaseMapper<CustomerBalanceR
* @param day 日期形如2020-03-03
* @return list
*/
List
<
CustomerBalanceRecord
>
getXcxChargeRecord
(
String
day
);
List
<
CustomerBalanceRecord
>
getXcxChargeRecord
(
LocalDate
day
);
/**
* 查询会员卡消费记录
...
...
src/main/java/com/gogirl/infrastructure/schedule/Schedule.java
View file @
90402558
...
...
@@ -163,16 +163,9 @@ public class Schedule {
log
.
debug
(
"每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束"
);
}
/**
* 每天23:50设置推荐人:当天服务的技师为推荐人。
*/
@Scheduled
(
cron
=
"0 50 23 * * *"
)
public
void
setChargeReferees
()
{
log
.
debug
(
"每天晚上11:50定时设置当天服务的技师为推荐人** 任务开始"
);
SimpleDateFormat
yyyyMMdd
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
public
void
setChargeReferees
(
LocalDate
localDate
)
{
String
day
=
yyyyMMdd
.
format
(
new
Date
());
log
.
debug
(
"设置推荐人:当天服务的技师为推荐人"
);
Map
<
String
,
String
>
mapTechnicianManage
=
new
HashMap
<>();
...
...
@@ -184,7 +177,7 @@ public class Schedule {
}
//找到当天的订单的推荐人
List
<
CustomerBalanceRecord
>
list
=
balanceRecordDao
.
getXcxChargeRecord
(
day
);
List
<
CustomerBalanceRecord
>
list
=
balanceRecordDao
.
getXcxChargeRecord
(
localDate
);
//遍历设置推荐人
for
(
CustomerBalanceRecord
customerBalanceRecord
:
list
)
{
...
...
@@ -222,7 +215,17 @@ public class Schedule {
}
}
log
.
debug
(
"每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束"
);
}
/**
* 每天23:50设置推荐人:当天服务的技师为推荐人。
*/
@Scheduled
(
cron
=
"0 0 3 * * *"
)
public
void
setChargeReferees
()
{
log
.
debug
(
"每天晚上03:00定时设置昨天服务的技师为推荐人** 任务开始"
);
LocalDate
day
=
LocalDate
.
now
().
minusDays
(
1
);
this
.
setChargeReferees
(
day
);
log
.
debug
(
"每天晚上03:00定时设置昨天服务的技师为推荐人** 任务结束"
);
}
/**
...
...
src/main/resources/mapper/user/CustomerBalanceRecordMapper.xml
View file @
90402558
...
...
@@ -59,7 +59,7 @@
</select>
<select
id=
"getXcxChargeRecord"
resultMap=
"BaseResultMap"
parameterType=
"java.
lang.String
"
>
<select
id=
"getXcxChargeRecord"
resultMap=
"BaseResultMap"
parameterType=
"java.
time.LocalDate
"
>
select cbr.id,
group_concat(os.technician_id) referee_id,
(select om.department_id
...
...
src/test/java/com/gogirl/Test.java
View file @
90402558
...
...
@@ -302,63 +302,6 @@ public class Test {
@Resource
CustomerBalanceRecordMapper
customerBalanceRecordMapper
;
@org
.
junit
.
Test
public
void
setChargeReferees
()
{
log
.
debug
(
"每天晚上11:50定时设置当天服务的技师为推荐人** 任务开始"
);
SimpleDateFormat
yyyyMMdd
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
day
=
"2020-04-04"
;
log
.
debug
(
"设置推荐人:当天服务的技师为推荐人"
);
Map
<
String
,
String
>
mapTechnicianManage
=
new
HashMap
<>();
List
<
StoreTechnician
>
listTechnicianManage
=
storeTechnicianService
.
listTechnicianForPage
(
new
StoreTechnician
());
//查出所有的技师,找到技师id和user_id
for
(
StoreTechnician
item
:
listTechnicianManage
)
{
mapTechnicianManage
.
put
(
String
.
valueOf
(
item
.
getTechnicianId
()),
String
.
valueOf
(
item
.
getUserId
()));
}
//找到当天的订单的推荐人
List
<
CustomerBalanceRecord
>
list
=
customerBalanceRecordMapper
.
getXcxChargeRecord
(
day
);
//遍历设置推荐人
for
(
CustomerBalanceRecord
customerBalanceRecord
:
list
)
{
//推荐人列表
Map
<
String
,
String
>
map
=
new
HashMap
<>();
//推荐人id
StringBuilder
referee_ids
=
new
StringBuilder
();
//充值记录
CustomerBalanceRecord
cbrt
=
customerBalanceRecordMapper
.
selectById
(
customerBalanceRecord
.
getId
());
//每次都修改推荐人,且每晚都会设置推荐人
if
(
customerBalanceRecord
.
getRefereeId
()
!=
null
)
{
String
[]
arr
=
customerBalanceRecord
.
getRefereeId
().
split
(
","
);
//
for
(
String
s
:
arr
)
{
if
(!
map
.
containsKey
(
s
))
{
map
.
put
(
s
,
s
);
referee_ids
.
append
(
","
).
append
(
mapTechnicianManage
.
get
(
s
));
}
}
//去掉首尾,
if
(
referee_ids
.
toString
().
startsWith
(
","
))
{
referee_ids
=
new
StringBuilder
(
referee_ids
.
substring
(
1
));
}
customerBalanceRecord
.
setRefereeId
(
referee_ids
.
toString
());
}
//如果店铺id不为空
if
(
cbrt
!=
null
&&
cbrt
.
getDepartmentId
()
!=
null
)
{
customerBalanceRecord
.
setDepartmentId
(
cbrt
.
getDepartmentId
());
}
if
(
customerBalanceRecord
.
getId
()
!=
null
&&
(
customerBalanceRecord
.
getRefereeId
()
!=
null
||
customerBalanceRecord
.
getDepartmentId
()
!=
null
))
{
customerBalanceRecordMapper
.
updateById
(
customerBalanceRecord
);
}
}
log
.
debug
(
"每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束"
);
}
@Resource
PurchaseStockMapper
purchaseStockMapper
;
...
...
src/test/java/com/gogirl/infrastructure/schedule/ScheduleTest.java
View file @
90402558
package
com
.
gogirl
.
infrastructure
.
schedule
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.time.LocalDate
;
/**
* <p>
*
...
...
@@ -24,5 +27,9 @@ public class ScheduleTest {
@Autowired
Schedule
schedule
;
@Test
public
void
setChargeReferees
()
{
schedule
.
setChargeReferees
(
LocalDate
.
of
(
2021
,
2
,
5
));
}
}
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