记得上下班打卡 | 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
f0eed3b2
Commit
f0eed3b2
authored
Apr 13, 2022
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改搜索接口
parent
3ff1a6d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
544 additions
and
503 deletions
+544
-503
GoblinFrontServiceImpl.java
...t/service/goblin/service/impl/GoblinFrontServiceImpl.java
+544
-503
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinFrontServiceImpl.java
View file @
f0eed3b2
...
...
@@ -58,59 +58,60 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public
ArrayList
<
GoblinFrontBannerVo
>
getListBanner
()
{
List
<
GoblinFrontBanner
>
list
=
goblinRedisUtils
.
getListBanner
();
if
(
null
==
list
)
{
List
<
GoblinFrontBanner
>
list
=
goblinRedisUtils
.
getListBanner
();
if
(
null
==
list
)
{
return
null
;
}
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
ArrayList
<
GoblinFrontBanner
>
goblinFrontBannerArrayList
=
ObjectUtil
.
getGoblinFrontBannerArrayList
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
ArrayList
<
GoblinFrontBanner
>
goblinFrontBannerArrayList
=
ObjectUtil
.
getGoblinFrontBannerArrayList
();
//查看是否有失效的时间
for
(
GoblinFrontBanner
goblinFrontBanner:
list
)
{
if
(
null
!=
goblinFrontBanner
.
getEndTime
()&&
null
!=
goblinFrontBanner
.
getStartTime
())
{
if
(
nowTime
.
isAfter
(
goblinFrontBanner
.
getEndTime
()))
{
}
else
{
if
(
nowTime
.
isBefore
(
goblinFrontBanner
.
getStartTime
()))
{
}
else
{
for
(
GoblinFrontBanner
goblinFrontBanner
:
list
)
{
if
(
null
!=
goblinFrontBanner
.
getEndTime
()
&&
null
!=
goblinFrontBanner
.
getStartTime
())
{
if
(
nowTime
.
isAfter
(
goblinFrontBanner
.
getEndTime
()))
{
}
else
{
if
(
nowTime
.
isBefore
(
goblinFrontBanner
.
getStartTime
()))
{
}
else
{
goblinFrontBannerArrayList
.
add
(
goblinFrontBanner
);
}
}
}
else
{
}
else
{
goblinFrontBannerArrayList
.
add
(
goblinFrontBanner
);
}
}
ArrayList
<
GoblinFrontBannerVo
>
list1
=
ObjectUtil
.
goblinFrontBannerVoArrayList
();
for
(
GoblinFrontBanner
goblinFrontBanner:
goblinFrontBannerArrayList
)
{
GoblinFrontBannerVo
goblinFrontBannerVo
=
GoblinFrontBannerVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinFrontBanner
,
goblinFrontBannerVo
);
ArrayList
<
GoblinFrontBannerVo
>
list1
=
ObjectUtil
.
goblinFrontBannerVoArrayList
();
for
(
GoblinFrontBanner
goblinFrontBanner
:
goblinFrontBannerArrayList
)
{
GoblinFrontBannerVo
goblinFrontBannerVo
=
GoblinFrontBannerVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinFrontBanner
,
goblinFrontBannerVo
);
list1
.
add
(
goblinFrontBannerVo
);
}
return
list1
;
}
public
ArrayList
<
GoblinFrontBannerVo
>
getMiddleBanner
()
{
List
<
GoblinFrontBanner
>
list
=
goblinRedisUtils
.
getMiddleBanner
();
if
(
null
==
list
)
{
List
<
GoblinFrontBanner
>
list
=
goblinRedisUtils
.
getMiddleBanner
();
if
(
null
==
list
)
{
return
null
;
}
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
ArrayList
<
GoblinFrontBanner
>
goblinFrontBannerArrayList
=
ObjectUtil
.
getGoblinFrontBannerArrayList
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
ArrayList
<
GoblinFrontBanner
>
goblinFrontBannerArrayList
=
ObjectUtil
.
getGoblinFrontBannerArrayList
();
//查看是否有失效的时间
for
(
GoblinFrontBanner
goblinFrontBanner:
list
)
{
if
(
null
!=
goblinFrontBanner
.
getEndTime
())
{
if
(
nowTime
.
isAfter
(
goblinFrontBanner
.
getEndTime
()))
{
}
else
{
if
(
nowTime
.
isBefore
(
goblinFrontBanner
.
getStartTime
()))
{
}
else
{
for
(
GoblinFrontBanner
goblinFrontBanner
:
list
)
{
if
(
null
!=
goblinFrontBanner
.
getEndTime
())
{
if
(
nowTime
.
isAfter
(
goblinFrontBanner
.
getEndTime
()))
{
}
else
{
if
(
nowTime
.
isBefore
(
goblinFrontBanner
.
getStartTime
()))
{
}
else
{
goblinFrontBannerArrayList
.
add
(
goblinFrontBanner
);
}
}
}
else
{
}
else
{
goblinFrontBannerArrayList
.
add
(
goblinFrontBanner
);
}
}
ArrayList
<
GoblinFrontBannerVo
>
list1
=
ObjectUtil
.
goblinFrontBannerVoArrayList
();
for
(
GoblinFrontBanner
goblinFrontBanner:
goblinFrontBannerArrayList
)
{
GoblinFrontBannerVo
goblinFrontBannerVo
=
GoblinFrontBannerVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinFrontBanner
,
goblinFrontBannerVo
);
ArrayList
<
GoblinFrontBannerVo
>
list1
=
ObjectUtil
.
goblinFrontBannerVoArrayList
();
for
(
GoblinFrontBanner
goblinFrontBanner
:
goblinFrontBannerArrayList
)
{
GoblinFrontBannerVo
goblinFrontBannerVo
=
GoblinFrontBannerVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinFrontBanner
,
goblinFrontBannerVo
);
list1
.
add
(
goblinFrontBannerVo
);
}
return
list1
;
...
...
@@ -118,8 +119,8 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public
GoblinFrontHotWord
getHotWord
()
{
List
<
GoblinFrontHotWord
>
list
=
goblinRedisUtils
.
getHotWord
();
// int index= (int) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD_INDEX);
List
<
GoblinFrontHotWord
>
list
=
goblinRedisUtils
.
getHotWord
();
// int index= (int) redisUtil.get(GoblinRedisConst.FRONT_HOTWORD_INDEX);
//获得value
/* index++;
String hotWord="";
...
...
@@ -129,25 +130,25 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}else{
hotWord= list.get(0).getWord();
}*/
if
(
null
==
list
||
list
.
size
()==
0
)
{
if
(
null
==
list
||
list
.
size
()
==
0
)
{
return
null
;
}
else
{
}
else
{
return
list
.
get
(
0
);
}
}
@Override
public
GoblinFrontNavigationVoo
getNavigation
()
{
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_NAVIGATION
))
{
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_NAVIGATION
))
{
return
null
;
}
GoblinFrontNavigationVoo
goblinFrontNavigationVoo
=
GoblinFrontNavigationVoo
.
getNew
();
GoblinFrontNavigationVoo
goblinFrontNavigationVoo
=
GoblinFrontNavigationVoo
.
getNew
();
List
<
GoblinFrontNavigation
>
list
=
(
List
<
GoblinFrontNavigation
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_NAVIGATION
);
ArrayList
<
GoblinFrontNavigationVo
>
list1
=
ObjectUtil
.
getgoblinFrontNavigationVoArrayList
();
for
(
GoblinFrontNavigation
navigation:
list
)
{
ArrayList
<
GoblinFrontNavigationVo
>
list1
=
ObjectUtil
.
getgoblinFrontNavigationVoArrayList
();
for
(
GoblinFrontNavigation
navigation
:
list
)
{
goblinFrontNavigationVoo
.
setDisplayType
(
navigation
.
getDisplayType
());
GoblinFrontNavigationVo
goblinFrontNavigationVo
=
GoblinFrontNavigationVo
.
getNew
();
BeanUtils
.
copyProperties
(
navigation
,
goblinFrontNavigationVo
);
GoblinFrontNavigationVo
goblinFrontNavigationVo
=
GoblinFrontNavigationVo
.
getNew
();
BeanUtils
.
copyProperties
(
navigation
,
goblinFrontNavigationVo
);
list1
.
add
(
goblinFrontNavigationVo
);
}
goblinFrontNavigationVoo
.
setList
(
list1
);
...
...
@@ -157,100 +158,100 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public
GoblinFrontSeckillVo
getSeckilll
()
throws
ParseException
{
//获得秒杀列表绑定
List
<
GoblinFrontSeckill
>
list
=
(
List
<
GoblinFrontSeckill
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SECKILL
);
GoblinFrontSeckillVo
goblinFrontSeckillVo
=
GoblinFrontSeckillVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
();
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
)
{
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"
))
{
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
(!
StringUtil
.
isNotBlank
(
goblinFrontSeckillVo
.
getStartTime
()))
{
GoblinSelfMarketingVo
goblinSelfMarketingVo
=
goblinRedisUtils
.
getSelfMarket
(
idM
);
if
(!
StringUtil
.
isNotBlank
(
goblinFrontSeckillVo
.
getStartTime
()))
{
goblinFrontSeckillVo
.
setStartTime
(
goblinSelfMarketingVo
.
getStartTime
());
goblinFrontSeckillVo
.
setEndTime
(
goblinSelfMarketingVo
.
getEndTime
());
}
if
(
goblinSelfMarketingVo
==
null
)
{
if
(
goblinSelfMarketingVo
==
null
)
{
break
;
}
if
(!
openBoolean
)
{
if
(!
openBoolean
)
{
//效验该活动是否在当前时间
if
(!
belongCalendar
(
goblinSelfMarketingVo
.
getStartTime
(),
goblinSelfMarketingVo
.
getEndTime
()))
{
if
(!
belongCalendar
(
goblinSelfMarketingVo
.
getStartTime
(),
goblinSelfMarketingVo
.
getEndTime
()))
{
//如果不是在当前时间
break
;
}
}
//查看 活动绑定的 spu sku
List
<
GoblinMarketRelationVo
>
list1
=
goblinRedisUtils
.
getMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
goblinSelfMarketingVo
.
getSelfMarketId
());
List
<
GoblinMarketRelationVo
>
list1
=
goblinRedisUtils
.
getMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
goblinSelfMarketingVo
.
getSelfMarketId
());
//遍历 活动表
for
(
GoblinMarketRelationVo
goblinMarketRelationVo:
list1
)
{
for
(
GoblinMarketRelationVo
goblinMarketRelationVo
:
list1
)
{
//找到对应的spu商品
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinMarketRelationVo
.
getSpuId
());
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinMarketRelationVo
.
getSpuId
());
//遍历sku 找到
List
<
String
>
skuList
=
goblinMarketRelationVo
.
getSkuList
();
int
sellPrice
=
0
;
int
i
=
0
;
for
(
String
skuId:
skuList
)
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
if
(
i
==
0
)
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
List
<
String
>
skuList
=
goblinMarketRelationVo
.
getSkuList
();
int
sellPrice
=
0
;
int
i
=
0
;
for
(
String
skuId
:
skuList
)
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
if
(
i
==
0
)
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
}
if
(
sellPrice
>
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
())
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
if
(
sellPrice
>
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
())
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
}
}
}
goblinGoodsInfoVo
.
setSellPrice
(
new
BigDecimal
(
sellPrice
));
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo
);
}
}
else
if
(
type
.
equals
(
"s"
))
{
}
else
if
(
type
.
equals
(
"s"
))
{
//商铺活动的vo
GoblinStoreMarketVo
goblinStoreMarketVo
=
goblinRedisUtils
.
getGoblinStoreMarketVo
(
idM
);
if
(!
StringUtil
.
isNotBlank
(
goblinFrontSeckillVo
.
getStartTime
()))
{
GoblinStoreMarketVo
goblinStoreMarketVo
=
goblinRedisUtils
.
getGoblinStoreMarketVo
(
idM
);
if
(!
StringUtil
.
isNotBlank
(
goblinFrontSeckillVo
.
getStartTime
()))
{
goblinFrontSeckillVo
.
setStartTime
(
goblinStoreMarketVo
.
getStartTime
());
goblinFrontSeckillVo
.
setEndTime
(
goblinStoreMarketVo
.
getEndTime
());
}
if
(
goblinStoreMarketVo
==
null
)
{
if
(
goblinStoreMarketVo
==
null
)
{
break
;
}
boolean
isGet
=
false
;
if
(
openBoolean
)
{
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
;
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
)
{
if
(
isGet
)
{
//获取商铺 对应关系
List
<
GoblinMarketRelationVo
>
list1
=
goblinRedisUtils
.
getMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
goblinStoreMarketVo
.
getStoreMarketId
());
List
<
GoblinMarketRelationVo
>
list1
=
goblinRedisUtils
.
getMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
goblinStoreMarketVo
.
getStoreMarketId
());
//获得商品
//遍历 活动表
for
(
GoblinMarketRelationVo
goblinMarketRelationVo:
list1
)
{
for
(
GoblinMarketRelationVo
goblinMarketRelationVo
:
list1
)
{
//找到对应的spu商品
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinMarketRelationVo
.
getSpuId
());
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinMarketRelationVo
.
getSpuId
());
//遍历sku 找到
List
<
String
>
skuList
=
goblinMarketRelationVo
.
getSkuList
();
int
sellPrice
=
0
;
int
i
=
0
;
for
(
String
skuId:
skuList
)
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
if
(
i
==
0
)
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
List
<
String
>
skuList
=
goblinMarketRelationVo
.
getSkuList
();
int
sellPrice
=
0
;
int
i
=
0
;
for
(
String
skuId
:
skuList
)
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
if
(
i
==
0
)
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
}
if
(
sellPrice
>
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
())
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
if
(
sellPrice
>
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
())
{
sellPrice
=
goblinGoodsSkuInfoVo
.
getSellPrice
().
intValue
();
}
}
}
...
...
@@ -266,108 +267,114 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
return
goblinFrontSeckillVo
;
}
//获取库存设置的报警数量
public
int
getStockCount
(
String
storeId
){
String
configVal
=
""
;
List
<
GoblinStoreConfigVo
>
listVo
=
goblinRedisUtils
.
getStoreConfigVos
(
storeId
);
public
int
getStockCount
(
String
storeId
)
{
String
configVal
=
""
;
List
<
GoblinStoreConfigVo
>
listVo
=
goblinRedisUtils
.
getStoreConfigVos
(
storeId
);
//ONOFF_SOLD_OUT_SHOW ON 开启
for
(
GoblinStoreConfigVo
goblinStoreConfigVo:
listVo
)
{
for
(
GoblinStoreConfigVo
goblinStoreConfigVo
:
listVo
)
{
//获取是 售罄是否开启
if
(
goblinStoreConfigVo
.
getConfigKey
().
equals
(
GoblinStoreConf
.
LIMIT_WARNING_STOCK
))
{
configVal
=
goblinStoreConfigVo
.
getConfigVal
();
if
(
goblinStoreConfigVo
.
getConfigKey
().
equals
(
GoblinStoreConf
.
LIMIT_WARNING_STOCK
))
{
configVal
=
goblinStoreConfigVo
.
getConfigVal
();
}
}
if
(
StringUtil
.
isNotBlank
(
configVal
))
{
if
(
StringUtil
.
isNotBlank
(
configVal
))
{
return
Integer
.
parseInt
(
configVal
);
}
else
{
}
else
{
return
-
1
;
}
}
/**
* 获得商品详情
*/
public
GoblinFrontGoodDetailVo
getGoodsDetail
(
String
spuId
)
{
Integer
buyCount
=
0
;
GoblinFrontGoodDetailVo
goblinFrontGoodDetailVo
=
GoblinFrontGoodDetailVo
.
getNew
();
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuId
);
GoblinGoodsInfoDetailVo
goblinGoodsInfoDetailVo
=
GoblinGoodsInfoDetailVo
.
getNew
();
public
GoblinFrontGoodDetailVo
getGoodsDetail
(
String
spuId
)
{
Integer
buyCount
=
0
;
GoblinFrontGoodDetailVo
goblinFrontGoodDetailVo
=
GoblinFrontGoodDetailVo
.
getNew
();
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuId
);
GoblinGoodsInfoDetailVo
goblinGoodsInfoDetailVo
=
GoblinGoodsInfoDetailVo
.
getNew
();
//skuIdList
if
(
null
!=
goblinGoodsInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoDetailVo
);
if
(
null
!=
goblinGoodsInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoDetailVo
);
goblinFrontGoodDetailVo
.
setGoblinGoodsInfoVo
(
goblinGoodsInfoDetailVo
);
// int limit= getStockCount(goblinGoodsInfoVo.getStoreId());
List
<
String
>
skuIdList
=
goblinGoodsInfoVo
.
getSkuIdList
();
ArrayList
<
GoblinGoodsSkuInfoDetailVo
>
list
=
ObjectUtil
.
goblinGoodsSkuInfoDetailVos
();
for
(
String
sku:
skuIdList
)
{
String
userId
=
CurrentUtil
.
getCurrentUid
();
if
(
StringUtils
.
isNotBlank
(
userId
))
{
buyCount
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
sku
);
// int limit= getStockCount(goblinGoodsInfoVo.getStoreId());
List
<
String
>
skuIdList
=
goblinGoodsInfoVo
.
getSkuIdList
();
ArrayList
<
GoblinGoodsSkuInfoDetailVo
>
list
=
ObjectUtil
.
goblinGoodsSkuInfoDetailVos
();
for
(
String
sku
:
skuIdList
)
{
String
userId
=
CurrentUtil
.
getCurrentUid
();
if
(
StringUtils
.
isNotBlank
(
userId
))
{
buyCount
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
sku
);
}
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
sku
);
if
(
null
!=
goblinGoodsSkuInfoVo
&&
goblinGoodsSkuInfoVo
.
getDelFlg
().
equals
(
"0"
)&&
goblinGoodsSkuInfoVo
.
getShelvesStatus
().
equals
(
"3"
))
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
sku
);
if
(
null
!=
goblinGoodsSkuInfoVo
&&
goblinGoodsSkuInfoVo
.
getDelFlg
().
equals
(
"0"
)
&&
goblinGoodsSkuInfoVo
.
getShelvesStatus
().
equals
(
"3"
))
{
//获取 sku 库存数量
String
pre
=
GoblinStatusConst
.
MarketPreStatus
.
getPre
(
spuId
);
int
stock
=
goblinRedisUtils
.
getSkuStock
(
pre
,
goblinGoodsSkuInfoVo
.
getSkuId
());
log
.
debug
(
"skuId:{},库存数量{}"
,
goblinGoodsSkuInfoVo
.
getSkuId
(),
stock
);
GoblinGoodsSkuInfoDetailVo
goblinGoodsSkuInfoDetailVo
=
GoblinGoodsSkuInfoDetailVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsSkuInfoVo
,
goblinGoodsSkuInfoDetailVo
);
if
(
0
!=
goblinGoodsSkuInfoDetailVo
.
getBuyLimit
())
{
if
(
null
==
buyCount
)
{
buyCount
=
0
;
int
stock
=
goblinRedisUtils
.
getSkuStock
(
pre
,
goblinGoodsSkuInfoVo
.
getSkuId
());
log
.
debug
(
"skuId:{},库存数量{}"
,
goblinGoodsSkuInfoVo
.
getSkuId
(),
stock
);
GoblinGoodsSkuInfoDetailVo
goblinGoodsSkuInfoDetailVo
=
GoblinGoodsSkuInfoDetailVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsSkuInfoVo
,
goblinGoodsSkuInfoDetailVo
);
if
(
0
!=
goblinGoodsSkuInfoDetailVo
.
getBuyLimit
())
{
if
(
null
==
buyCount
)
{
buyCount
=
0
;
}
goblinGoodsSkuInfoDetailVo
.
setCanBuy
(
goblinGoodsSkuInfoDetailVo
.
getBuyLimit
()-
buyCount
);
}
else
{
goblinGoodsSkuInfoDetailVo
.
setCanBuy
(-
9999
);}
if
(
stock
<=
0
){
goblinGoodsSkuInfoDetailVo
.
setCanBuy
(
goblinGoodsSkuInfoDetailVo
.
getBuyLimit
()
-
buyCount
);
}
else
{
goblinGoodsSkuInfoDetailVo
.
setCanBuy
(-
9999
);
}
if
(
stock
<=
0
)
{
goblinGoodsSkuInfoDetailVo
.
setStockLess
(
true
);
}
else
{
}
else
{
goblinGoodsSkuInfoDetailVo
.
setStockLess
(
false
);
}
list
.
add
(
goblinGoodsSkuInfoDetailVo
);
}
}
//goblinGoodsInfoVo
GoblinStoreInfoVo
goblinStoreInfoVo
=
this
.
getStore
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
GoblinStoreInfoVo
goblinStoreInfoVo
=
this
.
getStore
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
goblinFrontGoodDetailVo
.
setStoreName
(
goblinStoreInfoVo
.
getStoreName
());
}
goblinFrontGoodDetailVo
.
setGoblinGoodsSkuInfoVolist
(
list
);
}
else
{
}
else
{
return
null
;
}
ArrayList
<
String
>
list
=
goblinCouponService
.
getSpuType
(
spuId
,
goblinGoodsInfoDetailVo
.
getStoreId
());
ArrayList
<
String
>
list
=
goblinCouponService
.
getSpuType
(
spuId
,
goblinGoodsInfoDetailVo
.
getStoreId
());
goblinFrontGoodDetailVo
.
setGetSpuType
(
list
);
return
goblinFrontGoodDetailVo
;
return
goblinFrontGoodDetailVo
;
}
/**
* 获取组件排序
*/
public
List
getMoudleIndex
()
{
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
MOUDLE_INDEX
))
{
public
List
getMoudleIndex
()
{
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
MOUDLE_INDEX
))
{
return
null
;
}
//GoblinGoodsInfoVo goblinGoodsInfoVo=goblinRedisUtils.get(spuId);
List
<
GoblinFrontMoudleIndex
>
list
=
(
List
<
GoblinFrontMoudleIndex
>)
redisUtil
.
get
(
GoblinRedisConst
.
MOUDLE_INDEX
);
return
list
;
List
<
GoblinFrontMoudleIndex
>
list
=
(
List
<
GoblinFrontMoudleIndex
>)
redisUtil
.
get
(
GoblinRedisConst
.
MOUDLE_INDEX
);
return
list
;
}
/***
* @author zhangfuxin
* @Description:获取魔方
* @date 2022/1/10 下午4:49
*/
public
GoblinFrontCubeVo
getRecommend
(){
GoblinFrontCubeVo
goblinFrontCubeVo
=
GoblinFrontCubeVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_GOBLIN_RECOMMEND
))
{
public
GoblinFrontCubeVo
getRecommend
()
{
GoblinFrontCubeVo
goblinFrontCubeVo
=
GoblinFrontCubeVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_GOBLIN_RECOMMEND
))
{
return
null
;
}
List
<
GoblinFrontCube
>
list
=
(
List
<
GoblinFrontCube
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_GOBLIN_RECOMMEND
);
if
(
list
.
size
()>
0
)
{
BeanUtils
.
copyProperties
(
list
.
get
(
0
),
goblinFrontCubeVo
);
for
(
String
spuid:
goblinFrontCubeVo
.
getSpuId
().
split
(
","
))
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuid
);
if
(
null
!=
goblinGoodsInfoVo
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo1
=
GoblinGoodsInfoVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoVo1
);
List
<
GoblinFrontCube
>
list
=
(
List
<
GoblinFrontCube
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_GOBLIN_RECOMMEND
);
if
(
list
.
size
()
>
0
)
{
BeanUtils
.
copyProperties
(
list
.
get
(
0
),
goblinFrontCubeVo
);
for
(
String
spuid
:
goblinFrontCubeVo
.
getSpuId
().
split
(
","
))
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuid
);
if
(
null
!=
goblinGoodsInfoVo
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo1
=
GoblinGoodsInfoVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoVo1
);
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo1
);
}
}
...
...
@@ -376,25 +383,26 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
return
goblinFrontCubeVo
;
}
/***
* @author zhangfuxin
* @Description:获取魔方
* @date 2022/1/10 下午4:49
*/
public
GoblinFrontCubeVo
getCube
(){
GoblinFrontCubeVo
goblinFrontCubeVo
=
GoblinFrontCubeVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_GOBLINFRONTCUBE
))
{
public
GoblinFrontCubeVo
getCube
()
{
GoblinFrontCubeVo
goblinFrontCubeVo
=
GoblinFrontCubeVo
.
getNew
();
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
FRONT_GOBLINFRONTCUBE
))
{
return
null
;
}
List
<
GoblinFrontCube
>
list
=
(
List
<
GoblinFrontCube
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_GOBLINFRONTCUBE
);
if
(
list
.
size
()>
0
)
{
BeanUtils
.
copyProperties
(
list
.
get
(
0
),
goblinFrontCubeVo
);
for
(
String
spuid:
goblinFrontCubeVo
.
getSpuId
().
split
(
","
))
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuid
);
if
(
null
!=
goblinGoodsInfoVo
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo1
=
GoblinGoodsInfoVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoVo1
);
List
<
GoblinFrontCube
>
list
=
(
List
<
GoblinFrontCube
>)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_GOBLINFRONTCUBE
);
if
(
list
.
size
()
>
0
)
{
BeanUtils
.
copyProperties
(
list
.
get
(
0
),
goblinFrontCubeVo
);
for
(
String
spuid
:
goblinFrontCubeVo
.
getSpuId
().
split
(
","
))
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuid
);
if
(
null
!=
goblinGoodsInfoVo
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo1
=
GoblinGoodsInfoVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoVo1
);
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo1
);
}
}
...
...
@@ -403,45 +411,48 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
return
goblinFrontCubeVo
;
}
public
GoblinStoreInfoVo
getStore
(
String
storId
){
public
GoblinStoreInfoVo
getStore
(
String
storId
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"storeId"
).
is
(
storId
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
));
long
count
=
mongoTemplate
.
count
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
storId
);
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
storId
);
//GoblinStoreNoticeVo goblinStoreNoticeVo=goblinRedisUtils.getStoreNoticeVo(storId,LocalDateTime.now());
goblinStoreInfoVo
.
setCount
((
int
)
count
);
return
goblinStoreInfoVo
;
return
goblinStoreInfoVo
;
}
/***
* @author zhangfuxin
* @Description:获得商铺分类
* @date 2022/1/18 下午1:44
*/
public
List
<
GoblinStoreGoodsCategoryVo
>
getStoreCategory
(
String
storId
){
public
List
<
GoblinStoreGoodsCategoryVo
>
getStoreCategory
(
String
storId
)
{
//店铺分类数据源
List
<
GoblinStoreGoodsCategoryVo
>
list
=
goblinRedisUtils
.
getStoreGoodsCategoryVos
(
storId
);
List
<
GoblinStoreGoodsCategoryVo
>
list
=
goblinRedisUtils
.
getStoreGoodsCategoryVos
(
storId
);
return
list
;
}
/**
* 找到分类
*/
public
GoblinCategoryzfVo
getCategory
(
String
categoryId
){
GoblinCategoryzfVo
goblinCategoryzfVo
=
GoblinCategoryzfVo
.
getNew
();
ArrayList
<
GoblinSelfGoodsCategoryVo
>
list1
=
ObjectUtil
.
getGoblinSelfGoodsCategoryVoArrayList
();
public
GoblinCategoryzfVo
getCategory
(
String
categoryId
)
{
GoblinCategoryzfVo
goblinCategoryzfVo
=
GoblinCategoryzfVo
.
getNew
();
ArrayList
<
GoblinSelfGoodsCategoryVo
>
list1
=
ObjectUtil
.
getGoblinSelfGoodsCategoryVoArrayList
();
//先找到 当前的分类id
GoblinSelfGoodsCategoryVo
pa
=
null
;
GoblinSelfGoodsCategoryVo
pa
=
null
;
//获取到分类
List
<
GoblinSelfGoodsCategoryVo
>
list
=
goblinRedisUtils
.
getSelfGoodsCategoryVos
();
for
(
GoblinSelfGoodsCategoryVo
goblinSelfGoodsCategoryVo:
list
)
{
List
<
GoblinSelfGoodsCategoryVo
>
list
=
goblinRedisUtils
.
getSelfGoodsCategoryVos
();
for
(
GoblinSelfGoodsCategoryVo
goblinSelfGoodsCategoryVo
:
list
)
{
if
(
categoryId
.
equals
(
goblinSelfGoodsCategoryVo
.
getCateId
()))
{
goblinCategoryzfVo
.
setGoblinSelfGoodsCategoryVo
(
goblinSelfGoodsCategoryVo
);
pa
=
goblinSelfGoodsCategoryVo
;
pa
=
goblinSelfGoodsCategoryVo
;
}
}
//找到 该分类的子集
if
(
null
!=
pa
)
{
for
(
GoblinSelfGoodsCategoryVo
goblinSelfGoodsCategoryVo:
list
)
{
if
(
pa
.
getCateId
().
equals
(
goblinSelfGoodsCategoryVo
.
getCatePid
()))
{
if
(
null
!=
pa
)
{
for
(
GoblinSelfGoodsCategoryVo
goblinSelfGoodsCategoryVo
:
list
)
{
if
(
pa
.
getCateId
().
equals
(
goblinSelfGoodsCategoryVo
.
getCatePid
()))
{
list1
.
add
(
goblinSelfGoodsCategoryVo
);
}
...
...
@@ -451,74 +462,77 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return
goblinCategoryzfVo
;
}
public
List
<
GoblinGoodsInfoListVo
>
searchGoodesName
(
String
name
){
List
<
String
>
listStore
=
mongoUtils
.
getStoreInfoVoRegexName
(
name
);
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
name
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
public
List
<
GoblinGoodsInfoListVo
>
searchGoodesName
(
String
name
)
{
List
<
String
>
listStore
=
mongoUtils
.
getStoreInfoVoRegexName
(
name
);
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
name
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
Query
query
=
new
Query
();
query
.
addCriteria
(
new
Criteria
().
orOperator
(
Criteria
.
where
(
"spuType"
).
is
(
0
),
//
Criteria.where("spuType").is(0),
Criteria
.
where
(
"name"
).
regex
(
pattern
),
Criteria
.
where
(
"storeId"
).
in
(
listStore
),
Criteria
.
where
(
"extagVoList.tagName"
).
is
(
name
)
));
// query.addCriteria(Criteria.where("name").regex(pattern).and("spuAppear").is("0").and("delFlg").is("0").and("shelvesStatus").is("3"));
// query.addCriteria(Criteria.where("name").regex(pattern).and("spuAppear").is("0").and("delFlg").is("0").and("shelvesStatus").is("3"));
query
.
addCriteria
(
Criteria
.
where
(
"spuAppear"
).
is
(
"0"
).
and
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"marketId"
).
is
(
null
));
query
.
addCriteria
(
Criteria
.
where
(
"spuType"
).
is
(
0
));
query
.
with
(
Sort
.
by
(
//Sort.Order.desc("count"),
Sort
.
Order
.
desc
(
"shelvesAt"
)
));
List
<
GoblinGoodsInfoVo
>
list
=
mongoTemplate
.
find
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
ArrayList
<
GoblinGoodsInfoListVo
>
list1
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
ArrayList
<
GoblinGoodsInfoListVo
>
list1
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
//遍历
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
//有音乐人的放前面
if
(
null
!=
goblinGoodsInfoVo
.
getExtagVoList
()&&
goblinGoodsInfoVo
.
getExtagVoList
().
size
()>
0
)
{
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
if
(
null
!=
goblinGoodsInfoVo
.
getExtagVoList
()
&&
goblinGoodsInfoVo
.
getExtagVoList
().
size
()
>
0
)
{
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
goblinGoodsInfoVo
.
setStoreName
(
goblinStoreInfoVo
.
getStoreName
());
}
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
list1
.
add
(
goblinGoodsInfoListVo
);
}
}
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
if
(
null
!=
goblinGoodsInfoVo
.
getExtagVoList
()&&
goblinGoodsInfoVo
.
getExtagVoList
().
size
()>
0
)
{
}
else
{
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
if
(
null
!=
goblinGoodsInfoVo
.
getExtagVoList
()
&&
goblinGoodsInfoVo
.
getExtagVoList
().
size
()
>
0
)
{
}
else
{
//无音乐人标签的
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
GoblinStoreInfoVo
goblinStoreInfoVo
=
goblinRedisUtils
.
getStoreInfoVo
(
goblinGoodsInfoVo
.
getStoreId
());
if
(
null
!=
goblinStoreInfoVo
)
{
goblinGoodsInfoVo
.
setStoreName
(
goblinStoreInfoVo
.
getStoreName
());
}
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
list1
.
add
(
goblinGoodsInfoListVo
);
}
}
return
list1
;
}
public
GoblinFrontCategoryListVo
getStoreGoodes
(
String
storeId
,
String
categoryId
,
String
name
){
String
configVal
=
""
;
List
<
GoblinStoreConfigVo
>
listVo
=
goblinRedisUtils
.
getStoreConfigVos
(
storeId
);
public
GoblinFrontCategoryListVo
getStoreGoodes
(
String
storeId
,
String
categoryId
,
String
name
)
{
String
configVal
=
""
;
List
<
GoblinStoreConfigVo
>
listVo
=
goblinRedisUtils
.
getStoreConfigVos
(
storeId
);
//ONOFF_SOLD_OUT_SHOW ON 开启
for
(
GoblinStoreConfigVo
goblinStoreConfigVo:
listVo
)
{
for
(
GoblinStoreConfigVo
goblinStoreConfigVo
:
listVo
)
{
//获取是 售罄是否开启
if
(
goblinStoreConfigVo
.
getConfigKey
().
equals
(
GoblinStoreConf
.
ONOFF_SOLD_OUT_SHOW
))
{
configVal
=
goblinStoreConfigVo
.
getConfigVal
();
if
(
goblinStoreConfigVo
.
getConfigKey
().
equals
(
GoblinStoreConf
.
ONOFF_SOLD_OUT_SHOW
))
{
configVal
=
goblinStoreConfigVo
.
getConfigVal
();
}
}
//
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"storeId"
).
is
(
storeId
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"marketId"
).
is
(
null
));
if
(
StringUtil
.
isNotBlank
(
categoryId
))
{
if
(
StringUtil
.
isNotBlank
(
categoryId
))
{
query
.
addCriteria
(
new
Criteria
().
orOperator
(
Criteria
.
where
(
"storeCateFid"
).
is
(
categoryId
),
Criteria
.
where
(
"storeCateSid"
).
is
(
categoryId
),
Criteria
.
where
(
"storeCateTid"
).
is
(
categoryId
)
));
}
if
(
StringUtil
.
isNotBlank
(
name
))
{
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
name
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
if
(
StringUtil
.
isNotBlank
(
name
))
{
Pattern
pattern
=
Pattern
.
compile
(
"^.*"
+
name
+
".*$"
,
Pattern
.
CASE_INSENSITIVE
);
query
.
addCriteria
(
Criteria
.
where
(
"name"
).
regex
(
pattern
));
}
query
.
with
(
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
));
...
...
@@ -527,54 +541,54 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
// 计算库存
Iterator
<
GoblinGoodsInfoVo
>
iterator
=
list
.
iterator
();
//删掉库存没有的商品
while
(
iterator
.
hasNext
())
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
iterator
.
next
();
List
<
String
>
skuIdList
=
goblinGoodsInfoVo
.
getSkuIdList
();
int
count
=
0
;
for
(
String
skuId:
skuIdList
)
{
count
=
count
+
goblinRedisUtils
.
getSkuStock
(
null
,
skuId
);
while
(
iterator
.
hasNext
())
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
iterator
.
next
();
List
<
String
>
skuIdList
=
goblinGoodsInfoVo
.
getSkuIdList
();
int
count
=
0
;
for
(
String
skuId
:
skuIdList
)
{
count
=
count
+
goblinRedisUtils
.
getSkuStock
(
null
,
skuId
);
}
if
(
StringUtil
.
isNotBlank
(
configVal
)&&!
configVal
.
equals
(
"ON"
))
{
if
(
count
==
0
)
{
if
(
StringUtil
.
isNotBlank
(
configVal
)
&&
!
configVal
.
equals
(
"ON"
))
{
if
(
count
==
0
)
{
iterator
.
remove
();
}
}
}
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
listVos
.
add
(
goblinGoodsInfoListVo
);
}
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
goblinFrontCategoryListVo
.
setSpuList
(
listVos
);
return
goblinFrontCategoryListVo
;
}
/**
*音乐人列表
*
音乐人列表
*/
public
GoblinFrontCategoryListVo
getMusic
(
String
tagId
,
String
type
,
int
page
,
int
pageSize
)
{
public
GoblinFrontCategoryListVo
getMusic
(
String
tagId
,
String
type
,
int
page
,
int
pageSize
)
{
//
Query
query
=
new
Query
();
query
.
addCriteria
(
new
Criteria
().
orOperator
(
Criteria
.
where
(
"extagVoList.tagId"
).
is
(
tagId
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"marketId"
).
is
(
null
)
));
Pageable
pageable
=
null
;
Pageable
pageable
=
null
;
//
boolean
isRe
=
false
;
if
(
type
.
equals
(
"1"
))
{
boolean
isRe
=
false
;
if
(
type
.
equals
(
"1"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
));
}
else
if
(
type
.
equals
(
"2"
))
{
}
else
if
(
type
.
equals
(
"2"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
));
}
else
if
(
type
.
equals
(
"3"
))
{
}
else
if
(
type
.
equals
(
"3"
))
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
Collation
collation
=
Collation
.
from
(
source
);
query
.
collation
(
collation
);
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"priceGe"
));
}
else
if
(
type
.
equals
(
"4"
))
{
}
else
if
(
type
.
equals
(
"4"
))
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
...
...
@@ -604,13 +618,13 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return -(arg0.getCount().compareTo(arg1.getCount()));
}});
}*/
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
listVos
.
add
(
goblinGoodsInfoListVo
);
}
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
goblinFrontCategoryListVo
.
setCount
(
count
);
goblinFrontCategoryListVo
.
setSpuList
(
listVos
);
return
goblinFrontCategoryListVo
;
...
...
@@ -620,7 +634,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* 获取分类列表
* 1、销量优先、2、新品优先、3、价格降序、4、价格升序
*/
public
GoblinFrontCategoryListVo
getCategoryList
(
String
type
,
String
categoryId
,
int
page
,
int
pageSize
)
{
public
GoblinFrontCategoryListVo
getCategoryList
(
String
type
,
String
categoryId
,
int
page
,
int
pageSize
)
{
//
Query
query
=
new
Query
();
query
.
addCriteria
(
new
Criteria
().
orOperator
(
...
...
@@ -629,40 +643,40 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
Criteria
.
where
(
"cateTid"
).
is
(
categoryId
)
));
query
.
addCriteria
(
Criteria
.
where
(
"spuAppear"
).
is
(
"0"
).
and
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"marketId"
).
is
(
null
));
Pageable
pageable
=
null
;
Pageable
pageable
=
null
;
//
if
(
type
.
equals
(
"1"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"2"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"3"
))
{
if
(
type
.
equals
(
"1"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"2"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"3"
))
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
Collation
collation
=
Collation
.
from
(
source
);
query
.
collation
(
collation
);
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"priceGe"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"4"
))
{
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"priceGe"
,
"createdAt"
));
}
else
if
(
type
.
equals
(
"4"
))
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
Collation
collation
=
Collation
.
from
(
source
);
query
.
collation
(
collation
);
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"priceGe"
,
"createdAt"
));
pageable
=
PageRequest
.
of
(
page
,
pageSize
,
Sort
.
by
(
Sort
.
Direction
.
ASC
,
"priceGe"
,
"createdAt"
));
}
// 排序 分页
// Query query = Query.query(Criteria.where("status").ne(1).and("status").ne(0));
// Query query = Query.query(Criteria.where("status").ne(1).and("status").ne(0));
// 查询总数
long
count
=
mongoTemplate
.
count
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
query
.
with
(
pageable
);
List
<
GoblinGoodsInfoVo
>
list
=
mongoTemplate
.
find
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
GoblinFrontCategoryListVo
goblinFrontCategoryListVo
=
GoblinFrontCategoryListVo
.
getNew
();
goblinFrontCategoryListVo
.
setCount
(
count
);
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
ArrayList
<
GoblinGoodsInfoListVo
>
listVos
=
ObjectUtil
.
getGoblinGoodsInfoListVo
();
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
GoblinGoodsInfoListVo
goblinGoodsInfoListVo
=
GoblinGoodsInfoListVo
.
getNew
();
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoListVo
);
listVos
.
add
(
goblinGoodsInfoListVo
);
}
goblinFrontCategoryListVo
.
setSpuList
(
listVos
);
...
...
@@ -671,34 +685,35 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
/**
* 获取 mongodb里面的spuId
*
* @return
*/
public
String
getspuId
(
String
spuids
,
int
page
,
int
pageSize
)
{
public
String
getspuId
(
String
spuids
,
int
page
,
int
pageSize
)
{
Query
query
=
new
Query
();
if
(
StringUtil
.
isNotBlank
(
spuids
))
{
if
(
StringUtil
.
isNotBlank
(
spuids
))
{
query
.
addCriteria
(
Criteria
.
where
(
"spuId"
).
nin
(
spuids
.
split
(
","
)));
}
query
.
addCriteria
(
Criteria
.
where
(
"delFlg"
).
is
(
"0"
).
and
(
"shelvesStatus"
).
is
(
"3"
).
and
(
"spuAppear"
).
is
(
"0"
).
and
(
"marketId"
).
is
(
null
));
//redis里面获取排序规则 1、上架时间2、销量3、价格高到低4、价格低到高
int
sortType
=
0
;
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SORT
))
{
sortType
=
(
int
)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS_SORT
);
int
sortType
=
0
;
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SORT
))
{
sortType
=
(
int
)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS_SORT
);
}
Sort
sortName
=
null
;
if
(
sortType
==
1
)
{
Sort
sortName
=
null
;
if
(
sortType
==
1
)
{
sortName
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"shelvesAt"
);
}
else
if
(
sortType
==
2
)
{
sortName
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
,
"createdAt"
);
}
else
if
(
sortType
==
3
)
{
}
else
if
(
sortType
==
2
)
{
sortName
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"count"
,
"createdAt"
);
}
else
if
(
sortType
==
3
)
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
Collation
collation
=
Collation
.
from
(
source
);
query
.
collation
(
collation
);
sortName
=
Sort
.
by
(
Sort
.
Direction
.
DESC
,
"priceGe"
);
}
else
{
}
else
{
Document
source
=
new
Document
();
source
.
put
(
"locale"
,
"zh"
);
source
.
put
(
"numericOrdering"
,
true
);
...
...
@@ -711,89 +726,92 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
query
.
with
(
sortName
);
List
<
GoblinGoodsInfoVo
>
list
=
mongoTemplate
.
find
(
query
,
GoblinGoodsInfoVo
.
class
,
GoblinGoodsInfoVo
.
class
.
getSimpleName
());
StringBuffer
sb
=
new
StringBuffer
();
int
index
=
0
;
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo:
list
)
{
if
(
index
==
0
)
{
int
index
=
0
;
for
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
:
list
)
{
if
(
index
==
0
)
{
sb
.
append
(
goblinGoodsInfoVo
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinGoodsInfoVo
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinGoodsInfoVo
.
getSpuId
());
}
index
++;
}
return
sb
.
toString
();
}
public
void
setPage1
(
List
<
GoblinFrontSelectGoods
>
list
,
int
pageSize
){
public
void
setPage1
(
List
<
GoblinFrontSelectGoods
>
list
,
int
pageSize
)
{
StringBuffer
sb
=
new
StringBuffer
();
//足够了 拼接字符串
int
i
=
0
;
for
(
GoblinFrontSelectGoods
goblinFrontSelectGoods:
list
)
{
if
(
i
==
0
)
{
int
i
=
0
;
for
(
GoblinFrontSelectGoods
goblinFrontSelectGoods
:
list
)
{
if
(
i
==
0
)
{
sb
.
append
(
goblinFrontSelectGoods
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinFrontSelectGoods
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinFrontSelectGoods
.
getSpuId
());
}
i
++;
if
(
i
==
pageSize
)
break
;
if
(
i
==
pageSize
)
break
;
}
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
,
sb
.
toString
());
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
,
sb
.
toString
());
}
public
void
setPage1AndSpu
(
List
<
GoblinFrontSelectGoods
>
list
,
int
pageSize
){
public
void
setPage1AndSpu
(
List
<
GoblinFrontSelectGoods
>
list
,
int
pageSize
)
{
validate
(
list
);
//sb 为配置的 精选商品 spuid
StringBuffer
sb
=
new
StringBuffer
();
if
(
null
!=
list
&&
list
.
size
()>
0
)
{
int
i
=
0
;
for
(
GoblinFrontSelectGoods
goblinFrontSelectGoods:
list
)
{
if
(
i
==
0
)
{
if
(
null
!=
list
&&
list
.
size
()
>
0
)
{
int
i
=
0
;
for
(
GoblinFrontSelectGoods
goblinFrontSelectGoods
:
list
)
{
if
(
i
==
0
)
{
sb
.
append
(
goblinFrontSelectGoods
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinFrontSelectGoods
.
getSpuId
());
}
else
{
sb
.
append
(
","
+
goblinFrontSelectGoods
.
getSpuId
());
}
i
++;
}
}
//获得没有配置的spuid s 是没有配置的精选商品spuid
String
s
=
this
.
getspuId
(
sb
.
toString
(),
0
,
0
);
String
supids
=
""
;
if
(
StringUtil
.
isNotBlank
(
sb
.
toString
())&&
StringUtil
.
isNotBlank
(
s
))
{
supids
=
sb
.
toString
()+
","
+
s
;
}
else
if
(
StringUtil
.
isNotBlank
(
sb
.
toString
()))
{
supids
=
sb
.
toString
();
}
else
if
(
StringUtil
.
isNotBlank
(
s
))
{
supids
=
s
;
}
log
.
debug
(
"spuid所有的为:{}"
,
supids
);
int
index
=
0
;
String
s
=
this
.
getspuId
(
sb
.
toString
(),
0
,
0
);
String
supids
=
""
;
if
(
StringUtil
.
isNotBlank
(
sb
.
toString
())
&&
StringUtil
.
isNotBlank
(
s
))
{
supids
=
sb
.
toString
()
+
","
+
s
;
}
else
if
(
StringUtil
.
isNotBlank
(
sb
.
toString
()))
{
supids
=
sb
.
toString
();
}
else
if
(
StringUtil
.
isNotBlank
(
s
))
{
supids
=
s
;
}
log
.
debug
(
"spuid所有的为:{}"
,
supids
);
int
index
=
0
;
//sb1 为 第一页的 spuid
StringBuffer
sb1
=
new
StringBuffer
();
for
(
String
ss:
supids
.
split
(
","
))
{
if
(
index
==
0
)
{
for
(
String
ss
:
supids
.
split
(
","
))
{
if
(
index
==
0
)
{
sb1
.
append
(
ss
);
}
else
{
sb1
.
append
(
","
+
ss
);
}
else
{
sb1
.
append
(
","
+
ss
);
}
index
++;
if
(
index
==
pageSize
)
{
if
(
index
==
pageSize
)
{
break
;
}
}
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
,
sb1
.
toString
());
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
,
supids
);
if
(
StringUtil
.
isBlank
(
supids
))
{
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS_ISHAVE
,
"1"
);
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
,
sb1
.
toString
());
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
,
supids
);
if
(
StringUtil
.
isBlank
(
supids
))
{
redisUtil
.
set
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS_ISHAVE
,
"1"
);
}
}
public
void
validate
(
List
<
GoblinFrontSelectGoods
>
list
){
if
(
null
!=
list
&&
list
.
size
()>
0
){
public
void
validate
(
List
<
GoblinFrontSelectGoods
>
list
)
{
if
(
null
!=
list
&&
list
.
size
()
>
0
)
{
Iterator
<
GoblinFrontSelectGoods
>
it
=
list
.
iterator
();
while
(
it
.
hasNext
())
{
GoblinFrontSelectGoods
goblinFrontSelectGoods
=
it
.
next
();
if
(
StringUtils
.
isBlank
(
goblinFrontSelectGoods
.
getSpuId
()))
{
GoblinFrontSelectGoods
goblinFrontSelectGoods
=
it
.
next
();
if
(
StringUtils
.
isBlank
(
goblinFrontSelectGoods
.
getSpuId
()))
{
it
.
remove
();
}
else
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinFrontSelectGoods
.
getSpuId
());
if
(
null
==
goblinGoodsInfoVo
||
StringUtil
.
isNotBlank
(
goblinGoodsInfoVo
.
getMarketId
()))
{
}
else
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinFrontSelectGoods
.
getSpuId
());
if
(
null
==
goblinGoodsInfoVo
||
StringUtil
.
isNotBlank
(
goblinGoodsInfoVo
.
getMarketId
()))
{
it
.
remove
();
}
}
...
...
@@ -801,14 +819,15 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
}
public
String
getRedisKey
(
String
key
)
{
Object
value
=
redisUtil
.
get
(
key
);
if
(
null
!=
value
)
{
public
String
getRedisKey
(
String
key
)
{
Object
value
=
redisUtil
.
get
(
key
);
if
(
null
!=
value
)
{
return
value
.
toString
();
}
else
{
}
else
{
return
""
;
}
}
/**
* @author zhangfuxin
* @Description:精选商品列表
...
...
@@ -816,44 +835,44 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
*/
@Override
public
GoblinFrontSelectGoodVo
getSelectGoods
(
int
page
,
int
pageSize
)
{
GoblinFrontSelectGoodVo
goblinFrontSelectGoodVo
=
GoblinFrontSelectGoodVo
.
getNew
();
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS_ISHAVE
))
{
GoblinFrontSelectGoodVo
goblinFrontSelectGoodVo
=
GoblinFrontSelectGoodVo
.
getNew
();
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS_ISHAVE
))
{
return
goblinFrontSelectGoodVo
;
}
//先从redis里 查 是否有第一页的值
String
spuIds
=
""
;
if
(
page
==
0
)
{
String
selectGoodsPage1
=
getRedisKey
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
);
if
(
StringUtil
.
isNotBlank
(
selectGoodsPage1
))
{
String
[]
spuids
=
selectGoodsPage1
.
split
(
","
);
log
.
debug
(
"spuids{}"
,
spuids
);
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
for
(
String
id:
spuids
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
id
);
if
(
null
!=
goblinGoodsInfoVo
)
{
String
spuIds
=
""
;
if
(
page
==
0
)
{
String
selectGoodsPage1
=
getRedisKey
(
GoblinRedisConst
.
SELECT_GOODS_PAGE1
);
if
(
StringUtil
.
isNotBlank
(
selectGoodsPage1
))
{
String
[]
spuids
=
selectGoodsPage1
.
split
(
","
);
log
.
debug
(
"spuids{}"
,
spuids
);
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
for
(
String
id
:
spuids
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
id
);
if
(
null
!=
goblinGoodsInfoVo
)
{
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo
);
}
}
goblinFrontSelectGoodVo
.
setGoblinGoodsInfoVoList
(
goblinGoodsInfoVoArrayList
);
return
goblinFrontSelectGoodVo
;
}
else
{
}
else
{
//从redis里面查出配置的 spu
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS
))
{
List
<
GoblinFrontSelectGoods
>
list
=
(
List
<
GoblinFrontSelectGoods
>)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS
);
if
(
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS
))
{
List
<
GoblinFrontSelectGoods
>
list
=
(
List
<
GoblinFrontSelectGoods
>)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS
);
validate
(
list
);
if
(
list
.
size
()>=
pageSize
)
{
this
.
setPage1
(
list
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
}
else
{
setPage1AndSpu
(
list
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
if
(
list
.
size
()
>=
pageSize
)
{
this
.
setPage1
(
list
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
}
else
{
setPage1AndSpu
(
list
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
}
}
else
{
setPage1AndSpu
(
null
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
}
else
{
setPage1AndSpu
(
null
,
pageSize
);
return
this
.
getSelectGoods
(
page
,
pageSize
);
}
}
}
else
{
}
else
{
/* //查看是否有 配置的 spuid的顺序
String selectGoodsSpuids= getRedisKey(GoblinRedisConst.SELECT_GOODS_PAGE1);
if(StringUtil.isBlank(selectGoodsSpuids)){
...
...
@@ -865,24 +884,24 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//查看是否有 配置的 spuid的顺序
/* String selectGoodsSpuids= getRedisKey(GoblinRedisConst.SELECT_GOODS_PAGE1);*/
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
))
{
List
<
GoblinFrontSelectGoods
>
list
=
(
List
<
GoblinFrontSelectGoods
>)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS
);
setPage1AndSpu
(
list
,
pageSize
);
this
.
getSelectGoods
(
page
,
pageSize
);
if
(!
redisUtil
.
hasKey
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
))
{
List
<
GoblinFrontSelectGoods
>
list
=
(
List
<
GoblinFrontSelectGoods
>)
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS
);
setPage1AndSpu
(
list
,
pageSize
);
this
.
getSelectGoods
(
page
,
pageSize
);
}
String
[]
spuidss
=
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
).
toString
().
split
(
","
);
String
[]
spuidss
=
redisUtil
.
get
(
GoblinRedisConst
.
SELECT_GOODS_SPUIDS
).
toString
().
split
(
","
);
//String[] spuidss=selectGoodsSpuids.split(",");
//找到对应的spuid
int
start
=
page
*
pageSize
;
int
end
=(
page
+
1
)*
pageSize
;
if
(
end
>
spuidss
.
length
)
{
end
=
spuidss
.
length
;
int
start
=
page
*
pageSize
;
int
end
=
(
page
+
1
)
*
pageSize
;
if
(
end
>
spuidss
.
length
)
{
end
=
spuidss
.
length
;
}
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
for
(
int
i
=
0
;
i
<
end
;
i
++)
{
if
(
i
>=
start
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuidss
[
i
]);
ArrayList
<
GoblinGoodsInfoVo
>
goblinGoodsInfoVoArrayList
=
ObjectUtil
.
getGoblinGoodsInfoVos
();
for
(
int
i
=
0
;
i
<
end
;
i
++)
{
if
(
i
>=
start
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
spuidss
[
i
]);
goblinGoodsInfoVoArrayList
.
add
(
goblinGoodsInfoVo
);
}
}
...
...
@@ -938,13 +957,13 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
@Override
public
List
<
GoblinGoodsInfoVo
>
getGoodByMusicTagP
(
String
musicTag
,
String
performanceId
)
{
return
goblinRedisUtils
.
getMusicTagList
(
musicTag
,
performanceId
);
return
goblinRedisUtils
.
getMusicTagList
(
musicTag
,
performanceId
);
}
public
boolean
belongCalendar
(
String
startString
,
String
endString
)
throws
ParseException
{
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
);
Date
end
=
simpleDateFormat
.
parse
(
endString
);
Calendar
date
=
Calendar
.
getInstance
();
date
.
setTime
(
new
Date
());
Calendar
after
=
Calendar
.
getInstance
();
...
...
@@ -957,6 +976,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return
false
;
}
}
//判断是否是该时间之后
public
boolean
afterCalendar
(
String
time
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DateUtil
.
DATE_FULL_STR
);
//注意月份是MM
...
...
@@ -969,6 +989,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return
false
;
}
}
//判断是否是该时间之后
public
boolean
beforeCalendar
(
String
time
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DateUtil
.
DATE_FULL_STR
);
//注意月份是MM
...
...
@@ -981,197 +1002,203 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return
false
;
}
}
public
boolean
validateShoopCartNumber
(
String
skuId
,
String
type
,
Integer
buyCount
,
String
userId
){
if
(!
type
.
equals
(
"1"
)){
public
boolean
validateShoopCartNumber
(
String
skuId
,
String
type
,
Integer
buyCount
,
String
userId
)
{
if
(!
type
.
equals
(
"1"
))
{
return
true
;
}
//获取sku
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
==
goblinGoodsSkuInfoVo
)
{
return
false
;
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
skuId
);
if
(
null
==
goblinGoodsSkuInfoVo
)
{
return
false
;
}
if
(
null
==
goblinGoodsSkuInfoVo
.
getBuyLimit
()||
goblinGoodsSkuInfoVo
.
getBuyLimit
()==
0
)
{
return
true
;
if
(
null
==
goblinGoodsSkuInfoVo
.
getBuyLimit
()
||
goblinGoodsSkuInfoVo
.
getBuyLimit
()
==
0
)
{
return
true
;
}
//已经购买的数量
Integer
buyCounts
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
skuId
);
if
(
goblinGoodsSkuInfoVo
.
getBuyLimit
()<(
buyCounts
+
buyCount
))
{
Integer
buyCounts
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
skuId
);
if
(
goblinGoodsSkuInfoVo
.
getBuyLimit
()
<
(
buyCounts
+
buyCount
))
{
//
return
false
;
}
return
true
;
}
/**
* @author zhangfuxin
* @Description:添加购物车
* @date 2022/1/11 下午4:16
*/
public
ResponseDto
addShoopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
)
{
if
(
null
==
number
||
number
<=
0
)
{
public
ResponseDto
addShoopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
)
{
if
(
null
==
number
||
number
<=
0
)
{
return
ResponseDto
.
success
(
false
);
}
boolean
isGoods
=
false
;
String
cardId
=
""
;
boolean
isGoods
=
false
;
String
cardId
=
""
;
//判断该用户 redis里是否有购物车
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
==
goblinShoppingCartVoo
)
{
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
==
goblinShoppingCartVoo
)
{
//创建 voo
GoblinShoppingCartVoo
goblinShoppingCartVoo1
=
GoblinShoppingCartVoo
.
getNew
();
GoblinShoppingCartVoo
goblinShoppingCartVoo1
=
GoblinShoppingCartVoo
.
getNew
();
// 根据shop分类
ArrayList
<
GoblinShoppingCartVo
>
list
=
ObjectUtil
.
goblinShoppingCartVoArrayList
();
GoblinShoppingCartVo
goblinShoppingCartVo
=
GoblinShoppingCartVo
.
getNew
();
ArrayList
<
GoblinShoppingCartVo
>
list
=
ObjectUtil
.
goblinShoppingCartVoArrayList
();
GoblinShoppingCartVo
goblinShoppingCartVo
=
GoblinShoppingCartVo
.
getNew
();
goblinShoppingCartVo
.
setStoreId
(
storeId
);
//该商铺下的所有商品
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
//创建 购物车vo
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
list1
.
add
(
goblinShoppingCartVoDetail
);
goblinShoppingCartVo
.
setSkuList
(
list1
);
list
.
add
(
goblinShoppingCartVo
);
goblinShoppingCartVoo1
.
setShopList
(
list
);
goblinShoppingCartVoo1
.
setGoblinShoppingCartId
(
IDGenerator
.
nextSnowId
());
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo1
,
userId
,
type
);
insertShopCartMysql
(
goblinShoppingCartVoDetail
.
getCarId
(),
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
}
else
{
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo1
,
userId
,
type
);
insertShopCartMysql
(
goblinShoppingCartVoDetail
.
getCarId
(),
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
}
else
{
//查看是否有该商铺
List
<
GoblinShoppingCartVo
>
list
=
goblinShoppingCartVoo
.
getShopList
();
boolean
isShop
=
false
;
for
(
GoblinShoppingCartVo
goblinShoppingCartVo:
list
)
{
if
(
storeId
.
equals
(
goblinShoppingCartVo
.
getStoreId
()))
{
List
<
GoblinShoppingCartVo
>
list
=
goblinShoppingCartVoo
.
getShopList
();
boolean
isShop
=
false
;
for
(
GoblinShoppingCartVo
goblinShoppingCartVo
:
list
)
{
if
(
storeId
.
equals
(
goblinShoppingCartVo
.
getStoreId
()))
{
//有这个商铺的 东西
List
<
GoblinShoppingCartVoDetail
>
list1
=
goblinShoppingCartVo
.
getSkuList
();
List
<
GoblinShoppingCartVoDetail
>
list1
=
goblinShoppingCartVo
.
getSkuList
();
//查看是否有这个商品
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
list1
)
{
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
()))
{
isGoods
=
true
;
if
(!
validateShoopCartNumber
(
skuId
,
type
,(
goblinShoppingCartVoDetail
.
getNumber
()+
number
),
userId
))
{
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
:
list1
)
{
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
()))
{
isGoods
=
true
;
if
(!
validateShoopCartNumber
(
skuId
,
type
,
(
goblinShoppingCartVoDetail
.
getNumber
()
+
number
),
userId
))
{
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
goblinShoppingCartVoDetail
.
setNumber
((
goblinShoppingCartVoDetail
.
getNumber
()
+
number
));
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
goblinShoppingCartVoDetail
.
setNumber
((
goblinShoppingCartVoDetail
.
getNumber
()
+
number
));
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
}
}
if
(
isGoods
)
{
if
(
isGoods
)
{
//添加商品 数量
//不需要做
}
else
{
}
else
{
//创建商品放入到list
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
list1
.
add
(
goblinShoppingCartVoDetail
);
}
isShop
=
true
;
isShop
=
true
;
}
}
if
(!
isShop
)
{
GoblinShoppingCartVo
goblinShoppingCartVo
=
GoblinShoppingCartVo
.
getNew
();
if
(!
isShop
)
{
GoblinShoppingCartVo
goblinShoppingCartVo
=
GoblinShoppingCartVo
.
getNew
();
goblinShoppingCartVo
.
setStoreId
(
storeId
);
//该商铺下的所有商品
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
))
{
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
//创建 购物车vo
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
list1
.
add
(
goblinShoppingCartVoDetail
);
goblinShoppingCartVo
.
setSkuList
(
list1
);
list
.
add
(
goblinShoppingCartVo
);
}
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
if
(
isGoods
)
{
updateShopCartMysql
(
cardId
,
number
,
userId
);
}
else
{
insertShopCartMysql
(
cardId
,
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
if
(
isGoods
)
{
updateShopCartMysql
(
cardId
,
number
,
userId
);
}
else
{
insertShopCartMysql
(
cardId
,
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
}
}
return
ResponseDto
.
success
(
true
);
}
/***
* @author zhangfuxin
* @Description: 修改 购物车里 数量
* @date 2022/1/11 下午6:24
*/
public
boolean
updateShopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
)
{
if
(
null
==
number
||
number
<=
0
)
{
return
false
;
}
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
));
String
cardId
=
""
;
if
(
null
!=
goblinShoppingCartVoo
)
{
List
<
GoblinShoppingCartVo
>
list
=
goblinShoppingCartVoo
.
getShopList
();
public
boolean
updateShopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
)
{
if
(
null
==
number
||
number
<=
0
)
{
return
false
;
}
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
));
String
cardId
=
""
;
if
(
null
!=
goblinShoppingCartVoo
)
{
List
<
GoblinShoppingCartVo
>
list
=
goblinShoppingCartVoo
.
getShopList
();
//遍历商铺
for
(
GoblinShoppingCartVo
goblinShoppingCartVo:
list
)
{
if
(
storeId
.
equals
(
goblinShoppingCartVo
.
getStoreId
()))
{
for
(
GoblinShoppingCartVo
goblinShoppingCartVo
:
list
)
{
if
(
storeId
.
equals
(
goblinShoppingCartVo
.
getStoreId
()))
{
//找到 商品id
List
<
GoblinShoppingCartVoDetail
>
list1
=
goblinShoppingCartVo
.
getSkuList
();
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
list1
)
{
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
()))
{
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
List
<
GoblinShoppingCartVoDetail
>
list1
=
goblinShoppingCartVo
.
getSkuList
();
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
:
list1
)
{
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
()))
{
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
goblinShoppingCartVoDetail
.
setNumber
(
number
);
}
}
}
}
//调用储存方法
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
updateShopCartMysql
(
cardId
,
number
,
userId
);
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
updateShopCartMysql
(
cardId
,
number
,
userId
);
}
return
true
;
}
public
int
getShopCartCount
(
String
userId
,
String
type
)
{
log
.
debug
(
"获取商品数量{}"
,
userId
);
int
count
=
0
;
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
!=
goblinShoppingCartVoo
)
{
List
<
GoblinShoppingCartVo
>
shopList
=
goblinShoppingCartVoo
.
getShopList
();
for
(
GoblinShoppingCartVo
goblinShoppingCartVo:
shopList
)
{
List
<
GoblinShoppingCartVoDetail
>
skuList
=
goblinShoppingCartVo
.
getSkuList
();
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
skuList
)
{
count
=
goblinShoppingCartVoDetail
.
getNumber
()+
count
;
public
int
getShopCartCount
(
String
userId
,
String
type
)
{
log
.
debug
(
"获取商品数量{}"
,
userId
);
int
count
=
0
;
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
!=
goblinShoppingCartVoo
)
{
List
<
GoblinShoppingCartVo
>
shopList
=
goblinShoppingCartVoo
.
getShopList
();
for
(
GoblinShoppingCartVo
goblinShoppingCartVo
:
shopList
)
{
List
<
GoblinShoppingCartVoDetail
>
skuList
=
goblinShoppingCartVo
.
getSkuList
();
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
:
skuList
)
{
count
=
goblinShoppingCartVoDetail
.
getNumber
()
+
count
;
}
}
}
return
count
;
}
/***
* @author zhangfuxin
* @Description:存储信息
* @date 2022/1/17 下午4:55
*/
public
boolean
saveDate
(
String
data
,
String
userId
,
String
type
)
{
redisUtil
.
set
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
()),
data
,
60
*
60
*
24
);
public
boolean
saveDate
(
String
data
,
String
userId
,
String
type
)
{
redisUtil
.
set
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
()),
data
,
60
*
60
*
24
);
return
true
;
}
public
ResponseDto
getDate
(
String
userId
,
String
type
)
{
if
(
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
()))==
null
){
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20003"
));
public
ResponseDto
getDate
(
String
userId
,
String
type
)
{
if
(
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
()))
==
null
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20003"
));
}
return
ResponseDto
.
success
(
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
())));
return
ResponseDto
.
success
(
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART_TWO
.
concat
(
userId
).
concat
(
type
.
toString
())));
//return (String) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART_TWO.concat(userId).concat(type.toString()));
}
/**
* 删除购物车里面的商品
*/
public
boolean
delteShoppingCart
(
String
[]
skuIds
,
String
userId
,
String
type
)
{
public
boolean
delteShoppingCart
(
String
[]
skuIds
,
String
userId
,
String
type
)
{
boolean
isDeleteAll
=
false
;
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
));
if
(
null
!=
goblinShoppingCartVoo
)
{
List
<
GoblinShoppingCartVo
>
shopList
=
goblinShoppingCartVoo
.
getShopList
();
Iterator
<
GoblinShoppingCartVo
>
shopIter
=
shopList
.
iterator
();
while
(
shopIter
.
hasNext
()){
GoblinShoppingCartVo
goblinShoppingCartVo
=
shopIter
.
next
();
while
(
shopIter
.
hasNext
())
{
GoblinShoppingCartVo
goblinShoppingCartVo
=
shopIter
.
next
();
List
<
GoblinShoppingCartVoDetail
>
skuList
=
goblinShoppingCartVo
.
getSkuList
();
Iterator
<
GoblinShoppingCartVoDetail
>
iterator
=
skuList
.
iterator
();
while
(
iterator
.
hasNext
())
{
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
iterator
.
next
();
while
(
iterator
.
hasNext
())
{
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
iterator
.
next
();
for
(
String
skuId
:
skuIds
)
{
if
(
goblinShoppingCartVoDetail
.
getSkuId
().
equals
(
skuId
))
{
//skuList.remove(goblinShoppingCartVoDetail);
...
...
@@ -1179,16 +1206,16 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
}
}
if
(
skuList
.
size
()==
0
)
{
if
(
skuList
.
size
()
==
0
)
{
shopIter
.
remove
();
}
}
if
(
shopList
.
size
()==
0
)
{
deleteRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
skuIds
,
type
);
deleteMysql
(
userId
,
skuIds
);
}
else
{
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
deleteMysql
(
userId
,
skuIds
);
if
(
shopList
.
size
()
==
0
)
{
deleteRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
skuIds
,
type
);
deleteMysql
(
userId
,
skuIds
);
}
else
{
saveRedisMongodbMysqlShop
(
goblinShoppingCartVoo
,
userId
,
type
);
deleteMysql
(
userId
,
skuIds
);
}
}
...
...
@@ -1199,89 +1226,99 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId);
}
*/
return
true
;
return
true
;
}
//获得spu
public
GoblinGoodsInfoVo
getGoodsInfoVo
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
){
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinShoppingCartVoDetail
.
getSpuId
());
if
(
null
==
goblinGoodsInfoVo
)
{
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVoByUnShelves
(
goblinShoppingCartVoDetail
.
getSpuId
());
public
GoblinGoodsInfoVo
getGoodsInfoVo
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
)
{
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
goblinShoppingCartVoDetail
.
getSpuId
());
if
(
null
==
goblinGoodsInfoVo
)
{
goblinGoodsInfoVo
=
goblinRedisUtils
.
getGoodsInfoVoByUnShelves
(
goblinShoppingCartVoDetail
.
getSpuId
());
}
return
goblinGoodsInfoVo
;
}
//获得sku
public
GoblinGoodsSkuInfoVo
getGoblinGoodsSkuInfoVo
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
){
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
goblinShoppingCartVoDetail
.
getSkuId
());
if
(
null
==
goblinGoodsSkuInfoVo
)
{
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVoByUnShelves
(
goblinShoppingCartVoDetail
.
getSkuId
());
public
GoblinGoodsSkuInfoVo
getGoblinGoodsSkuInfoVo
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
)
{
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
goblinShoppingCartVoDetail
.
getSkuId
());
if
(
null
==
goblinGoodsSkuInfoVo
)
{
goblinGoodsSkuInfoVo
=
goblinRedisUtils
.
getGoodsSkuInfoVoByUnShelves
(
goblinShoppingCartVoDetail
.
getSkuId
());
}
return
goblinGoodsSkuInfoVo
;
}
//copy spu
public
GoblinGoodsInfoShopCartVo
copySpuVo
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
){
GoblinGoodsInfoShopCartVo
goblinGoodsInfoShopCartVo
=
GoblinGoodsInfoShopCartVo
.
getNew
();
if
(
null
!=
goblinGoodsInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoShopCartVo
);
public
GoblinGoodsInfoShopCartVo
copySpuVo
(
GoblinGoodsInfoVo
goblinGoodsInfoVo
)
{
GoblinGoodsInfoShopCartVo
goblinGoodsInfoShopCartVo
=
GoblinGoodsInfoShopCartVo
.
getNew
();
if
(
null
!=
goblinGoodsInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsInfoVo
,
goblinGoodsInfoShopCartVo
);
}
return
goblinGoodsInfoShopCartVo
;
}
//copy sku
public
GoblinGoodsSkuShopCartInfoVo
copySkuVo
(
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
,
String
userId
)
{
GoblinGoodsSkuShopCartInfoVo
goblinGoodsSkuShopCartInfoVo
=
GoblinGoodsSkuShopCartInfoVo
.
getNew
();
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsSkuInfoVo
,
goblinGoodsSkuShopCartInfoVo
);
public
GoblinGoodsSkuShopCartInfoVo
copySkuVo
(
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
,
String
userId
)
{
GoblinGoodsSkuShopCartInfoVo
goblinGoodsSkuShopCartInfoVo
=
GoblinGoodsSkuShopCartInfoVo
.
getNew
();
if
(
null
!=
goblinGoodsSkuInfoVo
)
{
BeanUtils
.
copyProperties
(
goblinGoodsSkuInfoVo
,
goblinGoodsSkuShopCartInfoVo
);
//查看是否有库存
String
pre
=
GoblinStatusConst
.
MarketPreStatus
.
getPre
(
goblinGoodsSkuInfoVo
.
getSpuId
());
int
stock
=
goblinRedisUtils
.
getSkuStock
(
pre
,
goblinGoodsSkuInfoVo
.
getSkuId
());
if
(
stock
<=
0
)
{
int
stock
=
goblinRedisUtils
.
getSkuStock
(
pre
,
goblinGoodsSkuInfoVo
.
getSkuId
());
if
(
stock
<=
0
)
{
goblinGoodsSkuShopCartInfoVo
.
setStockLess
(
true
);
}
else
{
goblinGoodsSkuShopCartInfoVo
.
setStockLess
(
false
);}
}
else
{
goblinGoodsSkuShopCartInfoVo
.
setStockLess
(
false
);
}
//查看已经购买数量
Integer
buyCount
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
goblinGoodsSkuShopCartInfoVo
.
getSkuId
());
Integer
buyCount
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
goblinGoodsSkuShopCartInfoVo
.
getSkuId
());
//查看限购数量
if
(
null
==
buyCount
){
buyCount
=
0
;}
if
(
null
!=
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()&&
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()>
0
){
goblinGoodsSkuShopCartInfoVo
.
setCanBuy
(
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()-
buyCount
);
}
else
{
if
(
null
==
buyCount
)
{
buyCount
=
0
;
}
if
(
null
!=
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()
&&
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()
>
0
)
{
goblinGoodsSkuShopCartInfoVo
.
setCanBuy
(
goblinGoodsSkuShopCartInfoVo
.
getBuyLimit
()
-
buyCount
);
}
else
{
goblinGoodsSkuShopCartInfoVo
.
setCanBuy
(-
9999
);
}
}
return
goblinGoodsSkuShopCartInfoVo
;
}
/**
* @author zhangfuxin
* @Description: 获得购物车列表
* @date 2022/1/12 下午2:36
*/
public
GoblinShoppingCartVoo
getShoppCart
(
String
userId
,
String
type
)
{
public
GoblinShoppingCartVoo
getShoppCart
(
String
userId
,
String
type
)
{
//判断该用户 redis里是否有购物车
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
==
goblinShoppingCartVoo
)
{
GoblinShoppingCartVoo
goblinShoppingCartVoo
=
(
GoblinShoppingCartVoo
)
redisUtil
.
get
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
if
(
null
==
goblinShoppingCartVoo
)
{
return
null
;
}
//遍历里面信息
for
(
GoblinShoppingCartVo
goblinShoppingCartVo:
goblinShoppingCartVoo
.
getShopList
())
{
if
(
null
!=
goblinRedisUtils
.
getStoreInfoVo
(
goblinShoppingCartVo
.
getStoreId
()))
{
for
(
GoblinShoppingCartVo
goblinShoppingCartVo
:
goblinShoppingCartVoo
.
getShopList
())
{
if
(
null
!=
goblinRedisUtils
.
getStoreInfoVo
(
goblinShoppingCartVo
.
getStoreId
()))
{
goblinShoppingCartVo
.
setStoreName
(
goblinRedisUtils
.
getStoreInfoVo
(
goblinShoppingCartVo
.
getStoreId
()).
getStoreName
());
}
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
goblinShoppingCartVo
.
getSkuList
())
{
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
:
goblinShoppingCartVo
.
getSkuList
())
{
//找到对应的 spu
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
getGoodsInfoVo
(
goblinShoppingCartVoDetail
);
GoblinGoodsInfoVo
goblinGoodsInfoVo
=
getGoodsInfoVo
(
goblinShoppingCartVoDetail
);
// 找到对应 sku
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
getGoblinGoodsSkuInfoVo
(
goblinShoppingCartVoDetail
);
GoblinGoodsSkuInfoVo
goblinGoodsSkuInfoVo
=
getGoblinGoodsSkuInfoVo
(
goblinShoppingCartVoDetail
);
//spu copy
GoblinGoodsInfoShopCartVo
goblinGoodsInfoShopCartVo
=
copySpuVo
(
goblinGoodsInfoVo
);
GoblinGoodsInfoShopCartVo
goblinGoodsInfoShopCartVo
=
copySpuVo
(
goblinGoodsInfoVo
);
//sku copy
GoblinGoodsSkuShopCartInfoVo
goblinGoodsSkuShopCartInfoVo
=
copySkuVo
(
goblinGoodsSkuInfoVo
,
userId
);
GoblinGoodsSkuShopCartInfoVo
goblinGoodsSkuShopCartInfoVo
=
copySkuVo
(
goblinGoodsSkuInfoVo
,
userId
);
goblinShoppingCartVoDetail
.
setGoblinGoodsInfoVo
(
goblinGoodsInfoShopCartVo
);
goblinShoppingCartVoDetail
.
setGoblinGoodsSkuInfoVo
(
goblinGoodsSkuShopCartInfoVo
);
}
}
goblinShoppingCartVoo
.
setShoopingCount
(
this
.
getShopCartCount
(
userId
,
type
));
goblinShoppingCartVoo
.
setShoopingCount
(
this
.
getShopCartCount
(
userId
,
type
));
return
goblinShoppingCartVoo
;
}
public
GoblinShoppingCartVoDetail
setValue
(
String
userId
,
String
storeId
,
String
spuId
,
String
skuId
,
Integer
number
){
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
GoblinShoppingCartVoDetail
.
getNew
();
public
GoblinShoppingCartVoDetail
setValue
(
String
userId
,
String
storeId
,
String
spuId
,
String
skuId
,
Integer
number
)
{
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
GoblinShoppingCartVoDetail
.
getNew
();
goblinShoppingCartVoDetail
.
setCarId
(
IDGenerator
.
nextSnowId
());
goblinShoppingCartVoDetail
.
setUserId
(
userId
);
goblinShoppingCartVoDetail
.
setStoreId
(
storeId
);
...
...
@@ -1293,26 +1330,28 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoDetail
.
setUpdatedAt
(
LocalDateTime
.
now
());
return
goblinShoppingCartVoDetail
;
}
public
void
saveRedisMongodbMysqlShop
(
GoblinShoppingCartVoo
goblinShoppingCartVoo
,
String
userId
,
String
type
){
public
void
saveRedisMongodbMysqlShop
(
GoblinShoppingCartVoo
goblinShoppingCartVoo
,
String
userId
,
String
type
)
{
goblinShoppingCartVoo
.
setUserId
(
userId
);
//redis存储
redisUtil
.
set
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()),
goblinShoppingCartVoo
);
redisUtil
.
set
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()),
goblinShoppingCartVoo
);
//mongodb存储
boolean
exists2
=
mongoTemplate
.
exists
(
Query
.
query
(
Criteria
.
where
(
"goblinShoppingCartId"
).
is
(
goblinShoppingCartVoo
.
getGoblinShoppingCartId
())),
GoblinShoppingCartVoo
.
class
,
GoblinShoppingCartVoo
.
class
.
getSimpleName
());
boolean
exists2
=
mongoTemplate
.
exists
(
Query
.
query
(
Criteria
.
where
(
"goblinShoppingCartId"
).
is
(
goblinShoppingCartVoo
.
getGoblinShoppingCartId
())),
GoblinShoppingCartVoo
.
class
,
GoblinShoppingCartVoo
.
class
.
getSimpleName
());
goblinShoppingCartVoo
.
setType
(
type
);
if
(
exists2
)
{
if
(
exists2
)
{
BasicDBObject
orderObject
=
new
BasicDBObject
(
"$set"
,
JSON
.
parse
(
JsonUtils
.
toJson
(
goblinShoppingCartVoo
)));
mongoTemplate
.
getCollection
(
GoblinShoppingCartVoo
.
class
.
getSimpleName
()).
updateOne
(
Query
.
query
(
Criteria
.
where
(
"goblinShoppingCartId"
).
is
(
goblinShoppingCartVoo
.
getGoblinShoppingCartId
())).
getQueryObject
(),
orderObject
);
}
else
{
mongoTemplate
.
save
(
goblinShoppingCartVoo
,
GoblinShoppingCartVoo
.
class
.
getSimpleName
());
}
else
{
mongoTemplate
.
save
(
goblinShoppingCartVoo
,
GoblinShoppingCartVoo
.
class
.
getSimpleName
());
}
//mysql 消息队列
}
//删除redis 删除mongodb
public
void
deleteRedisMongodbMysqlShop
(
GoblinShoppingCartVoo
goblinShoppingCartVoo
,
String
userId
,
String
[]
skuIds
,
String
type
)
{
public
void
deleteRedisMongodbMysqlShop
(
GoblinShoppingCartVoo
goblinShoppingCartVoo
,
String
userId
,
String
[]
skuIds
,
String
type
)
{
//redis存储
redisUtil
.
del
(
GoblinRedisConst
.
FRONT_SHOPCART
.
concat
(
userId
).
concat
(
type
.
toString
()));
//mongodb 删除
...
...
@@ -1321,47 +1360,49 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
sqls
.
add
(
SqlMapping
.
get
(
"goblin_shop.cart.delete"
));
LinkedList
<
Object
[]>
sqlData
=
CollectionUtil
.
linkedListObjectArr
();
for
(
String
sku:
skuIds
)
{
for
(
String
sku
:
skuIds
)
{
sqlData
.
add
(
new
Object
[]{
userId
,
sku
,
0
userId
,
sku
,
0
});
}
String
sqlDatas
=
SqlMapping
.
gets
(
sqls
,
sqlData
);
log
.
debug
(
"sql信息{}"
,
sqlDatas
);
log
.
debug
(
"sql信息{}"
,
sqlDatas
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_SHOP_CART
.
getKey
(),
sqlDatas
);
}
public
void
insertShopCartMysql
(
String
carId
,
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
){
public
void
insertShopCartMysql
(
String
carId
,
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
)
{
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
sqls
.
add
(
SqlMapping
.
get
(
"goblin_shop.cart.insert"
));
LinkedList
<
Object
[]>
sqlData
=
CollectionUtil
.
linkedListObjectArr
();
sqlData
.
add
(
new
Object
[]{
//car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`
carId
,
userId
,
storeId
,
spuId
,
skuId
,
number
,
""
,
0
,
""
,
type
//car_id, user_id, store_id,spu_id, sku_id, `number`,marketing_id, del_tag, `comment`
carId
,
userId
,
storeId
,
spuId
,
skuId
,
number
,
""
,
0
,
""
,
type
});
String
sqlDatas
=
SqlMapping
.
gets
(
sqls
,
sqlData
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_SHOP_CART
.
getKey
(),
sqlDatas
);
}
public
void
updateShopCartMysql
(
String
carId
,
Integer
number
,
String
userId
){
public
void
updateShopCartMysql
(
String
carId
,
Integer
number
,
String
userId
)
{
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
sqls
.
add
(
SqlMapping
.
get
(
"goblin_shop.cart.update"
));
LinkedList
<
Object
[]>
sqlData
=
CollectionUtil
.
linkedListObjectArr
();
sqlData
.
add
(
new
Object
[]{
//update goblin_shopping_cart set `number` = ? where car_id=? and user_id=?
number
,
carId
,
userId
number
,
carId
,
userId
});
String
sqlDatas
=
SqlMapping
.
gets
(
sqls
,
sqlData
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_SHOP_CART
.
getKey
(),
sqlDatas
);
}
//删除
public
void
deleteMysql
(
String
userId
,
String
[]
skuIds
)
{
public
void
deleteMysql
(
String
userId
,
String
[]
skuIds
)
{
//mysql 删除 按照 userid 、skuid
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
sqls
.
add
(
SqlMapping
.
get
(
"goblin_shop.cart.delete"
));
LinkedList
<
Object
[]>
sqlData
=
CollectionUtil
.
linkedListObjectArr
();
for
(
String
sku:
skuIds
)
{
for
(
String
sku
:
skuIds
)
{
sqlData
.
add
(
new
Object
[]{
1
,
userId
,
sku
1
,
userId
,
sku
});
}
String
sqlDatas
=
SqlMapping
.
gets
(
sqls
,
sqlData
);
...
...
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