Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-03-06 11:46:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e4d5f7bfed9bb308c2828eded04de89f401126ef
e4d5f7bf
1 parent
d5645b97
fix
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
View file @
e4d5f7b
...
...
@@ -539,9 +539,12 @@ public class OrderServiceRpcClient {
.
build
();
final
var
menuById
=
menuServiceRpcClient
.
getMenuById
(
createOrderDto
.
getEnterpriseId
(),
createOrderDto
.
getMenuId
());
OrderStatusEnum
orderStatus
=
OrderStatusEnum
.
TO_PREPARE
;
if
(
menuById
.
getResponse
().
getOrderRuleJson
().
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
&&
menuById
.
getResponse
().
getOrderRuleJson
().
getCloseTimeType
()
==
CloseTimeTypeEnum
.
IMMEDIATELY
)
{
if
(
createOrderDto
.
getOnlinePay
()
!=
OnlinePayEnum
.
ONLINE
)
{
var
orderRuleJson
=
menuById
.
getResponse
().
getOrderRuleJson
();
if
(
orderRuleJson
.
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
&&
orderRuleJson
.
getCloseTimeType
()
==
CloseTimeTypeEnum
.
IMMEDIATELY
)
{
orderStatus
=
OrderStatusEnum
.
PREPARING
;
}
}
final
var
creation
=
ClientCustomerOrderCreation
.
newBuilder
()
.
setShouldCreateCustomerId
(
createOrderDto
.
getShouldCreateCustomerId
())
.
setShouldCreateCustomerId
(
true
).
setCustomerId
(
createOrderDto
.
getCustomerId
())
...
...
@@ -553,7 +556,7 @@ public class OrderServiceRpcClient {
.
setShouldCreateRoomNo
(!
createOrderDto
.
getRoomNo
().
isEmpty
()).
setRoomNo
(
createOrderDto
.
getRoomNo
())
.
setShouldCreateTableCode
(
createOrderDto
.
getCloseTimeType
().
equals
(
CloseTimeType
.
IMMEDIATELY
)
||
StringUtils
.
isNotEmpty
(
createOrderDto
.
getTableCode
())).
setTableCode
(
createOrderDto
.
getTableCode
()
==
null
?
""
:
createOrderDto
.
getTableCode
())
.
setShouldCreateOnlinePay
(
true
).
setOnlinePay
(
createOrderDto
.
getOnlinePay
())
.
setShouldCreatePayStatus
(
true
).
setPayStatus
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
ONLINE
||
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
LEAVE_HOSPITAL
?
PayStatusEnum
.
TO_PAY
:
PayStatusEnum
.
SUCCEED
)
.
setShouldCreatePayStatus
(
true
).
setPayStatus
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
ONLINE
?
PayStatusEnum
.
TO_PAY
:
PayStatusEnum
.
SUCCEED
)
.
setMenuId
(
createOrderDto
.
getMenuId
())
.
setTotalNum
(
createOrderDto
.
getTotalNum
())
.
setShouldCreatePayPrice
(
createOrderDto
.
getOnlinePay
()
==
OnlinePayEnum
.
LEAVE_HOSPITAL
).
setPayPrice
(
createOrderDto
.
getPayPrice
())
...
...
@@ -571,13 +574,10 @@ public class OrderServiceRpcClient {
final
var
skuSellQuantities
=
this
.
querySkuSellQuantitiesByStallAndSkuIds
(
createOrderDto
.
getEnterpriseId
(),
createOrderDto
.
getStallId
(),
skuIds
);
final
var
skuSellQuantityMap
=
skuSellQuantities
.
stream
().
collect
(
Collectors
.
toMap
(
SingleSkuSellQuantityRpcResponse:
:
getSkuId
,
Function
.
identity
()));
final
var
skuMap
=
skuServiceRpcClient
.
getSkusByIds
(
skuIds
).
stream
().
collect
(
Collectors
.
toMap
(
SingleSkuResponse:
:
getId
,
Function
.
identity
()));
final
var
soldOutSkus
=
new
ArrayList
<
String
>();
final
var
skuStockMap
=
new
HashMap
<
String
,
Integer
>();
for
(
var
orderDetail
:
createOrderDto
.
getOrderDetailDtos
())
{
final
var
skuSellQuantityRpcResponse
=
skuSellQuantityMap
.
get
(
orderDetail
.
getSkuId
());
if
(
skuSellQuantityRpcResponse
==
null
)
{
log
.
error
(
"skuSellQuantityRpcResponse is null; stallId:{}, skuId:{}"
,
createOrderDto
.
getStallId
(),
orderDetail
.
getSkuId
());
soldOutSkus
.
add
(
skuMap
.
get
(
orderDetail
.
getSkuId
()).
getName
());
continue
;
}
if
((
skuSellQuantityRpcResponse
.
getTodaySellQuantity
()
+
orderDetail
.
getCount
())
>
skuSellQuantityRpcResponse
.
getMaxSellQuantity
())
{
...
...
@@ -585,9 +585,6 @@ public class OrderServiceRpcClient {
skuStockMap
.
put
(
skuMap
.
get
(
orderDetail
.
getSkuId
()).
getName
(),
skuSellQuantityRpcResponse
.
getMaxSellQuantity
()
-
skuSellQuantityRpcResponse
.
getTodaySellQuantity
());
}
}
if
(!
soldOutSkus
.
isEmpty
())
{
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
SKUS_SOLD_OUT_TODAY
,
String
.
join
(
","
,
soldOutSkus
));
}
if
(!
skuStockMap
.
isEmpty
())
{
final
var
noEnoughSkus
=
String
.
join
(
", "
,
skuStockMap
.
keySet
());
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
SKUS_STOCK_NO_ENOUGH_TODAY
,
noEnoughSkus
);
...
...
Please
register
or
login
to post a comment