Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
7d1fbc74
Commit
7d1fbc74
authored
Nov 25, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
签到测试数据插入接口
parent
88a8cf28
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
12 deletions
+93
-12
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserSignInDao.java
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserSignInDao.java
+2
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/UserSignInDaoImpl.java
.../src/main/java/com/wwdz/ch/db/impl/UserSignInDaoImpl.java
+12
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
.../main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
+10
-12
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/UserSigninController.java
...rc/main/java/com/wwdz/ch/wx/web/UserSigninController.java
+69
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserSignInDao.java
View file @
7d1fbc74
...
@@ -36,4 +36,6 @@ public interface UserSignInDao {
...
@@ -36,4 +36,6 @@ public interface UserSignInDao {
boolean
update
(
UserSignIn
userSignin
);
boolean
update
(
UserSignIn
userSignin
);
boolean
updateByPrimaryKey
(
UserSignIn
userSignin
);
boolean
updateByPrimaryKey
(
UserSignIn
userSignin
);
boolean
deleteTodayRecord
(
long
userId
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/impl/UserSignInDaoImpl.java
View file @
7d1fbc74
...
@@ -97,4 +97,16 @@ public class UserSignInDaoImpl implements UserSignInDao {
...
@@ -97,4 +97,16 @@ public class UserSignInDaoImpl implements UserSignInDao {
public
boolean
updateByPrimaryKey
(
UserSignIn
userSignin
)
{
public
boolean
updateByPrimaryKey
(
UserSignIn
userSignin
)
{
return
userSignInMapper
.
updateByPrimaryKeySelective
(
userSignin
)
>
0
;
return
userSignInMapper
.
updateByPrimaryKeySelective
(
userSignin
)
>
0
;
}
}
@Override
public
boolean
deleteTodayRecord
(
long
userId
)
{
LocalDate
today
=
LocalDate
.
now
();
String
todayString
=
DateUtils
.
DATE
.
format
(
today
);
UserSignInExample
example
=
new
UserSignInExample
();
UserSignInExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andUserIdEqualTo
(
userId
);
criteria
.
andSignInDateEqualTo
(
todayString
);
return
userSignInMapper
.
deleteByExample
(
example
)
>
0
;
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
View file @
7d1fbc74
package
com.wwdz.ch.wx.impl
;
package
com.wwdz.ch.wx.impl
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.DistributionEnum
;
import
com.wwdz.ch.core.consts.SigninEnum
;
import
com.wwdz.ch.core.consts.SigninEnum
;
...
@@ -24,7 +23,6 @@ import com.xxdxxs.utils.DateUtils;
...
@@ -24,7 +23,6 @@ import com.xxdxxs.utils.DateUtils;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.JsonUtils
;
import
com.xxdxxs.utils.JsonUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
com.xxdxxs.utils.StringUtils
;
import
org.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -45,7 +43,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -45,7 +43,7 @@ public class UserSigninServiceImpl implements UserSigninService {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserSigninServiceImpl
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserSigninServiceImpl
.
class
);
@Autowired
@Autowired
UserSignInDao
userSign
i
nDao
;
UserSignInDao
userSign
I
nDao
;
@Autowired
@Autowired
SupplierItemDao
supplierItemDao
;
SupplierItemDao
supplierItemDao
;
...
@@ -68,11 +66,11 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -68,11 +66,11 @@ public class UserSigninServiceImpl implements UserSigninService {
long
userId
=
dto
.
getUserId
();
long
userId
=
dto
.
getUserId
();
//检查是否已签到过
//检查是否已签到过
String
todayStr
=
DateUtils
.
DATE
.
format
(
LocalDate
.
now
());
String
todayStr
=
DateUtils
.
DATE
.
format
(
LocalDate
.
now
());
if
(
userSign
i
nDao
.
isExisted
(
userId
,
todayStr
))
{
if
(
userSign
I
nDao
.
isExisted
(
userId
,
todayStr
))
{
return
Result
.
failed
(
"您今天已签到过"
);
return
Result
.
failed
(
"您今天已签到过"
);
}
}
//今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天
//今天尚未签到,则进行记录,先查询昨天的打卡记录,有则再连续打卡天数上+1,没有则算签到第一天
UserSignIn
yesterdaySignin
=
userSign
i
nDao
.
findYesterdayRecord
(
userId
);
UserSignIn
yesterdaySignin
=
userSign
I
nDao
.
findYesterdayRecord
(
userId
);
if
(
yesterdaySignin
==
null
)
{
if
(
yesterdaySignin
==
null
)
{
UserSignIn
userSignin
=
new
UserSignIn
();
UserSignIn
userSignin
=
new
UserSignIn
();
userSignin
.
setUserId
(
userId
);
userSignin
.
setUserId
(
userId
);
...
@@ -83,7 +81,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -83,7 +81,7 @@ public class UserSigninServiceImpl implements UserSigninService {
userSignin
.
setIsGet
(
false
);
userSignin
.
setIsGet
(
false
);
userSignin
.
setIsReward
(
false
);
userSignin
.
setIsReward
(
false
);
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
ZERO
.
getCode
());
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
ZERO
.
getCode
());
userSign
i
nDao
.
insert
(
userSignin
);
userSign
I
nDao
.
insert
(
userSignin
);
}
else
{
}
else
{
UserSignIn
userSignin
=
new
UserSignIn
();
UserSignIn
userSignin
=
new
UserSignIn
();
userSignin
.
setUserId
(
userId
);
userSignin
.
setUserId
(
userId
);
...
@@ -115,7 +113,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -115,7 +113,7 @@ public class UserSigninServiceImpl implements UserSigninService {
break
;
break
;
}
}
userSignin
.
setIsGet
(
false
);
userSignin
.
setIsGet
(
false
);
userSign
i
nDao
.
insert
(
userSignin
);
userSign
I
nDao
.
insert
(
userSignin
);
}
}
Result
getShareInfoResult
=
getShareInfo
(
dto
);
Result
getShareInfoResult
=
getShareInfo
(
dto
);
if
(
getShareInfoResult
.
getSuccess
())
{
if
(
getShareInfoResult
.
getSuccess
())
{
...
@@ -134,7 +132,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -134,7 +132,7 @@ public class UserSigninServiceImpl implements UserSigninService {
public
Result
getReward
(
UserSignInRequestDto
dto
)
{
public
Result
getReward
(
UserSignInRequestDto
dto
)
{
try
{
try
{
//查询签到记录
//查询签到记录
UserSignIn
userSignin
=
userSign
i
nDao
.
findRecord
(
dto
.
getUserId
(),
dto
.
getSignInDate
());
UserSignIn
userSignin
=
userSign
I
nDao
.
findRecord
(
dto
.
getUserId
(),
dto
.
getSignInDate
());
if
(!
userSignin
.
getIsReward
())
{
if
(!
userSignin
.
getIsReward
())
{
return
Result
.
failed
(
"尚未完成连续签到的天数"
);
return
Result
.
failed
(
"尚未完成连续签到的天数"
);
}
}
...
@@ -145,7 +143,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -145,7 +143,7 @@ public class UserSigninServiceImpl implements UserSigninService {
updateDto
.
setId
(
userSignin
.
getId
());
updateDto
.
setId
(
userSignin
.
getId
());
updateDto
.
setIsGet
(
true
);
updateDto
.
setIsGet
(
true
);
updateDto
.
setUpdateTime
(
new
Date
());
updateDto
.
setUpdateTime
(
new
Date
());
userSign
i
nDao
.
updateByPrimaryKey
(
updateDto
);
userSign
I
nDao
.
updateByPrimaryKey
(
updateDto
);
//创建赠品订单
//创建赠品订单
DistributionOrder
distributionOrder
=
new
DistributionOrder
();
DistributionOrder
distributionOrder
=
new
DistributionOrder
();
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
CommConsts
.
DISTRIBUTION_ORDER_PREFIX
);
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
CommConsts
.
DISTRIBUTION_ORDER_PREFIX
);
...
@@ -181,7 +179,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -181,7 +179,7 @@ public class UserSigninServiceImpl implements UserSigninService {
long
userId
=
dto
.
getUserId
();
long
userId
=
dto
.
getUserId
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
//查询今天的打卡记录
//查询今天的打卡记录
UserSignIn
todayRecord
=
userSign
i
nDao
.
findTodayRecord
(
userId
);
UserSignIn
todayRecord
=
userSign
I
nDao
.
findTodayRecord
(
userId
);
if
(
todayRecord
!=
null
)
{
if
(
todayRecord
!=
null
)
{
resultMap
.
put
(
"todaySignIn"
,
true
);
resultMap
.
put
(
"todaySignIn"
,
true
);
}
else
{
}
else
{
...
@@ -189,7 +187,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -189,7 +187,7 @@ public class UserSigninServiceImpl implements UserSigninService {
}
}
//检查昨天是否打过卡
//检查昨天是否打过卡
UserSignIn
yesterdaySignIn
=
userSign
i
nDao
.
findYesterdayRecord
(
userId
);
UserSignIn
yesterdaySignIn
=
userSign
I
nDao
.
findYesterdayRecord
(
userId
);
if
(
yesterdaySignIn
==
null
)
{
if
(
yesterdaySignIn
==
null
)
{
//连续签到天数
//连续签到天数
resultMap
.
put
(
"consecutiveDays"
,
0
);
resultMap
.
put
(
"consecutiveDays"
,
0
);
...
@@ -247,7 +245,7 @@ public class UserSigninServiceImpl implements UserSigninService {
...
@@ -247,7 +245,7 @@ public class UserSigninServiceImpl implements UserSigninService {
Date
endTime
=
DateTimeUtil
.
getDateWithMaxTime
(
dateList
.
get
((
dateList
.
size
()
-
1
)));
Date
endTime
=
DateTimeUtil
.
getDateWithMaxTime
(
dateList
.
get
((
dateList
.
size
()
-
1
)));
dto
.
setStartQueryTime
(
startTime
);
dto
.
setStartQueryTime
(
startTime
);
dto
.
setEndQueryTime
(
endTime
);
dto
.
setEndQueryTime
(
endTime
);
List
<
UserSignIn
>
userSignInList
=
userSign
i
nDao
.
findList
(
dto
);
List
<
UserSignIn
>
userSignInList
=
userSign
I
nDao
.
findList
(
dto
);
List
<
String
>
signDateList
=
userSignInList
.
stream
().
map
(
UserSignIn:
:
getSignInDate
).
collect
(
Collectors
.
toList
());
List
<
String
>
signDateList
=
userSignInList
.
stream
().
map
(
UserSignIn:
:
getSignInDate
).
collect
(
Collectors
.
toList
());
Map
<
String
,
UserSignIn
>
signDateMap
=
userSignInList
.
stream
().
collect
(
Collectors
.
toMap
(
UserSignIn:
:
getSignInDate
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
Map
<
String
,
UserSignIn
>
signDateMap
=
userSignInList
.
stream
().
collect
(
Collectors
.
toMap
(
UserSignIn:
:
getSignInDate
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
List
<
SignDateRecord
>
calendar
=
new
ArrayList
<>();
List
<
SignDateRecord
>
calendar
=
new
ArrayList
<>();
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/UserSigninController.java
View file @
7d1fbc74
...
@@ -2,10 +2,14 @@ package com.wwdz.ch.wx.web;
...
@@ -2,10 +2,14 @@ package com.wwdz.ch.wx.web;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.wwdz.ch.core.consts.ResultCode
;
import
com.wwdz.ch.core.consts.SigninEnum
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.core.type.Result
;
import
com.wwdz.ch.db.dao.UserSignInDao
;
import
com.wwdz.ch.db.domain.UserSignIn
;
import
com.wwdz.ch.db.dto.request.UserSignInRequestDto
;
import
com.wwdz.ch.db.dto.request.UserSignInRequestDto
;
import
com.wwdz.ch.wx.service.UserSigninService
;
import
com.wwdz.ch.wx.service.UserSigninService
;
import
com.xxdxxs.service.FormHandler
;
import
com.xxdxxs.service.FormHandler
;
import
com.xxdxxs.utils.DateUtils
;
import
com.xxdxxs.validation.Validator
;
import
com.xxdxxs.validation.Validator
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -16,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
...
@@ -16,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDate
;
import
java.util.Date
;
@RestController
@RestController
@RequestMapping
(
"/wx/userSignIn"
)
@RequestMapping
(
"/wx/userSignIn"
)
public
class
UserSigninController
{
public
class
UserSigninController
{
...
@@ -25,6 +32,9 @@ public class UserSigninController {
...
@@ -25,6 +32,9 @@ public class UserSigninController {
@Autowired
@Autowired
UserSigninService
userSigninService
;
UserSigninService
userSigninService
;
@Autowired
UserSignInDao
userSignInDao
;
@ApiOperation
(
value
=
"用户签到"
)
@ApiOperation
(
value
=
"用户签到"
)
@PostMapping
(
"/signIn"
)
@PostMapping
(
"/signIn"
)
public
Result
signIn
(
@RequestBody
UserSignInRequestDto
dto
)
{
public
Result
signIn
(
@RequestBody
UserSignInRequestDto
dto
)
{
...
@@ -81,4 +91,63 @@ public class UserSigninController {
...
@@ -81,4 +91,63 @@ public class UserSigninController {
}
}
return
userSigninService
.
getShareInfo
(
dto
);
return
userSigninService
.
getShareInfo
(
dto
);
}
}
@ApiOperation
(
value
=
"删除今天的签到记录,测试用"
)
@PostMapping
(
"/deleteTodayRecord"
)
public
Result
deleteTodayRecord
(
@RequestBody
UserSignInRequestDto
dto
)
{
logger
.
info
(
"【请求开始】删除今天的签到记录,测试用,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户id"
).
must
().
number
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
ResultCode
.
PARAM_ERROR
);
}
userSignInDao
.
deleteTodayRecord
(
dto
.
getUserId
());
return
Result
.
success
();
}
@ApiOperation
(
value
=
"签到,测试用"
)
@PostMapping
(
"/testSignIn"
)
public
Result
testSignIn
(
@RequestBody
UserSignInRequestDto
dto
)
{
logger
.
info
(
"【请求开始】签到,测试用,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户id"
).
must
().
number
()
.
end
();
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
ResultCode
.
PARAM_ERROR
);
}
for
(
int
i
=
dto
.
getConsecutiveDays
()
-
1
;
i
>
0
;
i
--)
{
LocalDate
startDate
=
LocalDate
.
now
().
minusDays
(
i
);
String
startDateStr
=
DateUtils
.
DATE
.
format
(
startDate
);
UserSignIn
userSignin
=
new
UserSignIn
();
userSignin
.
setUserId
(
dto
.
getUserId
());
userSignin
.
setSignInDate
(
startDateStr
);
userSignin
.
setCreateTime
(
new
Date
());
userSignin
.
setUpdateTime
(
new
Date
());
userSignin
.
setConsecutiveDays
(
dto
.
getConsecutiveDays
()
-
i
);
switch
(
userSignin
.
getConsecutiveDays
())
{
case
7
:
userSignin
.
setIsReward
(
true
);
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
FIRST
.
getCode
());
break
;
case
14
:
userSignin
.
setIsReward
(
true
);
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
SECOND
.
getCode
());
break
;
case
21
:
userSignin
.
setIsReward
(
true
);
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
THIRD
.
getCode
());
break
;
default
:
userSignin
.
setIsReward
(
false
);
userSignin
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
ZERO
.
getCode
());
break
;
}
userSignin
.
setIsGet
(
false
);
userSignInDao
.
insert
(
userSignin
);
}
return
Result
.
success
();
}
}
}
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