记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
057a7eb6
Commit
057a7eb6
authored
Apr 14, 2022
by
GaoHu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exit
parent
4ea9f164
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
75 deletions
+28
-75
GoblinGoodsAnticipateServiceImpl.java
...goblin/service/impl/GoblinGoodsAnticipateServiceImpl.java
+1
-21
GoblinGoodsAnticipateMgServiceImpl.java
...rvice/impl/manage/GoblinGoodsAnticipateMgServiceImpl.java
+4
-33
GoblinAnticipateUtils.java
.../liquidnet/service/goblin/util/GoblinAnticipateUtils.java
+21
-2
GoblinRedisUtils.java
...a/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
+2
-19
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinGoodsAnticipateServiceImpl.java
View file @
057a7eb6
...
...
@@ -15,7 +15,6 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.util.LinkedList
;
/**
...
...
@@ -42,7 +41,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//查询该skuId是否能被预约
GoblinGoodsAnticipateValueVo
anticipateValueVo
=
goblinRedisUtils
.
getValueBySkuId
(
skuId
);
if
(
anticipateValueVo
!=
null
)
{
anticipateValueVo
.
setState
(
setState
(
anticipateValueVo
.
getAboutStartDate
(),
anticipateValueVo
.
getAboutEndDate
()));
anticipateValueVo
.
setState
(
GoblinAnticipateUtils
.
setState
(
anticipateValueVo
.
getAboutStartDate
(),
anticipateValueVo
.
getAboutEndDate
()));
if
(!
anticipateValueVo
.
getState
().
equals
(
1
))
{
return
ResponseDto
.
failure
(
"该商品预约尚未开始或已经结束,不可预约!"
);
}
...
...
@@ -90,25 +89,6 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
return
ResponseDto
.
success
(
goblinRedisUtils
.
getUserAboutAut
(
skuId
,
userInfo
.
getUid
())
!=
null
)
;
}
private
Integer
setState
(
LocalDateTime
startDate
,
LocalDateTime
endDate
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
startDate
.
isAfter
(
now
))
{
//未开始 0
return
0
;
}
if
(
startDate
.
isBefore
(
now
)
&&
endDate
.
isAfter
(
now
))
{
//预约中 1
return
1
;
}
if
(
endDate
.
isBefore
(
now
))
{
//已结束 2
return
2
;
}
//其他
return
null
;
}
public
void
sendRedis
(
String
sqlKey
,
LinkedList
<
Object
[]>
sqlData
)
{
LinkedList
<
String
>
sql
=
CollectionUtil
.
linkedListString
();
sql
.
add
(
SqlMapping
.
get
(
sqlKey
));
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinGoodsAnticipateMgServiceImpl.java
View file @
057a7eb6
...
...
@@ -13,6 +13,7 @@ import com.liquidnet.service.goblin.dto.manage.vo.AnticipateValueVo;
import
com.liquidnet.service.goblin.dto.manage.vo.GoblinGoodsAnticipateValueVo
;
import
com.liquidnet.service.goblin.dto.vo.GoblinGoodsAnticipateVo
;
import
com.liquidnet.service.goblin.service.manage.IGoblinGoodsAnticipateMgService
;
import
com.liquidnet.service.goblin.util.GoblinAnticipateUtils
;
import
com.liquidnet.service.goblin.util.GoblinMongoUtils
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.goblin.util.QueueUtils
;
...
...
@@ -142,7 +143,7 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
//实际预约人数
anticipateValueVo
.
setActualPeople
(
autIdPeople
);
//设置预约状态
anticipateValueVo
.
setState
(
setState
(
anticipateValueVo
.
getAboutStartDate
(),
anticipateValueVo
.
getAboutEndDate
()));
anticipateValueVo
.
setState
(
GoblinAnticipateUtils
.
setState
(
anticipateValueVo
.
getAboutStartDate
(),
anticipateValueVo
.
getAboutEndDate
()));
}
pageInfo
.
setPageNum
(
goodsAnticipateValueParam
.
getPageNum
());
...
...
@@ -152,25 +153,6 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
return
ResponseDto
.
success
(
pageInfo
);
}
private
Integer
setState
(
LocalDateTime
startDate
,
LocalDateTime
endDate
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
startDate
.
isAfter
(
now
))
{
//未开始 0
return
0
;
}
if
(
startDate
.
isBefore
(
now
)
&&
endDate
.
isAfter
(
now
))
{
//预约中 1
return
1
;
}
if
(
endDate
.
isBefore
(
now
))
{
//已结束 2
return
2
;
}
//其他
return
null
;
}
@Override
public
ResponseDto
<
Object
>
updatePeople
(
String
skuId
,
BigInteger
people
)
{
//修改Mongodb
...
...
@@ -191,7 +173,7 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
GoblinGoodsAnticipateValueVo
goodsAnticipateValueVo
=
goblinRedisUtils
.
getValueBySkuId
(
skuId
);
if
(
goodsAnticipateValueVo
!=
null
)
{
goodsAnticipateValueVo
.
setState
(
setState
(
goodsAnticipateValueVo
.
getAboutStartDate
(),
goodsAnticipateValueVo
.
getAboutEndDate
()));
goodsAnticipateValueVo
.
setState
(
GoblinAnticipateUtils
.
setState
(
goodsAnticipateValueVo
.
getAboutStartDate
(),
goodsAnticipateValueVo
.
getAboutEndDate
()));
//没有开启则可以删除预约
if
(!
goodsAnticipateValueVo
.
getState
().
equals
(
0
))
{
return
ResponseDto
.
failure
(
"预约状态为已开启或已结束,不可删除!"
);
...
...
@@ -210,24 +192,13 @@ public class GoblinGoodsAnticipateMgServiceImpl implements IGoblinGoodsAnticipat
return
ResponseDto
.
failure
(
"该预约不存在"
);
}
private
void
delUserBySkuId
(
String
skuId
)
{
//删除redis 和mongodb
goblinMongoUtils
.
delUserBySkuId
(
skuId
);
//数据库修改 用户预约过该skuId的表字段全部修改未 1
LinkedList
<
Object
[]>
sqlValue
=
CollectionUtil
.
linkedListObjectArr
();
sqlValue
.
add
(
new
Object
[]{
skuId
});
sendRedis
(
"goblin_goods_anticipate_user_update_sku"
,
sqlValue
);
}
@Override
public
AnticipateValueVo
getAnticipateValueBySkuId
(
String
skuId
,
int
hasHead
)
{
GoblinGoodsAnticipateValueVo
anticipateValueVo
=
goblinRedisUtils
.
getValueBySkuId
(
skuId
);
AnticipateValueVo
valueVo
=
AnticipateValueVo
.
getNew
();
if
(
anticipateValueVo
!=
null
)
{
valueVo
=
valueVo
.
copy
(
anticipateValueVo
);
valueVo
.
setState
(
setState
(
valueVo
.
getAboutStartDate
(),
valueVo
.
getAboutEndDate
()));
valueVo
.
setState
(
GoblinAnticipateUtils
.
setState
(
valueVo
.
getAboutStartDate
(),
valueVo
.
getAboutEndDate
()));
}
else
{
valueVo
.
setState
(
null
);
valueVo
.
setAboutEndDate
(
null
);
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinAnticipateUtils.java
View file @
057a7eb6
...
...
@@ -13,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
java.time.LocalDateTime
;
/**
* @author TT
*/
...
...
@@ -23,8 +25,6 @@ public class GoblinAnticipateUtils {
@Value
(
"${liquidnet.service.adam.url}"
)
private
String
adamUrl
;
private
final
String
avatar
=
""
;
public
AdamUserInfoVo
getUserInfo
()
{
try
{
MultiValueMap
<
String
,
String
>
header
=
CollectionUtil
.
linkedMultiValueMapStringString
();
...
...
@@ -45,4 +45,23 @@ public class GoblinAnticipateUtils {
return
null
;
}
}
public
static
Integer
setState
(
LocalDateTime
startDate
,
LocalDateTime
endDate
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
if
(
startDate
.
isAfter
(
now
))
{
//未开始 0
return
0
;
}
if
(
startDate
.
isBefore
(
now
)
&&
endDate
.
isAfter
(
now
))
{
//预约中 1
return
1
;
}
if
(
endDate
.
isBefore
(
now
))
{
//已结束 2
return
2
;
}
//其他
return
null
;
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
View file @
057a7eb6
...
...
@@ -89,14 +89,6 @@ public class GoblinRedisUtils {
redisUtil
.
set
(
GoblinRedisConst
.
USER_ANTICIPATE_STATE
.
concat
(
user
.
getSkuId
()).
concat
(
user
.
getUid
()),
user
,
60
*
60
*
24
*
30
);
}
/**
* 删除用户预约
*/
public
void
delUserAboutSku
(
String
skuId
,
String
uid
)
{
goblinMongoUtils
.
delGoodsAnticipateUserVo
(
uid
,
skuId
);
redisUtil
.
del
(
GoblinRedisConst
.
USER_ANTICIPATE_STATE
.
concat
(
skuId
).
concat
(
uid
));
}
/**
* 实际预约人数修改
*/
...
...
@@ -114,19 +106,12 @@ public class GoblinRedisUtils {
return
(
BigInteger
)
redisUtil
.
get
(
GoblinRedisConst
.
ANTICIPATE_PEOPLE
.
concat
(
skuId
));
}
/**
* 删除预约
*/
public
void
delGoodsSkuId
(
String
skuId
)
{
redisUtil
.
del
(
GoblinRedisConst
.
ANTICIPATE_SKUID
.
concat
(
skuId
));
}
/**
* 保存用户头像
*/
public
void
setUserAvatar
(
String
skuId
,
String
avatar
)
{
List
<
String
>
list
=
(
List
)
redisUtil
.
get
(
GoblinRedisConst
.
ANTICIPATE_SKUID_AVATAR
.
concat
(
skuId
));
List
<
String
>
urlList
=
list
!=
null
?
list
:
new
ArrayList
<
String
>
();
Object
list
=
redisUtil
.
get
(
GoblinRedisConst
.
ANTICIPATE_SKUID_AVATAR
.
concat
(
skuId
));
List
<
String
>
urlList
=
list
!=
null
?
(
List
<
String
>)
list
:
CollectionUtil
.
arrayListString
();
if
(
urlList
.
size
()<=
2
){
urlList
.
add
(
avatar
);
redisUtil
.
set
(
GoblinRedisConst
.
ANTICIPATE_SKUID_AVATAR
.
concat
(
skuId
),
urlList
);
...
...
@@ -135,8 +120,6 @@ public class GoblinRedisUtils {
/**
* 获取用户预约头像
* @param skuId
* @return
*/
public
List
<
String
>
getUserAvatar
(
String
skuId
){
String
rdk
=
GoblinRedisConst
.
ANTICIPATE_SKUID_AVATAR
.
concat
(
skuId
);
...
...
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