记得上下班打卡 | 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
d7799324
Commit
d7799324
authored
Feb 23, 2022
by
zhengfuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改购物车问题
parent
e12b3984
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
GoblinFrontLoginController.java
...service/goblin/controller/GoblinFrontLoginController.java
+1
-1
GoblinFrontServiceImpl.java
...t/service/goblin/service/impl/GoblinFrontServiceImpl.java
+37
-4
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/GoblinFrontLoginController.java
View file @
d7799324
...
@@ -32,7 +32,7 @@ public class GoblinFrontLoginController {
...
@@ -32,7 +32,7 @@ public class GoblinFrontLoginController {
@ApiOperation
(
"加入购物车"
)
@ApiOperation
(
"加入购物车"
)
public
ResponseDto
addShopCart
(
@RequestParam
(
name
=
"spuId"
,
required
=
true
)
String
spuId
,
@RequestParam
(
name
=
"storeId"
,
required
=
true
)
String
storeId
,
@RequestParam
(
name
=
"skuId"
,
required
=
true
)
String
skuId
,
@RequestParam
(
name
=
"number"
,
required
=
false
)
Integer
number
,
@RequestParam
(
name
=
"type"
,
required
=
true
)
String
type
)
{
public
ResponseDto
addShopCart
(
@RequestParam
(
name
=
"spuId"
,
required
=
true
)
String
spuId
,
@RequestParam
(
name
=
"storeId"
,
required
=
true
)
String
storeId
,
@RequestParam
(
name
=
"skuId"
,
required
=
true
)
String
skuId
,
@RequestParam
(
name
=
"number"
,
required
=
false
)
Integer
number
,
@RequestParam
(
name
=
"type"
,
required
=
true
)
String
type
)
{
String
userId
=
CurrentUtil
.
getCurrentUid
();
String
userId
=
CurrentUtil
.
getCurrentUid
();
return
ResponseDto
.
success
(
goblinFrontService
.
addShoopCart
(
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
)
);
return
goblinFrontService
.
addShoopCart
(
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
}
}
@GetMapping
(
"updateShopCart"
)
@GetMapping
(
"updateShopCart"
)
@ApiOperation
(
"修改购物车"
)
@ApiOperation
(
"修改购物车"
)
...
...
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/GoblinFrontServiceImpl.java
View file @
d7799324
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.goblin.service.impl;
...
@@ -3,6 +3,7 @@ package com.liquidnet.service.goblin.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.commons.lang.util.*
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
import
com.liquidnet.service.goblin.constant.GoblinRedisConst
;
...
@@ -902,14 +903,34 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -902,14 +903,34 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return
false
;
return
false
;
}
}
}
}
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
;
}
if
(
null
==
goblinGoodsSkuInfoVo
.
getBuyLimit
()&&
goblinGoodsSkuInfoVo
.
getBuyLimit
()==
0
){
return
true
;
}
//已经购买的数量
Integer
buyCounts
=
goblinRedisUtils
.
getSkuCountByUid
(
userId
,
skuId
);
if
(
goblinGoodsSkuInfoVo
.
getBuyLimit
()<(
buyCounts
+
buyCount
)){
//
return
false
;
}
return
true
;
}
/**
/**
* @author zhangfuxin
* @author zhangfuxin
* @Description:添加购物车
* @Description:添加购物车
* @date 2022/1/11 下午4:16
* @date 2022/1/11 下午4:16
*/
*/
public
boolean
addShoopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
){
public
ResponseDto
addShoopCart
(
String
spuId
,
String
storeId
,
String
skuId
,
Integer
number
,
String
userId
,
String
type
){
if
(
null
==
number
||
number
<=
0
){
if
(
null
==
number
||
number
<=
0
){
return
false
;
return
ResponseDto
.
success
(
false
)
;
}
}
boolean
isGoods
=
false
;
boolean
isGoods
=
false
;
String
cardId
=
""
;
String
cardId
=
""
;
...
@@ -924,6 +945,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -924,6 +945,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVo
.
setStoreId
(
storeId
);
goblinShoppingCartVo
.
setStoreId
(
storeId
);
//该商铺下的所有商品
//该商铺下的所有商品
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
)){
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
//创建 购物车vo
//创建 购物车vo
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
list1
.
add
(
goblinShoppingCartVoDetail
);
list1
.
add
(
goblinShoppingCartVoDetail
);
...
@@ -946,6 +970,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -946,6 +970,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
list1
){
for
(
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail:
list1
){
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
())){
if
(
skuId
.
equals
(
goblinShoppingCartVoDetail
.
getSkuId
())){
isGoods
=
true
;
isGoods
=
true
;
if
(!
validateShoopCartNumber
(
skuId
,
type
,(
goblinShoppingCartVoDetail
.
getNumber
()+
number
),
userId
)){
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
goblinShoppingCartVoDetail
.
setNumber
((
goblinShoppingCartVoDetail
.
getNumber
()+
number
));
goblinShoppingCartVoDetail
.
setNumber
((
goblinShoppingCartVoDetail
.
getNumber
()+
number
));
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
}
}
...
@@ -955,6 +982,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -955,6 +982,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//不需要做
//不需要做
}
else
{
}
else
{
//创建商品放入到list
//创建商品放入到list
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
)){
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
cardId
=
goblinShoppingCartVoDetail
.
getCarId
();
list1
.
add
(
goblinShoppingCartVoDetail
);
list1
.
add
(
goblinShoppingCartVoDetail
);
...
@@ -967,8 +997,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -967,8 +997,11 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVo
.
setStoreId
(
storeId
);
goblinShoppingCartVo
.
setStoreId
(
storeId
);
//该商铺下的所有商品
//该商铺下的所有商品
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
ArrayList
<
GoblinShoppingCartVoDetail
>
list1
=
ObjectUtil
.
goblinShoppingCartVoDetailArrayList
();
if
(!
validateShoopCartNumber
(
skuId
,
type
,
number
,
userId
)){
return
ResponseDto
.
failure
(
"当前商品购买数量超过了限购数量"
);
}
//创建 购物车vo
//创建 购物车vo
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
1
);
GoblinShoppingCartVoDetail
goblinShoppingCartVoDetail
=
this
.
setValue
(
userId
,
storeId
,
spuId
,
skuId
,
number
);
list1
.
add
(
goblinShoppingCartVoDetail
);
list1
.
add
(
goblinShoppingCartVoDetail
);
goblinShoppingCartVo
.
setSkuList
(
list1
);
goblinShoppingCartVo
.
setSkuList
(
list1
);
list
.
add
(
goblinShoppingCartVo
);
list
.
add
(
goblinShoppingCartVo
);
...
@@ -980,7 +1013,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
...
@@ -980,7 +1013,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
insertShopCartMysql
(
cardId
,
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
insertShopCartMysql
(
cardId
,
spuId
,
storeId
,
skuId
,
number
,
userId
,
type
);
}
}
}
}
return
true
;
return
ResponseDto
.
success
(
true
)
;
}
}
/***
/***
* @author zhangfuxin
* @author zhangfuxin
...
...
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