记得上下班打卡 | 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
09193595
Commit
09193595
authored
Aug 03, 2022
by
GaoHu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG:预约时间比较
parent
d946d35d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
19 deletions
+22
-19
GoblinGoodsAnticipateServiceImpl.java
...goblin/service/impl/GoblinGoodsAnticipateServiceImpl.java
+22
-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 @
09193595
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service.impl;
...
@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service.impl;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.CurrentUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.service.adam.dto.vo.AdamUserInfoVo
;
import
com.liquidnet.service.adam.dto.vo.AdamUserInfoVo
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ErrorMapping
;
...
@@ -20,9 +21,11 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -20,9 +21,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.unit.DataUnit
;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -86,16 +89,16 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -86,16 +89,16 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
return
ResponseDto
.
failure
(
"预约失败!"
);
return
ResponseDto
.
failure
(
"预约失败!"
);
}
}
}
else
{
}
else
{
log
.
debug
(
"skuId:{},需要助力人数:{},uid:{},该用户未开启分享助力!"
,
skuId
,
anticipateValueVo
.
getPeopleType
(),
uid
);
log
.
debug
(
"skuId:{},需要助力人数:{},uid:{},该用户未开启分享助力!"
,
skuId
,
anticipateValueVo
.
getPeopleType
(),
uid
);
return
ResponseDto
.
failure
(
"预约失败!"
);
return
ResponseDto
.
failure
(
"预约失败!"
);
}
}
}
}
uidAboutBySkuId
(
skuId
,
uid
,
null
);
uidAboutBySkuId
(
skuId
,
uid
,
null
);
}
}
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
}
private
void
uidAboutBySkuId
(
String
skuId
,
String
uid
,
String
avatar
)
{
private
void
uidAboutBySkuId
(
String
skuId
,
String
uid
,
String
avatar
)
{
GoblinGoodAnticipateUserVo
user
=
new
GoblinGoodAnticipateUserVo
();
GoblinGoodAnticipateUserVo
user
=
new
GoblinGoodAnticipateUserVo
();
user
.
setUid
(
uid
);
user
.
setUid
(
uid
);
user
.
setSkuId
(
skuId
);
user
.
setSkuId
(
skuId
);
...
@@ -121,7 +124,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -121,7 +124,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
List
<
String
>
userAvatar
=
goblinRedisUtils
.
getUserAvatar
(
skuId
);
List
<
String
>
userAvatar
=
goblinRedisUtils
.
getUserAvatar
(
skuId
);
if
(
userAvatar
!=
null
&&
userAvatar
.
size
()
<=
2
)
{
if
(
userAvatar
!=
null
&&
userAvatar
.
size
()
<=
2
)
{
//获取预约人头像
//获取预约人头像
if
(
avatar
==
null
)
{
if
(
avatar
==
null
)
{
avatar
=
goblinAnticipateUtils
.
getUserInfo
().
getAvatar
();
avatar
=
goblinAnticipateUtils
.
getUserInfo
().
getAvatar
();
}
}
goblinRedisUtils
.
setUserAvatar
(
skuId
,
avatar
);
goblinRedisUtils
.
setUserAvatar
(
skuId
,
avatar
);
...
@@ -151,8 +154,8 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -151,8 +154,8 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//可以创建分享
//可以创建分享
//查询redis关联记录
//查询redis关联记录
String
sid
=
goblinRedisUtils
.
getShare
(
skuId
,
uid
);
String
sid
=
goblinRedisUtils
.
getShare
(
skuId
,
uid
);
if
(
sid
!=
null
)
{
if
(
sid
!=
null
)
{
return
ResponseDto
.
failure
(
"0"
,
"已开启助力"
,
sid
);
return
ResponseDto
.
failure
(
"0"
,
"已开启助力"
,
sid
);
}
else
{
}
else
{
//查询sku需要助力人数
//查询sku需要助力人数
//Integer skuIdPeople = goblinRedisUtils.getSharePeopleBySkuId(skuId);
//Integer skuIdPeople = goblinRedisUtils.getSharePeopleBySkuId(skuId);
...
@@ -179,7 +182,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -179,7 +182,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//redis缓存
//redis缓存
Duration
between
=
Duration
.
between
(
valueBySkuId
.
getAboutStartDate
(),
valueBySkuId
.
getAboutEndDate
());
Duration
between
=
Duration
.
between
(
valueBySkuId
.
getAboutStartDate
(),
valueBySkuId
.
getAboutEndDate
());
goblinRedisUtils
.
setShare
(
skuId
,
uid
,
sid
,
between
.
toDays
());
goblinRedisUtils
.
setShare
(
skuId
,
uid
,
sid
,
between
.
toDays
());
//redis存储用户分享
//redis存储用户分享
goblinRedisUtils
.
setShareVo
(
goblinGoodsAnticipateShareVo
);
goblinRedisUtils
.
setShareVo
(
goblinGoodsAnticipateShareVo
);
...
@@ -215,7 +218,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -215,7 +218,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
//获取uid
//获取uid
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
if
(
shareVo
.
getUid
().
equals
(
uid
)){
if
(
shareVo
.
getUid
().
equals
(
uid
))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150003
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150003
));
}
}
//查询mongodb 是否助力过该分享
//查询mongodb 是否助力过该分享
...
@@ -237,10 +240,10 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -237,10 +240,10 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
if
(
helpUserAvatar
.
size
()
<=
6
)
{
if
(
helpUserAvatar
.
size
()
<=
6
)
{
//获取用户头像保存
//获取用户头像保存
AdamUserInfoVo
userInfo
=
goblinAnticipateUtils
.
getUserInfo
();
AdamUserInfoVo
userInfo
=
goblinAnticipateUtils
.
getUserInfo
();
if
(
userInfo
!=
null
)
{
if
(
userInfo
!=
null
)
{
//新增助力头像
//新增助力头像
goblinRedisUtils
.
setHelpUserAvatar
(
sid
,
userInfo
.
getAvatar
());
goblinRedisUtils
.
setHelpUserAvatar
(
sid
,
userInfo
.
getAvatar
());
}
else
{
}
else
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150008
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150008
));
}
}
}
}
...
@@ -262,13 +265,13 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -262,13 +265,13 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
sendRedis
(
"goblin_goods_anticipate_help"
,
sqlValue
);
sendRedis
(
"goblin_goods_anticipate_help"
,
sqlValue
);
//判断主力人数是否达标,达标则自动预约
//判断主力人数是否达标,达标则自动预约
if
(
shareVo
.
getPeopleType
().
equals
(
goblinRedisUtils
.
getHelpSidAddHelp
(
sid
))){
if
(
shareVo
.
getPeopleType
().
equals
(
goblinRedisUtils
.
getHelpSidAddHelp
(
sid
)))
{
//主力人数达到可预约条件
//主力人数达到可预约条件
uidAboutBySkuId
(
shareVo
.
getSkuId
(),
shareVo
.
getUid
(),
shareVo
.
getAvatar
());
uidAboutBySkuId
(
shareVo
.
getSkuId
(),
shareVo
.
getUid
(),
shareVo
.
getAvatar
());
}
}
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
else
{
}
else
{
log
.
debug
(
"help() false ------> sid:{}"
,
sid
);
log
.
debug
(
"help() false ------> sid:{}"
,
sid
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150004
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
150004
));
}
}
}
}
...
@@ -295,7 +298,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -295,7 +298,7 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
public
ResponseDto
<
Boolean
>
helpSid
(
String
sid
)
{
public
ResponseDto
<
Boolean
>
helpSid
(
String
sid
)
{
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
Integer
help
=
goblinRedisUtils
.
getHelpByUidAndSid
(
uid
,
sid
);
Integer
help
=
goblinRedisUtils
.
getHelpByUidAndSid
(
uid
,
sid
);
if
(
help
==
null
){
if
(
help
==
null
)
{
return
ResponseDto
.
success
(
false
);
return
ResponseDto
.
success
(
false
);
}
}
return
ResponseDto
.
success
(
true
);
return
ResponseDto
.
success
(
true
);
...
@@ -314,17 +317,17 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
...
@@ -314,17 +317,17 @@ public class GoblinGoodsAnticipateServiceImpl implements IGoblinGoodsAnticipateS
public
ResponseDto
<
Boolean
>
reserveByMix
(
String
mixId
)
{
public
ResponseDto
<
Boolean
>
reserveByMix
(
String
mixId
)
{
//获取udi
//获取udi
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
LocalDateTime
now
=
LocalDateTime
.
now
();
String
nowTime
=
DateUtil
.
getNowTime
();
//redis查询用户预约组合购记录
//redis查询用户预约组合购记录
if
(
goblinRedisUtils
.
getReserveMixByUid
(
uid
,
mixId
)
==
null
)
{
if
(
goblinRedisUtils
.
getReserveMixByUid
(
uid
,
mixId
)
==
null
)
{
//该混合狗能否被预约
//该混合狗能否被预约
GoblinMixDetailsVo
mixDetails
=
goblinRedisUtils
.
getMixDetails
(
mixId
);
GoblinMixDetailsVo
mixDetails
=
goblinRedisUtils
.
getMixDetails
(
mixId
);
LocalDateTime
st
=
LocalDateTime
.
parse
(
mixDetails
.
getTimeStart
(),
DTF_YMD_HMS
);
//组合购开启预约且当前时间大于预约购开始时间或者上架时间才可预约
//组合购开启预约且当前时间大于预约购开始时间或者上架时间才可预约
if
(
mixDetails
.
getReserve
()
!=
0
&&
now
.
isBefore
(
st
)
)
{
if
(
mixDetails
.
getReserve
()
!=
0
&&
DateUtil
.
compareStrDay
(
nowTime
,
mixDetails
.
getTimeStart
())
<=
0
)
{
GoblinMixReserveVo
goblinMixReserveVo
=
GoblinMixReserveVo
.
getNew
();
GoblinMixReserveVo
goblinMixReserveVo
=
GoblinMixReserveVo
.
getNew
();
goblinMixReserveVo
.
setMixId
(
mixId
);
goblinMixReserveVo
.
setMixId
(
mixId
);
goblinMixReserveVo
.
setCreatedDate
(
now
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
DateUtil
.
DATE_FULL_STR
);
goblinMixReserveVo
.
setCreatedDate
(
LocalDateTime
.
parse
(
nowTime
,
formatter
));
goblinMixReserveVo
.
setUid
(
uid
);
goblinMixReserveVo
.
setUid
(
uid
);
String
mobile
=
StringUtils
.
defaultString
(((
String
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_MOBILE
)),
""
);
String
mobile
=
StringUtils
.
defaultString
(((
String
)
CurrentUtil
.
getTokenClaims
().
get
(
CurrentUtil
.
TOKEN_MOBILE
)),
""
);
goblinMixReserveVo
.
setPhone
(
mobile
);
goblinMixReserveVo
.
setPhone
(
mobile
);
...
...
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