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-28 19:06:42 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c333601755f37a70d3918a4d9c461c31f8c92272
c3336017
1 parent
cba10c69
fix
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
15 deletions
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
src/main/java/com/infoloop/tianting/controller/SkuController.java
src/main/java/com/infoloop/tianting/service/ClientCustomerService.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/KdsServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/OrderServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/SettlementServiceImpl.java
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
View file @
c333601
...
...
@@ -47,6 +47,13 @@ public class ClientCustomerController {
return
clientCustomerService
.
getClientCustomerByHISCustomerId
(
hisCustomerId
);
}
@ApiOperation
(
value
=
"根据customerId获取ClientCustomer"
)
@GetMapping
(
"/customers/{customerId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientCustomerDto
getClientCustomerByCustomerId
(
@PathVariable
Integer
customerId
)
{
return
clientCustomerService
.
getClientCustomerByCustomerId
(
customerId
);
}
@ApiOperation
(
value
=
"根据phone获取ClientCustomer"
)
@GetMapping
(
"/customers/phone/{phone}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
...
...
src/main/java/com/infoloop/tianting/controller/SkuController.java
View file @
c333601
package
com
.
infoloop
.
tianting
.
controller
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto
;
import
com.infoloop.tianting.model.dto.SkuDbDTO.SkuDto
;
...
...
src/main/java/com/infoloop/tianting/service/ClientCustomerService.java
View file @
c333601
...
...
@@ -14,6 +14,8 @@ public interface ClientCustomerService {
ClientCustomerDto
getClientCustomerByHISCustomerId
(
String
hisCustomerId
);
ClientCustomerDto
getClientCustomerByCustomerId
(
Integer
customerId
);
ClientCustomerDto
getClientCustomerByPhone
(
String
phone
);
List
<
HospitalRecordDto
>
getClientCustomerHospitalRecordsByCustomerId
(
...
...
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
View file @
c333601
...
...
@@ -52,12 +52,15 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto
;
import
com.infoloop.tianting.utils.DateUtil
;
import
io.swagger.models.auth.In
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.ZoneOffset
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -69,6 +72,8 @@ public class OrderServiceRpcClient {
private
final
SkuServiceRpcClient
skuServiceRpcClient
;
private
final
OperatorServiceRpcClient
operatorServiceRpcClient
;
private
final
EnterpriseResourceServiceRpcClient
enterpriseResourceServiceRpcClient
;
private
final
RedissonClient
redissonClient
;
private
static
final
String
REDIS_KEY_PREFIX
=
"pickup_code_counter:"
;
public
List
<
SingleClientCustomerOrderRpcResponse
>
getOrdersByCustomerId
(
Integer
customerId
)
{
return
orderServiceRpcBlockingStub
.
getClientCustomerOrdersByCustomerId
(
...
...
@@ -369,6 +374,7 @@ public class OrderServiceRpcClient {
.
setAdjustOrderDetailJson
(
c
.
getAdjustOrderDetailJson
())
.
setShouldCreateOriginalOrderDetailJson
(
c
.
isShouldCreateOriginalOrderDetailJson
())
.
setOriginalOrderDetailJson
(
c
.
getOriginalOrderDetailJson
())
.
setType
(
c
.
getType
())
.
build
()).
collect
(
Collectors
.
toList
()))
.
setCreatedBy
(
batchOperationDto
.
getCreatedBy
())
.
setEnterpriseId
(
batchOperationDto
.
getEnterpriseId
())
...
...
@@ -417,6 +423,17 @@ public class OrderServiceRpcClient {
.
build
()).
getResponsesList
();
}
public
String
generatePickupCode
()
{
LocalDate
today
=
LocalDate
.
now
();
String
currentDate
=
DateUtil
.
formatDate
(
today
,
DateUtil
.
YYYY_MM_DD
);
String
redisKey
=
REDIS_KEY_PREFIX
+
currentDate
;
// 获取分布式原子Long对象,用于原子自增操作
org
.
redisson
.
api
.
RAtomicLong
atomicLong
=
redissonClient
.
getAtomicLong
(
redisKey
);
// 原子自增并获取当前值
long
counter
=
atomicLong
.
incrementAndGet
();
return
String
.
format
(
"%04d"
,
(
int
)
counter
);
}
public
CreateOrderResponse
createOrder
(
CreateOrderDto
createOrderDto
)
{
final
var
orderDetails
=
new
ArrayList
<
ClientCustomerOrderDetailCreation
>();
for
(
CreateOrderDetailDto
orderDetailDto:
createOrderDto
.
getOrderDetailDtos
())
{
...
...
@@ -487,9 +504,8 @@ public class OrderServiceRpcClient {
.
setPayPrice
(
createOrderDto
.
getPayPrice
())
.
setMealTime
(
mealDate
.
atStartOfDay
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
())
.
setShouldCreateTableCode
(
createOrderDto
.
getCloseTimeType
().
equals
(
CloseTimeType
.
IMMEDIATELY
))
.
setTableCode
(
createOrderDto
.
getTableCode
())
.
setShouldCreatePickupCode
(
createOrderDto
.
getCloseTimeType
().
equals
(
CloseTimeType
.
IMMEDIATELY
))
// .setPickupCode(createOrderDto.get
PickupCode())
.
setPickupCode
(
generate
PickupCode
())
.
setShouldCreateRemark
(
true
)
.
setRemark
(
createOrderDto
.
getRemark
())
.
setShouldCreateCustomerNoticeJson
(
true
)
...
...
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
View file @
c333601
...
...
@@ -82,6 +82,37 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
.
build
();
}
@Override
public
ClientCustomerDto
getClientCustomerByCustomerId
(
Integer
customerId
)
{
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
var
response
=
clientCustomerServiceRpcClient
.
getClientCustomerById
(
operatorLoginInfo
.
getEnterpriseId
(),
customerId
).
getResponse
();
return
ClientCustomerDto
.
builder
()
.
id
(
response
.
getId
())
.
clientId
(
response
.
getClientId
())
.
enterpriseId
(
response
.
getEnterpriseId
())
.
age
(
response
.
getAge
())
.
height
(
response
.
getHeight
())
.
HISCustomerId
(
response
.
getHISCustomerId
())
.
identityCardNo
(
response
.
getIdentityCardNo
())
.
mobile
(
response
.
getMobile
())
.
name
(
response
.
getName
())
.
openId
(
response
.
getOpenId
())
.
sex
(
response
.
getSex
())
.
stallId
(
response
.
getStallId
())
.
weight
(
response
.
getWeight
())
.
isDeleted
(
response
.
getIsDeleted
())
.
birthday
(
DateUtil
.
formatDate
(
response
.
getBirthday
()))
.
createdAt
(
DateUtil
.
formatDate
(
response
.
getCreatedAt
()))
.
createdBy
(
response
.
getCreatedBy
())
.
creationSource
(
response
.
getCreationSource
())
.
updatedAt
(
DateUtil
.
formatDate
(
response
.
getUpdatedAt
()))
.
updateSource
(
response
.
getUpdateSource
())
.
updatedBy
(
response
.
getUpdatedBy
())
.
build
();
}
@Override
public
ClientCustomerDto
getClientCustomerByPhone
(
String
phone
)
{
final
var
response
=
clientCustomerServiceRpcClient
.
getClientCustomerByMobile
(
phone
);
...
...
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
View file @
c333601
...
...
@@ -220,7 +220,7 @@ public class KdsServiceImpl implements KdsService {
LocalDate
today
=
LocalDate
.
now
();
LocalDateTime
todayZero
=
today
.
atStartOfDay
();
LocalDate
tomorrow
=
today
.
plusDays
(
1
);
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
();
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
()
.
minusMinutes
(
1
)
;
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
...
...
@@ -291,7 +291,7 @@ public class KdsServiceImpl implements KdsService {
LocalDate
today
=
LocalDate
.
now
();
LocalDateTime
todayZero
=
today
.
atStartOfDay
();
LocalDate
tomorrow
=
today
.
plusDays
(
1
);
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
();
LocalDateTime
tomorrowZero
=
tomorrow
.
atStartOfDay
()
.
minusMinutes
(
1
)
;
final
var
operatorLoginInfo
=
LoginContextHolder
.
getLoginInfo
();
...
...
@@ -342,7 +342,7 @@ public class KdsServiceImpl implements KdsService {
final
var
orderDetailList
=
orderServiceRpcClient
.
getOrderDetailsByOrderIds
(
orderIds
);
final
var
filteredOrderDetailList
=
orderDetailList
.
stream
()
.
filter
(
od
->
od
.
getMealId
()
==
queryDto
.
getMealId
())
.
filter
(
od
->
od
.
getMealId
()
==
queryDto
.
getMealId
()
&&
od
.
getServeStatus
()
!=
ServeStatusEnum
.
SERVE_REJECT
)
.
collect
(
Collectors
.
toList
());
//在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类
...
...
src/main/java/com/infoloop/tianting/service/impl/OrderServiceImpl.java
View file @
c333601
...
...
@@ -6,6 +6,7 @@ import com.infoloop.tianting.SingleSpecialResponse;
import
com.infoloop.tianting.clientcustomerorderservice.CloseTimeType
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderCountByStatus
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerLabelRefRpcResponse
;
...
...
@@ -141,7 +142,13 @@ public class OrderServiceImpl implements OrderService {
final
var
labels
=
deliveryRuleServiceRpcClient
.
GetClientLabelsByIds
(
customer
.
getEnterpriseId
(),
labelIds
).
getResponsesList
();
final
var
avoids
=
labels
.
stream
().
filter
(
l
->
l
.
getType
()
==
ClientLabelTypeEnum
.
CLIENT_LABEL_TYPE_AVOID
).
map
(
SingleClientLabelRpcResponse:
:
getName
).
collect
(
Collectors
.
toList
());
final
var
hisAllergies
=
meiZhongYiHeService
.
getHisCustomerAllergiesByCustomerId
(
customer
.
getHISCustomerId
());
List
<
HisAllergy
>
hisAllergies
=
new
ArrayList
<>();
List
<
HisMedicalAdviceDto
>
origionalHisDoctors
=
new
ArrayList
<>();
if
(!
customer
.
getHISCustomerId
().
isEmpty
())
{
hisAllergies
=
meiZhongYiHeService
.
getHisCustomerAllergiesByCustomerId
(
customer
.
getHISCustomerId
());
origionalHisDoctors
=
meiZhongYiHeService
.
getHisCustomerMedicalAdvicesByContractNo
(
record
.
getContractNo
());
}
final
var
allergyCodes
=
hisAllergies
.
stream
().
map
(
HisAllergy:
:
getAllergyCode
).
collect
(
Collectors
.
toList
());
final
var
allLabels
=
deliveryRuleServiceRpcClient
.
getLabelsByTypes
(
QueryLabelsDto
.
builder
()
.
enterpriseId
(
operatorLoginInfo
.
getEnterpriseId
())
...
...
@@ -149,7 +156,6 @@ public class OrderServiceImpl implements OrderService {
.
build
());
final
var
mappingAllergies
=
allLabels
.
getResponsesList
().
stream
().
filter
(
l
->
allergyCodes
.
contains
(
l
.
getCode
())).
map
(
SingleClientLabelRpcResponse:
:
getName
).
collect
(
Collectors
.
toList
());
final
var
origionalHisDoctors
=
meiZhongYiHeService
.
getHisCustomerMedicalAdvicesByContractNo
(
record
.
getContractNo
());
final
var
dietDoctors
=
origionalHisDoctors
.
stream
().
filter
(
d
->
d
.
getMedicalAdviceType
().
equals
(
MedicalAdviceTypeEnum
.
DIET
)).
map
(
HisMedicalAdviceDto:
:
getConnotation
).
collect
(
Collectors
.
toList
());
final
var
doctors
=
labels
.
stream
().
filter
(
l
->
l
.
getType
()
==
ClientLabelTypeEnum
.
CLIENT_LABEL_TYPE_DOCTOR
).
map
(
...
...
@@ -258,7 +264,8 @@ public class OrderServiceImpl implements OrderService {
.
openId
(
checkIfOrdered
.
getOpenId
())
.
build
();
final
var
orderList
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
return
orderList
.
size
();
final
var
filteredOrderList
=
orderList
.
stream
().
filter
(
o
->
o
.
getStatus
()!=
OrderStatusEnum
.
ORDER_CANCELED
).
collect
(
Collectors
.
toList
());
return
filteredOrderList
.
size
();
}
@Override
...
...
src/main/java/com/infoloop/tianting/service/impl/SettlementServiceImpl.java
View file @
c333601
...
...
@@ -387,15 +387,23 @@ public class SettlementServiceImpl implements SettlementService {
.
filter
(
m
->
curMenuMealIds
.
contains
(
m
.
getId
()))
.
collect
(
Collectors
.
toList
());
// 汇总每个餐别的情况
for
(
SingleMealRpcResponse
meal:
curMenuMeals
)
{
final
var
mealName
=
meal
.
getName
();
for
(
Integer
curMealId:
curMenuMealIds
)
{
String
mealName
=
"无餐别"
;
if
(
curMealId
!=
0
)
{
final
var
curMeal
=
allMeals
.
stream
().
filter
(
m
->
m
.
getId
()
==
curMealId
).
findFirst
();
if
(
curMeal
.
isEmpty
())
{
continue
;
}
else
{
mealName
=
curMeal
.
get
().
getName
();
}
}
if
(!
menusMap
.
containsKey
(
mealName
))
{
menusMap
.
put
(
me
nu
Name
,
new
HashMap
<>());
menusMap
.
put
(
me
al
Name
,
new
HashMap
<>());
}
final
var
mealsMap
=
menusMap
.
get
(
mealName
);
//当前餐别已点的order details
final
var
curMealOrderDetails
=
curMenuOrderDetails
.
stream
()
.
filter
(
od
->
od
.
getMealId
()
==
meal
.
getId
()
)
.
filter
(
od
->
od
.
getMealId
()
==
curMealId
)
.
collect
(
Collectors
.
toList
());
//找出所有需要的日期
final
var
dates
=
curMealOrderDetails
.
stream
()
...
...
@@ -454,7 +462,9 @@ public class SettlementServiceImpl implements SettlementService {
sheetTitleCell
.
setCellValue
(
settlementDataDto
.
getClient
());
Row
dateRangeRow
=
sheet
.
createRow
(
rowNum
++);
Cell
dateRangeCell
=
dateRangeRow
.
createCell
(
0
);
final
var
dateRange
=
settlementDataDto
.
getStartTime
()
+
"至"
+
settlementDataDto
.
getEndTime
();
final
var
startDateStr
=
DateUtil
.
formatDate
(
settlementDataDto
.
getStartTime
(),
DateUtil
.
YYYY_MM_DD
);
final
var
endDateStr
=
DateUtil
.
formatDate
(
settlementDataDto
.
getEndTime
(),
DateUtil
.
YYYY_MM_DD
);
final
var
dateRange
=
startDateStr
+
"至"
+
endDateStr
;
dateRangeCell
.
setCellValue
(
dateRange
);
Row
titleRow
=
sheet
.
createRow
(
rowNum
++);
int
columnNum
=
0
;
...
...
@@ -501,7 +511,10 @@ public class SettlementServiceImpl implements SettlementService {
columnNum
=
2
;
int
totalPrice
=
0
;
for
(
String
date:
dates
)
{
final
var
toWriteDateSkuList
=
skuMap
.
get
(
date
);
List
<
SettlementMenuMealDto
>
toWriteDateSkuList
=
skuMap
.
get
(
date
);
if
(
toWriteDateSkuList
==
null
)
{
toWriteDateSkuList
=
new
ArrayList
<>();
}
int
price
=
0
;
if
(!
toWriteDateSkuList
.
isEmpty
())
{
for
(
SettlementMenuMealDto
settlementMenuMealDto:
toWriteDateSkuList
)
{
...
...
@@ -518,7 +531,8 @@ public class SettlementServiceImpl implements SettlementService {
}
// 自动调整列宽
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
final
var
columnCnt
=
dates
.
size
()
+
2
;
for
(
int
i
=
0
;
i
<
columnCnt
;
i
++)
{
sheet
.
autoSizeColumn
(
i
);
}
...
...
Please
register
or
login
to post a comment