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
wangyingyang
2024-12-04 14:48:53 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aaecf96fb6aca9f601fe9a68fe7d14ed5f249b31
aaecf96f
1 parent
9796a46b
fix
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
181 additions
and
4 deletions
.DS_Store
src/main/java/com/infoloop/tianting/model/dto/ClientCustomerDbDTO.java
src/main/java/com/infoloop/tianting/model/dto/KdsDTO.java
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceHttpClient.java
src/main/java/com/infoloop/tianting/service/client/InventoryServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
.DS_Store
View file @
aaecf96
No preview for this file type
src/main/java/com/infoloop/tianting/model/dto/ClientCustomerDbDTO.java
View file @
aaecf96
...
...
@@ -99,7 +99,7 @@ public class ClientCustomerDbDTO {
@Builder
@ApiModel
(
description
=
"TodayOrderDto"
)
public
static
class
NotOrderCustomerDto
{
private
Integer
id
;
private
String
id
;
private
String
roomNo
;
private
String
name
;
private
List
<
MenuDto
>
menuList
;
...
...
src/main/java/com/infoloop/tianting/model/dto/KdsDTO.java
View file @
aaecf96
...
...
@@ -2,6 +2,8 @@ package com.infoloop.tianting.model.dto;
import
com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.models.auth.In
;
...
...
@@ -25,12 +27,17 @@ public class KdsDTO {
private
Integer
orderDetailId
;
private
String
tableCode
;
private
Integer
count
;
private
Integer
price
;
private
String
roomNo
;
private
String
remark
;
private
CustomerNotice
customerNotice
;
private
String
adjustSkuRemark
;
private
String
mealTime
;
private
ServeStatusEnum
serveStatus
;
private
String
createdAt
;
private
ClientDto
client
;
private
ClientDto
stall
;
private
CustomerDetailDto
customer
;
}
@Data
...
...
@@ -44,6 +51,7 @@ public class KdsDTO {
private
String
showName
;
private
String
adjustSkuRemark
;
private
ServeStatusEnum
serveStatus
;
private
Integer
price
;
}
@Data
...
...
@@ -71,6 +79,13 @@ public class KdsDTO {
private
String
remark
;
private
String
mealTime
;
private
CustomerNotice
customerNotice
;
private
Integer
totalPrice
;
private
Integer
payPrice
;
private
String
createdAt
;
private
String
orderCode
;
private
ClientDto
stall
;
private
ClientDto
client
;
private
CustomerDetailDto
customer
;
private
List
<
KdsOrderLocationDetailDto
>
orderDetailList
;
}
...
...
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceHttpClient.java
View file @
aaecf96
...
...
@@ -26,7 +26,7 @@ public class ClientCustomerServiceHttpClient {
try
{
String
url
=
""
;
if
(
isHis
)
{
url
=
"https://nutri2.infoscm.cn/v3/his
Client
customers/current/query"
;
url
=
"https://nutri2.infoscm.cn/v3/hiscustomers/current/query"
;
}
else
{
url
=
"https://nutri2.infoscm.cn/v3/clientcustomers/current/query"
;
}
...
...
@@ -46,7 +46,7 @@ public class ClientCustomerServiceHttpClient {
return
objectMapper
.
readValue
(
jsonData
,
CurrentClientCustomerListDto
.
class
).
getRows
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"error"
+
e
.
getMessage
());
throw
new
IllegalArgumentException
(
"获取
用户openid
失败"
);
throw
new
IllegalArgumentException
(
"获取
当日在住客户
失败"
);
}
}
}
\ No newline at end of file
...
...
src/main/java/com/infoloop/tianting/service/client/InventoryServiceRpcClient.java
View file @
aaecf96
...
...
@@ -2,12 +2,17 @@ package com.infoloop.tianting.service.client;
import
com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcRequest
;
import
com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcRequest
;
import
com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcRequest
;
import
com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcRequest
;
import
com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcRequest
;
import
com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse
;
import
com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -28,6 +33,24 @@ public class InventoryServiceRpcClient {
}
public
GetClientsByIdsRpcResponse
getClientsByIds
(
Integer
enterpriseId
,
List
<
Integer
>
clientIds
)
{
final
var
request
=
GetClientsByIdsRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
enterpriseId
)
.
addAllIds
(
clientIds
)
.
setIncludeDeleted
(
false
)
.
build
();
return
inventoryServiceRpcBlockingStub
.
getClientsByIds
(
request
);
}
public
GetStallsByIdsRpcResponse
getStallsByIds
(
Integer
enterpriseId
,
List
<
Integer
>
stallIds
)
{
final
var
request
=
GetStallsByIdsRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
enterpriseId
)
.
addAllIds
(
stallIds
)
.
setIncludeDeleted
(
false
)
.
build
();
return
inventoryServiceRpcBlockingStub
.
getStallsByIds
(
request
);
}
public
GetStallsByClientIdRpcResponse
getStallsByClientId
(
Integer
enterpriseId
,
Integer
clientId
)
{
final
var
request
=
GetStallsByClientIdRpcRequest
.
newBuilder
()
.
setEnterpriseId
(
enterpriseId
)
...
...
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
View file @
aaecf96
...
...
@@ -285,12 +285,19 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
public
TodayOrderDto
getTodayOrderStatistic
(
String
token
,
boolean
isHis
)
{
List
<
CurrentClientCustomerDto
>
currentCustomers
=
new
ArrayList
<>();
List
<
Integer
>
customerIds
=
new
ArrayList
<>();
// 没有找到clientCustomer的hisCustomerIds
List
<
CurrentClientCustomerDto
>
notOrderedHisCustomers
=
new
ArrayList
<>();
if
(
isHis
){
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
true
);
final
var
hisCustomerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
currentClientCustomers
=
clientCustomerServiceRpcClient
.
getClientCustomersByHISCustomerIds
(
hisCustomerIds
).
getResponsesList
();
customerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
final
var
mappingHisCustomerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getHISCustomerId
).
collect
(
Collectors
.
toList
());
// final var notOrderedHisCustomerIds = hisCustomerIds.stream().filter(i -> !mappingHisCustomerIds.contains(i)).collect(Collectors.toList());
notOrderedHisCustomers
=
currentCustomers
.
stream
().
filter
(
c
->
!
mappingHisCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
}
else
{
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
false
);
customerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
map
(
id
->
{
try
{
...
...
@@ -386,13 +393,25 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
.
publishAt
(
DateUtil
.
formatDate
(
menu
.
getPublishAt
()))
.
build
()).
collect
(
Collectors
.
toList
());
final
var
resNotOrderCustomer
=
NotOrderCustomerDto
.
builder
()
.
id
(
notOrderCustomerId
)
.
id
(
notOrderCustomerId
.
toString
()
)
.
name
(
notOrderCustomer
.
getName
())
.
roomNo
(
notOrderCustomer
.
getRoomNo
())
.
menuList
(
curMenuDtos
)
.
build
();
resNotOrderCustomers
.
add
(
resNotOrderCustomer
);
}
if
(
isHis
)
{
for
(
CurrentClientCustomerDto
currentClientCustomer:
notOrderedHisCustomers
)
{
final
var
resNotOrderCustomer
=
NotOrderCustomerDto
.
builder
()
.
id
(
currentClientCustomer
.
getId
())
.
name
(
currentClientCustomer
.
getName
())
.
roomNo
(
currentClientCustomer
.
getRoomNo
())
.
menuList
(
new
ArrayList
<>())
.
build
();
resNotOrderCustomers
.
add
(
resNotOrderCustomer
);
}
}
return
TodayOrderDto
.
builder
()
.
totalCurrentCustomerCount
(
currentCustomers
.
size
())
...
...
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
View file @
aaecf96
...
...
@@ -4,6 +4,7 @@ import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto
;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto
;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto
;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto
;
...
...
@@ -11,11 +12,14 @@ import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationQueryDto;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDetailDto
;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto
;
import
com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuQueryDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto
;
import
com.infoloop.tianting.service.KdsService
;
import
com.infoloop.tianting.service.MealService
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient
;
import
com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient
;
import
com.infoloop.tianting.service.client.InventoryServiceRpcClient
;
import
com.infoloop.tianting.service.client.MealServiceRpcClient
;
import
com.infoloop.tianting.service.client.MenuServiceRpcClient
;
import
com.infoloop.tianting.service.client.OrderServiceRpcClient
;
...
...
@@ -27,10 +31,12 @@ import java.time.LocalDateTime;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
javax.xml.bind.annotation.adapters.CollapsedStringAdapter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.integration.IntegrationProperties.RSocket.Client
;
import
org.springframework.stereotype.Service
;
@Slf4j
...
...
@@ -43,6 +49,8 @@ public class KdsServiceImpl implements KdsService {
private
final
WOperatorServiceRpcClient
wOperatorServiceRpcClient
;
private
final
MealServiceRpcClient
mealServiceRpcClient
;
private
final
SkuServiceRpcClient
skuServiceRpcClient
;
private
final
InventoryServiceRpcClient
inventoryServiceRpcClient
;
private
final
ClientCustomerServiceRpcClient
clientCustomerServiceRpcClient
;
@Override
public
List
<
KdsOrderSkuDto
>
getOrderDetailBySku
(
KdsOrderSkuQueryDto
queryDto
)
{
...
...
@@ -79,6 +87,24 @@ public class KdsServiceImpl implements KdsService {
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
clientIds
=
orderList
.
stream
()
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getClientId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
clients
=
inventoryServiceRpcClient
.
getClientsByIds
(
operator
.
getEnterpriseId
(),
clientIds
);
final
var
orderStallIds
=
orderList
.
stream
()
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getStallId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
stalls
=
inventoryServiceRpcClient
.
getStallsByIds
(
operator
.
getEnterpriseId
(),
orderStallIds
);
final
var
customerIds
=
orderList
.
stream
().
map
(
SingleClientCustomerOrderRpcResponse:
:
getCustomerId
).
collect
(
Collectors
.
toList
());
final
var
customerResponse
=
clientCustomerServiceRpcClient
.
getClientCustomersByIds
(
queryOrderDto
.
getEnterpriseId
(),
customerIds
);
final
var
orderDetailList
=
orderServiceRpcClient
.
getOrderDetailsByOrderIds
(
orderIds
);
final
var
filteredOrderDetailList
=
orderDetailList
.
stream
()
.
filter
(
od
->
od
.
getServeStatus
()
==
queryDto
.
getServeStatus
()
&&
od
.
getMealId
()
==
queryDto
.
getMealId
())
...
...
@@ -113,6 +139,35 @@ public class KdsServiceImpl implements KdsService {
if
(
order
.
isEmpty
())
{
continue
;
}
final
var
optionalClient
=
clients
.
getClientsList
().
stream
().
filter
(
c
->
c
.
getId
()
==
order
.
get
().
getClientId
()).
findFirst
();
ClientDto
client
=
ClientDto
.
builder
().
build
();
if
(
optionalClient
.
isPresent
())
{
client
=
ClientDto
.
builder
()
.
id
(
optionalClient
.
get
().
getId
())
.
name
(
optionalClient
.
get
().
getName
())
.
build
();
}
final
var
optionalStall
=
stalls
.
getClientsList
().
stream
().
filter
(
s
->
s
.
getId
()
==
order
.
get
().
getStallId
()).
findFirst
();
ClientDto
stall
=
ClientDto
.
builder
().
build
();
if
(
optionalStall
.
isPresent
())
{
stall
=
ClientDto
.
builder
()
.
id
(
optionalStall
.
get
().
getId
())
.
name
(
optionalStall
.
get
().
getName
())
.
build
();
}
final
var
optionalCustomer
=
customerResponse
.
getResponsesList
().
stream
()
.
filter
(
c
->
c
.
getId
()
==
order
.
get
().
getCustomerId
())
.
findFirst
();
CustomerDetailDto
customer
=
CustomerDetailDto
.
builder
().
build
();
if
(
optionalCustomer
.
isPresent
())
{
customer
=
CustomerDetailDto
.
builder
()
.
id
(
optionalCustomer
.
get
().
getId
())
.
phone
(
optionalCustomer
.
get
().
getMobile
())
.
name
(
optionalCustomer
.
get
().
getName
())
.
build
();
}
final
var
kdsOrder
=
KdsOrderSkuDetailDto
.
builder
()
.
count
(
detail
.
getCount
())
.
orderDetailId
(
detail
.
getId
())
...
...
@@ -126,7 +181,12 @@ public class KdsServiceImpl implements KdsService {
.
build
())
.
adjustSkuRemark
(
detail
.
getAdjustSkuRemark
())
.
mealTime
(
DateUtil
.
formatDate
(
order
.
get
().
getMealTime
()))
.
createdAt
(
DateUtil
.
formatDate
(
order
.
get
().
getCreatedAt
()))
.
client
(
client
)
.
stall
(
stall
)
.
customer
(
customer
)
.
serveStatus
(
detail
.
getServeStatus
())
.
price
(
detail
.
getPrice
())
.
build
();
kdsOrders
.
add
(
kdsOrder
);
}
...
...
@@ -261,6 +321,24 @@ public class KdsServiceImpl implements KdsService {
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
clientIds
=
orderList
.
stream
()
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getClientId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
clients
=
inventoryServiceRpcClient
.
getClientsByIds
(
operator
.
getEnterpriseId
(),
clientIds
);
final
var
orderStallIds
=
orderList
.
stream
()
.
map
(
SingleClientCustomerOrderRpcResponse:
:
getStallId
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
final
var
stalls
=
inventoryServiceRpcClient
.
getStallsByIds
(
operator
.
getEnterpriseId
(),
orderStallIds
);
final
var
customerIds
=
orderList
.
stream
().
map
(
SingleClientCustomerOrderRpcResponse:
:
getCustomerId
).
collect
(
Collectors
.
toList
());
final
var
customerResponse
=
clientCustomerServiceRpcClient
.
getClientCustomersByIds
(
queryOrderDto
.
getEnterpriseId
(),
customerIds
);
final
var
orderDetailList
=
orderServiceRpcClient
.
getOrderDetailsByOrderIds
(
orderIds
);
final
var
filteredOrderDetailList
=
orderDetailList
.
stream
()
.
filter
(
od
->
od
.
getMealId
()
==
queryDto
.
getMealId
())
...
...
@@ -285,8 +363,43 @@ public class KdsServiceImpl implements KdsService {
.
orderDetailId
(
od
.
getId
())
.
serveStatus
(
od
.
getServeStatus
())
.
showName
(
od
.
getShowName
())
.
price
(
od
.
getPrice
())
.
build
()
).
collect
(
Collectors
.
toList
());
final
var
detailPriceList
=
curOrderDetails
.
stream
()
.
map
(
d
->
d
.
getPrice
()
*
d
.
getCount
())
.
collect
(
Collectors
.
toList
());
final
var
totalPrice
=
detailPriceList
.
stream
().
mapToInt
(
integer
->
integer
).
sum
();
final
var
optionalClient
=
clients
.
getClientsList
().
stream
().
filter
(
c
->
c
.
getId
()
==
order
.
getClientId
()).
findFirst
();
ClientDto
client
=
ClientDto
.
builder
().
build
();
if
(
optionalClient
.
isPresent
())
{
client
=
ClientDto
.
builder
()
.
id
(
optionalClient
.
get
().
getId
())
.
name
(
optionalClient
.
get
().
getName
())
.
build
();
}
final
var
optionalStall
=
stalls
.
getClientsList
().
stream
().
filter
(
s
->
s
.
getId
()
==
order
.
getStallId
()).
findFirst
();
ClientDto
stall
=
ClientDto
.
builder
().
build
();
if
(
optionalStall
.
isPresent
())
{
stall
=
ClientDto
.
builder
()
.
id
(
optionalStall
.
get
().
getId
())
.
name
(
optionalStall
.
get
().
getName
())
.
build
();
}
final
var
optionalCustomer
=
customerResponse
.
getResponsesList
().
stream
()
.
filter
(
c
->
c
.
getId
()
==
order
.
getCustomerId
())
.
findFirst
();
CustomerDetailDto
customer
=
CustomerDetailDto
.
builder
().
build
();
if
(
optionalCustomer
.
isPresent
())
{
customer
=
CustomerDetailDto
.
builder
()
.
id
(
optionalCustomer
.
get
().
getId
())
.
phone
(
optionalCustomer
.
get
().
getMobile
())
.
name
(
optionalCustomer
.
get
().
getName
())
.
build
();
}
final
var
kdsOrder
=
KdsOrderLocationDto
.
builder
()
.
totalCount
(
order
.
getTotalNum
())
.
remark
(
order
.
getRemark
())
...
...
@@ -299,6 +412,13 @@ public class KdsServiceImpl implements KdsService {
.
build
())
.
orderDetailList
(
kdsOrderDetails
)
.
mealTime
(
DateUtil
.
formatDate
(
order
.
getMealTime
()))
.
orderCode
(
order
.
getOrderCode
())
.
payPrice
(
order
.
getPayPrice
())
.
totalPrice
(
totalPrice
)
.
createdAt
(
DateUtil
.
formatDate
(
order
.
getCreatedAt
()))
.
client
(
client
)
.
stall
(
stall
)
.
customer
(
customer
)
.
build
();
kdsOrderLocationList
.
add
(
kdsOrder
);
}
...
...
Please
register
or
login
to post a comment