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-10-29 18:44:12 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
32dce8b49037aa762c6fe58c3426921164db9d2b
32dce8b4
2 parents
2f8b7a62
58606037
Merge branch 'feature/2025-10-23' into 'master'
Feature/2025 10 23 See merge request
!12
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
54 deletions
src/main/java/com/infoloop/tianting/exception/ClientEndExceptions.java
src/main/java/com/infoloop/tianting/exception/ErrorCodeEnum.java
src/main/java/com/infoloop/tianting/model/dto/OrderDbDTO.java
src/main/java/com/infoloop/tianting/model/dto/SettlementDTO.java
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/SettlementServiceImpl.java
src/main/java/com/infoloop/tianting/exception/ClientEndExceptions.java
View file @
32dce8b
...
...
@@ -21,6 +21,10 @@ public class ClientEndExceptions {
* 权限登陆未认证异常
*/
public
static
class
AuthenticationFailure
extends
ClientEndException
{
private
AuthenticationFailure
(
ErrorCodeEnum
errorCodeEnum
)
{
super
(
errorCodeEnum
.
getCode
(),
errorCodeEnum
.
getMessage
());
}
private
AuthenticationFailure
(
String
message
)
{
super
(
ErrorCodeEnum
.
UNAUTHORIZED
.
getCode
(),
message
);
}
...
...
@@ -28,6 +32,10 @@ public class ClientEndExceptions {
public
synchronized
static
AuthenticationFailure
build
(
String
message
)
{
return
new
AuthenticationFailure
(
message
);
}
public
synchronized
static
AuthenticationFailure
build
(
ErrorCodeEnum
errorCodeEnum
)
{
return
new
AuthenticationFailure
(
errorCodeEnum
);
}
}
/**
...
...
src/main/java/com/infoloop/tianting/exception/ErrorCodeEnum.java
View file @
32dce8b
...
...
@@ -66,7 +66,9 @@ public enum ErrorCodeEnum implements BaseEnum {
MP_ACCOUNT_ALREADY_DISABLED
(
406000024
,
"账号已禁用"
),
DINER_MEAL_SUSPENDED
(
406000025
,
"当前就餐人处于停餐状态"
)
DINER_MEAL_SUSPENDED
(
406000025
,
"当前就餐人处于停餐状态"
),
ACCOUNT_OR_PASSWORD_IS_INCORRECT
(
406000026
,
"账号或密码错误"
)
;
...
...
src/main/java/com/infoloop/tianting/model/dto/OrderDbDTO.java
View file @
32dce8b
...
...
@@ -71,6 +71,7 @@ public class OrderDbDTO {
private
OrderStatusEnum
status
;
private
String
keyword
;
private
List
<
Integer
>
stallIds
;
private
String
mealTime
;
}
@Data
...
...
src/main/java/com/infoloop/tianting/model/dto/SettlementDTO.java
View file @
32dce8b
...
...
@@ -117,6 +117,7 @@ public class SettlementDTO {
private
String
skuName
;
private
Integer
count
;
private
String
avoids
;
private
String
doctors
;
private
String
remark
;
}
...
...
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
View file @
32dce8b
...
...
@@ -91,6 +91,7 @@ import java.io.IOException;
import
java.time.Duration
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalTime
;
import
java.time.ZoneOffset
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -494,24 +495,32 @@ public class OrderServiceRpcClient {
.
setStatus
(
queryOrderDto
.
getStatus
())
.
setEnterpriseId
(
queryOrderDto
.
getEnterpriseId
())
.
setShouldFilterClientIds
(
true
).
addClientIds
(
queryOrderDto
.
getClientId
())
.
setShouldFilterStallIds
(
true
).
addAllStallIds
(
queryOrderDto
.
getStallIds
())
.
build
();
return
orderServiceRpcBlockingStub
.
queryClientCustomerOrdersByCondition
(
request
);
.
setShouldFilterStallIds
(
true
).
addAllStallIds
(
queryOrderDto
.
getStallIds
());
if
(
StringUtils
.
isNotEmpty
(
queryOrderDto
.
getMealTime
()))
{
LocalDate
today
=
LocalDate
.
parse
(
queryOrderDto
.
getMealTime
(),
DateUtil
.
YYYY_MM_DD
);
LocalDateTime
todayZero
=
today
.
atStartOfDay
();
LocalDateTime
todayEnd
=
today
.
atTime
(
LocalTime
.
MAX
);
request
.
setShouldFilterMealTimeStart
(
true
)
.
setMealTimeStart
(
todayZero
.
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
())
.
setShouldFilterMealTimeEnd
(
true
)
.
setMealTimeEnd
(
todayEnd
.
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
());
}
return
orderServiceRpcBlockingStub
.
queryClientCustomerOrdersByCondition
(
request
.
build
());
}
public
QueryClientCustomerOrdersByPaginationRpcResponse
queryRefundClientCustomerOrdersByPagination
(
QueryRefundOrderByPaginationDto
queryOrderDto
)
{
QueryRefundOrderByPaginationDto
queryOrderDto
)
{
final
var
request
=
QueryClientCustomerOrdersByPaginationRpcRequest
.
newBuilder
()
.
setKeyword
(
queryOrderDto
.
getKeyword
()
==
null
?
""
:
queryOrderDto
.
getKeyword
())
.
setPageNo
(
queryOrderDto
.
getPn
())
.
setPageSize
(
queryOrderDto
.
getPz
())
.
setShouldFilterStatus
(
false
)
.
setShouldFilterPayStatus
(
true
)
.
setPayStatus
(
PayStatusEnum
.
REFUND
)
.
setEnterpriseId
(
queryOrderDto
.
getEnterpriseId
())
.
setClientId
(
queryOrderDto
.
getClientId
())
.
addAllStallIds
(
queryOrderDto
.
getStallIds
())
.
build
();
.
setKeyword
(
queryOrderDto
.
getKeyword
()
==
null
?
""
:
queryOrderDto
.
getKeyword
())
.
setPageNo
(
queryOrderDto
.
getPn
())
.
setPageSize
(
queryOrderDto
.
getPz
())
.
setShouldFilterStatus
(
false
)
.
setShouldFilterPayStatus
(
true
)
.
setPayStatus
(
PayStatusEnum
.
REFUND
)
.
setEnterpriseId
(
queryOrderDto
.
getEnterpriseId
())
.
setClientId
(
queryOrderDto
.
getClientId
())
.
addAllStallIds
(
queryOrderDto
.
getStallIds
())
.
build
();
return
orderServiceRpcBlockingStub
.
queryClientCustomerOrdersByPagination
(
request
);
}
...
...
@@ -646,11 +655,11 @@ public class OrderServiceRpcClient {
}
}
final
var
orderResponse
=
orderServiceRpcBlockingStub
.
createClientCustomerOrder
(
CreateClientCustomerOrderRpcRequest
.
newBuilder
()
.
setCreation
(
creation
)
.
setCreationSource
(
OrderSourceEnum
.
forNumber
(
createOrderDto
.
getCreationSource
()))
.
setEnterpriseId
(
createOrderDto
.
getEnterpriseId
())
.
setCreatedBy
(
createOrderDto
.
getCreatedBy
())
.
build
());
.
setCreation
(
creation
)
.
setCreationSource
(
OrderSourceEnum
.
forNumber
(
createOrderDto
.
getCreationSource
()))
.
setEnterpriseId
(
createOrderDto
.
getEnterpriseId
())
.
setCreatedBy
(
createOrderDto
.
getCreatedBy
())
.
build
());
if
(
orderResponse
.
getIsCreated
())
{
// 用餐时间为当天,并且非在线支付餐单,发送消息给客户端
if
(
createOrderDto
.
getMealTime
().
toLocalDate
().
equals
(
LocalDate
.
now
())
&&
menuById
.
getResponse
().
getOrderRuleJson
().
getModeOfPayment
()
!=
ModeOfPaymentEnum
.
ONLINE
)
{
...
...
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
View file @
32dce8b
...
...
@@ -314,9 +314,12 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
@Override
public
TodayOrderDto
getTodayOrderStatisticForHis
(
String
token
)
{
final
var
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
true
);
log
.
info
(
"currentCustomers size:{}"
,
currentCustomers
.
size
());
final
var
hisCustomerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
log
.
info
(
"hisCustomerIds size:{} {}"
,
hisCustomerIds
.
size
(),
hisCustomerIds
);
final
var
currentClientCustomers
=
clientCustomerServiceRpcClient
.
getClientCustomersByHISCustomerIds
(
hisCustomerIds
).
getResponsesList
();
final
var
customerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getId
).
distinct
().
collect
(
Collectors
.
toList
());
log
.
info
(
"customerIds size:{} {}"
,
customerIds
.
size
(),
customerIds
);
final
var
mappingHisCustomerIds
=
currentClientCustomers
.
stream
().
map
(
SingleClientCustomerRpcResponse:
:
getHISCustomerId
).
collect
(
Collectors
.
toList
());
final
var
notOrderedHisCustomers
=
currentCustomers
.
stream
().
filter
(
c
->
!
mappingHisCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
...
...
@@ -339,6 +342,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
}
List
<
Integer
>
uniqueOrderedCustomerIds
=
orderedResponseList
.
stream
().
map
(
SingleClientCustomerOrderRpcResponse:
:
getCustomerId
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
Integer
>
notOrderedCustomerIds
=
customerIds
.
stream
().
filter
(
id
->
!
uniqueOrderedCustomerIds
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
log
.
info
(
"notOrderedCustomerIds size:{} {}"
,
notOrderedCustomerIds
.
size
(),
notOrderedCustomerIds
);
// 根据customerIds 获取到menuRef列表
final
var
menuRefs
=
menuServiceRpcClient
.
getClientCustomerMenuRefsByCustomerIds
(
operatorLoginInfo
.
getEnterpriseId
(),
notOrderedCustomerIds
).
getResponsesList
();
final
var
menuIds
=
menuRefs
.
stream
().
map
(
SingleClientCustomerMenuRefRpcResponse:
:
getMenuId
).
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
View file @
32dce8b
...
...
@@ -135,13 +135,13 @@ public class LoginServiceImpl implements LoginService {
}
else
if
(
loginDto
.
isShouldLoginWithOperatorPhone
())
{
final
var
operator
=
operatorServiceRpcClient
.
getCOperatorByMobileOrEmail
(
loginDto
.
getOperatorPhone
());
if
(
operator
.
getId
()
==
0
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
UNAUTHORIZED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
if
(!
operator
.
getPassword
().
equals
(
sha1Hash
(
loginDto
.
getPassword
())))
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
if
(
operator
.
getStatus
()
!=
1
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
StpUtil
.
login
(
operator
.
getId
(),
SaLoginModel
.
create
()
.
setExtra
(
CommonConstants
.
ENTERPRISE_ID
,
operator
.
getEnterpriseId
())
...
...
@@ -151,13 +151,13 @@ public class LoginServiceImpl implements LoginService {
}
else
{
final
var
operator
=
wOperatorServiceRpcClient
.
getWOperatorByEmail
(
loginDto
.
getEmail
()).
getResponse
();
if
(
operator
.
getId
()
==
0
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
UNAUTHORIZED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
if
(!
operator
.
getPassword
().
equals
(
sha1Hash
(
loginDto
.
getPassword
())))
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
if
(
operator
.
getStatus
()
!=
WOperatorStatus
.
SHOW
)
{
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
()
);
throw
ClientEndExceptions
.
AuthenticationFailure
.
build
(
ErrorCodeEnum
.
ACCOUNT_OR_PASSWORD_IS_INCORRECT
);
}
StpUtil
.
login
(
operator
.
getId
(),
SaLoginModel
.
create
()
.
setExtra
(
CommonConstants
.
ENTERPRISE_ID
,
operator
.
getEnterpriseId
())
...
...
src/main/java/com/infoloop/tianting/service/impl/SettlementServiceImpl.java
View file @
32dce8b
...
...
@@ -63,7 +63,6 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.temporal.ChronoUnit
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -1139,21 +1138,8 @@ public class SettlementServiceImpl implements SettlementService {
// 查询订单列表
final
var
queryClientCustomerOrdersByConditionRpcResponse
=
orderServiceRpcClient
.
queryClientCustomerOrdersByCondition
(
queryOrderDto
);
// 今天开始时间的时间戳(毫秒)
final
long
todayStartTimestamp
=
LocalDate
.
now
().
atStartOfDay
()
.
atZone
(
ZoneId
.
systemDefault
())
.
toInstant
()
.
toEpochMilli
();
final
var
orderList
=
queryClientCustomerOrdersByConditionRpcResponse
.
getResponsesList
()
.
stream
()
.
filter
(
e
->
{
boolean
payStatusMatch
=
e
.
getPayStatus
()
==
PayStatusEnum
.
SUCCEED
||
e
.
getPayStatus
()
==
PayStatusEnum
.
PAY_CANCELED
;
// 过滤时间:只查询今天和以后的订单
boolean
timeMatch
=
e
.
getMealTime
()
>=
todayStartTimestamp
;
return
payStatusMatch
&&
timeMatch
;
})
.
toList
();
final
var
orderList
=
queryClientCustomerOrdersByConditionRpcResponse
.
getResponsesList
();
if
(
orderList
.
isEmpty
())
{
log
.
warn
(
"未查询到订单数据,enterpriseId: {}"
,
enterpriseId
);
return
createEmptyExcelBySeparateMeal
();
...
...
@@ -1272,6 +1258,10 @@ public class SettlementServiceImpl implements SettlementService {
List
<
String
>
avoidsList
=
getAvoidsSafely
(
order
);
String
avoidsStr
=
String
.
join
(
", "
,
avoidsList
);
// 安全获取医生信息(列表转字符串)
List
<
String
>
doctorsList
=
getDoctorsSafely
(
order
);
String
doctorsStr
=
String
.
join
(
", "
,
doctorsList
);
String
remark
=
order
.
getRemark
();
String
avoidRemark
=
order
.
getAvoidRemark
();
String
combinedRemark
=
""
;
...
...
@@ -1293,6 +1283,7 @@ public class SettlementServiceImpl implements SettlementService {
.
skuName
(
skuName
)
.
count
(
orderDetail
.
getCount
()
!=
0
?
orderDetail
.
getCount
()
:
0
)
.
avoids
(
avoidsStr
)
.
doctors
(
doctorsStr
)
.
remark
(
combinedRemark
)
.
build
();
mealDetails
.
add
(
mealDetail
);
...
...
@@ -1369,7 +1360,7 @@ public class SettlementServiceImpl implements SettlementService {
mainTitleCell
.
setCellStyle
(
titleStyle
);
// 合并第一行的8列
CellRangeAddress
titleRegion
=
new
CellRangeAddress
(
0
,
0
,
0
,
7
);
CellRangeAddress
titleRegion
=
new
CellRangeAddress
(
0
,
0
,
0
,
8
);
sheet
.
addMergedRegion
(
titleRegion
);
// 为合并区域设置边框
...
...
@@ -1399,25 +1390,29 @@ public class SettlementServiceImpl implements SettlementService {
cell2
.
setCellStyle
(
headerStyle
);
Cell
cell3
=
titleRow
.
createCell
(
columnNum
++);
cell3
.
setCellValue
(
"
餐单名称
"
);
cell3
.
setCellValue
(
"
医嘱信息
"
);
cell3
.
setCellStyle
(
headerStyle
);
Cell
cell4
=
titleRow
.
createCell
(
columnNum
++);
cell4
.
setCellValue
(
"
菜品
名称"
);
cell4
.
setCellValue
(
"
餐单
名称"
);
cell4
.
setCellStyle
(
headerStyle
);
Cell
cell5
=
titleRow
.
createCell
(
columnNum
++);
cell5
.
setCellValue
(
"菜品
数量
"
);
cell5
.
setCellValue
(
"菜品
名称
"
);
cell5
.
setCellStyle
(
headerStyle
);
Cell
cell6
=
titleRow
.
createCell
(
columnNum
++);
cell6
.
setCellValue
(
"
忌口信息
"
);
cell6
.
setCellValue
(
"
菜品数量
"
);
cell6
.
setCellStyle
(
headerStyle
);
Cell
cell7
=
titleRow
.
createCell
(
columnNum
++);
cell7
.
setCellValue
(
"
备注
"
);
cell7
.
setCellValue
(
"
忌口信息
"
);
cell7
.
setCellStyle
(
headerStyle
);
Cell
cell8
=
titleRow
.
createCell
(
columnNum
++);
cell8
.
setCellValue
(
"备注"
);
cell8
.
setCellStyle
(
headerStyle
);
// 填充数据
final
var
mealDetails
=
separateMealDataDto
.
getMealDetails
();
if
(
mealDetails
!=
null
)
{
...
...
@@ -1438,29 +1433,33 @@ public class SettlementServiceImpl implements SettlementService {
dataCell2
.
setCellStyle
(
dataStyle
);
Cell
dataCell3
=
dataRow
.
createCell
(
columnNum
++);
dataCell3
.
setCellValue
(
mealDetail
.
get
MenuName
()
!=
null
?
mealDetail
.
getMenuName
()
:
""
);
dataCell3
.
setCellValue
(
mealDetail
.
get
Doctors
()
!=
null
?
mealDetail
.
getDoctors
()
:
""
);
dataCell3
.
setCellStyle
(
dataStyle
);
Cell
dataCell4
=
dataRow
.
createCell
(
columnNum
++);
dataCell4
.
setCellValue
(
mealDetail
.
get
SkuName
()
!=
null
?
mealDetail
.
getSk
uName
()
:
""
);
dataCell4
.
setCellValue
(
mealDetail
.
get
MenuName
()
!=
null
?
mealDetail
.
getMen
uName
()
:
""
);
dataCell4
.
setCellStyle
(
dataStyle
);
Cell
dataCell5
=
dataRow
.
createCell
(
columnNum
++);
dataCell5
.
setCellValue
(
mealDetail
.
get
Count
()
!=
null
?
mealDetail
.
getCount
()
:
0
);
dataCell5
.
setCellValue
(
mealDetail
.
get
SkuName
()
!=
null
?
mealDetail
.
getSkuName
()
:
""
);
dataCell5
.
setCellStyle
(
dataStyle
);
Cell
dataCell6
=
dataRow
.
createCell
(
columnNum
++);
dataCell6
.
setCellValue
(
mealDetail
.
get
Avoids
()
!=
null
?
mealDetail
.
getAvoids
()
:
""
);
dataCell6
.
setCellValue
(
mealDetail
.
get
Count
()
!=
null
?
mealDetail
.
getCount
()
:
0
);
dataCell6
.
setCellStyle
(
dataStyle
);
Cell
dataCell7
=
dataRow
.
createCell
(
columnNum
++);
dataCell7
.
setCellValue
(
mealDetail
.
get
Remark
()
!=
null
?
mealDetail
.
getRemark
()
:
""
);
dataCell7
.
setCellValue
(
mealDetail
.
get
Avoids
()
!=
null
?
mealDetail
.
getAvoids
()
:
""
);
dataCell7
.
setCellStyle
(
dataStyle
);
Cell
dataCell8
=
dataRow
.
createCell
(
columnNum
++);
dataCell8
.
setCellValue
(
mealDetail
.
getRemark
()
!=
null
?
mealDetail
.
getRemark
()
:
""
);
dataCell8
.
setCellStyle
(
dataStyle
);
}
}
// 自动调整列宽
for
(
int
i
=
0
;
i
<
8
;
i
++)
{
for
(
int
i
=
0
;
i
<
9
;
i
++)
{
sheet
.
autoSizeColumn
(
i
);
}
...
...
Please
register
or
login
to post a comment