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-02-20 11:51:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c06206bcdb2520dcb2b08b02cc5bbdfa0548b367
c06206bc
1 parent
17248b24
优化
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
327 additions
and
1070 deletions
src/main/java/com/infoloop/tianting/config/GrpcConfig.java
src/main/java/com/infoloop/tianting/config/ResourceInjectorConfig.java
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
src/main/java/com/infoloop/tianting/controller/ClientOrderController.java
src/main/java/com/infoloop/tianting/controller/InventoryController.java
src/main/java/com/infoloop/tianting/controller/LoginController.java
src/main/java/com/infoloop/tianting/controller/MenuController.java
src/main/java/com/infoloop/tianting/controller/OrderController.java
src/main/java/com/infoloop/tianting/controller/PayController.java
src/main/java/com/infoloop/tianting/controller/SkuController.java
src/main/java/com/infoloop/tianting/controller/TestController.java
src/main/java/com/infoloop/tianting/exception/ErrorCodeEnum.java
src/main/java/com/infoloop/tianting/intercepter/ResourceInjector.java
src/main/java/com/infoloop/tianting/model/create/TestExampleDbCreate.java
src/main/java/com/infoloop/tianting/model/dto/SkuDbDTO.java
src/main/java/com/infoloop/tianting/model/dto/TestExampleDbDTO.java
src/main/java/com/infoloop/tianting/model/query/TestExampleDbQuery.java
src/main/java/com/infoloop/tianting/model/update/TestExampleDbUpdate.java
src/main/java/com/infoloop/tianting/model/vo/TestExampleDbVO.java
src/main/java/com/infoloop/tianting/service/TestService.java
src/main/java/com/infoloop/tianting/service/client/CategoriesServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceHttpClient.java
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/DeliveryRuleServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/EnterpriseResourceServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/ExampleServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/InventoryServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/MealServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/MeiZhongYiHeServiceClient.java
src/main/java/com/infoloop/tianting/service/client/MenuServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/OperatorServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/PayServiceClient.java
src/main/java/com/infoloop/tianting/service/client/SkuServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/WOperatorServiceRpcClient.java
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramClient.java
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramHttpClient.java
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/InventoryServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/MealServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/MeiZhongYiHeServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/MenuServiceImpl.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/service/impl/SkuServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/TestServiceImpl.java
src/main/java/com/infoloop/tianting/service/impl/WxMiniProgramServiceImpl.java
src/main/proto/ExampleService.proto
src/main/proto/SkuServiceProtoRpc.proto
src/main/resources/application.properties
src/main/java/com/infoloop/tianting/config/GrpcConfig.java
View file @
c06206b
...
...
@@ -12,14 +12,9 @@ import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcG
import
com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc
;
import
com.infoloop.tianting.menuservice.MenuServiceRpcGrpc
;
import
com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc
;
import
com.tianting.infoloop.grpc.exampleservice.ExampleServiceRpcGrpc
;
//import com.tianting.infoloop.grpc.menuservice.MenuServiceRpcGrpc;
//import com.tianting.infoloop.grpc.orderservice.OrderServiceRpcGrpc;
import
io.grpc.ClientInterceptor
;
import
io.grpc.ManagedChannel
;
import
io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder
;
import
io.swagger.models.auth.In
;
import
javax.validation.Valid
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -43,9 +38,6 @@ import static com.infoloop.tianting.constant.ConfigConstants.DELIVERY_SERVICE_RP
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
ENTERPRISE_RESOURCE_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
ENTERPRISE_RESOURCE_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
ENTERPRISE_RESOURCE_SERVICE_RPC_URL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
EXAMPLE_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
EXAMPLE_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
EXAMPLE_SERVICE_RPC_URL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MEAL_SERVICE_CHANNEL
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MEAL_SERVICE_RPC_PORT
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MEAL_SERVICE_RPC_URL
;
...
...
@@ -73,23 +65,6 @@ public class GrpcConfig {
private
static
final
int
DEFAULT_TIMEOUT_DAYS
=
7
;
@Bean
(
EXAMPLE_SERVICE_CHANNEL
)
public
ManagedChannel
exampleServiceChannel
(
@Value
(
EXAMPLE_SERVICE_RPC_URL
)
final
String
url
,
@Value
(
EXAMPLE_SERVICE_RPC_PORT
)
final
int
port
,
@Autowired
final
ClientInterceptor
clientInterceptor
)
{
return
NettyChannelBuilder
.
forAddress
(
url
,
port
)
.
idleTimeout
(
DEFAULT_TIMEOUT_DAYS
,
TimeUnit
.
DAYS
)
.
intercept
(
clientInterceptor
)
.
usePlaintext
()
.
maxInboundMessageSize
(
Integer
.
MAX_VALUE
)
.
build
();
}
@Bean
public
ExampleServiceRpcGrpc
.
ExampleServiceRpcBlockingStub
exampleServiceRpcBlockingStub
(
@Autowired
@Qualifier
(
EXAMPLE_SERVICE_CHANNEL
)
final
ManagedChannel
channel
)
{
return
ExampleServiceRpcGrpc
.
newBlockingStub
(
channel
);
}
@Bean
(
ORDER_SERVICE_CHANNEL
)
public
ManagedChannel
orderServiceChannel
(
@Value
(
ORDER_SERVICE_RPC_URL
)
final
String
url
,
@Value
(
ORDER_SERVICE_RPC_PORT
)
final
int
port
,
...
...
src/main/java/com/infoloop/tianting/config/ResourceInjectorConfig.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
config
;
import
com.infoloop.tianting.intercepter.ResourceInjector
;
import
com.infoloop.tianting.service.client.ExampleServiceRpcClient
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
...
...
@@ -10,9 +9,8 @@ public class ResourceInjectorConfig {
@Bean
public
ResourceInjector
resourceInjector
(
final
ExampleServiceRpcClient
exampleServiceRpcClient
)
{
return
new
ResourceInjector
(
exampleServiceRpcClient
);
return
new
ResourceInjector
();
}
}
...
...
src/main/java/com/infoloop/tianting/controller/ClientCustomerController.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
controller
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
cn.dev33.satoken.stp.SaTokenInfo
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.TodayOrderDto
;
import
com.infoloop.tianting.model.dto.PermissionDTO.LoginDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto
;
import
com.infoloop.tianting.service.ClientCustomerService
;
import
com.infoloop.tianting.service.LoginService
;
import
com.infoloop.tianting.service.WxMiniProgramService
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceHttpClient
;
import
io.lettuce.core.dynamic.annotation.Param
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@Api
(
tags
=
"ClientCustomer"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -36,9 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ClientCustomerController
{
private
final
ClientCustomerService
clientCustomerService
;
private
final
WxMiniProgramService
wxMiniProgramService
;
private
final
ClientCustomerServiceHttpClient
clientCustomerServiceHttpClient
;
@ApiOperation
(
value
=
"根据hisCustomerId获取ClientCustomer"
)
@GetMapping
(
"/customers/his/{hisCustomerId}"
)
...
...
src/main/java/com/infoloop/tianting/controller/ClientOrderController.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
controller
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.common.OrderPageResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.dto.OrderDbDTO
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto
;
import
com.infoloop.tianting.service.OrderService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
@Api
(
tags
=
"院区端订单"
)
@ApiSupport
(
order
=
0
)
@Slf4j
...
...
src/main/java/com/infoloop/tianting/controller/InventoryController.java
View file @
c06206b
...
...
@@ -5,12 +5,9 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto
;
import
com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto
;
import
com.infoloop.tianting.service.InventoryService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -23,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"院区"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -36,8 +36,7 @@ public class InventoryController {
@ApiOperation
(
value
=
"根据Id获取Client"
)
@GetMapping
(
"/enterprises/{enterpriseId}/clients/{clientId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
ClientDto
getClientById
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
clientId
)
{
public
ClientDto
getClientById
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
clientId
)
{
return
inventoryService
.
getClientById
(
enterpriseId
,
clientId
);
}
...
...
@@ -49,7 +48,6 @@ public class InventoryController {
return
inventoryService
.
getStallsByClientId
(
enterpriseId
,
clientId
);
}
// @SaIgnore
@ApiOperation
(
value
=
"获取桌号"
)
@PostMapping
(
"/tableCodes"
)
@ResponseStatus
(
HttpStatus
.
OK
)
...
...
src/main/java/com/infoloop/tianting/controller/LoginController.java
View file @
c06206b
...
...
@@ -2,20 +2,11 @@ package com.infoloop.tianting.controller;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
cn.dev33.satoken.stp.SaTokenInfo
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.dto.PermissionDTO
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto1
;
import
com.infoloop.tianting.service.LoginService
;
import
com.infoloop.tianting.utils.JsonUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.LinkedHashMap
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -26,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
@Api
(
tags
=
"登陆"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
src/main/java/com/infoloop/tianting/controller/MenuController.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
controller
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto
;
import
com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto
;
...
...
@@ -10,10 +9,7 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.MenuRefDto;
import
com.infoloop.tianting.service.MenuService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.Value
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -25,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"餐单"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
...
...
@@ -73,7 +72,7 @@ public class MenuController {
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
MenuRefDto
>
queryMenuRefsByCustomerId
(
@PathVariable
Integer
enterpriseId
,
@PathVariable
Integer
customerId
)
{
)
{
return
menuService
.
getClientCustomerMenuRefsByCustomerId
(
enterpriseId
,
customerId
);
}
...
...
@@ -81,8 +80,8 @@ public class MenuController {
@PostMapping
(
"/menuRefs/creation"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
BatchCreateMenuRefsResponseDto
batchCreateMenuRefsByCustomerId
(
@Valid
@RequestBody
BatchCreateMenuRefsDto
batchCreateMenuRefsDto
)
{
@Valid
@RequestBody
BatchCreateMenuRefsDto
batchCreateMenuRefsDto
)
{
return
menuService
.
batchCreateMenuRefs
(
batchCreateMenuRefsDto
);
}
...
...
src/main/java/com/infoloop/tianting/controller/OrderController.java
View file @
c06206b
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
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.BatchUpdateOrderDetailResponse
;
...
...
@@ -8,19 +7,14 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDto;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderResponse
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderAndDetailsDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderDetailDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.OrderDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse
;
import
com.infoloop.tianting.service.OrderService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.models.auth.In
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.annotation.SuppressAjWarnings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -32,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"订单"
)
@ApiSupport
(
order
=
0
)
@Slf4j
...
...
@@ -82,7 +79,7 @@ public class OrderController {
return
orderService
.
orderCreation
(
createOrderDto
);
}
// @SaIgnore
// @SaIgnore
@ApiOperation
(
value
=
"修改订单"
)
@PatchMapping
(
"/orders/modification"
)
@ResponseStatus
(
HttpStatus
.
OK
)
...
...
@@ -90,7 +87,7 @@ public class OrderController {
return
orderService
.
updateOrder
(
updateOrderDto
);
}
// @SaIgnore
// @SaIgnore
@ApiOperation
(
value
=
"批量修改订单详情"
)
@PatchMapping
(
"/order_details/modification"
)
@ResponseStatus
(
HttpStatus
.
OK
)
...
...
src/main/java/com/infoloop/tianting/controller/PayController.java
View file @
c06206b
...
...
@@ -7,7 +7,6 @@ import com.infoloop.tianting.model.dto.PayDTO.PayResponseDto;
import
com.infoloop.tianting.service.client.PayServiceClient
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,23 +17,32 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
@Api
(
tags
=
"支付"
)
@ApiSupport
(
order
=
0
)
@ApiSupport
(
order
=
1
)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
PayController
{
private
final
PayServiceClient
payServiceClient
;
@SaIgnore
@ApiOperation
(
value
=
"支付通知
"
)
@ApiOperation
(
value
=
"支付
"
)
@PostMapping
(
"/pay/inform"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
PayResponseDto
pay
(
@Valid
@RequestBody
PayDTO
.
PayInformRequestDto
payInformRequestDto
){
public
PayResponseDto
pay
(
@Valid
@RequestBody
PayDTO
.
PayInformRequestDto
payInformRequestDto
)
{
return
payServiceClient
.
payInform
(
payInformRequestDto
);
}
@SaIgnore
@ApiOperation
(
value
=
"支付通知"
)
@PostMapping
(
"/pay/callback"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
void
callback
(
@Valid
@RequestBody
PayDTO
.
PayInformRequestDto
payInformRequestDto
)
{
payServiceClient
.
callback
(
payInformRequestDto
);
}
}
\ No newline at end of file
...
...
src/main/java/com/infoloop/tianting/controller/SkuController.java
View file @
c06206b
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
;
import
com.infoloop.tianting.model.dto.SkuDbDTO.SkuIdsDto
;
import
com.infoloop.tianting.service.SkuService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.util.List
;
import
javax.validation.Valid
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"sku"
)
@ApiSupport
(
order
=
0
)
@ApiSupport
(
order
=
2
)
@Slf4j
@Validated
@RestController
...
...
@@ -35,7 +32,7 @@ public class SkuController {
@ApiOperation
(
value
=
"根据sku ids获取"
)
@PostMapping
(
"/skus"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
SkuDto
>
getOrderByCustomerId
(
@Valid
@RequestBody
SkuIdsDto
skuIdsDto
)
{
public
List
<
SkuDto
>
getOrderByCustomerId
(
@Valid
@RequestBody
SkuIdsDto
skuIdsDto
)
{
return
skuService
.
getSkusByIds
(
skuIdsDto
.
getIds
());
}
}
...
...
src/main/java/com/infoloop/tianting/controller/TestController.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
controller
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.infoloop.tianting.constant.PathVariableResourceConstants
;
import
com.infoloop.tianting.model.common.CreatedResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.dto.TestExampleDbDTO
;
import
com.infoloop.tianting.model.vo.TestExampleDbVO
;
import
com.infoloop.tianting.service.TestService
;
import
com.tianting.infoloop.grpc.exampleservice.SingleTestExampleDbRpcResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PatchMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestAttribute
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.validation.Valid
;
import
java.util.List
;
@Api
(
tags
=
"示例"
)
@ApiSupport
(
order
=
-
1
)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
TestController
{
private
final
TestService
testService
;
@ApiOperation
(
value
=
"分页查询"
)
@PostMapping
(
"/testexampledbs/page"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
PageResult
<
TestExampleDbVO
>
queryPage
(
@Valid
@RequestBody
TestExampleDbDTO
.
QueryPage
queryPage
)
{
return
testService
.
queryPage
(
queryPage
);
}
@ApiOperation
(
value
=
"查询所有"
)
@PostMapping
(
"/testexampledbs/queryall"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
List
<
TestExampleDbVO
>
queryAll
()
{
return
testService
.
queryAll
();
}
@ApiOperation
(
value
=
"新增"
)
@PutMapping
(
"/testexampledb"
)
@ResponseStatus
(
HttpStatus
.
CREATED
)
public
CreatedResult
<
TestExampleDbVO
>
createTestExampleDb
(
@Valid
@RequestBody
TestExampleDbDTO
.
CreateTestExampleDb
createTestExampleDb
)
{
return
testService
.
createTestExampleDb
(
createTestExampleDb
);
}
@ApiOperation
(
value
=
"修改"
)
@PatchMapping
(
"/testexampledb/{testExampleDbId}"
)
@ResponseStatus
(
HttpStatus
.
NO_CONTENT
)
public
void
updateTestExampleDb
(
@ApiIgnore
@RequestAttribute
(
PathVariableResourceConstants
.
INJECTED_TEST_EXAMPLE_DB
)
final
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
,
@Valid
@RequestBody
TestExampleDbDTO
.
UpdateTestExampleDb
updateTestExampleDb
)
{
testService
.
updateTestExampleDb
(
testExampleDbRpcResponse
,
updateTestExampleDb
);
}
@ApiOperation
(
value
=
"删除"
)
@DeleteMapping
(
"/testexampledb/{testExampleDbId}"
)
@ResponseStatus
(
HttpStatus
.
NO_CONTENT
)
public
void
deleteTestExampleDb
(
@ApiIgnore
@RequestAttribute
(
PathVariableResourceConstants
.
INJECTED_TEST_EXAMPLE_DB
)
final
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
)
{
testService
.
deleteTestExampleDb
(
testExampleDbRpcResponse
);
}
@ApiOperation
(
value
=
"详情"
)
@GetMapping
(
"/testexampledb/{testExampleDbId}"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
TestExampleDbVO
getTestExampleDb
(
@ApiIgnore
@RequestAttribute
(
PathVariableResourceConstants
.
INJECTED_TEST_EXAMPLE_DB
)
final
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
)
{
return
testService
.
getTestExampleDb
(
testExampleDbRpcResponse
);
}
}
src/main/java/com/infoloop/tianting/exception/ErrorCodeEnum.java
View file @
c06206b
...
...
@@ -27,6 +27,8 @@ public enum ErrorCodeEnum implements BaseEnum {
GENERATE_EXCEL_ERROR
(
406000004
,
"生成excel失败"
),
ORDER_COUNT_LIMIT
(
406000005
,
"已超过该餐单预定次数"
),
QUERY_CLIENT_CUSTOMER_ERROR
(
406000006
,
"获取当日在住客户失败"
),
;
private
final
int
code
;
...
...
src/main/java/com/infoloop/tianting/intercepter/ResourceInjector.java
View file @
c06206b
...
...
@@ -2,10 +2,6 @@ package com.infoloop.tianting.intercepter;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
cn.dev33.satoken.strategy.SaStrategy
;
import
cn.hutool.core.convert.Convert
;
import
com.infoloop.tianting.constant.PathVariableResourceConstants
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
import
com.infoloop.tianting.service.client.ExampleServiceRpcClient
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,8 +18,6 @@ import java.util.Map;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ResourceInjector
implements
HandlerInterceptor
{
private
final
ExampleServiceRpcClient
exampleServiceRpcClient
;
@Override
@SuppressWarnings
(
"unchecked"
)
public
boolean
preHandle
(
@NonNull
final
HttpServletRequest
httpServletRequest
,
@NonNull
final
HttpServletResponse
httpServletResponse
,
@NonNull
final
Object
handler
)
{
...
...
@@ -39,24 +33,6 @@ public class ResourceInjector implements HandlerInterceptor {
if
(
pathVariables
==
null
)
{
return
true
;
}
/*
注入TestExampleDb
*/
if
(
pathVariables
.
containsKey
(
PathVariableResourceConstants
.
TEST_EXAMPLE_DB_ID_PATH_VARIABLE
))
{
final
var
idStr
=
pathVariables
.
get
(
PathVariableResourceConstants
.
TEST_EXAMPLE_DB_ID_PATH_VARIABLE
);
final
var
id
=
Convert
.
toInt
(
idStr
,
0
);
if
(
id
<=
0
)
{
throw
ClientEndExceptions
.
ResourceNotFound
.
build
(
"示例不存在"
);
}
final
var
response
=
exampleServiceRpcClient
.
getTestExampleDbById
(
id
);
if
(
response
==
null
)
{
throw
ClientEndExceptions
.
ResourceNotFound
.
build
(
"示例不存在"
);
}
httpServletRequest
.
setAttribute
(
PathVariableResourceConstants
.
INJECTED_TEST_EXAMPLE_DB
,
response
);
}
return
true
;
}
}
...
...
src/main/java/com/infoloop/tianting/model/create/TestExampleDbCreate.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
model
.
create
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbStatusEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
TestExampleDbCreate
{
private
String
name
;
private
TestExampleDbStatusEnum
status
;
}
src/main/java/com/infoloop/tianting/model/dto/SkuDbDTO.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
model
.
dto
;
import
com.infoloop.tianting.SkuAttribute
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.models.auth.In
;
import
java.util.List
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.util.List
;
@Data
@ApiModel
(
description
=
"SkuDTO"
)
public
class
SkuDbDTO
{
...
...
@@ -65,5 +64,6 @@ public class SkuDbDTO {
List
<
SkuSpecialDetailSingleResponseDto
>
doctorList
;
// 医嘱
List
<
SkuDetailSingleResponseDto
>
avoidList
;
// 忌口
List
<
SkuDetailSingleResponseDto
>
skuList
;
// 配料
List
<
SkuDetailSingleResponseDto
>
cecommendList
;
}
}
...
...
src/main/java/com/infoloop/tianting/model/dto/TestExampleDbDTO.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
model
.
dto
;
import
com.infoloop.tianting.model.common.PageInfo
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbStatusEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotEmpty
;
import
javax.validation.constraints.NotNull
;
@Data
@ApiModel
(
description
=
"示例参数信息"
)
public
class
TestExampleDbDTO
{
@Data
@ApiModel
(
description
=
"查询分页参数"
)
public
static
class
QueryPage
{
@ApiModelProperty
(
"分页信息"
)
@Valid
private
PageInfo
pageInfo
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"状态"
)
private
TestExampleDbStatusEnum
status
;
}
@Data
@ApiModel
(
description
=
"条件查询参数"
)
public
static
class
QueryByCondition
{
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"状态"
)
private
TestExampleDbStatusEnum
status
;
}
@Data
@ApiModel
(
description
=
"创建信息参数"
)
public
static
class
CreateTestExampleDb
{
@ApiModelProperty
(
"名称"
)
@NotEmpty
(
message
=
"名称不能为空"
)
private
String
name
;
@ApiModelProperty
(
"状态"
)
@NotNull
(
message
=
"状态不能为空"
)
private
TestExampleDbStatusEnum
status
;
}
@Data
@ApiModel
(
description
=
"修改信息参数"
)
public
static
class
UpdateTestExampleDb
{
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"状态"
)
private
TestExampleDbStatusEnum
status
;
}
}
src/main/java/com/infoloop/tianting/model/query/TestExampleDbQuery.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
model
.
query
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbStatusEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
TestExampleDbQuery
{
private
String
name
;
private
TestExampleDbStatusEnum
status
;
}
src/main/java/com/infoloop/tianting/model/update/TestExampleDbUpdate.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
model
.
update
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbStatusEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
TestExampleDbUpdate
{
private
int
id
;
private
String
name
;
private
TestExampleDbStatusEnum
status
;
}
src/main/java/com/infoloop/tianting/model/vo/TestExampleDbVO.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
model
.
vo
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbStatusEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.ToString
;
@Data
@Builder
@ToString
@ApiModel
(
description
=
"示例试图"
)
public
class
TestExampleDbVO
{
@ApiModelProperty
(
"ID"
)
private
int
id
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"状态"
)
private
TestExampleDbStatusEnum
status
;
@ApiModelProperty
(
"创建时间"
)
private
String
createdAt
;
@ApiModelProperty
(
"修改时间"
)
private
String
updatedAt
;
}
src/main/java/com/infoloop/tianting/service/TestService.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
service
;
import
com.infoloop.tianting.model.common.CreatedResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.dto.TestExampleDbDTO
;
import
com.infoloop.tianting.model.vo.TestExampleDbVO
;
import
com.tianting.infoloop.grpc.exampleservice.SingleTestExampleDbRpcResponse
;
import
javax.validation.Valid
;
import
java.util.List
;
public
interface
TestService
{
PageResult
<
TestExampleDbVO
>
queryPage
(
TestExampleDbDTO
.
@Valid
QueryPage
queryPage
);
List
<
TestExampleDbVO
>
queryAll
();
CreatedResult
<
TestExampleDbVO
>
createTestExampleDb
(
TestExampleDbDTO
.
CreateTestExampleDb
createTestExampleDb
);
void
updateTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
,
TestExampleDbDTO
.
UpdateTestExampleDb
updateTestExampleDb
);
void
deleteTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
);
TestExampleDbVO
getTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
);
}
src/main/java/com/infoloop/tianting/service/client/CategoriesServiceRpcClient.java
View file @
c06206b
...
...
@@ -11,8 +11,7 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
CategoriesServiceRpcClient
{
private
final
CategoriesServiceProtoRpcGrpc
.
CategoriesServiceProtoRpcBlockingStub
categoriesServiceProtoRpcBlockingStub
;
private
final
CategoriesServiceProtoRpcGrpc
.
CategoriesServiceProtoRpcBlockingStub
categoriesServiceProtoRpcBlockingStub
;
public
QueryCategoriesServiceAllRpcResponse
queryCategoriesAll
(
Integer
enterpriseId
)
{
final
var
request
=
QueryCategoriesServiceAllRpcRequest
.
newBuilder
()
...
...
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceHttpClient.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.infoloop.tianting.config.BusinessConfig
;
import
com.infoloop.tianting.constant.CommonConstants
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
import
com.infoloop.tianting.exception.ErrorCodeEnum
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerListDto
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.List
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
@RequiredArgsConstructor
public
class
ClientCustomerServiceHttpClient
{
private
final
BusinessConfig
businessConfig
;
private
final
OkHttpClient
client
=
new
OkHttpClient
();
private
final
RestTemplate
restTemplate
;
public
List
<
CurrentClientCustomerDto
>
getCurrentClientCustomer
(
String
token
,
boolean
isHis
)
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
url
=
isHis
?
businessConfig
.
getHisCustomerQueryUrl
()
:
businessConfig
.
getClientCustomerQueryUrl
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
headers
.
set
(
CommonConstants
.
AUTHORIZATION
,
token
);
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
"{}"
,
headers
);
try
{
String
url
;
if
(
isHis
)
{
url
=
businessConfig
.
getHisCustomerQueryUrl
();
}
else
{
url
=
businessConfig
.
getClientCustomerQueryUrl
();
ResponseEntity
<
CurrentClientCustomerListDto
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
CurrentClientCustomerListDto
.
class
);
if
(!
responseEntity
.
getStatusCode
().
is2xxSuccessful
()
||
responseEntity
.
getBody
()
==
null
)
{
log
.
error
(
"Failed to fetch client customer data. Response: {}"
,
responseEntity
);
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
QUERY_CLIENT_CUSTOMER_ERROR
);
}
MediaType
mediaType
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
"{}"
);
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
post
(
body
)
.
addHeader
(
"Authorization"
,
token
)
.
build
();
Response
response
=
client
.
newCall
(
request
).
execute
();
String
jsonData
=
response
.
body
().
string
();
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
return
objectMapper
.
readValue
(
jsonData
,
CurrentClientCustomerListDto
.
class
).
getRows
();
return
responseEntity
.
getBody
().
getRows
();
}
catch
(
Exception
e
)
{
log
.
error
(
"获取当日在住客户失败
"
,
e
);
throw
new
IllegalArgumentException
(
"获取当日在住客户失败"
);
log
.
error
(
"Error fetching client customer data
"
,
e
);
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
QUERY_CLIENT_CUSTOMER_ERROR
);
}
}
}
\ No newline at end of file
...
...
src/main/java/com/infoloop/tianting/service/client/ClientCustomerServiceRpcClient.java
View file @
c06206b
...
...
@@ -122,8 +122,6 @@ public class ClientCustomerServiceRpcClient {
.
setEnterpriseId
(
enterpriseId
)
.
setShouldFilterCustomerIds
(
true
)
.
addAllCustomerIds
(
List
.
of
(
customerId
))
.
setShouldFilterLabelIds
(
false
)
.
addLabelIds
(
0
)
.
build
();
return
clientCustomerServiceRpcBlockingStub
.
queryClientCustomerLabelRefsByCondition
(
request
);
}
...
...
src/main/java/com/infoloop/tianting/service/client/DeliveryRuleServiceRpcClient.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.tianting.deliveryruleservice.ClientLabelTypeEnum
;
import
com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest
;
import
com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse
;
import
com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest
;
import
com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse
;
import
com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
DeliveryRuleServiceRpcClient
{
...
...
src/main/java/com/infoloop/tianting/service/client/EnterpriseResourceServiceRpcClient.java
View file @
c06206b
src/main/java/com/infoloop/tianting/service/client/ExampleServiceRpcClient.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.tianting.model.common.PageInfo
;
import
com.infoloop.tianting.model.create.TestExampleDbCreate
;
import
com.infoloop.tianting.model.query.TestExampleDbQuery
;
import
com.infoloop.tianting.model.update.TestExampleDbUpdate
;
import
com.tianting.infoloop.grpc.exampleservice.BatchCreateTestExampleDbRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.BatchCreateTestExampleDbRpcResponse
;
import
com.tianting.infoloop.grpc.exampleservice.BatchUpdateTestExampleDbRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.CreateTestExampleDbRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.CreateTestExampleDbRpcResponse
;
import
com.tianting.infoloop.grpc.exampleservice.DeleteTestExampleDbByIdsRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.ExampleServiceRpcGrpc
;
import
com.tianting.infoloop.grpc.exampleservice.GetAllTestExampleDbRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.GetTestExampleDbByIdRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.GetTestExampleDbByIdsRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.QueryTestExampleDbByConditionRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.QueryTestExampleDbByPaginationRpcRequest
;
import
com.tianting.infoloop.grpc.exampleservice.QueryTestExampleDbByPaginationRpcResponse
;
import
com.tianting.infoloop.grpc.exampleservice.SingleTestExampleDbRpcResponse
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbCreation
;
import
com.tianting.infoloop.grpc.exampleservice.TestExampleDbModification
;
import
com.tianting.infoloop.grpc.exampleservice.UpdateTestExampleDbRpcRequest
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.lang.Nullable
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
ExampleServiceRpcClient
{
private
final
ExampleServiceRpcGrpc
.
ExampleServiceRpcBlockingStub
exampleServiceRpcBlockingStub
;
/**
* RPC Client示例
*/
@Nullable
public
SingleTestExampleDbRpcResponse
getTestExampleDbById
(
int
id
)
{
final
var
response
=
exampleServiceRpcBlockingStub
.
getTestExampleDbById
(
GetTestExampleDbByIdRpcRequest
.
newBuilder
()
.
setId
(
id
)
.
build
());
if
(!
response
.
hasResponse
())
{
return
null
;
}
return
response
.
getResponse
();
}
public
List
<
SingleTestExampleDbRpcResponse
>
getTestExampleDbByIds
(
List
<
Integer
>
ids
)
{
return
exampleServiceRpcBlockingStub
.
getTestExampleDbByIds
(
GetTestExampleDbByIdsRpcRequest
.
newBuilder
()
.
addAllIds
(
ids
)
.
build
()).
getResponsesList
();
}
public
List
<
SingleTestExampleDbRpcResponse
>
getAllTestExampleDb
()
{
return
exampleServiceRpcBlockingStub
.
getAllTestExampleDb
(
GetAllTestExampleDbRpcRequest
.
newBuilder
().
build
()).
getResponsesList
();
}
public
List
<
SingleTestExampleDbRpcResponse
>
queryTestExampleDbByCondition
(
TestExampleDbQuery
query
)
{
final
var
builder
=
QueryTestExampleDbByConditionRpcRequest
.
newBuilder
();
if
(
query
.
getName
()
!=
null
)
{
builder
.
setName
(
query
.
getName
());
}
if
(
query
.
getStatus
()
!=
null
)
{
builder
.
setStatus
(
query
.
getStatus
());
}
return
exampleServiceRpcBlockingStub
.
queryTestExampleDbByCondition
(
builder
.
build
()).
getResponsesList
();
}
public
QueryTestExampleDbByPaginationRpcResponse
queryTestExampleDbByPagination
(
PageInfo
pageInfo
,
TestExampleDbQuery
query
)
{
final
var
builder
=
QueryTestExampleDbByPaginationRpcRequest
.
newBuilder
();
builder
.
setPageNo
(
pageInfo
.
getPageNo
());
builder
.
setPageSize
(
pageInfo
.
getPageSize
());
if
(
query
.
getName
()
!=
null
)
{
builder
.
setName
(
query
.
getName
());
}
if
(
query
.
getStatus
()
!=
null
)
{
builder
.
setStatus
(
query
.
getStatus
());
}
return
exampleServiceRpcBlockingStub
.
queryTestExampleDbByPagination
(
builder
.
build
());
}
public
CreateTestExampleDbRpcResponse
createTestExampleDb
(
TestExampleDbCreate
create
)
{
final
var
creation
=
TestExampleDbCreation
.
newBuilder
()
.
setName
(
create
.
getName
())
.
setStatus
(
create
.
getStatus
())
.
build
();
return
exampleServiceRpcBlockingStub
.
createTestExampleDb
(
CreateTestExampleDbRpcRequest
.
newBuilder
().
setCreation
(
creation
).
build
());
}
public
BatchCreateTestExampleDbRpcResponse
batchCreateTestExampleDb
(
List
<
TestExampleDbCreate
>
createList
)
{
final
var
creationList
=
createList
.
stream
().
map
(
e
->
TestExampleDbCreation
.
newBuilder
()
.
setName
(
e
.
getName
())
.
setStatus
(
e
.
getStatus
())
.
build
()).
collect
(
Collectors
.
toList
());
return
exampleServiceRpcBlockingStub
.
batchCreateTestExampleDb
(
BatchCreateTestExampleDbRpcRequest
.
newBuilder
().
addAllCreations
(
creationList
).
build
());
}
public
boolean
updateTestExampleDb
(
TestExampleDbUpdate
update
)
{
final
var
builder
=
TestExampleDbModification
.
newBuilder
()
.
setId
(
update
.
getId
());
if
(
update
.
getName
()
!=
null
)
{
builder
.
setName
(
update
.
getName
());
}
if
(
update
.
getStatus
()
!=
null
)
{
builder
.
setStatus
(
update
.
getStatus
());
}
return
exampleServiceRpcBlockingStub
.
updateTestExampleDb
(
UpdateTestExampleDbRpcRequest
.
newBuilder
().
setModification
(
builder
.
build
()).
build
()).
getIsUpdated
();
}
public
boolean
batchUpdateTestExampleDb
(
List
<
TestExampleDbUpdate
>
updateList
)
{
final
var
modificationList
=
updateList
.
stream
().
map
(
update
->
{
final
var
builder
=
TestExampleDbModification
.
newBuilder
()
.
setId
(
update
.
getId
());
if
(
update
.
getName
()
!=
null
)
{
builder
.
setName
(
update
.
getName
());
}
if
(
update
.
getStatus
()
!=
null
)
{
builder
.
setStatus
(
update
.
getStatus
());
}
return
builder
.
build
();
}).
collect
(
Collectors
.
toList
());
return
exampleServiceRpcBlockingStub
.
batchUpdateTestExampleDb
(
BatchUpdateTestExampleDbRpcRequest
.
newBuilder
().
addAllModifications
(
modificationList
).
build
()).
getIsUpdated
();
}
public
boolean
deleteTestExampleDbByIds
(
List
<
Integer
>
ids
)
{
return
exampleServiceRpcBlockingStub
.
deleteTestExampleDbByIds
(
DeleteTestExampleDbByIdsRpcRequest
.
newBuilder
().
addAllIds
(
ids
).
build
()).
getIsDeleted
();
}
}
src/main/java/com/infoloop/tianting/service/client/InventoryServiceRpcClient.java
View file @
c06206b
...
...
@@ -12,11 +12,12 @@ import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByCondi
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
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
InventoryServiceRpcClient
{
...
...
src/main/java/com/infoloop/tianting/service/client/MealServiceRpcClient.java
View file @
c06206b
...
...
@@ -5,11 +5,12 @@ import com.infoloop.tianting.setmealscheduleservice.GetAllMealsRpcResponse;
import
com.infoloop.tianting.setmealscheduleservice.GetMealsByIdsRpcRequest
;
import
com.infoloop.tianting.setmealscheduleservice.GetMealsByIdsRpcResponse
;
import
com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
MealServiceRpcClient
{
...
...
@@ -35,5 +36,4 @@ public class MealServiceRpcClient {
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/MeiZhongYiHeServiceClient.java
View file @
c06206b
...
...
@@ -5,28 +5,27 @@ import com.infoloop.rpc.meizhongyiheservice.GetCustomerAllergiesByCustomerIdsRpc
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcRequest
;
import
com.infoloop.rpc.meizhongyiheservice.GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse
;
import
com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
MeiZhongYiHeServiceClient
{
private
final
MeiZhongYiHeServiceRpcGrpc
.
MeiZhongYiHeServiceRpcBlockingStub
meiZhongYiHeServiceRpcBlockingStub
;
private
final
MeiZhongYiHeServiceRpcGrpc
.
MeiZhongYiHeServiceRpcBlockingStub
meiZhongYiHeServiceRpcBlockingStub
;
public
GetCustomerAllergiesByCustomerIdsRpcResponse
getHisCustomerAllergiesByCustomerId
(
String
hisCustomerId
)
{
String
hisCustomerId
)
{
final
var
request
=
GetCustomerAllergiesByCustomerIdsRpcRequest
.
newBuilder
()
.
addAllCustomerIds
(
List
.
of
(
hisCustomerId
))
.
build
();
return
meiZhongYiHeServiceRpcBlockingStub
.
getCustomerAllergiesByCustomerIds
(
request
);
}
public
GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse
getHisCustomerMedicalAdvicesByContractNo
(
String
contractNo
)
{
public
GetCustomerMedicalAdvicesByHospitalRecordIdsRpcResponse
getHisCustomerMedicalAdvicesByContractNo
(
String
contractNo
)
{
final
var
request
=
GetCustomerMedicalAdvicesByHospitalRecordIdsRpcRequest
.
newBuilder
()
.
addAllHospitalRecordIds
(
List
.
of
(
contractNo
))
.
build
();
...
...
src/main/java/com/infoloop/tianting/service/client/MenuServiceRpcClient.java
View file @
c06206b
...
...
@@ -21,15 +21,14 @@ import com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcRequest;
import
com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcResponse
;
import
com.infoloop.tianting.menuservice.MenuServiceRpcGrpc
;
import
com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto
;
import
com.infoloop.tianting.utils.DateUtil
;
import
io.swagger.models.auth.In
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.time.ZoneOffset
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
@@ -128,7 +127,7 @@ public class MenuServiceRpcClient {
public
BatchCreateClientCustomerMenuRefsRpcResponse
batchCreateClientCustomerMenuRefs
(
BatchCreateMenuRefsDto
batchCreateMenuRefsDto
)
{
final
var
creations
=
batchCreateMenuRefsDto
.
getCreations
().
stream
().
map
(
mr
->
final
var
creations
=
batchCreateMenuRefsDto
.
getCreations
().
stream
().
map
(
mr
->
ClientCustomerMenuRefCreation
.
newBuilder
()
.
setIsTop
(
mr
.
isTop
())
.
setMenuId
(
mr
.
getMenuId
())
...
...
src/main/java/com/infoloop/tianting/service/client/OperatorServiceRpcClient.java
View file @
c06206b
...
...
@@ -3,7 +3,6 @@ package com.infoloop.tianting.service.client;
import
com.infoloop.tianting.COperatorServiceProtoRpcGrpc
;
import
com.infoloop.tianting.GetCOperatorByIdRpcRequest
;
import
com.infoloop.tianting.GetCOperatorByMobileOrEmailRpcRequest
;
import
com.infoloop.tianting.GetCOperatorByMobileOrEmailRpcResponse
;
import
com.infoloop.tianting.SingleCOperatorRpcResponse
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,8 +12,7 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
OperatorServiceRpcClient
{
private
final
COperatorServiceProtoRpcGrpc
.
COperatorServiceProtoRpcBlockingStub
cOperatorServiceProtoRpcBlockingStub
;
private
final
COperatorServiceProtoRpcGrpc
.
COperatorServiceProtoRpcBlockingStub
cOperatorServiceProtoRpcBlockingStub
;
public
SingleCOperatorRpcResponse
getCOperatorByMobileOrEmail
(
String
keyword
)
{
final
var
request
=
GetCOperatorByMobileOrEmailRpcRequest
.
newBuilder
()
...
...
@@ -29,5 +27,4 @@ public class OperatorServiceRpcClient {
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/OrderServiceRpcClient.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.infoloop.tianting.SingleResponse
;
import
com.infoloop.tianting.SingleSpecialResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperationRecordsRequest
;
...
...
@@ -49,6 +47,7 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto;
import
com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto
;
import
com.infoloop.tianting.utils.DateUtil
;
import
com.infoloop.tianting.utils.JsonUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RedissonClient
;
...
...
@@ -65,13 +64,12 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
OrderServiceRpcClient
{
private
static
final
String
REDIS_KEY_PREFIX
=
"pickup_code_counter:"
;
private
final
ClientCustomerOrderServiceRpcGrpc
.
ClientCustomerOrderServiceRpcBlockingStub
orderServiceRpcBlockingStub
;
private
final
MenuServiceRpcClient
menuServiceRpcClient
;
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
(
...
...
@@ -148,13 +146,13 @@ public class OrderServiceRpcClient {
List
<
Integer
>
idsOfNeedUpdateMenuDetails
=
new
ArrayList
<>();
List
<
Integer
>
idsOfAddCount
=
new
ArrayList
<>();
List
<
OrderDetailDto
>
orgionalOrderDetails
=
new
ArrayList
<>();
List
<
OrderDetailDto
>
newOrderDetails
=
new
ArrayList
<>()
;
final
var
modifications
=
orderDetailBatchUpdateDto
.
getDetails
().
stream
().
map
(
d
->
{
MealDetail
mealDetail
=
MealDetail
.
newBuilder
().
build
();
;
List
<
OrderDetailDto
>
newOrderDetails
;
final
var
modifications
=
orderDetailBatchUpdateDto
.
getDetails
().
stream
().
map
(
d
->
{
MealDetail
mealDetail
=
MealDetail
.
newBuilder
().
build
()
;
Integer
menuDetailId
=
0
;
Integer
mealId
=
0
;
Integer
categoryId
=
0
;
Integer
skuId
=
0
;
int
mealId
=
0
;
int
categoryId
=
0
;
int
skuId
=
0
;
String
showName
=
""
;
if
(
d
.
getShouldUpdateMenuDetailId
())
{
idsOfNeedUpdateMenuDetails
.
add
(
d
.
getId
());
...
...
@@ -199,7 +197,7 @@ public class OrderServiceRpcClient {
idsOfAddCount
.
add
(
d
.
getId
());
count
=
d
.
getCount
();
}
final
var
detail
=
ClientCustomerOrderDetailModification
.
newBuilder
()
return
ClientCustomerOrderDetailModification
.
newBuilder
()
.
setId
(
d
.
getId
())
.
setShouldUpdateMenuDetailId
(
d
.
getShouldUpdateMenuDetailId
())
.
setMenuDetailId
(
menuDetailId
)
...
...
@@ -218,7 +216,6 @@ public class OrderServiceRpcClient {
.
setShouldUpdateMealDetailJson
(
d
.
getShouldUpdateMenuDetailId
())
.
setMealDetailJson
(
mealDetail
)
.
build
();
return
detail
;
}
).
collect
(
Collectors
.
toList
());
final
var
request
=
BatchUpdateClientCustomerOrderDetailsRpcRequest
.
newBuilder
()
...
...
@@ -267,7 +264,7 @@ public class OrderServiceRpcClient {
.
build
()).
collect
(
Collectors
.
toList
());
}
final
var
res
=
orderServiceRpcBlockingStub
.
batchUpdateClientCustomerOrderDetails
(
request
);
if
(
res
.
getIsUpdated
())
{
if
(
res
.
getIsUpdated
())
{
if
(!
idsOfNeedUpdateMenuDetails
.
isEmpty
()
||
!
idsOfAddCount
.
isEmpty
())
{
final
var
newResponseList
=
getClientCustomerOrderDetailsByIds
(
totalIds
);
...
...
@@ -308,15 +305,13 @@ public class OrderServiceRpcClient {
// 替换菜品的操作记录
List
<
SingleOperationDto
>
operations
=
new
ArrayList
<>();
for
(
OrderDetailDto
orgionalDetail
:
orgionalOrderDetails
)
{
for
(
OrderDetailDto
orgionalDetail
:
orgionalOrderDetails
)
{
OrderOperationType
orderOperationType
=
OrderOperationType
.
UNKNOWN_OPERATION_TYPE
;
if
(
idsOfNeedUpdateMenuDetails
.
contains
(
orgionalDetail
.
getId
()))
{
orderOperationType
=
OrderOperationType
.
REPLACE_DISHES
;
}
else
if
(
idsOfAddCount
.
contains
(
orgionalDetail
.
getId
()))
{
}
else
if
(
idsOfAddCount
.
contains
(
orgionalDetail
.
getId
()))
{
orderOperationType
=
OrderOperationType
.
ADD_DISHES
;
}
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
orgionalDetailStr
=
""
;
String
newDetailStr
=
""
;
final
var
newDetail
=
newOrderDetails
.
stream
().
filter
(
n
->
n
.
getId
().
equals
(
orgionalDetail
.
getId
())).
findFirst
();
...
...
@@ -329,13 +324,8 @@ public class OrderServiceRpcClient {
.
adjustSkuRemark
(
newDetail
.
get
().
getAdjustSkuRemark
())
.
serveStatus
(
newDetail
.
get
().
getServeStatus
().
name
())
.
build
();
try
{
newDetailStr
=
objectMapper
.
writeValueAsString
(
List
.
of
(
newOrderDetailOperation
));
}
catch
(
JsonProcessingException
e
)
{
log
.
error
(
"orderDetail json 转换失败"
);
newDetailStr
=
JsonUtil
.
writeAsJson
(
List
.
of
(
newOrderDetailOperation
));
}
}
try
{
final
var
orgionalOrderDetailOperation
=
OrderDetailOperationDto
.
builder
()
.
id
(
orgionalDetail
.
getId
())
.
skuId
(
orgionalDetail
.
getSkuId
())
...
...
@@ -344,10 +334,7 @@ public class OrderServiceRpcClient {
.
adjustSkuRemark
(
orgionalDetail
.
getAdjustSkuRemark
())
.
serveStatus
(
orgionalDetail
.
getServeStatus
().
name
())
.
build
();
orgionalDetailStr
=
objectMapper
.
writeValueAsString
(
List
.
of
(
orgionalOrderDetailOperation
));
}
catch
(
JsonProcessingException
e
)
{
log
.
error
(
"orderDetail json 转换失败"
);
}
orgionalDetailStr
=
JsonUtil
.
writeAsJson
(
List
.
of
(
orgionalOrderDetailOperation
));
final
var
operation
=
SingleOperationDto
.
builder
()
.
orderId
(
orgionalDetail
.
getOrderId
())
.
shouldCreateAdjustOrderDetailJson
(
true
)
...
...
@@ -450,7 +437,7 @@ public class OrderServiceRpcClient {
public
CreateOrderResponse
createOrder
(
CreateOrderDto
createOrderDto
)
{
final
var
orderDetails
=
new
ArrayList
<
ClientCustomerOrderDetailCreation
>();
for
(
CreateOrderDetailDto
orderDetailDto
:
createOrderDto
.
getOrderDetailDtos
())
{
for
(
CreateOrderDetailDto
orderDetailDto
:
createOrderDto
.
getOrderDetailDtos
())
{
final
var
mealDetail
=
MealDetail
.
newBuilder
()
.
setBasicMaterials
(
orderDetailDto
.
getMealDetailJson
().
getBasicMaterials
())
.
addAllTastes
(
orderDetailDto
.
getMealDetailJson
().
getTastes
())
...
...
src/main/java/com/infoloop/tianting/service/client/PayServiceClient.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.fasterxml.jackson.core.JsonParser.Feature
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.MapperFeature
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.PropertyNamingStrategy
;
import
com.infoloop.tianting.config.BusinessConfig
;
...
...
@@ -13,13 +11,15 @@ import com.infoloop.tianting.utils.DateUtil;
import
com.infoloop.tianting.utils.EncryptionUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.time.LocalDateTime
;
...
...
@@ -29,54 +29,63 @@ import java.time.LocalDateTime;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
PayServiceClient
{
private
final
OkHttpClient
client
=
new
OkHttpClient
();
private
final
RestTemplate
restTemplate
;
private
final
BusinessConfig
businessConfig
;
private
final
ObjectMapper
objectMapper
;
@Value
(
"${payment.client-id:Order0001}"
)
private
String
clientId
;
public
PayResponseDto
payInform
(
PayInformRequestDto
payRequestDto
)
{
try
{
String
url
=
businessConfig
.
getPayUrl
();
String
clientId
=
"Order0001"
;
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
requestDate
=
DateUtil
.
formatDate
(
LocalDateTime
.
now
(),
DateUtil
.
YMDHMS
);
ThirdPartyPayInformRequestDto
jsonData
=
buildRequestData
(
payRequestDto
,
requestDate
);
String
jsonDataString
;
try
{
objectMapper
.
setPropertyNamingStrategy
(
PropertyNamingStrategy
.
UPPER_CAMEL_CASE
);
jsonDataString
=
objectMapper
.
writeValueAsString
(
jsonData
);
}
catch
(
JsonProcessingException
e
)
{
log
.
error
(
"Failed to serialize request data"
,
e
);
throw
new
IllegalArgumentException
(
"支付通知失败: JSON 解析错误"
);
}
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
jsonDataString
,
createHeaders
());
log
.
info
(
"payInform request: {}"
,
jsonDataString
);
ResponseEntity
<
PayResponseDto
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
PayResponseDto
.
class
);
return
processResponse
(
responseEntity
);
}
private
ThirdPartyPayInformRequestDto
buildRequestData
(
PayInformRequestDto
payRequestDto
,
String
requestDate
)
{
ThirdPartyPayInformRequestDto
jsonData
=
new
ThirdPartyPayInformRequestDto
();
jsonData
.
setClientId
(
clientId
);
jsonData
.
setTradeId
(
payRequestDto
.
getOrderId
());
//payRequestDto.getOrderId()
String
requestDate
=
DateUtil
.
formatDate
(
LocalDateTime
.
now
(),
DateUtil
.
YMDHMS
);
jsonData
.
setTradeId
(
payRequestDto
.
getOrderId
());
jsonData
.
setRequestDate
(
requestDate
);
jsonData
.
setRequestSource
(
"OFWXApplet"
);
jsonData
.
setPayerOpenId
(
payRequestDto
.
getOpenId
());
jsonData
.
setHospitalCode
(
"AMCAREBJLD"
);
//payRequestDto.getHospitalCode()
jsonData
.
setHospitalCode
(
payRequestDto
.
getHospitalCode
());
jsonData
.
setPID
(
payRequestDto
.
getPhone
());
jsonData
.
setRemark
(
""
);
jsonData
.
setTransAmount
(
payRequestDto
.
getPrice
());
jsonData
.
setTradeDesc
(
""
);
String
signStr
=
EncryptionUtil
.
sha1Encryption
(
clientId
+
payRequestDto
.
getOrderId
()
+
requestDate
+
"Order0001"
);
jsonData
.
setSign
(
signStr
);
String
jsonDataString
=
objectMapper
.
writeValueAsString
(
jsonData
);
// 设置请求体的媒体类型为JSON
MediaType
mediaType
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
jsonDataString
);
Request
getPhoneRequest
=
new
Request
.
Builder
()
.
url
(
url
)
.
post
(
body
)
.
build
();
log
.
info
(
"payInform json:{}"
,
jsonDataString
);
Response
payResponse
=
client
.
newCall
(
getPhoneRequest
).
execute
();
if
(
payResponse
.
code
()
!=
200
||
payResponse
.
body
()
==
null
)
{
log
.
error
(
"payInform response:{}"
,
payResponse
);
throw
new
IllegalArgumentException
(
"支付通知失败"
);
jsonData
.
setSign
(
EncryptionUtil
.
sha1Encryption
(
clientId
+
payRequestDto
.
getOrderId
()
+
requestDate
+
clientId
));
return
jsonData
;
}
private
HttpHeaders
createHeaders
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
return
headers
;
}
String
payJsonData
=
payResponse
.
body
().
string
();
log
.
info
(
"pay json:{}"
,
payJsonData
);
ObjectMapper
objectMapper2
=
new
ObjectMapper
();
objectMapper2
.
configure
(
Feature
.
ALLOW_MISSING_VALUES
,
true
);
objectMapper2
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
objectMapper2
.
configure
(
MapperFeature
.
ACCEPT_CASE_INSENSITIVE_VALUES
,
false
);
return
objectMapper2
.
readValue
(
payJsonData
,
PayResponseDto
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"payInform error"
,
e
);
private
PayResponseDto
processResponse
(
ResponseEntity
<
PayResponseDto
>
responseEntity
)
{
if
(!
responseEntity
.
getStatusCode
().
is2xxSuccessful
()
||
responseEntity
.
getBody
()
==
null
)
{
log
.
error
(
"payInform failed with response: {}"
,
responseEntity
.
getBody
());
throw
new
IllegalArgumentException
(
"支付通知失败"
);
}
log
.
info
(
"payInform response: {}"
,
responseEntity
.
getBody
());
return
responseEntity
.
getBody
();
}
public
void
callback
(
PayInformRequestDto
payInformRequestDto
)
{
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/SkuServiceRpcClient.java
View file @
c06206b
...
...
@@ -2,23 +2,23 @@ package com.infoloop.tianting.service.client;
import
com.infoloop.tianting.GeDishSkuByIdsRpcResponse
;
import
com.infoloop.tianting.GetSkusByIdsRpcRequest
;
import
com.infoloop.tianting.GetSkusByIdsRpcResponse
;
import
com.infoloop.tianting.SkuServiceProtoRpcGrpc
;
import
java.util.List
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
SkuServiceRpcClient
{
private
final
SkuServiceProtoRpcGrpc
.
SkuServiceProtoRpcBlockingStub
skuServiceProtoRpcBlockingStub
;
public
GeDishSkuByIdsRpcResponse
getDishSkusByIds
(
List
<
Integer
>
ids
)
{
public
GeDishSkuByIdsRpcResponse
getDishSkusByIds
(
List
<
Integer
>
ids
)
{
final
var
request
=
GetSkusByIdsRpcRequest
.
newBuilder
()
.
addAllIds
(
ids
)
.
setIncludeDeleted
(
false
)
.
build
();
final
var
res
=
skuServiceProtoRpcBlockingStub
.
getDishSkusByIds
(
request
);
return
res
;
}
return
skuServiceProtoRpcBlockingStub
.
getDishSkusByIds
(
request
);
}
}
...
...
src/main/java/com/infoloop/tianting/service/client/WOperatorServiceRpcClient.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.tianting.COperatorServiceProtoRpcGrpc
;
import
com.infoloop.tianting.GetWOperatorByEmailRpcRequest
;
import
com.infoloop.tianting.GetWOperatorByEmailRpcResponse
;
import
com.infoloop.tianting.GetWOperatorByIdRpcRequest
;
...
...
@@ -14,8 +13,7 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
WOperatorServiceRpcClient
{
private
final
WOperatorServiceProtoRpcGrpc
.
WOperatorServiceProtoRpcBlockingStub
wOperatorServiceProtoRpcBlockingStub
;
private
final
WOperatorServiceProtoRpcGrpc
.
WOperatorServiceProtoRpcBlockingStub
wOperatorServiceProtoRpcBlockingStub
;
public
GetWOperatorByEmailRpcResponse
getWOperatorByEmail
(
String
email
)
{
final
var
request
=
GetWOperatorByEmailRpcRequest
.
newBuilder
()
...
...
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramClient.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserCodeDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserTokenDto
;
import
lombok.RequiredArgsConstructor
;
import
okhttp3.MediaType
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MINI_PROGRAM_APP_ID
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MINI_PROGRAM_APP_SECRET
;
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
WxMiniProgramClient
{
@Value
(
MINI_PROGRAM_APP_ID
)
private
String
appId
;
@Value
(
MINI_PROGRAM_APP_SECRET
)
private
String
appSecret
;
private
final
OkHttpClient
client
=
new
OkHttpClient
();
public
WxUserPhoneResponseDto
getUserPhoneInfoByCode
(
String
code
)
{
try
{
String
getTokenUrl
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+
appId
+
"&secret="
+
appSecret
;
Request
getTokenRequest
=
new
Request
.
Builder
()
.
url
(
getTokenUrl
)
.
build
();
Response
getTokenResponse
=
client
.
newCall
(
getTokenRequest
).
execute
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
String
tokenJsonData
=
getTokenResponse
.
body
().
string
();
WxUserTokenDto
wxUserTokenDto
=
objectMapper
.
readValue
(
tokenJsonData
,
WxUserTokenDto
.
class
);
String
getPhoneUrl
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token="
+
wxUserTokenDto
.
getAccess_token
();
WxUserCodeDto
jsonData
=
new
WxUserCodeDto
();
jsonData
.
setCode
(
code
);
String
jsonDataString
=
objectMapper
.
writeValueAsString
(
jsonData
);
MediaType
mediaType
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
RequestBody
body
=
RequestBody
.
create
(
mediaType
,
jsonDataString
);
Request
getPhoneRequest
=
new
Request
.
Builder
()
.
url
(
getPhoneUrl
)
.
post
(
body
)
.
build
();
Response
getPhoneResponse
=
client
.
newCall
(
getPhoneRequest
).
execute
();
String
phoneJsonData
=
getPhoneResponse
.
body
().
string
();
WxUserPhoneResponseDto
wxUserPhoneResponseDto
=
objectMapper
.
readValue
(
phoneJsonData
,
WxUserPhoneResponseDto
.
class
);
return
wxUserPhoneResponseDto
;
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
"获取用户手机号失败"
);
}
}
public
WxUserOpenIdDto
getUserOpenIdByCode
(
String
code
)
{
try
{
String
url
=
"https://api.weixin.qq.com/sns/jscode2session"
+
"?appid="
+
appId
+
"&secret="
+
appSecret
+
"&js_code="
+
code
+
"&grant_type=authorization_code"
;
Request
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
build
();
Response
response
=
client
.
newCall
(
request
).
execute
();
String
jsonData
=
response
.
body
().
string
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
return
objectMapper
.
readValue
(
jsonData
,
WxUserOpenIdDto
.
class
);
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
"获取用户openid失败"
);
}
}
}
src/main/java/com/infoloop/tianting/service/client/WxMiniProgramHttpClient.java
0 → 100644
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
client
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserTokenDto
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MINI_PROGRAM_APP_ID
;
import
static
com
.
infoloop
.
tianting
.
constant
.
ConfigConstants
.
MINI_PROGRAM_APP_SECRET
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
WxMiniProgramHttpClient
{
private
static
final
String
TOKEN_URL
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appId}&secret={appSecret}"
;
private
static
final
String
PHONE_URL
=
"https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={accessToken}"
;
private
final
RestTemplate
restTemplate
;
@Value
(
MINI_PROGRAM_APP_ID
)
private
String
appId
;
@Value
(
MINI_PROGRAM_APP_SECRET
)
private
String
appSecret
;
public
WxUserPhoneResponseDto
getUserPhoneInfoByCode
(
String
code
)
{
try
{
String
accessToken
=
fetchAccessToken
();
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
Map
<
String
,
Object
>
jsonDataMap
=
new
HashMap
<>();
jsonDataMap
.
put
(
"code"
,
code
);
HttpEntity
<
Map
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
jsonDataMap
,
headers
);
return
fetchPhoneNumber
(
accessToken
,
requestEntity
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error fetching user phone info"
,
e
);
throw
new
IllegalArgumentException
(
"获取用户手机号失败"
);
}
}
private
String
fetchAccessToken
()
{
log
.
info
(
"Fetching WeChat access token..."
);
ResponseEntity
<
WxUserTokenDto
>
tokenResponse
=
restTemplate
.
getForEntity
(
TOKEN_URL
,
WxUserTokenDto
.
class
,
appId
,
appSecret
);
if
(!
tokenResponse
.
getStatusCode
().
is2xxSuccessful
()
||
tokenResponse
.
getBody
()
==
null
)
{
log
.
error
(
"Failed to fetch access token: {}"
,
tokenResponse
);
throw
new
IllegalArgumentException
(
"获取 access_token 失败"
);
}
String
accessToken
=
tokenResponse
.
getBody
().
getAccess_token
();
log
.
info
(
"WeChat access token received: {}"
,
accessToken
);
return
accessToken
;
}
private
WxUserPhoneResponseDto
fetchPhoneNumber
(
String
accessToken
,
HttpEntity
<
Map
<
String
,
Object
>>
requestEntity
)
{
log
.
info
(
"Fetching phone number..."
);
ResponseEntity
<
WxUserPhoneResponseDto
>
phoneResponse
=
restTemplate
.
exchange
(
PHONE_URL
,
HttpMethod
.
POST
,
requestEntity
,
WxUserPhoneResponseDto
.
class
,
accessToken
);
if
(!
phoneResponse
.
getStatusCode
().
is2xxSuccessful
()
||
phoneResponse
.
getBody
()
==
null
)
{
log
.
error
(
"Failed to fetch phone number: {}"
,
phoneResponse
);
throw
new
IllegalArgumentException
(
"获取手机号失败"
);
}
log
.
info
(
"WeChat phone number response: {}"
,
phoneResponse
.
getBody
());
return
phoneResponse
.
getBody
();
}
public
WxUserOpenIdDto
getUserOpenIdByCode
(
String
code
)
{
try
{
final
var
url
=
"https://api.weixin.qq.com/sns/jscode2session"
+
"?appid="
+
appId
+
"&secret="
+
appSecret
+
"&js_code="
+
code
+
"&grant_type=authorization_code"
;
final
var
response
=
restTemplate
.
getForEntity
(
url
,
WxUserOpenIdDto
.
class
);
return
response
.
getBody
();
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
"获取用户openid失败"
);
}
}
}
src/main/java/com/infoloop/tianting/service/impl/ClientCustomerServiceImpl.java
View file @
c06206b
package
com
.
infoloop
.
tianting
.
service
.
impl
;
import
com.fasterxml.jackson.annotation.JacksonInject.Value
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse
;
import
com.infoloop.tianting.context.LoginContextHolder
;
import
com.infoloop.tianting.menuservice.SingleClientCustomerMenuRefRpcResponse
;
import
com.infoloop.tianting.menuservice.SingleMenuRpcResponse
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto
;
import
com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto
;
...
...
@@ -26,19 +24,16 @@ import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient;
import
com.infoloop.tianting.service.client.MenuServiceRpcClient
;
import
com.infoloop.tianting.service.client.OrderServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.Objects
;
import
java.util.Set
;
import
javax.mail.search.SearchTerm
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
@Slf4j
...
...
@@ -317,7 +312,8 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
List
<
CurrentClientCustomerDto
>
currentCustomers
=
new
ArrayList
<>();
List
<
Integer
>
customerIds
=
new
ArrayList
<>();
currentCustomers
=
clientCustomerServiceHttpClient
.
getCurrentClientCustomer
(
token
,
false
);
customerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
map
(
id
->
{
try
{
customerIds
=
currentCustomers
.
stream
().
map
(
CurrentClientCustomerDto:
:
getId
).
map
(
id
->
{
try
{
return
Integer
.
valueOf
(
id
);
}
catch
(
NumberFormatException
e
)
{
return
null
;
...
...
@@ -364,7 +360,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
final
var
notOrderCustomers
=
currentCustomers
.
stream
().
filter
(
c
->
notOrderedCustomerIds
.
contains
(
Integer
.
valueOf
(
c
.
getId
()))).
collect
(
Collectors
.
toList
());
for
(
CurrentClientCustomerDto
notOrderCustomer
:
notOrderCustomers
)
{
for
(
CurrentClientCustomerDto
notOrderCustomer
:
notOrderCustomers
)
{
// 在ref里找到这个用户的menu ids
final
var
notOrderCustomerId
=
Integer
.
valueOf
(
notOrderCustomer
.
getId
());
...
...
@@ -477,7 +473,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
final
var
notOrderCustomers
=
currentClientCustomers
.
stream
().
filter
(
c
->
notOrderedCustomerIds
.
contains
(
c
.
getId
())).
collect
(
Collectors
.
toList
());
for
(
SingleClientCustomerRpcResponse
notOrderCustomer
:
notOrderCustomers
)
{
for
(
SingleClientCustomerRpcResponse
notOrderCustomer
:
notOrderCustomers
)
{
// 在ref里找到这个用户的menu ids
final
var
notOrderCustomerId
=
Integer
.
valueOf
(
notOrderCustomer
.
getId
());
...
...
@@ -535,7 +531,7 @@ public class ClientCustomerServiceImpl implements ClientCustomerService {
resNotOrderCustomers
.
add
(
resNotOrderCustomer
);
}
for
(
CurrentClientCustomerDto
currentClientCustomer
:
notOrderedHisCustomers
)
{
for
(
CurrentClientCustomerDto
currentClientCustomer
:
notOrderedHisCustomers
)
{
final
var
resNotOrderCustomer
=
NotOrderCustomerDto
.
builder
()
.
id
(
currentClientCustomer
.
getId
())
.
name
(
currentClientCustomer
.
getName
())
...
...
src/main/java/com/infoloop/tianting/service/impl/InventoryServiceImpl.java
View file @
c06206b
...
...
@@ -3,17 +3,17 @@ package com.infoloop.tianting.service.impl;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto
;
import
com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto
;
import
com.infoloop.tianting.model.dto.MenuDbDTO.MenuDetailDto
;
import
com.infoloop.tianting.service.InventoryService
;
import
com.infoloop.tianting.service.client.InventoryServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
src/main/java/com/infoloop/tianting/service/impl/KdsServiceImpl.java
View file @
c06206b
...
...
@@ -17,28 +17,24 @@ 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
;
import
com.infoloop.tianting.service.client.SkuServiceRpcClient
;
import
com.infoloop.tianting.service.client.WOperatorServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
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
@Service
...
...
@@ -124,16 +120,16 @@ public class KdsServiceImpl implements KdsService {
final
var
skus
=
skuServiceRpcClient
.
getDishSkusByIds
(
skuIds
).
getResponseList
();
List
<
KdsOrderSkuDto
>
kdsOrderSkuList
=
new
ArrayList
<>();
for
(
Integer
menuDetailId
:
menuDetailIds
)
{
for
(
Integer
menuDetailId
:
menuDetailIds
)
{
// 找出该menuDetailId 的所有orderDetail
final
var
curOrderDetails
=
filteredOrderDetailList
.
stream
()
.
filter
(
d
->
d
.
getMenuDetailId
()
==
menuDetailId
)
.
filter
(
d
->
d
.
getMenuDetailId
()
==
menuDetailId
)
.
collect
(
Collectors
.
toList
());
final
var
totalCount
=
curOrderDetails
.
stream
()
.
mapToInt
(
SingleClientCustomerOrderDetailRpcResponse:
:
getCount
)
.
sum
();
List
<
KdsOrderSkuDetailDto
>
kdsOrders
=
new
ArrayList
<>();
for
(
SingleClientCustomerOrderDetailRpcResponse
detail
:
curOrderDetails
)
{
for
(
SingleClientCustomerOrderDetailRpcResponse
detail
:
curOrderDetails
)
{
final
var
order
=
orderList
.
stream
()
.
filter
(
o
->
o
.
getId
()
==
detail
.
getOrderId
())
.
findFirst
();
...
...
@@ -162,7 +158,7 @@ public class KdsServiceImpl implements KdsService {
.
filter
(
c
->
c
.
getId
()
==
order
.
get
().
getCustomerId
())
.
findFirst
();
CustomerDetailDto
customer
=
CustomerDetailDto
.
builder
().
build
();
if
(
optionalCustomer
.
isPresent
())
{
if
(
optionalCustomer
.
isPresent
())
{
customer
=
CustomerDetailDto
.
builder
()
.
id
(
optionalCustomer
.
get
().
getId
())
.
phone
(
optionalCustomer
.
get
().
getMobile
())
...
...
@@ -207,9 +203,7 @@ public class KdsServiceImpl implements KdsService {
.
orderList
(
kdsOrders
)
.
build
();
kdsOrderSkuList
.
add
(
kdsOrderSku
);
}
return
kdsOrderSkuList
;
}
...
...
@@ -260,10 +254,10 @@ public class KdsServiceImpl implements KdsService {
final
var
allMeals
=
mealServiceRpcClient
.
getAllMeals
(
operatorLoginInfo
.
getEnterpriseId
()).
getResponsesList
();
List
<
KdsMealDetailDto
>
kdsMealDetailDtoList
=
new
ArrayList
<>();
for
(
Integer
mealId
:
mealIds
)
{
for
(
Integer
mealId
:
mealIds
)
{
final
var
meal
=
allMeals
.
stream
().
filter
(
m
->
m
.
getId
()
==
mealId
).
findFirst
();
String
mealName
=
"无餐别"
;
if
(
meal
.
isEmpty
()
&&
mealId
!=
0
)
{
if
(
meal
.
isEmpty
()
&&
mealId
!=
0
)
{
continue
;
}
if
(
meal
.
isPresent
())
{
...
...
@@ -353,9 +347,9 @@ public class KdsServiceImpl implements KdsService {
List
<
KdsOrderLocationDto
>
kdsOrderLocationList
=
new
ArrayList
<>();
for
(
SingleClientCustomerOrderRpcResponse
order
:
orderList
)
{
for
(
SingleClientCustomerOrderRpcResponse
order
:
orderList
)
{
final
var
curOrderDetails
=
filteredOrderDetailList
.
stream
()
.
filter
(
d
->
d
.
getOrderId
()
==
order
.
getId
())
.
filter
(
d
->
d
.
getOrderId
()
==
order
.
getId
())
.
collect
(
Collectors
.
toList
());
final
var
kdsOrderDetails
=
curOrderDetails
.
stream
().
map
(
od
->
KdsOrderLocationDetailDto
.
builder
()
...
...
@@ -396,7 +390,7 @@ public class KdsServiceImpl implements KdsService {
.
filter
(
c
->
c
.
getId
()
==
order
.
getCustomerId
())
.
findFirst
();
CustomerDetailDto
customer
=
CustomerDetailDto
.
builder
().
build
();
if
(
optionalCustomer
.
isPresent
())
{
if
(
optionalCustomer
.
isPresent
())
{
customer
=
CustomerDetailDto
.
builder
()
.
id
(
optionalCustomer
.
get
().
getId
())
.
phone
(
optionalCustomer
.
get
().
getMobile
())
...
...
src/main/java/com/infoloop/tianting/service/impl/LoginServiceImpl.java
View file @
c06206b
...
...
@@ -3,21 +3,16 @@ package com.infoloop.tianting.service.impl;
import
cn.dev33.satoken.stp.SaLoginModel
;
import
cn.dev33.satoken.stp.SaTokenInfo
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.infoloop.tianting.COperatorServiceProtoRpcGrpc
;
import
com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum
;
import
com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcRequest
;
import
com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse
;
import
com.infoloop.tianting.constant.CommonConstants
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
import
com.infoloop.tianting.exception.ErrorCodeEnum
;
import
com.infoloop.tianting.model.dto.PermissionDTO.LoginDto
;
import
com.infoloop.tianting.service.ClientCustomerService
;
import
com.infoloop.tianting.service.LoginService
;
import
com.infoloop.tianting.service.WxMiniProgramService
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient
;
import
com.infoloop.tianting.service.client.OperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.WOperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.WxMiniProgramClient
;
import
com.infoloop.tianting.service.client.WxMiniProgram
Http
Client
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -30,13 +25,13 @@ public class LoginServiceImpl implements LoginService {
private
final
ClientCustomerServiceRpcClient
clientCustomerServiceRpcClient
;
private
final
OperatorServiceRpcClient
operatorServiceRpcClient
;
private
final
WxMiniProgramClient
wxMiniProgram
Client
;
private
final
WxMiniProgramHttpClient
wxMiniProgramHttp
Client
;
private
final
WOperatorServiceRpcClient
wOperatorServiceRpcClient
;
@Override
public
SaTokenInfo
login
(
LoginDto
loginDto
)
{
if
(
loginDto
.
isShouldLoginWithOpenCode
())
{
final
var
wxUserOpenIdDto
=
wxMiniProgram
Client
.
getUserOpenIdByCode
(
loginDto
.
getOpenCode
());
final
var
wxUserOpenIdDto
=
wxMiniProgramHttp
Client
.
getUserOpenIdByCode
(
loginDto
.
getOpenCode
());
StpUtil
.
login
(
wxUserOpenIdDto
.
getOpenid
(),
SaLoginModel
.
create
()
...
...
@@ -68,8 +63,6 @@ public class LoginServiceImpl implements LoginService {
ErrorCodeEnum
.
VALIDATE_FAILED
.
name
());
}
}
}
else
{
}
StpUtil
.
login
(
customer
.
getId
(),
...
...
src/main/java/com/infoloop/tianting/service/impl/MealServiceImpl.java
View file @
c06206b
...
...
@@ -5,14 +5,14 @@ import com.infoloop.tianting.model.dto.MealDbDTO.MealDto;
import
com.infoloop.tianting.service.MealService
;
import
com.infoloop.tianting.service.client.MealServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.sql.DataTruncation
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
src/main/java/com/infoloop/tianting/service/impl/MeiZhongYiHeServiceImpl.java
View file @
c06206b
...
...
@@ -5,14 +5,15 @@ import com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto;
import
com.infoloop.tianting.service.MeiZhongYiHeService
;
import
com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
@@ -36,10 +37,10 @@ public class MeiZhongYiHeServiceImpl implements MeiZhongYiHeService {
}
@Override
public
List
<
HisMedicalAdviceDto
>
getHisCustomerMedicalAdvicesByContractNo
(
String
contractNo
)
{
public
List
<
HisMedicalAdviceDto
>
getHisCustomerMedicalAdvicesByContractNo
(
String
contractNo
)
{
final
var
response
=
meiZhongYiHeServiceClient
.
getHisCustomerMedicalAdvicesByContractNo
(
contractNo
);
if
(
response
.
getCustomerMedicalAdvicesCount
()
==
0
)
{
if
(
response
.
getCustomerMedicalAdvicesCount
()
==
0
)
{
return
new
ArrayList
<>();
}
return
response
.
getCustomerMedicalAdvices
(
0
).
getMedicalAdvicesList
().
stream
().
map
(
...
...
src/main/java/com/infoloop/tianting/service/impl/MenuServiceImpl.java
View file @
c06206b
...
...
@@ -10,13 +10,14 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson;
import
com.infoloop.tianting.service.MenuService
;
import
com.infoloop.tianting.service.client.MenuServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
@@ -25,9 +26,7 @@ public class MenuServiceImpl implements MenuService {
private
final
MenuServiceRpcClient
menuServiceRpcClient
;
@Override
public
List
<
MenuDto
>
queryMiniProgramPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
public
List
<
MenuDto
>
queryMiniProgramPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
final
var
response
=
menuServiceRpcClient
.
queryMiniProgramPublishedMenusByStallId
(
enterpriseId
,
stallId
);
return
response
.
getResponsesList
().
stream
().
map
(
menu
->
...
...
@@ -69,7 +68,6 @@ public class MenuServiceImpl implements MenuService {
@Override
public
List
<
MenuDto
>
queryPublishedMenusByStallId
(
Integer
enterpriseId
,
Integer
stallId
)
{
final
var
response
=
menuServiceRpcClient
.
queryPublishedMenusByStallId
(
enterpriseId
,
stallId
);
return
response
.
getResponsesList
().
stream
().
map
(
menu
->
...
...
src/main/java/com/infoloop/tianting/service/impl/OrderServiceImpl.java
View file @
c06206b
...
...
@@ -4,7 +4,6 @@ import com.infoloop.rpc.meizhongyiheservice.MedicalAdviceTypeEnum;
import
com.infoloop.tianting.SingleResponse
;
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
;
...
...
@@ -20,12 +19,10 @@ import com.infoloop.tianting.menuservice.CloseTimeTypeEnum;
import
com.infoloop.tianting.menuservice.ModeOfPaymentEnum
;
import
com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse
;
import
com.infoloop.tianting.model.common.OrderPageResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto
;
import
com.infoloop.tianting.model.dto.ClientLabelDTO.QueryLabelsDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.BatchUpdateOrderDetailResponse
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.getMenuOrderCountDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDetailDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.CreateOrderResponse
;
...
...
@@ -43,29 +40,27 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto;
import
com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByPaginationDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderDto
;
import
com.infoloop.tianting.model.dto.OrderDbDTO.UpdateOrderResponse
;
import
com.infoloop.tianting.
service.ClientCustomerService
;
import
com.infoloop.tianting.
model.dto.OrderDbDTO.getMenuOrderCountDto
;
import
com.infoloop.tianting.service.MeiZhongYiHeService
;
import
com.infoloop.tianting.service.OrderService
;
import
com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient
;
import
com.infoloop.tianting.service.client.DeliveryRuleServiceRpcClient
;
import
com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient
;
import
com.infoloop.tianting.service.client.MenuServiceRpcClient
;
import
com.infoloop.tianting.service.client.OperatorServiceRpcClient
;
import
com.infoloop.tianting.service.client.OrderServiceRpcClient
;
import
com.infoloop.tianting.service.client.SkuServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
com.infoloop.tianting.utils.PageUtil
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
...
...
@@ -123,7 +118,7 @@ public class OrderServiceImpl implements OrderService {
createOrderDto
.
setEnterpriseId
(
operatorLoginInfo
.
getEnterpriseId
());
// createOrderDto.setStallId();
var
onlinePay
=
false
;
if
(
menu
.
getOrderRuleJson
().
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
)
{
if
(
menu
.
getOrderRuleJson
().
getModeOfPayment
()
==
ModeOfPaymentEnum
.
ONLINE
)
{
onlinePay
=
true
;
}
createOrderDto
.
setOnlinePay
(
onlinePay
);
...
...
@@ -177,10 +172,10 @@ public class OrderServiceImpl implements OrderService {
.
collect
(
Collectors
.
toList
());
final
var
rpcSkus
=
skuServiceRpcClient
.
getDishSkusByIds
(
skuIds
).
getResponseList
();
Integer
totalSkuCount
=
0
;
for
(
OperatorCreateOrderDetailDto
orderDetail
:
operatorCreateOrderDto
.
getOrderDetailDtos
())
{
for
(
OperatorCreateOrderDetailDto
orderDetail
:
operatorCreateOrderDto
.
getOrderDetailDtos
())
{
totalSkuCount
+=
orderDetail
.
getCount
();
final
var
optionalTargetMenuDetail
=
menuDetails
.
stream
().
filter
(
detail
->
detail
.
getId
()
==
orderDetail
.
getMenuDetailId
()).
findFirst
();
if
(
optionalTargetMenuDetail
.
isEmpty
())
{
if
(
optionalTargetMenuDetail
.
isEmpty
())
{
continue
;
}
final
var
optionalSku
=
rpcSkus
.
stream
().
filter
(
sku
->
sku
.
getId
()
==
optionalTargetMenuDetail
.
get
().
getSkuId
()).
findFirst
();
...
...
@@ -258,13 +253,13 @@ public class OrderServiceImpl implements OrderService {
.
mealTimeEnd
(
mealTimeEnd
)
.
shouldFilterMenuId
(
true
)
.
menuId
(
checkIfOrdered
.
getMenuId
())
.
shouldFilterCustomerIds
(
checkIfOrdered
.
getCustomerId
().
equals
(
0
)?
false
:
true
)
.
shouldFilterCustomerIds
(!
checkIfOrdered
.
getCustomerId
().
equals
(
0
)
)
.
customerIds
(
List
.
of
(
checkIfOrdered
.
getCustomerId
()))
.
shouldFilterOpenId
(
checkIfOrdered
.
getOpenId
().
isEmpty
()?
false
:
true
)
.
shouldFilterOpenId
(!
checkIfOrdered
.
getOpenId
().
isEmpty
()
)
.
openId
(
checkIfOrdered
.
getOpenId
())
.
build
();
final
var
orderList
=
orderServiceRpcClient
.
getOrdersByCondition
(
queryOrderDto
);
final
var
filteredOrderList
=
orderList
.
stream
().
filter
(
o
->
o
.
getStatus
()
!=
OrderStatusEnum
.
ORDER_CANCELED
).
collect
(
Collectors
.
toList
());
final
var
filteredOrderList
=
orderList
.
stream
().
filter
(
o
->
o
.
getStatus
()
!=
OrderStatusEnum
.
ORDER_CANCELED
).
collect
(
Collectors
.
toList
());
return
filteredOrderList
.
size
();
}
...
...
src/main/java/com/infoloop/tianting/service/impl/SettlementServiceImpl.java
View file @
c06206b
This diff is collapsed. Click to expand it.
src/main/java/com/infoloop/tianting/service/impl/SkuServiceImpl.java
View file @
c06206b
...
...
@@ -6,14 +6,14 @@ import com.infoloop.tianting.model.dto.SkuDbDTO.SkuSpecialDetailSingleResponseDt
import
com.infoloop.tianting.service.SkuService
;
import
com.infoloop.tianting.service.client.SkuServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
lombok.Data
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
...
...
@@ -52,6 +52,7 @@ public class SkuServiceImpl implements SkuService {
Collectors
.
toList
()))
.
allergyList
(
sku
.
getAllergiesList
().
stream
().
map
(
allergy
->
SkuSpecialDetailSingleResponseDto
.
builder
().
id
(
allergy
.
getId
()).
name
(
allergy
.
getName
()).
build
()).
collect
(
Collectors
.
toList
()))
.
cecommendList
(
sku
.
getCecommendsList
().
stream
().
map
(
cecommend
->
SkuDetailSingleResponseDto
.
builder
().
id
(
cecommend
.
getId
()).
name
(
cecommend
.
getName
()).
build
()).
collect
(
Collectors
.
toList
()))
.
build
()
).
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/infoloop/tianting/service/impl/TestServiceImpl.java
deleted
100644 → 0
View file @
17248b2
package
com
.
infoloop
.
tianting
.
service
.
impl
;
import
com.infoloop.tianting.exception.ClientEndExceptions
;
import
com.infoloop.tianting.exception.ErrorCodeEnum
;
import
com.infoloop.tianting.model.common.CreatedResult
;
import
com.infoloop.tianting.model.common.PageResult
;
import
com.infoloop.tianting.model.create.TestExampleDbCreate
;
import
com.infoloop.tianting.model.dto.TestExampleDbDTO
;
import
com.infoloop.tianting.model.query.TestExampleDbQuery
;
import
com.infoloop.tianting.model.update.TestExampleDbUpdate
;
import
com.infoloop.tianting.model.vo.TestExampleDbVO
;
import
com.infoloop.tianting.service.TestService
;
import
com.infoloop.tianting.service.client.ExampleServiceRpcClient
;
import
com.infoloop.tianting.utils.DateUtil
;
import
com.infoloop.tianting.utils.PageUtil
;
import
com.tianting.infoloop.grpc.exampleservice.SingleTestExampleDbRpcResponse
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.validation.Valid
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
TestServiceImpl
implements
TestService
{
private
final
ExampleServiceRpcClient
exampleServiceRpcClient
;
@Override
public
PageResult
<
TestExampleDbVO
>
queryPage
(
TestExampleDbDTO
.
@Valid
QueryPage
queryPage
)
{
TestExampleDbQuery
query
=
TestExampleDbQuery
.
builder
()
.
name
(
queryPage
.
getName
())
.
status
(
queryPage
.
getStatus
())
.
build
();
final
var
response
=
exampleServiceRpcClient
.
queryTestExampleDbByPagination
(
queryPage
.
getPageInfo
(),
query
);
final
var
results
=
response
.
getResponsesList
().
stream
().
map
(
e
->
TestExampleDbVO
.
builder
()
.
id
(
e
.
getId
())
.
name
(
e
.
getName
())
.
status
(
e
.
getStatus
())
.
createdAt
(
DateUtil
.
formatDate
(
e
.
getCreatedAt
()))
.
updatedAt
(
DateUtil
.
formatDate
(
e
.
getUpdatedAt
()))
.
build
()).
collect
(
Collectors
.
toList
());
return
PageUtil
.
from
(
results
,
response
.
getTotal
(),
response
.
getPages
(),
queryPage
.
getPageInfo
().
getPageNo
(),
queryPage
.
getPageInfo
().
getPageSize
());
}
@Override
public
List
<
TestExampleDbVO
>
queryAll
()
{
final
var
responseList
=
exampleServiceRpcClient
.
getAllTestExampleDb
();
return
responseList
.
stream
().
map
(
e
->
TestExampleDbVO
.
builder
()
.
id
(
e
.
getId
())
.
name
(
e
.
getName
())
.
status
(
e
.
getStatus
())
.
createdAt
(
DateUtil
.
formatDate
(
e
.
getCreatedAt
()))
.
updatedAt
(
DateUtil
.
formatDate
(
e
.
getUpdatedAt
()))
.
build
()).
collect
(
Collectors
.
toList
());
}
@Override
public
CreatedResult
<
TestExampleDbVO
>
createTestExampleDb
(
TestExampleDbDTO
.
CreateTestExampleDb
createTestExampleDb
)
{
final
var
create
=
TestExampleDbCreate
.
builder
()
.
name
(
createTestExampleDb
.
getName
())
.
status
(
createTestExampleDb
.
getStatus
())
.
build
();
final
var
response
=
exampleServiceRpcClient
.
createTestExampleDb
(
create
);
final
var
testExampleDbVO
=
TestExampleDbVO
.
builder
()
.
id
(
response
.
getId
())
.
name
(
create
.
getName
())
.
status
(
create
.
getStatus
())
//TODO: 其他新增信息
.
build
();
return
CreatedResult
.<
TestExampleDbVO
>
builder
().
isCreated
(
response
.
getIsCreated
()).
id
(
response
.
getId
()).
data
(
testExampleDbVO
).
build
();
}
@Override
public
void
updateTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
,
TestExampleDbDTO
.
UpdateTestExampleDb
updateTestExampleDb
)
{
final
var
update
=
TestExampleDbUpdate
.
builder
()
.
id
(
testExampleDbRpcResponse
.
getId
())
.
name
(
updateTestExampleDb
.
getName
())
.
status
(
updateTestExampleDb
.
getStatus
())
.
build
();
final
var
isUpdated
=
exampleServiceRpcClient
.
updateTestExampleDb
(
update
);
if
(!
isUpdated
)
{
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
UPDATE_DATA_ERROR
);
}
}
@Override
public
void
deleteTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
)
{
final
var
isDeleted
=
exampleServiceRpcClient
.
deleteTestExampleDbByIds
(
List
.
of
(
testExampleDbRpcResponse
.
getId
()));
if
(!
isDeleted
)
{
throw
ClientEndExceptions
.
BusinessException
.
build
(
ErrorCodeEnum
.
DELETE_DATA_ERROR
);
}
}
@Override
public
TestExampleDbVO
getTestExampleDb
(
SingleTestExampleDbRpcResponse
testExampleDbRpcResponse
)
{
// final var testExampleDb = exampleServiceRpcClient.getTestExampleDbById(testExampleDbRpcResponse.getId());
return
TestExampleDbVO
.
builder
()
.
id
(
testExampleDbRpcResponse
.
getId
())
.
name
(
testExampleDbRpcResponse
.
getName
())
.
status
(
testExampleDbRpcResponse
.
getStatus
())
.
createdAt
(
DateUtil
.
formatDate
(
testExampleDbRpcResponse
.
getCreatedAt
()))
.
updatedAt
(
DateUtil
.
formatDate
(
testExampleDbRpcResponse
.
getUpdatedAt
()))
.
build
();
}
}
src/main/java/com/infoloop/tianting/service/impl/WxMiniProgramServiceImpl.java
View file @
c06206b
...
...
@@ -3,7 +3,7 @@ package com.infoloop.tianting.service.impl;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto
;
import
com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto
;
import
com.infoloop.tianting.service.WxMiniProgramService
;
import
com.infoloop.tianting.service.client.WxMiniProgramClient
;
import
com.infoloop.tianting.service.client.WxMiniProgram
Http
Client
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -14,16 +14,16 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
(
onConstructor
=
@__
(
@Autowired
))
public
class
WxMiniProgramServiceImpl
implements
WxMiniProgramService
{
private
final
WxMiniProgramClient
wxMiniProgram
Client
;
private
final
WxMiniProgramHttpClient
wxMiniProgramHttp
Client
;
@Override
public
WxUserOpenIdDto
getWxUserOpenIdByCode
(
String
code
)
{
return
wxMiniProgram
Client
.
getUserOpenIdByCode
(
code
);
return
wxMiniProgramHttp
Client
.
getUserOpenIdByCode
(
code
);
}
@Override
public
WxUserPhoneResponseDto
getUserPhoneInfoByCode
(
String
code
)
{
return
wxMiniProgram
Client
.
getUserPhoneInfoByCode
(
code
);
public
WxUserPhoneResponseDto
getUserPhoneInfoByCode
(
String
code
)
{
return
wxMiniProgramHttp
Client
.
getUserPhoneInfoByCode
(
code
);
}
}
...
...
src/main/proto/ExampleService.proto
deleted
100644 → 0
View file @
17248b2
syntax
=
"proto3"
;
option
java_multiple_files
=
true
;
option
java_package
=
"com.tianting.infoloop.grpc.exampleservice"
;
option
java_outer_classname
=
"ExampleServiceProto"
;
option
objc_class_prefix
=
"OP"
;
package
com
.
tianting.infoloop.grpc.exampleservice
;
service
ExampleServiceRpc
{
rpc
GetTestExampleDbById
(
GetTestExampleDbByIdRpcRequest
)
returns
(
GetTestExampleDbByIdRpcResponse
)
{}
rpc
GetTestExampleDbByIds
(
GetTestExampleDbByIdsRpcRequest
)
returns
(
GetTestExampleDbByIdsRpcResponse
)
{}
rpc
GetAllTestExampleDb
(
GetAllTestExampleDbRpcRequest
)
returns
(
GetAllTestExampleDbRpcResponse
)
{}
rpc
QueryTestExampleDbByCondition
(
QueryTestExampleDbByConditionRpcRequest
)
returns
(
QueryTestExampleDbByConditionRpcResponse
)
{}
rpc
QueryTestExampleDbByPagination
(
QueryTestExampleDbByPaginationRpcRequest
)
returns
(
QueryTestExampleDbByPaginationRpcResponse
)
{}
rpc
CreateTestExampleDb
(
CreateTestExampleDbRpcRequest
)
returns
(
CreateTestExampleDbRpcResponse
)
{}
rpc
BatchCreateTestExampleDb
(
BatchCreateTestExampleDbRpcRequest
)
returns
(
BatchCreateTestExampleDbRpcResponse
)
{}
rpc
UpdateTestExampleDb
(
UpdateTestExampleDbRpcRequest
)
returns
(
UpdateTestExampleDbRpcResponse
)
{}
rpc
BatchUpdateTestExampleDb
(
BatchUpdateTestExampleDbRpcRequest
)
returns
(
BatchUpdateTestExampleDbRpcResponse
)
{}
rpc
DeleteTestExampleDbByIds
(
DeleteTestExampleDbByIdsRpcRequest
)
returns
(
DeleteTestExampleDbRpcResponse
)
{}
}
enum
TestExampleDbStatusEnum
{
STATUS_UNKNOWN
=
0
;
STATUS_ENABLED
=
1
;
STATUS_DISABLED
=
2
;
}
message
SingleTestExampleDbRpcResponse
{
int32
id
=
1
;
int32
enterpriseId
=
2
;
string
name
=
3
;
TestExampleDbStatusEnum
status
=
4
;
int32
createdBy
=
5
;
int64
createdAt
=
6
;
int32
creationSource
=
7
;
int32
updatedBy
=
8
;
int64
updatedAt
=
9
;
int32
updateSource
=
10
;
bool
isDeleted
=
11
;
}
message
GetTestExampleDbByIdRpcRequest
{
int32
id
=
1
;
}
message
GetTestExampleDbByIdRpcResponse
{
SingleTestExampleDbRpcResponse
response
=
1
;
}
message
GetTestExampleDbByIdsRpcRequest
{
repeated
int32
ids
=
1
;
}
message
GetTestExampleDbByIdsRpcResponse
{
repeated
SingleTestExampleDbRpcResponse
responses
=
1
;
}
message
GetAllTestExampleDbRpcRequest
{
}
message
GetAllTestExampleDbRpcResponse
{
repeated
SingleTestExampleDbRpcResponse
responses
=
1
;
}
message
QueryTestExampleDbByConditionRpcRequest
{
optional
string
name
=
1
;
optional
TestExampleDbStatusEnum
status
=
2
;
}
message
QueryTestExampleDbByConditionRpcResponse
{
repeated
SingleTestExampleDbRpcResponse
responses
=
1
;
}
message
QueryTestExampleDbByPaginationRpcRequest
{
optional
string
name
=
1
;
optional
TestExampleDbStatusEnum
status
=
2
;
int32
pageNo
=
3
;
int32
pageSize
=
4
;
}
message
QueryTestExampleDbByPaginationRpcResponse
{
int64
total
=
1
;
int64
pages
=
2
;
repeated
SingleTestExampleDbRpcResponse
responses
=
3
;
}
message
TestExampleDbCreation
{
string
name
=
1
;
TestExampleDbStatusEnum
status
=
2
;
}
message
CreateTestExampleDbRpcRequest
{
TestExampleDbCreation
creation
=
1
;
}
message
CreateTestExampleDbRpcResponse
{
int32
id
=
1
;
bool
isCreated
=
2
;
}
message
BatchCreateTestExampleDbRpcRequest
{
repeated
TestExampleDbCreation
creations
=
1
;
}
message
BatchCreateTestExampleDbRpcResponse
{
repeated
int32
ids
=
1
;
bool
isCreated
=
2
;
}
message
TestExampleDbModification
{
int32
id
=
1
;
optional
string
name
=
2
;
optional
TestExampleDbStatusEnum
status
=
3
;
}
message
UpdateTestExampleDbRpcRequest
{
TestExampleDbModification
modification
=
1
;
}
message
UpdateTestExampleDbRpcResponse
{
bool
isUpdated
=
1
;
}
message
BatchUpdateTestExampleDbRpcRequest
{
repeated
TestExampleDbModification
modifications
=
1
;
}
message
BatchUpdateTestExampleDbRpcResponse
{
bool
isUpdated
=
1
;
}
message
DeleteTestExampleDbByIdsRpcRequest
{
repeated
int32
ids
=
1
;
}
message
DeleteTestExampleDbRpcResponse
{
bool
isDeleted
=
1
;
}
src/main/proto/SkuServiceProtoRpc.proto
View file @
c06206b
...
...
@@ -108,6 +108,7 @@ message SingleDishSkuByIdsRpcResponse {
repeated
SingleSpecialResponse
doctors
=
18
;
// 医嘱
repeated
SingleResponse
avoids
=
19
;
// 忌口
repeated
SingleResponse
skus
=
20
;
// 配料
repeated
SingleResponse
cecommends
=
21
;
//推荐
}
...
...
@@ -323,10 +324,11 @@ message GetPSkuByIdsRpcResponse {
// 1: 标品2: 非标品3: 料箱isInspectionAndQuarantineTINYINT(1) 是否需要检验检疫证 0(false) YES 检验、检疫证
enum
SkuType
{
UNKNOWN_SKU_TYPE
=
0
;
//未知
NOT_SENT_SUPPLIER_QUOTATION_SHEET_SEND_STATUS
=
1
;
//未发送
BEEN_SENT_SUPPLIER_QUOTATION_SHEET_SEND_STATUS
=
2
;
//已发送
}
//报价单发送状态
STANDARD_SKU_TYPE
=
1
;
//标品,常温
UN_STANDARD_SKU_TYPE
=
2
;
//非标品
WAREHOUSE_USE_SKU_TYPE
=
3
;
//仓库用品
ICE_SKU_TYPE
=
4
;
//冻品
}
message
SinglePSkuByIdsRpcResponse
{
string
assistantUnit
=
1
;
...
...
@@ -357,6 +359,8 @@ message SinglePSkuByIdsRpcResponse {
int32
carbohydrate
=
26
;
int32
energy
=
27
;
int32
allergys
=
28
;
bool
isBOM
=
29
;
string
overentryRatio
=
30
;
}
//计算规则 0.四舍五入 1.进位到最小售卖量的倍数 2.舍位到最小售卖量倍数
...
...
@@ -443,6 +447,8 @@ message SingleSkuResponse {
string
assistantUnit
=
24
;
int32
conversionBase
=
25
;
int32
conversionQuantity
=
26
;
int32
isInWarehouseValid
=
27
;
string
overentryRatio
=
28
;
}
message
SingleSkuAllFieldRpcResponse
{
...
...
@@ -461,6 +467,8 @@ message SingleSkuAllFieldRpcResponse {
bool
isCurrentPrice
=
13
;
SkuAttribute
attribute
=
14
;
SkuDecimalRulesMethod
decimalRulesMethod
=
15
;
int32
isInWarehouseValid
=
16
;
string
overentryRatio
=
17
;
}
...
...
@@ -530,6 +538,8 @@ message SingleSkuRpcResponse {
string
originSpecification
=
63
;
string
basicMaterials
=
64
;
string
geometricProperties
=
65
;
int32
isInWarehouseValid
=
66
;
string
overentryRatio
=
67
;
}
message
GetSkusByIdsRpcResponse
{
...
...
@@ -829,7 +839,8 @@ message SingleUpdateSkus {
bool
shouldUpdateCode
=
59
;
int32
isDeleted
=
60
;
bool
shouldUpdateIsDeleted
=
61
;
bool
shouldUpdateOverentryRatio
=
62
;
string
overentryRatio
=
63
;
}
message
BatchUpdateSkusRequest
{
...
...
src/main/resources/application.properties
View file @
c06206b
...
...
@@ -34,9 +34,6 @@ okhttp.max-idle-connections=10
okhttp.keep-alive-
duration
=
300
##GRPC\u914D\u7F6E
grpc.example-
service.url
=
localhost
grpc.example-
service.port
=
4096
grpc.order-
service.url
=
localhost
grpc.order-
service.port
=
4096
...
...
Please
register
or
login
to post a comment