记得上下班打卡 | 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
3d9faa23
Commit
3d9faa23
authored
Dec 31, 2021
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
秒杀
parent
8cb1eaa9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
213 additions
and
4 deletions
+213
-4
GoblinFrontSeckillVo.java
...liquidnet/service/goblin/dto/vo/GoblinFrontSeckillVo.java
+100
-0
GoblinFrontController.java
...dnet/service/goblin/controller/GoblinFrontController.java
+109
-4
ObjectUtil.java
...in/java/com/liquidnet/service/goblin/util/ObjectUtil.java
+4
-0
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/vo/GoblinFrontSeckillVo.java
0 → 100644
View file @
3d9faa23
package
com
.
liquidnet
.
service
.
goblin
.
dto
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
* 秒杀表
* </p>
*
* @author liquidnet
* @since 2021-12-30
*/
@Data
public
class
GoblinFrontSeckillVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 主键
*/
@ApiModelProperty
(
value
=
"主键"
)
private
Long
mid
;
/**
* 官方活动id
*/
@ApiModelProperty
(
value
=
"活动id(官方g_,商铺s_),按照顺序添加"
)
private
String
selfActivityids
;
/**
* 1、一行三个2、两行三个
*/
@ApiModelProperty
(
value
=
"1、一行三个2、两行三个"
)
private
Integer
showType
;
/**
* 1、关闭模块2、保留模块
*/
@ApiModelProperty
(
value
=
"1、关闭模块2、保留模块"
)
private
Integer
activityType
;
/**
* 创建时间
*/
@ApiModelProperty
(
value
=
"创建时间"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
DateUtil
.
DATE_FULL_STR
)
private
LocalDateTime
createTime
;
/**
* 修改时间
*/
@ApiModelProperty
(
value
=
"修改时间"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
DateUtil
.
DATE_FULL_STR
)
private
LocalDateTime
updateTime
;
/**
* 0未删除1已删除
*/
@ApiModelProperty
(
value
=
"0未删除1已删除"
)
private
Integer
delTag
;
/**
* 排序
*/
@ApiModelProperty
(
value
=
"忽略"
)
private
Integer
indexs
;
/**
* 秒杀id
*/
@ApiModelProperty
(
value
=
"秒杀id"
)
private
String
seckilId
;
//活动
public
List
<
Map
>
acityList
;
private
static
final
GoblinFrontSeckillVo
obj
=
new
GoblinFrontSeckillVo
();
public
static
GoblinFrontSeckillVo
getNew
()
{
try
{
return
(
GoblinFrontSeckillVo
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
return
new
GoblinFrontSeckillVo
();
}
}
/**
* 商品
*/
private
List
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoList
;
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinFrontController.java
View file @
3d9faa23
package
com
.
liquidnet
.
service
.
goblin
.
controller
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.dto.vo.GoblinFrontBannerVo
;
import
com.liquidnet.service.goblin.constant.GoblinStatusConst
;
import
com.liquidnet.service.goblin.dto.vo.*
;
import
com.liquidnet.service.goblin.entity.GoblinFrontBanner
;
import
com.liquidnet.service.goblin.entity.GoblinFrontHotWord
;
import
com.liquidnet.service.goblin.entity.GoblinFrontNavigation
;
import
com.liquidnet.service.goblin.entity.GoblinFrontSeckill
;
import
com.liquidnet.service.goblin.util.GoblinRedisUtils
;
import
com.liquidnet.service.goblin.util.ObjectUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -17,8 +21,12 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -32,6 +40,8 @@ import java.util.List;
public
class
GoblinFrontController
{
@Autowired
private
RedisUtil
redisUtil
;
@Autowired
private
GoblinRedisUtils
goblinRedisUtils
;
@GetMapping
(
"getBanner"
)
@ApiOperation
(
"获取banner"
)
...
...
@@ -83,17 +93,112 @@ public class GoblinFrontController {
@GetMapping
(
"getSeckilll"
)
@ApiOperation
(
"获得秒杀首页要用的"
)
public
ResponseDto
getSeckilll
()
{
public
ResponseDto
getSeckilll
()
throws
ParseException
{
List
<
GoblinFrontSeckill
>
list
=
(
List
<
GoblinFrontSeckill
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SECKILL
);
GoblinFrontSeckillVo
goblinFrontSeckillVo
=
GoblinFrontSeckillVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
();
//判断是否有
if
(
null
!=
list
&&
list
.
size
()>
0
){
//
//遍历秒杀, 找到对应的 官方、商铺
GoblinFrontSeckill
goblinFrontSeckill
=
list
.
get
(
0
);
boolean
openBoolean
=
goblinFrontSeckill
.
getActivityType
()==
2
;
String
ids
=
goblinFrontSeckill
.
getSelfActivityids
();
if
(
StringUtil
.
isNotBlank
(
ids
)){
String
[]
idss
=
ids
.
split
(
","
);
for
(
String
id:
idss
){
String
type
=
id
.
split
(
"_"
)[
0
];
String
idM
=
id
.
split
(
"_"
)[
1
];
if
(
type
.
equals
(
"g"
)){
//找到对应官方的活动 判断时间是否过期,
GoblinSelfMarketingVo
goblinSelfMarketingVo
=
goblinRedisUtils
.
getSelfMarket
(
idM
);
if
(
goblinSelfMarketingVo
==
null
){
break
;
}
if
(!
openBoolean
){
//效验该活动是否在当前时间
if
(!
belongCalendar
(
goblinSelfMarketingVo
.
getStartTime
(),
goblinSelfMarketingVo
.
getEndTime
())){
//如果不是在当前时间
break
;
}
}
//查看 活动绑定的 spu sku
List
<
GoblinMarketRelationVo
>
list1
=
goblinRedisUtils
.
getMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
goblinSelfMarketingVo
.
getSelfMarketId
());
//遍历 活动表
for
(
GoblinMarketRelationVo
goblinMarketRelationVo:
list1
){
//找到对应的spu商品
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinMarketRelationVo
.
getSpuId
());
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo
);
}
}
else
if
(
type
.
equals
(
"s"
)){
//商铺的vo
GoblinStoreMarketVo
goblinStoreMarketVo
=
goblinRedisUtils
.
getGoblinStoreMarketVo
(
idM
);
if
(
goblinStoreMarketVo
==
null
){
break
;
}
boolean
isGet
=
false
;
if
(
openBoolean
){
//不做效验时间直接放true
isGet
=
true
;
}
else
if
(
goblinStoreMarketVo
.
getIsPre
()==
1
&&
afterCalendar
(
goblinStoreMarketVo
.
getPreTime
())&&
beforeCalendar
(
goblinStoreMarketVo
.
getEndTime
())){
isGet
=
true
;
}
else
if
(
goblinStoreMarketVo
.
getIsPre
()==
0
&&
belongCalendar
(
goblinStoreMarketVo
.
getStartTime
(),
goblinStoreMarketVo
.
getEndTime
())){
isGet
=
true
;
}
if
(
isGet
){
//获取商铺 对应关系
}
return
ResponseDto
.
success
(
list
);
}
}
goblinFrontSeckillVo
.
setGoblinGoodsInfoVoList
(
goblinGoodsInfoVoArrayList
);
}
}
return
ResponseDto
.
success
(
list
);
}
public
boolean
belongCalendar
(
String
startString
,
String
endString
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DateUtil
.
DATE_FULL_STR
);
//注意月份是MM
Date
from
=
simpleDateFormat
.
parse
(
startString
);
Date
end
=
simpleDateFormat
.
parse
(
endString
);
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
new
Date
());
Calendar
after
=
Calendar
.
getInstance
();
after
.
setTime
(
from
);
Calendar
before
=
Calendar
.
getInstance
();
before
.
setTime
(
end
);
if
(
date
.
after
(
after
)
&&
date
.
before
(
before
))
{
return
true
;
}
else
{
return
false
;
}
}
//判断是否是该时间之后
public
boolean
afterCalendar
(
String
time
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DateUtil
.
DATE_FULL_STR
);
//注意月份是MM
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
new
Date
());
Date
timefrom
=
simpleDateFormat
.
parse
(
time
);
if
(
date
.
after
(
timefrom
))
{
return
true
;
}
else
{
return
false
;
}
}
//判断是否是该时间之后
public
boolean
beforeCalendar
(
String
time
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DateUtil
.
DATE_FULL_STR
);
//注意月份是MM
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
new
Date
());
Date
timefrom
=
simpleDateFormat
.
parse
(
time
);
if
(
date
.
before
(
timefrom
))
{
return
true
;
}
else
{
return
false
;
}
}
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/ObjectUtil.java
View file @
3d9faa23
...
...
@@ -12,6 +12,7 @@ import java.util.ArrayList;
public
class
ObjectUtil
{
private
static
final
PagedResult
<
GoblinStoreMgtGoodsListVo
>
goblinStoreMgtGoodsVoPagedResult
=
new
PagedResult
<>();
private
static
final
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinFrontBanner
>
goblinFrontBannerArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinFrontBannerVo
>
goblinFrontBannerVoArrayList
=
new
ArrayList
<>();
private
static
final
ArrayList
<
GoblinSelfMarketingVo
>
goblinSelfMarketingVoArrayList
=
new
ArrayList
<>();
...
...
@@ -32,6 +33,9 @@ public class ObjectUtil {
return
goblinStoreMgtGoodsVoPagedResult
.
clone
();
}
public
static
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
()
{
return
(
ArrayList
<
GoblinGoodsInfoVo
>)
goblinGoodsInfoVoArrayList
.
clone
();
}
public
static
ArrayList
<
GoblinFrontBannerVo
>
goblinFrontBannerVoArrayList
()
{
return
(
ArrayList
<
GoblinFrontBannerVo
>)
goblinFrontBannerVoArrayList
.
clone
();
}
...
...
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