Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
23a591f7
Commit
23a591f7
authored
Jun 11, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加库存剩余件数提示
parent
c209442f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
shopping-cart-application-service/src/main/java/cn/freemud/interceptor/BizExceptionHandler.java
+6
-0
shopping-cart-application-service/src/main/java/cn/freemud/interceptor/BizServiceException.java
+49
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+9
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/interceptor/BizExceptionHandler.java
View file @
23a591f7
...
@@ -47,6 +47,12 @@ public class BizExceptionHandler {
...
@@ -47,6 +47,12 @@ public class BizExceptionHandler {
return
ResponseUtil
.
error
(
e
.
getResult
());
return
ResponseUtil
.
error
(
e
.
getResult
());
}
}
@ExceptionHandler
(
BizServiceException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BaseResponse
bindException
(
BizServiceException
e
)
{
return
ResponseUtil
.
error
(
e
.
getResult
().
getCode
(),
e
.
getMessage
());
}
@ExceptionHandler
(
ParameterException
.
class
)
@ExceptionHandler
(
ParameterException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BaseResponse
bindException
(
ParameterException
e
)
{
public
BaseResponse
bindException
(
ParameterException
e
)
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/interceptor/BizServiceException.java
0 → 100644
View file @
23a591f7
package
cn
.
freemud
.
interceptor
;
import
cn.freemud.enums.ResponseResult
;
import
com.freemud.application.sdk.api.exception.IgnoreErrorAnnotation
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.interceptor BizServiceException
* @Description: TDO 描述....
* @author: family
* @date: 2020/6/11
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@SuppressWarnings
(
"serial"
)
@IgnoreErrorAnnotation
public
class
BizServiceException
extends
RuntimeException
{
private
ResponseResult
result
;
private
String
message
;
public
BizServiceException
(
ResponseResult
result
)
{
this
.
result
=
result
;
this
.
message
=
result
.
getMessage
();
}
public
BizServiceException
(
ResponseResult
result
,
String
message
)
{
this
.
result
=
result
;
this
.
message
=
message
;
}
public
ResponseResult
getResult
()
{
return
result
;
}
public
void
setResult
(
ResponseResult
result
)
{
this
.
result
=
result
;
}
@Override
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
23a591f7
...
@@ -30,6 +30,7 @@ import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
...
@@ -30,6 +30,7 @@ import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.*
;
import
cn.freemud.enums.*
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.interceptor.BizServiceException
;
import
cn.freemud.service.*
;
import
cn.freemud.service.*
;
import
cn.freemud.service.thirdparty.*
;
import
cn.freemud.service.thirdparty.*
;
import
cn.freemud.utils.PromotionFactory
;
import
cn.freemud.utils.PromotionFactory
;
...
@@ -412,6 +413,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -412,6 +413,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
GetProductStockResponseDto
availableStocks
=
stockClient
.
getAvailableStocks
(
requestDto
);
GetProductStockResponseDto
availableStocks
=
stockClient
.
getAvailableStocks
(
requestDto
);
if
((
availableStocks
!=
null
)
&&
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
())))
{
if
((
availableStocks
!=
null
)
&&
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
())))
{
if
((
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
()))
||
(
qty
>
availableStocks
.
getResult
().
get
(
0
).
getQty
()))
{
if
((
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
()))
||
(
qty
>
availableStocks
.
getResult
().
get
(
0
).
getQty
()))
{
Integer
stock
=
0
;
if
((
stock
=
availableStocks
.
getResult
().
get
(
0
).
getQty
())
>
0
)
{
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件"
);
}
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
}
}
}
...
@@ -1210,6 +1215,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1210,6 +1215,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
availableStocks
!=
null
&&
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
())
&&
if
(
availableStocks
!=
null
&&
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
())
&&
(
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
())
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
==
null
(
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
())
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
==
null
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
<
qty
))
{
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
<
qty
))
{
Integer
stock
=
0
;
if
((
stock
=
availableStocks
.
getResult
().
get
(
0
).
getQty
())
>
0
)
{
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件"
);
}
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
}
}
}
...
...
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