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
f1ed8e80
Commit
f1ed8e80
authored
Nov 22, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
签到
parent
f35e3c30
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
157 additions
and
561 deletions
+157
-561
ch-core/src/main/java/com/wwdz/ch/core/entity/SignDateRecord.java
...src/main/java/com/wwdz/ch/core/entity/SignDateRecord.java
+59
-0
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
+10
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/UserSigninMapper.xml
...main/resources/com/wwdz/ch/db/mapper/UserSigninMapper.xml
+0
-542
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
.../main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
+81
-14
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/UserSigninService.java
...c/main/java/com/wwdz/ch/wx/service/UserSigninService.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/UserSigninController.java
...rc/main/java/com/wwdz/ch/wx/web/UserSigninController.java
+4
-4
No files found.
ch-core/src/main/java/com/wwdz/ch/core/entity/SignDateRecord.java
0 → 100644
View file @
f1ed8e80
package
com.wwdz.ch.core.entity
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
@Data
public
class
SignDateRecord
implements
Entity
{
/**
* 日期字符串
* 不含月份
*/
private
Integer
dayStr
;
/**
* 签到日期
* 2024-11-22
*/
private
String
signDate
;
/**
* 是否达到了奖励的签到天数
*/
private
Boolean
isReward
;
/**
* 奖励
*/
private
String
rewardImageUrl
;
/**
* 连续天数
*/
private
Integer
consecutiveDays
;
/**
* 奖励等级
*/
private
Integer
rewardLevel
;
/**
* 是否领取奖励
*/
private
Boolean
isGet
;
/**
* 是否签到过
*/
private
Boolean
isSignIn
;
/**
* 日期的状态
* 0过去,1当前,2未来
*/
private
Integer
dateState
;
}
ch-dao/src/main/java/com/wwdz/ch/db/dao/UserSigninDao.java
View file @
f1ed8e80
...
...
@@ -20,6 +20,8 @@ public interface UserSigninDao {
*/
UserSignIn
findYesterdayRecord
(
long
userId
);
UserSignIn
findTodayRecord
(
long
userId
);
/**
* 判断某一日期是否签到过
* @param userId
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/UserSigninDaoImpl.java
View file @
f1ed8e80
...
...
@@ -54,6 +54,16 @@ public class UserSigninDaoImpl implements UserSigninDao {
return
userSignInMapper
.
selectOneByExample
(
example
);
}
@Override
public
UserSignIn
findTodayRecord
(
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
.
selectOneByExample
(
example
);
}
@Override
public
boolean
isExisted
(
long
userId
,
String
date
)
{
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/UserSigninMapper.xml
View file @
f1ed8e80
...
...
@@ -369,546 +369,4 @@
</if>
limit 1
</select>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.UserSignIn"
>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"sign_in_date"
jdbcType=
"VARCHAR"
property=
"signInDate"
/>
<result
column=
"consecutive_days"
jdbcType=
"INTEGER"
property=
"consecutiveDays"
/>
<result
column=
"is_reward"
jdbcType=
"BIT"
property=
"isReward"
/>
<result
column=
"reward_level"
jdbcType=
"INTEGER"
property=
"rewardLevel"
/>
<result
column=
"is_get"
jdbcType=
"BIT"
property=
"isGet"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
<foreach
collection=
"oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Update_By_Example_Where_Clause"
>
<where>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, user_id, create_time, update_time, sign_in_date, consecutive_days, is_reward,
reward_level, is_get
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSignInExample"
resultMap=
"BaseResultMap"
>
select
<if
test=
"distinct"
>
distinct
</if>
'true' as QUERYID,
<include
refid=
"Base_Column_List"
/>
from user_sign_in
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from user_sign_in
where id = #{id,jdbcType=BIGINT}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Long"
>
delete from user_sign_in
where id = #{id,jdbcType=BIGINT}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSignInExample"
>
delete from user_sign_in
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into user_sign_in (user_id, create_time, update_time,
sign_in_date, consecutive_days, is_reward,
reward_level, is_get)
values (#{userId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{signInDate,jdbcType=VARCHAR}, #{consecutiveDays,jdbcType=INTEGER}, #{isReward,jdbcType=BIT},
#{rewardLevel,jdbcType=INTEGER}, #{isGet,jdbcType=BIT})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into user_sign_in
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"signInDate != null"
>
sign_in_date,
</if>
<if
test=
"consecutiveDays != null"
>
consecutive_days,
</if>
<if
test=
"isReward != null"
>
is_reward,
</if>
<if
test=
"rewardLevel != null"
>
reward_level,
</if>
<if
test=
"isGet != null"
>
is_get,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
#{userId,jdbcType=BIGINT},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"signInDate != null"
>
#{signInDate,jdbcType=VARCHAR},
</if>
<if
test=
"consecutiveDays != null"
>
#{consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"isReward != null"
>
#{isReward,jdbcType=BIT},
</if>
<if
test=
"rewardLevel != null"
>
#{rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"isGet != null"
>
#{isGet,jdbcType=BIT},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSignInExample"
resultType=
"java.lang.Long"
>
select count(*) from user_sign_in
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
update user_sign_in
<set>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=BIGINT},
</if>
<if
test=
"record.userId != null"
>
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if
test=
"record.createTime != null"
>
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"record.updateTime != null"
>
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"record.signInDate != null"
>
sign_in_date = #{record.signInDate,jdbcType=VARCHAR},
</if>
<if
test=
"record.consecutiveDays != null"
>
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"record.isReward != null"
>
is_reward = #{record.isReward,jdbcType=BIT},
</if>
<if
test=
"record.rewardLevel != null"
>
reward_level = #{record.rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"record.isGet != null"
>
is_get = #{record.isGet,jdbcType=BIT},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
update user_sign_in
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
sign_in_date = #{record.signInDate,jdbcType=VARCHAR},
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
is_reward = #{record.isReward,jdbcType=BIT},
reward_level = #{record.rewardLevel,jdbcType=INTEGER},
is_get = #{record.isGet,jdbcType=BIT}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
update user_sign_in
<set>
<if
test=
"userId != null"
>
user_id = #{userId,jdbcType=BIGINT},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"signInDate != null"
>
sign_in_date = #{signInDate,jdbcType=VARCHAR},
</if>
<if
test=
"consecutiveDays != null"
>
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"isReward != null"
>
is_reward = #{isReward,jdbcType=BIT},
</if>
<if
test=
"rewardLevel != null"
>
reward_level = #{rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"isGet != null"
>
is_get = #{isGet,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
update user_sign_in
set user_id = #{userId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
sign_in_date = #{signInDate,jdbcType=VARCHAR},
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
is_reward = #{isReward,jdbcType=BIT},
reward_level = #{rewardLevel,jdbcType=INTEGER},
is_get = #{isGet,jdbcType=BIT}
where id = #{id,jdbcType=BIGINT}
</update>
<resultMap
id=
"BaseResultMap"
type=
"com.wwdz.ch.db.domain.UserSignIn"
>
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"user_id"
jdbcType=
"BIGINT"
property=
"userId"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"signin_date"
jdbcType=
"VARCHAR"
property=
"signinDate"
/>
<result
column=
"consecutive_days"
jdbcType=
"INTEGER"
property=
"consecutiveDays"
/>
<result
column=
"is_reward"
jdbcType=
"BIT"
property=
"isReward"
/>
<result
column=
"reward_level"
jdbcType=
"INTEGER"
property=
"rewardLevel"
/>
<result
column=
"is_get"
jdbcType=
"BIT"
property=
"isGet"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
<foreach
collection=
"oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Update_By_Example_Where_Clause"
>
<where>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, user_id, create_time, update_time, signin_date, consecutive_days, is_reward,
reward_level, is_get
</sql>
<select
id=
"selectByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSigninExample"
resultMap=
"BaseResultMap"
>
select
<if
test=
"distinct"
>
distinct
</if>
'true' as QUERYID,
<include
refid=
"Base_Column_List"
/>
from user_signin
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from user_signin
where id = #{id,jdbcType=BIGINT}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Long"
>
delete from user_signin
where id = #{id,jdbcType=BIGINT}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSigninExample"
>
delete from user_signin
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into user_signin (user_id, create_time, update_time,
signin_date, consecutive_days, is_reward,
reward_level, is_get)
values (#{userId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{signinDate,jdbcType=VARCHAR}, #{consecutiveDays,jdbcType=INTEGER}, #{isReward,jdbcType=BIT},
#{rewardLevel,jdbcType=INTEGER}, #{isGet,jdbcType=BIT})
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into user_signin
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"signinDate != null"
>
signin_date,
</if>
<if
test=
"consecutiveDays != null"
>
consecutive_days,
</if>
<if
test=
"isReward != null"
>
is_reward,
</if>
<if
test=
"rewardLevel != null"
>
reward_level,
</if>
<if
test=
"isGet != null"
>
is_get,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"userId != null"
>
#{userId,jdbcType=BIGINT},
</if>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"signinDate != null"
>
#{signinDate,jdbcType=VARCHAR},
</if>
<if
test=
"consecutiveDays != null"
>
#{consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"isReward != null"
>
#{isReward,jdbcType=BIT},
</if>
<if
test=
"rewardLevel != null"
>
#{rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"isGet != null"
>
#{isGet,jdbcType=BIT},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.wwdz.ch.db.domain.UserSigninExample"
resultType=
"java.lang.Long"
>
select count(*) from user_signin
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
update user_signin
<set>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=BIGINT},
</if>
<if
test=
"record.userId != null"
>
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if
test=
"record.createTime != null"
>
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"record.updateTime != null"
>
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"record.signinDate != null"
>
signin_date = #{record.signinDate,jdbcType=VARCHAR},
</if>
<if
test=
"record.consecutiveDays != null"
>
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"record.isReward != null"
>
is_reward = #{record.isReward,jdbcType=BIT},
</if>
<if
test=
"record.rewardLevel != null"
>
reward_level = #{record.rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"record.isGet != null"
>
is_get = #{record.isGet,jdbcType=BIT},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
update user_signin
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
signin_date = #{record.signinDate,jdbcType=VARCHAR},
consecutive_days = #{record.consecutiveDays,jdbcType=INTEGER},
is_reward = #{record.isReward,jdbcType=BIT},
reward_level = #{record.rewardLevel,jdbcType=INTEGER},
is_get = #{record.isGet,jdbcType=BIT}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
update user_signin
<set>
<if
test=
"userId != null"
>
user_id = #{userId,jdbcType=BIGINT},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"signinDate != null"
>
signin_date = #{signinDate,jdbcType=VARCHAR},
</if>
<if
test=
"consecutiveDays != null"
>
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
</if>
<if
test=
"isReward != null"
>
is_reward = #{isReward,jdbcType=BIT},
</if>
<if
test=
"rewardLevel != null"
>
reward_level = #{rewardLevel,jdbcType=INTEGER},
</if>
<if
test=
"isGet != null"
>
is_get = #{isGet,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"com.wwdz.ch.db.domain.UserSignIn"
>
update user_signin
set user_id = #{userId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
signin_date = #{signinDate,jdbcType=VARCHAR},
consecutive_days = #{consecutiveDays,jdbcType=INTEGER},
is_reward = #{isReward,jdbcType=BIT},
reward_level = #{rewardLevel,jdbcType=INTEGER},
is_get = #{isGet,jdbcType=BIT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/UserSigninServiceImpl.java
View file @
f1ed8e80
...
...
@@ -21,10 +21,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.util.CollectionUtils
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.
Date
;
import
java.util.
List
;
import
java.util.
*
;
import
java.util.
function.Function
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -39,7 +41,7 @@ public class UserSigninServiceImpl implements UserSigninService {
DistributionOrderDao
distributionOrderDao
;
@Override
public
Result
sign
i
n
(
UserSignInRequestDto
dto
)
{
public
Result
sign
I
n
(
UserSignInRequestDto
dto
)
{
try
{
long
userId
=
dto
.
getUserId
();
//检查是否已签到过
...
...
@@ -66,8 +68,11 @@ public class UserSigninServiceImpl implements UserSigninService {
userSignin
.
setSignInDate
(
todayStr
);
userSignin
.
setCreateTime
(
new
Date
());
userSignin
.
setUpdateTime
(
new
Date
());
//连续签到天数
int
consecutiveDays
=
yesterdaySignin
.
getConsecutiveDays
()
+
1
;
int
consecutiveDays
=
1
;
//连续签到天数, 21天清零重新计算
if
(
yesterdaySignin
.
getConsecutiveDays
()
!=
21
)
{
consecutiveDays
=
yesterdaySignin
.
getConsecutiveDays
()
+
1
;
}
userSignin
.
setConsecutiveDays
(
consecutiveDays
);
switch
(
consecutiveDays
)
{
case
7
:
...
...
@@ -143,6 +148,34 @@ public class UserSigninServiceImpl implements UserSigninService {
@Override
public
Result
findList
(
UserSignInRequestDto
dto
)
{
try
{
long
userId
=
dto
.
getUserId
();
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
//检查昨天是否打过卡
UserSignIn
yesterdaySignIn
=
userSigninDao
.
findYesterdayRecord
(
userId
);
if
(
yesterdaySignIn
==
null
)
{
//连续签到天数
resultMap
.
put
(
"consecutiveDays"
,
0
);
//还需签到的天数
resultMap
.
put
(
"needConsecutiveDays"
,
7
);
}
else
{
//查询今天的打卡记录
UserSignIn
todayRecord
=
userSigninDao
.
findLastedRecord
(
userId
);
if
(
todayRecord
!=
null
)
{
resultMap
.
put
(
"consecutiveDays"
,
todayRecord
.
getConsecutiveDays
());
}
else
{
resultMap
.
put
(
"consecutiveDays"
,
yesterdaySignIn
.
getConsecutiveDays
());
}
int
consecutiveDays
=
Integer
.
valueOf
(
resultMap
.
get
(
"consecutiveDays"
).
toString
());
if
(
yesterdaySignIn
.
getConsecutiveDays
()
<
7
)
{
resultMap
.
put
(
"needConsecutiveDays"
,
7
-
consecutiveDays
);
}
else
if
(
consecutiveDays
>=
7
&&
consecutiveDays
<
14
)
{
resultMap
.
put
(
"needConsecutiveDays"
,
14
-
consecutiveDays
);
}
else
{
resultMap
.
put
(
"needConsecutiveDays"
,
21
-
consecutiveDays
);
}
}
//当前是几号
LocalDate
today
=
LocalDate
.
now
();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMdd"
);
...
...
@@ -155,8 +188,15 @@ public class UserSigninServiceImpl implements UserSigninService {
if
(
StringUtils
.
isEmpty
(
dto
.
getYear
())
||
StringUtils
.
isEmpty
(
dto
.
getMonth
()))
{
dto
.
setYearMonth
(
year
+
"-"
+
month
);
}
else
{
year
=
Integer
.
parseInt
(
dto
.
getYear
());
month
=
Integer
.
parseInt
(
dto
.
getMonth
());
dto
.
setYearMonth
(
dto
.
getYear
()
+
"-"
+
dto
.
getMonth
());
}
resultMap
.
put
(
"year"
,
year
);
resultMap
.
put
(
"month"
,
month
);
//每个月一号是周几
resultMap
.
put
(
"firstDayOfWeek"
,
DateTimeUtil
.
getFirstDayOfMonth
(
year
,
month
));
//该月份所有的日期
List
<
String
>
dateList
=
DateTimeUtil
.
getMonthDates
(
dto
.
getYearMonth
());
Date
startTime
=
DateTimeUtil
.
getDateWithMinTime
(
dateList
.
get
(
0
));
...
...
@@ -165,8 +205,12 @@ public class UserSigninServiceImpl implements UserSigninService {
dto
.
setEndQueryTime
(
endTime
);
List
<
UserSignIn
>
userSignInList
=
userSigninDao
.
findList
(
dto
);
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
));
List
<
SignDateRecord
>
calendar
=
new
ArrayList
<>();
for
(
String
dateStr
:
dateList
)
{
SignDateRecord
signDateRecord
=
new
SignDateRecord
();
signDateRecord
.
setDayStr
(
DateTimeUtil
.
getDayFromDateString
(
dateStr
));
signDateRecord
.
setSignDate
(
dateStr
);
int
day
=
Integer
.
parseInt
(
dateStr
.
replace
(
"-"
,
""
));
if
(
day
<
currentDay
)
{
signDateRecord
.
setDateState
(
SigninEnum
.
DateStateEnum
.
PASS
.
getCode
());
...
...
@@ -174,14 +218,44 @@ public class UserSigninServiceImpl implements UserSigninService {
signDateRecord
.
setDateState
(
SigninEnum
.
DateStateEnum
.
CURRENT
.
getCode
());
}
else
{
signDateRecord
.
setDateState
(
SigninEnum
.
DateStateEnum
.
FUTURE
.
getCode
());
if
(
yesterdaySignIn
==
null
)
{
//昨天没签到就以今天的时间预测之后的奖励日期
if
(
today
.
plusDays
(
6
).
format
(
formatter
).
equals
(
dateStr
)
||
today
.
plusDays
(
13
).
format
(
formatter
).
equals
(
dateStr
)
||
today
.
plusDays
(
20
).
format
(
formatter
).
equals
(
dateStr
))
{
signDateRecord
.
setIsReward
(
true
);
signDateRecord
.
setIsGet
(
false
);
}
}
else
{
//如果昨天签到了,就以昨天的时间作为预测会拿到签到奖励的起始时间
int
ConsecutiveDays
=
yesterdaySignIn
.
getConsecutiveDays
();
if
(
today
.
plusDays
(
6
-
ConsecutiveDays
).
format
(
formatter
).
equals
(
dateStr
)
||
today
.
plusDays
(
13
-
ConsecutiveDays
).
format
(
formatter
).
equals
(
dateStr
)
||
today
.
plusDays
(
20
-
ConsecutiveDays
).
format
(
formatter
).
equals
(
dateStr
))
{
signDateRecord
.
setIsReward
(
true
);
signDateRecord
.
setIsGet
(
false
);
}
}
}
//签到记录里包含该日期则表示已签到
if
(
signDateList
.
contains
(
dateStr
))
{
signDateRecord
.
setIsSignIn
(
true
);
signDateRecord
.
setIsReward
(
signDateMap
.
get
(
dateStr
).
getIsReward
());
signDateRecord
.
setIsGet
(
signDateMap
.
get
(
dateStr
).
getIsGet
());
signDateRecord
.
setRewardLevel
(
signDateMap
.
get
(
dateStr
).
getRewardLevel
());
signDateRecord
.
setConsecutiveDays
(
signDateMap
.
get
(
dateStr
).
getConsecutiveDays
());
}
else
{
signDateRecord
.
setIsSignIn
(
false
);
signDateRecord
.
setIsReward
(
false
);
signDateRecord
.
setIsGet
(
false
);
signDateRecord
.
setRewardLevel
(
SigninEnum
.
LevelEnum
.
ZERO
.
getCode
());
signDateRecord
.
setConsecutiveDays
(
0
);
}
calendar
.
add
(
signDateRecord
);
}
return
Result
.
success
();
//日历数据
resultMap
.
put
(
"calendar"
,
calendar
);
//签到进度
resultMap
.
put
(
"rate"
,
(
int
)
Math
.
ceil
((
Double
.
valueOf
(
resultMap
.
get
(
"consecutiveDays"
).
toString
())
/
21
)
*
100
));
return
Result
.
success
(
resultMap
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询签到记录失败 error : {}"
,
e
);
}
...
...
@@ -200,11 +274,4 @@ public class UserSigninServiceImpl implements UserSigninService {
}
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
dateList
=
DateTimeUtil
.
getMonthDates
(
"2024-11"
);
Date
startTime
=
DateTimeUtil
.
getDateWithMinTime
(
dateList
.
get
(
0
));
Date
endTime
=
DateTimeUtil
.
getDateWithMaxTime
(
dateList
.
get
((
dateList
.
size
()
-
1
)));
System
.
out
.
println
(
startTime
);
System
.
out
.
println
(
endTime
);
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/UserSigninService.java
View file @
f1ed8e80
...
...
@@ -10,7 +10,7 @@ public interface UserSigninService {
* @param dto
* @return
*/
Result
sign
i
n
(
UserSignInRequestDto
dto
);
Result
sign
I
n
(
UserSignInRequestDto
dto
);
/**
* 领取奖励
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/UserSigninController.java
View file @
f1ed8e80
...
...
@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/wx/userSign
i
n"
)
@RequestMapping
(
"/wx/userSign
I
n"
)
public
class
UserSigninController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserSigninController
.
class
);
...
...
@@ -26,8 +26,8 @@ public class UserSigninController {
UserSigninService
userSigninService
;
@ApiOperation
(
value
=
"用户签到"
)
@PostMapping
(
"/
checkAbleToOpenShop
"
)
public
Result
checkAbleToOpenShop
(
@RequestBody
UserSignInRequestDto
dto
)
{
@PostMapping
(
"/
signIn
"
)
public
Result
signIn
(
@RequestBody
UserSignInRequestDto
dto
)
{
logger
.
info
(
"【请求开始】用户签到,请求参数:{}"
,
JSON
.
toJSONString
(
dto
));
Validator
validator
=
new
Validator
(
FormHandler
.
ofEntity
(
dto
));
validator
.
set
(
"userId"
,
"用户id"
).
must
().
number
()
...
...
@@ -35,7 +35,7 @@ public class UserSigninController {
if
(!
validator
.
isValid
())
{
return
Result
.
failed
(
ResultCode
.
PARAM_ERROR
);
}
return
userSigninService
.
sign
i
n
(
dto
);
return
userSigninService
.
sign
I
n
(
dto
);
}
...
...
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