Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
chenchao
6 years ago
Commit
59189f0bbccb773fe56cb72b253b34f28e1045ef
1 parent
be08e160
add judge num
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
11 deletions
order/src/main/java/com/yohoufo/order/controller/SellerOrderController.java
order/src/main/java/com/yohoufo/order/service/impl/SellerOrderService.java
order/src/main/java/com/yohoufo/order/service/proxy/UserProxyService.java
pom.xml
order/src/main/java/com/yohoufo/order/controller/SellerOrderController.java
View file @
59189f0
...
...
@@ -50,7 +50,8 @@ public class SellerOrderController {
@RequestParam
(
name
=
"storage_id"
,
required
=
true
)
int
storage_id
,
@RequestParam
(
name
=
"price"
,
required
=
true
)
String
price
,
@RequestParam
(
name
=
"num"
,
defaultValue
=
"1"
,
required
=
false
)
int
num
)
throws
GatewayException
{
SellerOrderComputeReq
req
=
SellerOrderComputeReq
.
builder
().
uid
(
uid
).
storageId
(
storage_id
).
price
(
price
).
build
();
SellerOrderComputeReq
req
=
SellerOrderComputeReq
.
builder
().
uid
(
uid
).
storageId
(
storage_id
).
price
(
price
)
.
num
(
num
).
build
();
logger
.
info
(
"in ufo.sellerOrder.computePublishPrd, req {}"
,
req
);
SoldPrdComputeBo
computeBo
=
sellerOrderService
.
computePublishPrd
(
req
);
return
new
ApiResponse
.
ApiResponseBuilder
().
code
(
200
).
data
(
computeBo
).
message
(
"算费成功"
).
build
();
...
...
order/src/main/java/com/yohoufo/order/service/impl/SellerOrderService.java
View file @
59189f0
...
...
@@ -12,6 +12,7 @@ import com.yohoufo.common.alarm.EventBusPublisher;
import
com.yohoufo.common.alarm.SmsAlarmEvent
;
import
com.yohoufo.common.exception.GatewayException
;
import
com.yohoufo.common.utils.AddressUtil
;
import
com.yohoufo.common.utils.BigDecimalHelper
;
import
com.yohoufo.common.utils.DateUtil
;
import
com.yohoufo.dal.order.*
;
import
com.yohoufo.dal.order.model.*
;
...
...
@@ -23,6 +24,8 @@ import com.yohoufo.order.event.OrderCancelEvent;
import
com.yohoufo.order.model.AddressInfo
;
import
com.yohobuy.ufo.model.order.bo.GoodsInfo
;
import
com.yohoufo.order.model.SellerOrderContext
;
import
com.yohoufo.order.model.dto.EarnestMoney
;
import
com.yohoufo.order.model.dto.PlatformFeeDto
;
import
com.yohoufo.order.model.dto.SellerOrderComputeResult
;
import
com.yohoufo.order.model.request.OrderListRequest
;
import
com.yohoufo.order.model.request.OrderRequest
;
...
...
@@ -110,13 +113,22 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
public
SoldPrdComputeBo
computePublishPrd
(
SellerOrderComputeReq
req
)
throws
GatewayException
{
log
.
info
(
"in computePublishPrd, req {}"
,
req
);
int
uid
=
req
.
getUid
();
if
(
uid
<=
0
){
log
.
warn
(
"in computePublishPrd uid illegal , req {}"
,
req
);
throw
new
GatewayException
(
400
,
"用户ID错误"
);
}
//
Integer
storageId
=
req
.
getStorageId
();
if
(
storageId
<=
0
){
log
.
warn
(
"in computePublishPrd storageId illegal , req {}"
,
req
);
throw
new
GatewayException
(
400
,
"storageId 错误"
);
}
int
num
;
if
((
num
=
req
.
getNum
())<=
0
){
log
.
warn
(
"in computePublishPrd num illegal , req {}"
,
req
);
throw
new
GatewayException
(
400
,
"非法数量值"
);
}
/*商品鉴定费 ¥10.00
商品包装费 ¥10.00
...
...
@@ -133,19 +145,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
throw
new
GatewayException
(
400
,
"价格须为以9结尾的正整数"
);
}
BigDecimal
prdPrice
=
null
;
try
{
prdPrice
=
new
BigDecimal
(
price
);
}
catch
(
Exception
e
){
log
.
warn
(
"in computePublishPrd price convert BigDecimal fail, {}"
,
req
);
return
null
;
throw
new
GatewayException
(
400
,
"非法数字"
)
;
}
checkPrice
(
storageId
,
prdPrice
,
false
);
return
buildSoldPrdComputeBo
(
prdPrice
);
return
buildSoldPrdComputeBo
(
uid
,
num
,
prdPrice
);
}
...
...
@@ -481,9 +489,28 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
private
boolean
isEnough
(
int
uid
,
BigDecimal
mEarestMoney
){
//todo 取出入驻商家的钱包余额,判断保证金总额是否足够扣减
return
false
;
}
p
ublic
SoldPrdComputeBo
buildSoldPrdComputeBo
(
BigDecimal
prdPrice
){
p
rivate
SoldPrdComputeBo
buildSoldPrdComputeBo
(
int
uid
,
int
num
,
BigDecimal
prdPrice
){
SellerOrderComputeResult
computeResult
=
computeHandler
.
compute
(
prdPrice
);
/**
* 验证是否是入驻商家
*/
boolean
isEntryShop
=
userProxyService
.
isEntryShop
(
uid
);
if
(
isEntryShop
){
BigDecimal
singleEarestMoney
=
computeResult
.
getEarnestMoney
().
getEarnestMoney
();
BigDecimal
mEarestMoney
=
BigDecimalHelper
.
halfUp
(
new
BigDecimal
(
num
).
multiply
(
singleEarestMoney
));
boolean
isEnough
=
isEnough
(
uid
,
mEarestMoney
);
if
(!
isEnough
){
throw
new
ServiceException
(
ServiceError
.
WALLET_EARNESTMONEY_IS_NOT_ENOUGH
);
}
}
SoldPrdComputeBo
computeBo
=
SellerOrderConvertor
.
computeResult2SoldPrdComputeBo
(
computeResult
);
return
computeBo
;
}
...
...
order/src/main/java/com/yohoufo/order/service/proxy/UserProxyService.java
View file @
59189f0
...
...
@@ -8,6 +8,7 @@ import com.yoho.error.ServiceError;
import
com.yoho.error.exception.ServiceException
;
import
com.yoho.service.model.request.UserAddressReqBO
;
import
com.yohoufo.common.ApiResponse
;
import
com.yohoufo.common.caller.UfoServiceCaller
;
import
com.yohoufo.order.convert.AddressInfoConvertor
;
import
com.yohoufo.order.model.AddressInfo
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -38,6 +39,9 @@ public class UserProxyService {
@Value
(
"${uic.url:http://uic.yohoops.org/uic}"
)
private
String
uicUrl
;
@Autowired
private
UfoServiceCaller
ufoServiceCaller
;
/**
* 获取用户信息
* @param uid
...
...
@@ -133,4 +137,20 @@ public class UserProxyService {
}
return
mobile
;
}
public
boolean
isEntryShop
(
int
uid
){
//入驻商户 method=ufo.user.isStoredSeller ,入参 uid
ApiResponse
userInfo
;
try
{
userInfo
=
ufoServiceCaller
.
call
(
"ufo.user.isStoredSeller"
,
uid
);
}
catch
(
Exception
ex
){
logger
.
warn
(
"in getMobile fail, uid {}"
,
uid
,
ex
);
throw
new
ServiceException
(
ServiceError
.
USER_IS_NOT_EXIST
);
}
logger
.
info
(
"judge user is entry shop, uid {} resp {}"
,
uid
,
userInfo
);
return
(
userInfo
==
null
||
userInfo
.
getData
()
==
null
)
?
false
:
(
boolean
)
userInfo
.
getData
();
}
}
...
...
pom.xml
View file @
59189f0
...
...
@@ -6,7 +6,7 @@
<parent>
<groupId>
com.yoho
</groupId>
<artifactId>
parent
</artifactId>
<version>
1.4.
7
-SNAPSHOT
</version>
<version>
1.4.
8
-SNAPSHOT
</version>
</parent>
<groupId>
com.yohoufo.fore
</groupId>
...
...
@@ -18,7 +18,7 @@
<properties>
<qiniu.version>
7.0.5
</qiniu.version>
<project-name>
yohoufo-fore
</project-name>
<model.version>
test-1
.0-SNAPSHOT
</model.version>
<model.version>
2
.0-SNAPSHOT
</model.version>
</properties>
<dependencyManagement>
...
...
Please
register
or
login
to post a comment