Showing
59 changed files
with
2714 additions
and
95 deletions
| ... | @@ -48,6 +48,7 @@ dependencies { | ... | @@ -48,6 +48,7 @@ dependencies { |
| 48 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 | 48 | implementation 'com.aliyun:aliyun-java-sdk-core:4.6.4' //阿里云SDK核心库 |
| 49 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK | 49 | implementation 'com.aliyun:aliyun-java-sdk-dysmsapi:2.2.1'//阿里云短信服务SDK |
| 50 | implementation 'com.aliyun:aliyun-java-sdk-dm:3.3.2'//阿里云邮件服务SDK | 50 | implementation 'com.aliyun:aliyun-java-sdk-dm:3.3.2'//阿里云邮件服务SDK |
| 51 | + implementation "com.aliyun.oss:aliyun-sdk-oss:3.11.1"//阿里云OSS服务 | ||
| 51 | 52 | ||
| 52 | implementation "io.zipkin.brave:brave:5.12.5" | 53 | implementation "io.zipkin.brave:brave:5.12.5" |
| 53 | implementation "io.zipkin.brave:brave-context-slf4j:5.12.5" | 54 | implementation "io.zipkin.brave:brave-context-slf4j:5.12.5" |
| ... | @@ -61,8 +62,8 @@ dependencies { | ... | @@ -61,8 +62,8 @@ dependencies { |
| 61 | 62 | ||
| 62 | // compileOnly 'org.projectlombok:lombok' | 63 | // compileOnly 'org.projectlombok:lombok' |
| 63 | // annotationProcessor 'org.projectlombok:lombok' | 64 | // annotationProcessor 'org.projectlombok:lombok' |
| 64 | - compileOnly 'org.projectlombok:lombok:1.18.20' | 65 | + compileOnly 'org.projectlombok:lombok:1.18.24' |
| 65 | - annotationProcessor 'org.projectlombok:lombok:1.18.20' | 66 | + annotationProcessor 'org.projectlombok:lombok:1.18.24' |
| 66 | 67 | ||
| 67 | testImplementation 'org.springframework.boot:spring-boot-starter-test' | 68 | testImplementation 'org.springframework.boot:spring-boot-starter-test' |
| 68 | } | 69 | } |
| ... | @@ -113,5 +114,6 @@ sourceSets { | ... | @@ -113,5 +114,6 @@ sourceSets { |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | test { | 116 | test { |
| 117 | + enabled = false | ||
| 116 | useJUnitPlatform() | 118 | useJUnitPlatform() |
| 117 | } | 119 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -58,7 +58,6 @@ public class RepeatSubmitAspect { | ... | @@ -58,7 +58,6 @@ public class RepeatSubmitAspect { |
| 58 | * 获取LockKey | 58 | * 获取LockKey |
| 59 | * | 59 | * |
| 60 | * @param joinPoint 切入点 | 60 | * @param joinPoint 切入点 |
| 61 | - * @return | ||
| 62 | */ | 61 | */ |
| 63 | public static String getLockKey(ProceedingJoinPoint joinPoint) { | 62 | public static String getLockKey(ProceedingJoinPoint joinPoint) { |
| 64 | //获取连接点的方法签名对象 | 63 | //获取连接点的方法签名对象 |
| ... | @@ -79,13 +78,13 @@ public class RepeatSubmitAspect { | ... | @@ -79,13 +78,13 @@ public class RepeatSubmitAspect { |
| 79 | continue; | 78 | continue; |
| 80 | } | 79 | } |
| 81 | //如果属性是RequestKeyParam注解,则拼接 连接符 "& + RequestKeyParam" | 80 | //如果属性是RequestKeyParam注解,则拼接 连接符 "& + RequestKeyParam" |
| 82 | - if (sb.length() > 0) { | 81 | + if (!sb.isEmpty()) { |
| 83 | sb.append(requestLock.delimiter()); | 82 | sb.append(requestLock.delimiter()); |
| 84 | } | 83 | } |
| 85 | sb.append(args[i]); | 84 | sb.append(args[i]); |
| 86 | } | 85 | } |
| 87 | //如果方法上没有加RequestKeyParam注解 | 86 | //如果方法上没有加RequestKeyParam注解 |
| 88 | - if (StringUtils.isEmpty(sb.toString())) { | 87 | + if (!StringUtils.hasText((sb.toString()))) { |
| 89 | //获取方法上的多个注解(为什么是两层数组:因为第二层数组是只有一个元素的数组) | 88 | //获取方法上的多个注解(为什么是两层数组:因为第二层数组是只有一个元素的数组) |
| 90 | final var parameterAnnotations = method.getParameterAnnotations(); | 89 | final var parameterAnnotations = method.getParameterAnnotations(); |
| 91 | //循环注解 | 90 | //循环注解 |
| ... | @@ -103,7 +102,7 @@ public class RepeatSubmitAspect { | ... | @@ -103,7 +102,7 @@ public class RepeatSubmitAspect { |
| 103 | //如果有,设置Accessible为true(为true时可以使用反射访问私有变量,否则不能访问私有变量) | 102 | //如果有,设置Accessible为true(为true时可以使用反射访问私有变量,否则不能访问私有变量) |
| 104 | field.setAccessible(true); | 103 | field.setAccessible(true); |
| 105 | //如果属性是RequestKeyParam注解,则拼接 连接符" & + RequestKeyParam" | 104 | //如果属性是RequestKeyParam注解,则拼接 连接符" & + RequestKeyParam" |
| 106 | - if (sb.length() > 0) { | 105 | + if (!sb.isEmpty()) { |
| 107 | sb.append(requestLock.delimiter()); | 106 | sb.append(requestLock.delimiter()); |
| 108 | } | 107 | } |
| 109 | sb.append(ReflectionUtils.getField(field, object)); | 108 | sb.append(ReflectionUtils.getField(field, object)); |
| ... | @@ -112,9 +111,9 @@ public class RepeatSubmitAspect { | ... | @@ -112,9 +111,9 @@ public class RepeatSubmitAspect { |
| 112 | } | 111 | } |
| 113 | if (requestLock.isLockByLoginUser()) { | 112 | if (requestLock.isLockByLoginUser()) { |
| 114 | final var operatorId = LoginContextHolder.hasLogin() ? LoginContextHolder.getId() : null; | 113 | final var operatorId = LoginContextHolder.hasLogin() ? LoginContextHolder.getId() : null; |
| 115 | - return requestLock.prefix() + (operatorId != null ? CommonConstants.COLON + operatorId : "") + (sb.length() > 0 ? CommonConstants.UNDERLINE + sb : ""); | 114 | + return requestLock.prefix() + (operatorId != null ? CommonConstants.COLON + operatorId : "") + (!sb.isEmpty() ? CommonConstants.UNDERLINE + sb : ""); |
| 116 | } else { | 115 | } else { |
| 117 | - return requestLock.prefix() + (sb.length() > 0 ? CommonConstants.UNDERLINE + sb : ""); | 116 | + return requestLock.prefix() + (!sb.isEmpty() ? CommonConstants.UNDERLINE + sb : ""); |
| 118 | } | 117 | } |
| 119 | } | 118 | } |
| 120 | } | 119 | } | ... | ... |
| ... | @@ -3,11 +3,14 @@ package com.infoloop.tianting.config; | ... | @@ -3,11 +3,14 @@ package com.infoloop.tianting.config; |
| 3 | import com.aliyuncs.DefaultAcsClient; | 3 | import com.aliyuncs.DefaultAcsClient; |
| 4 | import com.aliyuncs.profile.DefaultProfile; | 4 | import com.aliyuncs.profile.DefaultProfile; |
| 5 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; | 5 | import com.fasterxml.jackson.dataformat.xml.XmlMapper; |
| 6 | +import com.infoloop.tianting.server.StorageService; | ||
| 7 | +import com.infoloop.tianting.server.StorageServiceFactory; | ||
| 6 | import com.infoloop.tianting.store.LoginCodeStore; | 8 | import com.infoloop.tianting.store.LoginCodeStore; |
| 7 | import com.infoloop.tianting.utils.SmsUtil; | 9 | import com.infoloop.tianting.utils.SmsUtil; |
| 8 | import io.lettuce.core.api.StatefulRedisConnection; | 10 | import io.lettuce.core.api.StatefulRedisConnection; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.beans.factory.annotation.Qualifier; | 12 | import org.springframework.beans.factory.annotation.Qualifier; |
| 13 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| 11 | import org.springframework.context.annotation.Bean; | 14 | import org.springframework.context.annotation.Bean; |
| 12 | import org.springframework.context.annotation.Configuration; | 15 | import org.springframework.context.annotation.Configuration; |
| 13 | import org.springframework.context.annotation.Import; | 16 | import org.springframework.context.annotation.Import; |
| ... | @@ -35,6 +38,12 @@ public class AppConfig { | ... | @@ -35,6 +38,12 @@ public class AppConfig { |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | @Bean | 40 | @Bean |
| 41 | + @ConditionalOnProperty(name = "aliyun.oss.endpoint") | ||
| 42 | + public StorageService storageService(@Autowired OssConfig ossConfig) { | ||
| 43 | + return StorageServiceFactory.createStorageService(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret()); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Bean | ||
| 38 | public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter() { | 47 | public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter() { |
| 39 | return new MappingJackson2XmlHttpMessageConverter(new XmlMapper()); | 48 | return new MappingJackson2XmlHttpMessageConverter(new XmlMapper()); |
| 40 | } | 49 | } | ... | ... |
| ... | @@ -11,6 +11,7 @@ import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServi | ... | @@ -11,6 +11,7 @@ import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServi |
| 11 | import com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; | 11 | import com.infoloop.tianting.clientresourcetagservice.ClientResourceTagServiceRpcGrpc; |
| 12 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 12 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| 13 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; | 13 | import com.infoloop.tianting.enterpriseresourcetagservice.EnterpriseResourceTagServiceRpcGrpc; |
| 14 | +import com.infoloop.tianting.mealorderservice.MealOrderServiceRpcGrpc; | ||
| 14 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; | 15 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; |
| 15 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; | 16 | import com.infoloop.tianting.setmealscheduleservice.SetMealScheduleServiceRpcGrpc; |
| 16 | import io.grpc.ClientInterceptor; | 17 | import io.grpc.ClientInterceptor; |
| ... | @@ -86,6 +87,11 @@ public class GrpcConfig { | ... | @@ -86,6 +87,11 @@ public class GrpcConfig { |
| 86 | return ClientCustomerOrderServiceRpcGrpc.newBlockingStub(channel); | 87 | return ClientCustomerOrderServiceRpcGrpc.newBlockingStub(channel); |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 90 | + @Bean | ||
| 91 | + public MealOrderServiceRpcGrpc.MealOrderServiceRpcBlockingStub mealOrderServiceRpcBlockingStub(@Autowired @Qualifier(ORDER_SERVICE_CHANNEL) final ManagedChannel channel) { | ||
| 92 | + return MealOrderServiceRpcGrpc.newBlockingStub(channel); | ||
| 93 | + } | ||
| 94 | + | ||
| 89 | @Bean(MENU_SERVICE_CHANNEL) | 95 | @Bean(MENU_SERVICE_CHANNEL) |
| 90 | public ManagedChannel menuServiceChannel(@Value(MENU_SERVICE_RPC_URL) final String url, | 96 | public ManagedChannel menuServiceChannel(@Value(MENU_SERVICE_RPC_URL) final String url, |
| 91 | @Value(MENU_SERVICE_RPC_PORT) final int port, | 97 | @Value(MENU_SERVICE_RPC_PORT) final int port, | ... | ... |
| 1 | +package com.infoloop.tianting.config; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 5 | +import org.springframework.context.annotation.PropertySource; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +@Component | ||
| 9 | +@ConfigurationProperties(prefix = "aliyun.oss") | ||
| 10 | +@Data | ||
| 11 | +@PropertySource(encoding = "UTF-8", value = "classpath:application.properties", ignoreResourceNotFound = true) | ||
| 12 | +public class OssConfig { | ||
| 13 | + | ||
| 14 | + private String accessKeyId; | ||
| 15 | + | ||
| 16 | + private String accessKeySecret; | ||
| 17 | + | ||
| 18 | + private String endpoint; | ||
| 19 | + | ||
| 20 | + private String host; | ||
| 21 | + | ||
| 22 | + private String bucket; | ||
| 23 | +} |
| 1 | package com.infoloop.tianting.config; | 1 | package com.infoloop.tianting.config; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.intercepter.ResourceInjector; | 3 | import com.infoloop.tianting.intercepter.ResourceInjector; |
| 4 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 5 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 4 | import org.springframework.context.annotation.Bean; | 6 | import org.springframework.context.annotation.Bean; |
| 5 | import org.springframework.context.annotation.Configuration; | 7 | import org.springframework.context.annotation.Configuration; |
| 6 | 8 | ||
| ... | @@ -8,9 +10,9 @@ import org.springframework.context.annotation.Configuration; | ... | @@ -8,9 +10,9 @@ import org.springframework.context.annotation.Configuration; |
| 8 | public class ResourceInjectorConfig { | 10 | public class ResourceInjectorConfig { |
| 9 | 11 | ||
| 10 | @Bean | 12 | @Bean |
| 11 | - public ResourceInjector resourceInjector( | 13 | + public ResourceInjector resourceInjector(final MealOrderServiceRpcClient mealOrderServiceRpcClient, |
| 12 | - | 14 | + final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient |
| 13 | ) { | 15 | ) { |
| 14 | - return new ResourceInjector(); | 16 | + return new ResourceInjector(mealOrderServiceRpcClient, clientInventoryServiceRpcClient); |
| 15 | } | 17 | } |
| 16 | } | 18 | } | ... | ... |
| ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.intercepter.LoginInterceptor; | ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.intercepter.LoginInterceptor; |
| 7 | import com.infoloop.tianting.intercepter.RequestMonitor; | 7 | import com.infoloop.tianting.intercepter.RequestMonitor; |
| 8 | import com.infoloop.tianting.intercepter.ResourceInjector; | 8 | import com.infoloop.tianting.intercepter.ResourceInjector; |
| 9 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 9 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 10 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 11 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 10 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 12 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 11 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 13 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 12 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; | 14 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; |
| ... | @@ -38,12 +40,15 @@ public class WebMvcConfig implements WebMvcConfigurer { | ... | @@ -38,12 +40,15 @@ public class WebMvcConfig implements WebMvcConfigurer { |
| 38 | final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient, | 40 | final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient, |
| 39 | final OperatorServiceRpcClient operatorServiceRpcClient, | 41 | final OperatorServiceRpcClient operatorServiceRpcClient, |
| 40 | final WOperatorServiceRpcClient wOperatorServiceRpcClient, | 42 | final WOperatorServiceRpcClient wOperatorServiceRpcClient, |
| 41 | - final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient) { | 43 | + final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient, |
| 44 | + final MealOrderServiceRpcClient mealOrderServiceRpcClient, | ||
| 45 | + final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient) { | ||
| 42 | this.httpInterceptors = new ArrayList<>(); | 46 | this.httpInterceptors = new ArrayList<>(); |
| 43 | this.httpInterceptors.add(new HttpTracingInterceptor(tracing)); | 47 | this.httpInterceptors.add(new HttpTracingInterceptor(tracing)); |
| 44 | this.httpInterceptors.add(new RequestMonitor()); | 48 | this.httpInterceptors.add(new RequestMonitor()); |
| 45 | this.httpInterceptors.add(new ApiSignInterceptor()); | 49 | this.httpInterceptors.add(new ApiSignInterceptor()); |
| 46 | this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, meiZhongYiHeServiceClient, operatorServiceRpcClient, wOperatorServiceRpcClient)); | 50 | this.httpInterceptors.add(new LoginInterceptor(clientCustomerServiceRpcClient, meiZhongYiHeServiceClient, operatorServiceRpcClient, wOperatorServiceRpcClient)); |
| 51 | + this.httpInterceptors.add(new ResourceInjector(mealOrderServiceRpcClient, clientInventoryServiceRpcClient)); | ||
| 47 | this.httpInterceptors.add(resourceInjector); | 52 | this.httpInterceptors.add(resourceInjector); |
| 48 | 53 | ||
| 49 | } | 54 | } | ... | ... |
| ... | @@ -24,10 +24,6 @@ public interface ConfigConstants { | ... | @@ -24,10 +24,6 @@ public interface ConfigConstants { |
| 24 | String ENTERPRISE_REDIS_PASSWORD = "${enterprise.redis.password}"; | 24 | String ENTERPRISE_REDIS_PASSWORD = "${enterprise.redis.password}"; |
| 25 | String ENTERPRISE_REDIS_DATABASE = "${enterprise.redis.database}"; | 25 | String ENTERPRISE_REDIS_DATABASE = "${enterprise.redis.database}"; |
| 26 | 26 | ||
| 27 | - String EXAMPLE_SERVICE_RPC_URL = "${grpc.example-service.url}"; | ||
| 28 | - String EXAMPLE_SERVICE_RPC_PORT = "${grpc.example-service.port}"; | ||
| 29 | - String EXAMPLE_SERVICE_CHANNEL = "example-service-channel"; | ||
| 30 | - | ||
| 31 | String ORDER_SERVICE_RPC_URL = "${grpc.order-service.url}"; | 27 | String ORDER_SERVICE_RPC_URL = "${grpc.order-service.url}"; |
| 32 | String ORDER_SERVICE_RPC_PORT = "${grpc.order-service.port}"; | 28 | String ORDER_SERVICE_RPC_PORT = "${grpc.order-service.port}"; |
| 33 | String ORDER_SERVICE_CHANNEL = "order-service-channel"; | 29 | String ORDER_SERVICE_CHANNEL = "order-service-channel"; | ... | ... |
| ... | @@ -2,9 +2,21 @@ package com.infoloop.tianting.constant; | ... | @@ -2,9 +2,21 @@ package com.infoloop.tianting.constant; |
| 2 | 2 | ||
| 3 | public interface PathVariableResourceConstants { | 3 | public interface PathVariableResourceConstants { |
| 4 | 4 | ||
| 5 | - String INJECTED_TEST_EXAMPLE_DB = "testExampleDb"; | ||
| 6 | - String TEST_EXAMPLE_DB_ID_PATH_VARIABLE = "testExampleDbId"; | ||
| 7 | 5 | ||
| 6 | + String INJECTED_MP_ACCOUNT = "mpAccount"; | ||
| 7 | + String MP_ACCOUNT_ID_PATH_VARIABLE = "mpAccountId"; | ||
| 8 | + | ||
| 9 | + String INJECTED_CLIENT = "client"; | ||
| 10 | + String CLIENT_ID_PATH_VARIABLE = "clientId"; | ||
| 11 | + | ||
| 12 | + String INJECTED_DINER = "diner"; | ||
| 13 | + String DINER_ID_PATH_VARIABLE = "dinerId"; | ||
| 14 | + | ||
| 15 | + String INJECTED_GRADE_CLASS = "gradeClass"; | ||
| 16 | + String GRADE_CLASS_ID_PATH_VARIABLE = "gradeClassId"; | ||
| 17 | + | ||
| 18 | + String INJECTED_MEAL_ORDER = "mealOrder"; | ||
| 19 | + String MEAL_ORDER_ID_PATH_VARIABLE = "mealOrderId"; | ||
| 8 | 20 | ||
| 9 | 21 | ||
| 10 | } | 22 | } | ... | ... |
| ... | @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 16 | 16 | ||
| 17 | import java.util.List; | 17 | import java.util.List; |
| 18 | 18 | ||
| 19 | -@Api(tags = "Category") | 19 | +@Api(tags = "品类") |
| 20 | @ApiSupport(order = -1) | 20 | @ApiSupport(order = -1) |
| 21 | @Slf4j | 21 | @Slf4j |
| 22 | @Validated | 22 | @Validated | ... | ... |
| ... | @@ -2,10 +2,10 @@ package com.infoloop.tianting.controller; | ... | @@ -2,10 +2,10 @@ package com.infoloop.tianting.controller; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 4 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 6 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | 6 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; |
| 7 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 7 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 8 | -import com.infoloop.tianting.service.InventoryService; | 8 | +import com.infoloop.tianting.service.ClientInventoryService; |
| 9 | import io.swagger.annotations.Api; | 9 | import io.swagger.annotations.Api; |
| 10 | import io.swagger.annotations.ApiOperation; | 10 | import io.swagger.annotations.ApiOperation; |
| 11 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| ... | @@ -17,40 +17,48 @@ import org.springframework.web.bind.annotation.GetMapping; | ... | @@ -17,40 +17,48 @@ import org.springframework.web.bind.annotation.GetMapping; |
| 17 | import org.springframework.web.bind.annotation.PathVariable; | 17 | import org.springframework.web.bind.annotation.PathVariable; |
| 18 | import org.springframework.web.bind.annotation.PostMapping; | 18 | import org.springframework.web.bind.annotation.PostMapping; |
| 19 | import org.springframework.web.bind.annotation.RequestBody; | 19 | import org.springframework.web.bind.annotation.RequestBody; |
| 20 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 20 | import org.springframework.web.bind.annotation.ResponseStatus; | 21 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 21 | import org.springframework.web.bind.annotation.RestController; | 22 | import org.springframework.web.bind.annotation.RestController; |
| 22 | 23 | ||
| 23 | import javax.validation.Valid; | 24 | import javax.validation.Valid; |
| 24 | import java.util.List; | 25 | import java.util.List; |
| 25 | 26 | ||
| 26 | -@Api(tags = "院区") | 27 | +@Api(tags = "项目点") |
| 27 | @ApiSupport(order = -1) | 28 | @ApiSupport(order = -1) |
| 28 | @Slf4j | 29 | @Slf4j |
| 29 | @Validated | 30 | @Validated |
| 30 | @RestController | 31 | @RestController |
| 31 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 32 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 32 | -public class InventoryController { | 33 | +public class ClientController { |
| 33 | - private final InventoryService inventoryService; | 34 | + private final ClientInventoryService clientInventoryService; |
| 34 | 35 | ||
| 35 | @SaIgnore | 36 | @SaIgnore |
| 36 | @ApiOperation(value = "根据Id获取Client") | 37 | @ApiOperation(value = "根据Id获取Client") |
| 37 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}") | 38 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}") |
| 38 | @ResponseStatus(HttpStatus.OK) | 39 | @ResponseStatus(HttpStatus.OK) |
| 39 | public ClientDto getClientById(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { | 40 | public ClientDto getClientById(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { |
| 40 | - return inventoryService.getClientById(enterpriseId, clientId); | 41 | + return clientInventoryService.getClientById(enterpriseId, clientId); |
| 42 | + } | ||
| 43 | + | ||
| 44 | + @ApiOperation(value = "根据Codes获取Clients") | ||
| 45 | + @GetMapping("/clients/bycodes") | ||
| 46 | + @ResponseStatus(HttpStatus.OK) | ||
| 47 | + public List<ClientDto> getClientsByCodes(@RequestParam List<String> codes) { | ||
| 48 | + return clientInventoryService.getClientsByCodes(codes); | ||
| 41 | } | 49 | } |
| 42 | 50 | ||
| 43 | @ApiOperation(value = "根据ClientId获取Stalls") | 51 | @ApiOperation(value = "根据ClientId获取Stalls") |
| 44 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}/stalls") | 52 | @GetMapping("/enterprises/{enterpriseId}/clients/{clientId}/stalls") |
| 45 | @ResponseStatus(HttpStatus.OK) | 53 | @ResponseStatus(HttpStatus.OK) |
| 46 | public List<ClientDto> getStallsByClientId(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { | 54 | public List<ClientDto> getStallsByClientId(@PathVariable Integer enterpriseId, @PathVariable Integer clientId) { |
| 47 | - return inventoryService.getStallsByClientId(enterpriseId, clientId); | 55 | + return clientInventoryService.getStallsByClientId(enterpriseId, clientId); |
| 48 | } | 56 | } |
| 49 | 57 | ||
| 50 | @ApiOperation(value = "获取桌号") | 58 | @ApiOperation(value = "获取桌号") |
| 51 | @PostMapping("/tableCodes") | 59 | @PostMapping("/tableCodes") |
| 52 | @ResponseStatus(HttpStatus.OK) | 60 | @ResponseStatus(HttpStatus.OK) |
| 53 | public List<ClientTableCodeDto> getTableCodes(@Valid @RequestBody TableCodeQueryConditionDto tableCodeQueryConditionDto) { | 61 | public List<ClientTableCodeDto> getTableCodes(@Valid @RequestBody TableCodeQueryConditionDto tableCodeQueryConditionDto) { |
| 54 | - return inventoryService.queryClientTableCodesByCondition(tableCodeQueryConditionDto); | 62 | + return clientInventoryService.queryClientTableCodesByCondition(tableCodeQueryConditionDto); |
| 55 | } | 63 | } |
| 56 | } | 64 | } | ... | ... |
| ... | @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 22 | import java.io.IOException; | 22 | import java.io.IOException; |
| 23 | import java.util.List; | 23 | import java.util.List; |
| 24 | 24 | ||
| 25 | -@Api(tags = "客户") | 25 | +@Api(tags = "项目点客户") |
| 26 | @ApiSupport(order = -1) | 26 | @ApiSupport(order = -1) |
| 27 | @Slf4j | 27 | @Slf4j |
| 28 | @Validated | 28 | @Validated | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 6 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 7 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 8 | +import com.infoloop.tianting.model.dto.DinerDTO; | ||
| 9 | +import com.infoloop.tianting.model.vo.DinerVO; | ||
| 10 | +import com.infoloop.tianting.model.vo.GradeClassVO; | ||
| 11 | +import com.infoloop.tianting.service.DinerService; | ||
| 12 | +import io.swagger.annotations.Api; | ||
| 13 | +import io.swagger.annotations.ApiOperation; | ||
| 14 | +import lombok.RequiredArgsConstructor; | ||
| 15 | +import lombok.extern.slf4j.Slf4j; | ||
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | +import org.springframework.http.HttpStatus; | ||
| 18 | +import org.springframework.validation.annotation.Validated; | ||
| 19 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.PatchMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 24 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 25 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 26 | +import org.springframework.web.bind.annotation.RestController; | ||
| 27 | + | ||
| 28 | +import javax.validation.Valid; | ||
| 29 | +import java.util.List; | ||
| 30 | + | ||
| 31 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_CLIENT; | ||
| 32 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_DINER; | ||
| 33 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_GRADE_CLASS; | ||
| 34 | + | ||
| 35 | +@Api(tags = "就餐人") | ||
| 36 | +@ApiSupport(order = -1) | ||
| 37 | +@Slf4j | ||
| 38 | +@Validated | ||
| 39 | +@RestController | ||
| 40 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 41 | +public class DinerController { | ||
| 42 | + | ||
| 43 | + private final DinerService dinerService; | ||
| 44 | + | ||
| 45 | + @ApiOperation(value = "用户就餐人列表") | ||
| 46 | + @GetMapping("/mpaccount/diners") | ||
| 47 | + @ResponseStatus(HttpStatus.OK) | ||
| 48 | + public List<DinerVO> getMpAccountDiners() { | ||
| 49 | + return dinerService.getMpAccountDiners(); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @ApiOperation(value = "添加就餐人") | ||
| 53 | + @PutMapping("/mpaccount/diner") | ||
| 54 | + @ResponseStatus(HttpStatus.CREATED) | ||
| 55 | + public CreatedResult<DinerVO> createMpAccountDiner(@RequestBody @Valid final DinerDTO.CreateDinerDTO createDinerDTO) { | ||
| 56 | + return dinerService.createMpAccountDiner(createDinerDTO); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @ApiOperation(value = "学校年级班级列表") | ||
| 60 | + @GetMapping("/client/{clientId}/gradeclasses") | ||
| 61 | + @ResponseStatus(HttpStatus.OK) | ||
| 62 | + public List<GradeClassVO> getClientGradeClasses(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client) { | ||
| 63 | + return dinerService.getClientGradeClasses(client); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @ApiOperation(value = "根据学校,班级和学号查询就餐人") | ||
| 67 | + @GetMapping("/client/{clientId}/gradeclass/{gradeClassId}/diner") | ||
| 68 | + @ResponseStatus(HttpStatus.OK) | ||
| 69 | + public DinerVO getClientClassDiner(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client, | ||
| 70 | + @RequestAttribute(INJECTED_GRADE_CLASS) final SingleGradeClassRpcResponse gradeClass, | ||
| 71 | + @RequestBody @Valid final DinerDTO.QueryUniqueDinerDTO queryUniqueDinerDTO) { | ||
| 72 | + return dinerService.getClientClassDiner(client, gradeClass, queryUniqueDinerDTO.getStudentNo()); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @ApiOperation(value = "修改就餐人") | ||
| 76 | + @PatchMapping("/mpaccount/diner/{dinerId}") | ||
| 77 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 78 | + public void updateMpAccountDiner(@RequestAttribute(INJECTED_DINER) final SingleDinerRpcResponse diner, | ||
| 79 | + @RequestBody @Valid final DinerDTO.UpdateDinerDTO updateDinerDTO) { | ||
| 80 | + dinerService.updateMpAccountDiner(diner, updateDinerDTO); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @ApiOperation(value = "删除就餐人") | ||
| 84 | + @DeleteMapping("/mpaccount/diner/{dinerId}") | ||
| 85 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 86 | + public void deleteMpAccountDiner(@RequestAttribute(INJECTED_DINER) final SingleDinerRpcResponse diner) { | ||
| 87 | + dinerService.deleteMpAccountDiner(diner); | ||
| 88 | + } | ||
| 89 | +} |
| ... | @@ -3,7 +3,10 @@ package com.infoloop.tianting.controller; | ... | @@ -3,7 +3,10 @@ package com.infoloop.tianting.controller; |
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import cn.dev33.satoken.stp.SaTokenInfo; | 4 | import cn.dev33.satoken.stp.SaTokenInfo; |
| 5 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 5 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 6 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 7 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 6 | import com.infoloop.tianting.model.dto.PermissionDTO; | 8 | import com.infoloop.tianting.model.dto.PermissionDTO; |
| 9 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 7 | import com.infoloop.tianting.service.LoginService; | 10 | import com.infoloop.tianting.service.LoginService; |
| 8 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 9 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| ... | @@ -12,7 +15,11 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -12,7 +15,11 @@ import lombok.extern.slf4j.Slf4j; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.http.HttpStatus; | 16 | import org.springframework.http.HttpStatus; |
| 14 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PatchMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 15 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 22 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 16 | import org.springframework.web.bind.annotation.RequestBody; | 23 | import org.springframework.web.bind.annotation.RequestBody; |
| 17 | import org.springframework.web.bind.annotation.ResponseStatus; | 24 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 18 | import org.springframework.web.bind.annotation.RestController; | 25 | import org.springframework.web.bind.annotation.RestController; |
| ... | @@ -20,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -20,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; |
| 20 | import javax.validation.Valid; | 27 | import javax.validation.Valid; |
| 21 | import java.security.NoSuchAlgorithmException; | 28 | import java.security.NoSuchAlgorithmException; |
| 22 | 29 | ||
| 30 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_MP_ACCOUNT; | ||
| 31 | + | ||
| 23 | @Api(tags = "登陆") | 32 | @Api(tags = "登陆") |
| 24 | @ApiSupport(order = -1) | 33 | @ApiSupport(order = -1) |
| 25 | @Slf4j | 34 | @Slf4j |
| ... | @@ -36,4 +45,20 @@ public class LoginController { | ... | @@ -36,4 +45,20 @@ public class LoginController { |
| 36 | public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) throws NoSuchAlgorithmException { | 45 | public SaTokenInfo login(@Valid @RequestBody PermissionDTO.LoginDto loginDto) throws NoSuchAlgorithmException { |
| 37 | return loginService.login(loginDto); | 46 | return loginService.login(loginDto); |
| 38 | } | 47 | } |
| 48 | + | ||
| 49 | + @SaIgnore | ||
| 50 | + @ApiOperation(value = "根据openId获取小程序用户") | ||
| 51 | + @GetMapping("/mpaccount/{openId}") | ||
| 52 | + @ResponseStatus(HttpStatus.OK) | ||
| 53 | + public MpAccountVO getMpAccountByOpenId(@PathVariable("openId") String openId) { | ||
| 54 | + return loginService.getMpAccountByOpenId(openId); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @ApiOperation(value = "修改小程序用户") | ||
| 58 | + @PatchMapping("/mpaccount/{mpAccountId}") | ||
| 59 | + @ResponseStatus(HttpStatus.NO_CONTENT) | ||
| 60 | + public void updateMpAccount(@RequestAttribute(INJECTED_MP_ACCOUNT) final SingleMpAccountRpcResponse mpAccount, | ||
| 61 | + @RequestBody @Valid MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO) { | ||
| 62 | + loginService.updateMpAccount(mpAccount, modifyMpAccountDTO); | ||
| 63 | + } | ||
| 39 | } | 64 | } | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import com.infoloop.tianting.annotation.RepeatSubmit; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 6 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 7 | +import com.infoloop.tianting.model.dto.MealOrderDTO; | ||
| 8 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 9 | +import com.infoloop.tianting.model.vo.MealOrderVO; | ||
| 10 | +import com.infoloop.tianting.service.MealOrderService; | ||
| 11 | +import io.swagger.annotations.Api; | ||
| 12 | +import io.swagger.annotations.ApiOperation; | ||
| 13 | +import lombok.RequiredArgsConstructor; | ||
| 14 | +import lombok.extern.slf4j.Slf4j; | ||
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | +import org.springframework.http.HttpStatus; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 22 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 23 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 24 | +import org.springframework.web.bind.annotation.RestController; | ||
| 25 | + | ||
| 26 | +import javax.validation.Valid; | ||
| 27 | +import java.util.List; | ||
| 28 | + | ||
| 29 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_MEAL_ORDER; | ||
| 30 | + | ||
| 31 | +@Api(tags = "订餐") | ||
| 32 | +@ApiSupport(order = -1) | ||
| 33 | +@Slf4j | ||
| 34 | +@Validated | ||
| 35 | +@RestController | ||
| 36 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 37 | +public class MealOrderController { | ||
| 38 | + | ||
| 39 | + private final MealOrderService mealOrderService; | ||
| 40 | + | ||
| 41 | + @ApiOperation(value = "订餐记录") | ||
| 42 | + @PostMapping("/mealorders") | ||
| 43 | + @ResponseStatus(HttpStatus.OK) | ||
| 44 | + public List<MealOrderVO> queryMealOrders(@RequestBody @Valid final MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) { | ||
| 45 | + return mealOrderService.queryMealOrders(queryMealOrderDTO); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @ApiOperation(value = "立即订餐") | ||
| 49 | + @PutMapping("/mealorder") | ||
| 50 | + @RepeatSubmit(prefix = "create.meal.order", isLockByLoginUser = false) | ||
| 51 | + @ResponseStatus(HttpStatus.CREATED) | ||
| 52 | + public CreatedResult<MealOrderVO> createMealOrder(@RequestBody @Valid final MealOrderDTO.CreateMealOrderDTO createMealOrderDTO) { | ||
| 53 | + return mealOrderService.createMealOrder(createMealOrderDTO); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @ApiOperation(value = "订餐记录详情") | ||
| 57 | + @GetMapping("/mealorder/{mealOrderId}") | ||
| 58 | + @ResponseStatus(HttpStatus.OK) | ||
| 59 | + public MealOrderVO getMealOrderById(@RequestAttribute(INJECTED_MEAL_ORDER) final SingleMealOrderRpcResponse mealOrder) { | ||
| 60 | + return mealOrderService.getMealOrderById(mealOrder); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @ApiOperation(value = "订餐规则") | ||
| 64 | + @GetMapping("/deliveryrule") | ||
| 65 | + @ResponseStatus(HttpStatus.OK) | ||
| 66 | + public DeliveryRuleVO getDeliveryRule() { | ||
| 67 | + return mealOrderService.getDeliveryRule(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | +} |
| 1 | package com.infoloop.tianting.controller; | 1 | package com.infoloop.tianting.controller; |
| 2 | 2 | ||
| 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; | 3 | import com.github.xiaoymin.knife4j.annotations.ApiSupport; |
| 4 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | import com.infoloop.tianting.model.dto.MenuDbDTO; | 5 | import com.infoloop.tianting.model.dto.MenuDbDTO; |
| 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; | 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; |
| 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; | 7 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; |
| ... | @@ -18,6 +19,7 @@ import org.springframework.validation.annotation.Validated; | ... | @@ -18,6 +19,7 @@ import org.springframework.validation.annotation.Validated; |
| 18 | import org.springframework.web.bind.annotation.GetMapping; | 19 | import org.springframework.web.bind.annotation.GetMapping; |
| 19 | import org.springframework.web.bind.annotation.PathVariable; | 20 | import org.springframework.web.bind.annotation.PathVariable; |
| 20 | import org.springframework.web.bind.annotation.PostMapping; | 21 | import org.springframework.web.bind.annotation.PostMapping; |
| 22 | +import org.springframework.web.bind.annotation.RequestAttribute; | ||
| 21 | import org.springframework.web.bind.annotation.RequestBody; | 23 | import org.springframework.web.bind.annotation.RequestBody; |
| 22 | import org.springframework.web.bind.annotation.ResponseStatus; | 24 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 23 | import org.springframework.web.bind.annotation.RestController; | 25 | import org.springframework.web.bind.annotation.RestController; |
| ... | @@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -25,6 +27,8 @@ import org.springframework.web.bind.annotation.RestController; |
| 25 | import javax.validation.Valid; | 27 | import javax.validation.Valid; |
| 26 | import java.util.List; | 28 | import java.util.List; |
| 27 | 29 | ||
| 30 | +import static com.infoloop.tianting.constant.PathVariableResourceConstants.INJECTED_CLIENT; | ||
| 31 | + | ||
| 28 | @Api(tags = "餐单") | 32 | @Api(tags = "餐单") |
| 29 | @ApiSupport(order = -1) | 33 | @ApiSupport(order = -1) |
| 30 | @Slf4j | 34 | @Slf4j |
| ... | @@ -76,4 +80,11 @@ public class MenuController { | ... | @@ -76,4 +80,11 @@ public class MenuController { |
| 76 | return menuService.batchCreateMenuRefs(batchCreateMenuRefsDto); | 80 | return menuService.batchCreateMenuRefs(batchCreateMenuRefsDto); |
| 77 | } | 81 | } |
| 78 | 82 | ||
| 83 | + @ApiOperation(value = "查询学校最新餐单") | ||
| 84 | + @GetMapping("/client/{clientId}/mealmenurecord") | ||
| 85 | + @ResponseStatus(HttpStatus.OK) | ||
| 86 | + public String queryClientLatestMealMenuRecord(@RequestAttribute(INJECTED_CLIENT) final SingleClientRpcResponse client) { | ||
| 87 | + return menuService.queryClientLatestMealMenuRecord(client); | ||
| 88 | + } | ||
| 89 | + | ||
| 79 | } | 90 | } | ... | ... |
| ... | @@ -27,6 +27,7 @@ public class MiniProgramController { | ... | @@ -27,6 +27,7 @@ public class MiniProgramController { |
| 27 | 27 | ||
| 28 | private final WxMiniProgramService wxMiniProgramService; | 28 | private final WxMiniProgramService wxMiniProgramService; |
| 29 | 29 | ||
| 30 | + @SaIgnore | ||
| 30 | @ApiOperation(value = "小程序:根据code获取openId") | 31 | @ApiOperation(value = "小程序:根据code获取openId") |
| 31 | @GetMapping("/wx/miniprogram/customers/openid/{code}") | 32 | @GetMapping("/wx/miniprogram/customers/openid/{code}") |
| 32 | @ResponseStatus(HttpStatus.OK) | 33 | @ResponseStatus(HttpStatus.OK) | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import cn.dev33.satoken.annotation.SaIgnore; | ||
| 4 | +import cn.hutool.core.io.IoUtil; | ||
| 5 | +import cn.hutool.core.io.file.FileNameUtil; | ||
| 6 | +import cn.hutool.core.util.IdUtil; | ||
| 7 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 8 | +import com.infoloop.tianting.config.OssConfig; | ||
| 9 | +import com.infoloop.tianting.server.StorageService; | ||
| 10 | +import io.swagger.annotations.Api; | ||
| 11 | +import io.swagger.annotations.ApiOperation; | ||
| 12 | +import lombok.extern.slf4j.Slf4j; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.http.HttpStatus; | ||
| 15 | +import org.springframework.http.MediaType; | ||
| 16 | +import org.springframework.util.Assert; | ||
| 17 | +import org.springframework.validation.annotation.Validated; | ||
| 18 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 21 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 22 | +import org.springframework.web.bind.annotation.RestController; | ||
| 23 | +import org.springframework.web.multipart.MultipartFile; | ||
| 24 | + | ||
| 25 | +import javax.annotation.Nullable; | ||
| 26 | +import javax.servlet.ServletOutputStream; | ||
| 27 | +import javax.servlet.http.HttpServletResponse; | ||
| 28 | +import java.io.File; | ||
| 29 | +import java.io.InputStream; | ||
| 30 | +import java.net.URLEncoder; | ||
| 31 | +import java.nio.charset.StandardCharsets; | ||
| 32 | +import java.time.LocalDateTime; | ||
| 33 | +import java.time.format.DateTimeFormatter; | ||
| 34 | + | ||
| 35 | +@Api(tags = "上传、下载管理") | ||
| 36 | +@ApiSupport(order = 99) | ||
| 37 | +@Slf4j | ||
| 38 | +@Validated | ||
| 39 | +@RestController | ||
| 40 | +public class UploadController { | ||
| 41 | + | ||
| 42 | + private final OssConfig ossConfig; | ||
| 43 | + | ||
| 44 | + private final StorageService storageService; | ||
| 45 | + | ||
| 46 | + @Autowired(required = false) | ||
| 47 | + public UploadController(OssConfig ossConfig, @Nullable StorageService storageService) { | ||
| 48 | + this.ossConfig = ossConfig; | ||
| 49 | + this.storageService = storageService; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @SaIgnore | ||
| 53 | + @ApiOperation("上传") | ||
| 54 | + @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
| 55 | + @ResponseStatus(HttpStatus.OK) | ||
| 56 | + public String upload(@RequestParam("file") MultipartFile file, | ||
| 57 | + @RequestParam(value = "folder", defaultValue = "upload") String folder) throws Exception { | ||
| 58 | + Assert.notNull(storageService, "存储服务未初始化,请检查配置 aliyun.oss.endpoint"); | ||
| 59 | + String extension = FileNameUtil.getSuffix(file.getOriginalFilename()); | ||
| 60 | + String path = generateUploadPath(folder, extension); | ||
| 61 | + File tempFile = File.createTempFile(IdUtil.fastSimpleUUID(), null); | ||
| 62 | + try { | ||
| 63 | + file.transferTo(tempFile); | ||
| 64 | + storageService.putObject(ossConfig.getBucket(), path, tempFile); | ||
| 65 | + } catch (Exception e) { | ||
| 66 | + log.error("上传失败: {}", file.getOriginalFilename(), e); | ||
| 67 | + throw new RuntimeException("文件上传失败,请稍后重试"); | ||
| 68 | + } finally { | ||
| 69 | + tempFile.delete(); | ||
| 70 | + } | ||
| 71 | + return String.format("%s/%s", ossConfig.getHost(), path); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @SaIgnore | ||
| 75 | + @ApiOperation("下载") | ||
| 76 | + @GetMapping(value = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) | ||
| 77 | + @ResponseStatus(HttpStatus.OK) | ||
| 78 | + public void download(@RequestParam("path") String path, HttpServletResponse response) { | ||
| 79 | + Assert.notNull(storageService, "存储服务未初始化,请检查配置 aliyun.oss.endpoint"); | ||
| 80 | + try (InputStream inputStream = storageService.getObjectInputStream(ossConfig.getBucket(), path); | ||
| 81 | + ServletOutputStream outputStream = response.getOutputStream()) { | ||
| 82 | + String fileName = path.substring(path.lastIndexOf("/") + 1); | ||
| 83 | + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); | ||
| 84 | + response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName, StandardCharsets.UTF_8) + "\""); | ||
| 85 | + IoUtil.copy(inputStream, outputStream); | ||
| 86 | + } catch (Exception e) { | ||
| 87 | + log.error("下载失败: {}", path, e); | ||
| 88 | + throw new RuntimeException("文件下载失败,请稍后重试"); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + private String generateUploadPath(String folder, String extension) { | ||
| 93 | + String datePath = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); | ||
| 94 | + return String.format("nutri-api/%s/%s/%s.%s", folder, datePath, IdUtil.fastSimpleUUID(), extension); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | +} |
| ... | @@ -42,7 +42,26 @@ public enum ErrorCodeEnum implements BaseEnum { | ... | @@ -42,7 +42,26 @@ public enum ErrorCodeEnum implements BaseEnum { |
| 42 | 42 | ||
| 43 | ORDER_NOT_ONLINE_PAY(406000012, "该订单不是在线支付"), | 43 | ORDER_NOT_ONLINE_PAY(406000012, "该订单不是在线支付"), |
| 44 | 44 | ||
| 45 | - ORDER_NOT_SUCCESS(406000013, "该订单未支付成功") | 45 | + ORDER_NOT_SUCCESS(406000013, "该订单未支付成功"), |
| 46 | + | ||
| 47 | + CLIENT_CODE_NOT_EXISTS(406000014, "学校编码不正确"), | ||
| 48 | + | ||
| 49 | + DINER_ALREADY_EXISTS(406000015, "该就餐人已存在"), | ||
| 50 | + | ||
| 51 | + DINER_ALREADY_RESERVED(406000016, "该就餐人已订餐"), | ||
| 52 | + | ||
| 53 | + DINER_NOT_FOUND(406000017, "该就餐人不存在"), | ||
| 54 | + | ||
| 55 | + MEAL_MENU_NOT_FOUND(406000018, "预定餐单不存在"), | ||
| 56 | + | ||
| 57 | + CLIENT_NOT_FOUND(406000019, "学校不存在"), | ||
| 58 | + | ||
| 59 | + CLIENT_NOT_ENABLED(406000020, "学校未启用"), | ||
| 60 | + | ||
| 61 | + GRADE_CLASS_NOT_FOUND(406000021, "班级不存在"), | ||
| 62 | + | ||
| 63 | + MEAL_ORDER_TIME_NOT_IN_RANGE(406000022, "当前时间不在选餐时间内") | ||
| 64 | + | ||
| 46 | ; | 65 | ; |
| 47 | private final int code; | 66 | private final int code; |
| 48 | 67 | ... | ... |
| ... | @@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor { | ... | @@ -70,6 +70,7 @@ public class LoginInterceptor implements HandlerInterceptor { |
| 70 | StpUtil.checkLogin(); | 70 | StpUtil.checkLogin(); |
| 71 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); | 71 | final var enterpriseId = Convert.toInt(StpUtil.getExtra(CommonConstants.ENTERPRISE_ID)); |
| 72 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); | 72 | final var loginSource = Convert.toInt(StpUtil.getExtra(CommonConstants.LOGIN_SOURCE)); |
| 73 | + final var userId = StpUtil.getExtra(CommonConstants.USER_ID); | ||
| 73 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { | 74 | if (loginSource.equals(LoginSourceEnum.CUSTOMER.getValue())) { |
| 74 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); | 75 | final var openId = Convert.toStr(StpUtil.getExtra(CommonConstants.OPEN_ID)); |
| 75 | final var loginId = StpUtil.getLoginIdAsInt(); | 76 | final var loginId = StpUtil.getLoginIdAsInt(); |
| ... | @@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor { | ... | @@ -115,8 +116,7 @@ public class LoginInterceptor implements HandlerInterceptor { |
| 115 | builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); | 116 | builder.id(loginId).enterpriseId(enterpriseId).name(operator.getName()).loginSource(LoginSourceEnum.KDS); |
| 116 | return true; | 117 | return true; |
| 117 | } else { | 118 | } else { |
| 118 | - final var loginId = StpUtil.getLoginIdAsString(); | 119 | + builder.id(userId == null ? null : Convert.toInt(userId)).openId(StpUtil.getLoginIdAsString()).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM); |
| 119 | - builder.openId(loginId).enterpriseId(enterpriseId).loginSource(LoginSourceEnum.MINI_PROGRAM); | ||
| 120 | return true; | 120 | return true; |
| 121 | } | 121 | } |
| 122 | } | 122 | } | ... | ... |
| ... | @@ -2,6 +2,12 @@ package com.infoloop.tianting.intercepter; | ... | @@ -2,6 +2,12 @@ package com.infoloop.tianting.intercepter; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.annotation.SaIgnore; | 3 | import cn.dev33.satoken.annotation.SaIgnore; |
| 4 | import cn.dev33.satoken.strategy.SaStrategy; | 4 | import cn.dev33.satoken.strategy.SaStrategy; |
| 5 | +import cn.hutool.core.convert.Convert; | ||
| 6 | +import com.infoloop.tianting.constant.PathVariableResourceConstants; | ||
| 7 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 8 | +import com.infoloop.tianting.exception.ClientEndExceptions; | ||
| 9 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 10 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 5 | import lombok.RequiredArgsConstructor; | 11 | import lombok.RequiredArgsConstructor; |
| 6 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | @@ -18,6 +24,10 @@ import java.util.Map; | ... | @@ -18,6 +24,10 @@ import java.util.Map; |
| 18 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 24 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 19 | public class ResourceInjector implements HandlerInterceptor { | 25 | public class ResourceInjector implements HandlerInterceptor { |
| 20 | 26 | ||
| 27 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 28 | + | ||
| 29 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | ||
| 30 | + | ||
| 21 | @Override | 31 | @Override |
| 22 | @SuppressWarnings("unchecked") | 32 | @SuppressWarnings("unchecked") |
| 23 | public boolean preHandle(@NonNull final HttpServletRequest httpServletRequest, @NonNull final HttpServletResponse httpServletResponse, @NonNull final Object handler) { | 33 | public boolean preHandle(@NonNull final HttpServletRequest httpServletRequest, @NonNull final HttpServletResponse httpServletResponse, @NonNull final Object handler) { |
| ... | @@ -33,6 +43,91 @@ public class ResourceInjector implements HandlerInterceptor { | ... | @@ -33,6 +43,91 @@ public class ResourceInjector implements HandlerInterceptor { |
| 33 | if (pathVariables == null) { | 43 | if (pathVariables == null) { |
| 34 | return true; | 44 | return true; |
| 35 | } | 45 | } |
| 46 | + | ||
| 47 | + /* | ||
| 48 | + 注入MpAccount | ||
| 49 | + */ | ||
| 50 | + if (pathVariables.containsKey(PathVariableResourceConstants.MP_ACCOUNT_ID_PATH_VARIABLE)) { | ||
| 51 | + final var idStr = pathVariables.get(PathVariableResourceConstants.MP_ACCOUNT_ID_PATH_VARIABLE); | ||
| 52 | + final var id = Convert.toInt(idStr, 0); | ||
| 53 | + if (id <= 0) { | ||
| 54 | + throw ClientEndExceptions.ResourceNotFound.build("小程序用户不存在"); | ||
| 55 | + } | ||
| 56 | + final var response = mealOrderServiceRpcClient.getMpAccountById(LoginContextHolder.getEnterpriseId(), id); | ||
| 57 | + if (response == null) { | ||
| 58 | + log.info("Resource not found; id:{}", id); | ||
| 59 | + throw ClientEndExceptions.ResourceNotFound.build("小程序用户不存在"); | ||
| 60 | + } | ||
| 61 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_MP_ACCOUNT, response); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + /* | ||
| 65 | + 注入Client | ||
| 66 | + */ | ||
| 67 | + if (pathVariables.containsKey(PathVariableResourceConstants.CLIENT_ID_PATH_VARIABLE)) { | ||
| 68 | + final var idStr = pathVariables.get(PathVariableResourceConstants.CLIENT_ID_PATH_VARIABLE); | ||
| 69 | + final var id = Convert.toInt(idStr, 0); | ||
| 70 | + if (id <= 0) { | ||
| 71 | + throw ClientEndExceptions.ResourceNotFound.build("项目点不存在"); | ||
| 72 | + } | ||
| 73 | + final var response = clientInventoryServiceRpcClient.getClientById(LoginContextHolder.getEnterpriseId(), id); | ||
| 74 | + if (response == null) { | ||
| 75 | + log.info("Resource not found; id:{}", id); | ||
| 76 | + throw ClientEndExceptions.ResourceNotFound.build("项目点不存在"); | ||
| 77 | + } | ||
| 78 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_CLIENT, response.getClient()); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /* | ||
| 82 | + 注入Diner | ||
| 83 | + */ | ||
| 84 | + if (pathVariables.containsKey(PathVariableResourceConstants.DINER_ID_PATH_VARIABLE)) { | ||
| 85 | + final var idStr = pathVariables.get(PathVariableResourceConstants.DINER_ID_PATH_VARIABLE); | ||
| 86 | + final var id = Convert.toInt(idStr, 0); | ||
| 87 | + if (id <= 0) { | ||
| 88 | + throw ClientEndExceptions.ResourceNotFound.build("就餐人不存在"); | ||
| 89 | + } | ||
| 90 | + final var response = mealOrderServiceRpcClient.getDinerById(LoginContextHolder.getEnterpriseId(), id); | ||
| 91 | + if (response == null) { | ||
| 92 | + log.info("Resource not found; id:{}", id); | ||
| 93 | + throw ClientEndExceptions.ResourceNotFound.build("就餐人不存在"); | ||
| 94 | + } | ||
| 95 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_DINER, response); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /* | ||
| 99 | + 注入GradeClass | ||
| 100 | + */ | ||
| 101 | + if (pathVariables.containsKey(PathVariableResourceConstants.GRADE_CLASS_ID_PATH_VARIABLE)) { | ||
| 102 | + final var idStr = pathVariables.get(PathVariableResourceConstants.GRADE_CLASS_ID_PATH_VARIABLE); | ||
| 103 | + final var id = Convert.toInt(idStr, 0); | ||
| 104 | + if (id <= 0) { | ||
| 105 | + throw ClientEndExceptions.ResourceNotFound.build("年级班级不存在"); | ||
| 106 | + } | ||
| 107 | + final var response = mealOrderServiceRpcClient.getGradeClassById(LoginContextHolder.getEnterpriseId(), id); | ||
| 108 | + if (response == null) { | ||
| 109 | + log.info("Resource not found; id:{}", id); | ||
| 110 | + throw ClientEndExceptions.ResourceNotFound.build("年级班级不存在"); | ||
| 111 | + } | ||
| 112 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_GRADE_CLASS, response); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + /* | ||
| 116 | + 注入MealOrder | ||
| 117 | + */ | ||
| 118 | + if (pathVariables.containsKey(PathVariableResourceConstants.MEAL_ORDER_ID_PATH_VARIABLE)) { | ||
| 119 | + final var idStr = pathVariables.get(PathVariableResourceConstants.MEAL_ORDER_ID_PATH_VARIABLE); | ||
| 120 | + final var id = Convert.toInt(idStr, 0); | ||
| 121 | + if (id <= 0) { | ||
| 122 | + throw ClientEndExceptions.ResourceNotFound.build("订餐记录不存在"); | ||
| 123 | + } | ||
| 124 | + final var response = mealOrderServiceRpcClient.getMealOrderById(LoginContextHolder.getEnterpriseId(), id); | ||
| 125 | + if (response == null) { | ||
| 126 | + log.info("Resource not found; id:{}", id); | ||
| 127 | + throw ClientEndExceptions.ResourceNotFound.build("订餐记录不存在"); | ||
| 128 | + } | ||
| 129 | + httpServletRequest.setAttribute(PathVariableResourceConstants.INJECTED_MEAL_ORDER, response); | ||
| 130 | + } | ||
| 36 | return true; | 131 | return true; |
| 37 | } | 132 | } |
| 38 | } | 133 | } | ... | ... |
| ... | @@ -21,8 +21,8 @@ import com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData; | ... | @@ -21,8 +21,8 @@ import com.infoloop.tianting.server.message.data.CustomerAlterRoomNoData; |
| 21 | import com.infoloop.tianting.server.session.UserSessionKey; | 21 | import com.infoloop.tianting.server.session.UserSessionKey; |
| 22 | import com.infoloop.tianting.server.session.UserTypeEnum; | 22 | import com.infoloop.tianting.server.session.UserTypeEnum; |
| 23 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 24 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 24 | import com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.ClientResourceTagServiceRpcClient; |
| 25 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | ||
| 26 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 26 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 27 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 27 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 28 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 28 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| ... | @@ -48,7 +48,7 @@ public class HisCustomerRoomNoTask { | ... | @@ -48,7 +48,7 @@ public class HisCustomerRoomNoTask { |
| 48 | 48 | ||
| 49 | private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; | 49 | private final ClientResourceTagServiceRpcClient clientResourceTagServiceRpcClient; |
| 50 | 50 | ||
| 51 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 51 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 52 | 52 | ||
| 53 | private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient; | 53 | private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient; |
| 54 | 54 | ||
| ... | @@ -62,7 +62,7 @@ public class HisCustomerRoomNoTask { | ... | @@ -62,7 +62,7 @@ public class HisCustomerRoomNoTask { |
| 62 | 62 | ||
| 63 | final var stallIdsList = clientResourceTagServiceRpcClient.getUserResources(cOperatorById.getEnterpriseId(), cOperatorById.getClientId(), cOperatorById.getId()).getStallIdsList(); | 63 | final var stallIdsList = clientResourceTagServiceRpcClient.getUserResources(cOperatorById.getEnterpriseId(), cOperatorById.getClientId(), cOperatorById.getId()).getStallIdsList(); |
| 64 | 64 | ||
| 65 | - final var stalls = inventoryServiceRpcClient.getStallsByIds(cOperatorById.getEnterpriseId(), stallIdsList).getClientsList(); | 65 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds(cOperatorById.getEnterpriseId(), stallIdsList).getClientsList(); |
| 66 | 66 | ||
| 67 | final var queryOrderDto = OrderDbDTO.QueryOrderByConditionDto.builder() | 67 | final var queryOrderDto = OrderDbDTO.QueryOrderByConditionDto.builder() |
| 68 | .enterpriseId(loginInfo.getEnterpriseId()) | 68 | .enterpriseId(loginInfo.getEnterpriseId()) | ... | ... |
| 1 | +package com.infoloop.tianting.logic.task; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 5 | +import com.infoloop.tianting.enums.LoginSourceEnum; | ||
| 6 | +import com.infoloop.tianting.mealorderservice.MealOrderCreation; | ||
| 7 | +import com.infoloop.tianting.mealorderservice.MealOrderOrderMethodEnum; | ||
| 8 | +import com.infoloop.tianting.mealorderservice.MenuSchedule; | ||
| 9 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 10 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 11 | +import com.infoloop.tianting.mealorderservice.SingleMealMenuRecordRpcResponse; | ||
| 12 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 13 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 14 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 15 | +import com.infoloop.tianting.utils.DateUtil; | ||
| 16 | +import lombok.RequiredArgsConstructor; | ||
| 17 | +import lombok.extern.slf4j.Slf4j; | ||
| 18 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 19 | +import org.springframework.stereotype.Component; | ||
| 20 | + | ||
| 21 | +import java.time.DayOfWeek; | ||
| 22 | +import java.time.Instant; | ||
| 23 | +import java.time.LocalDate; | ||
| 24 | +import java.time.LocalTime; | ||
| 25 | +import java.time.ZonedDateTime; | ||
| 26 | +import java.time.temporal.TemporalAdjusters; | ||
| 27 | +import java.util.List; | ||
| 28 | +import java.util.Map; | ||
| 29 | +import java.util.Objects; | ||
| 30 | +import java.util.function.Function; | ||
| 31 | +import java.util.stream.Collectors; | ||
| 32 | +import java.util.stream.IntStream; | ||
| 33 | + | ||
| 34 | +@Slf4j | ||
| 35 | +@Component | ||
| 36 | +@RequiredArgsConstructor | ||
| 37 | +public class AutoCreateMealOrderTask { | ||
| 38 | + | ||
| 39 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 40 | + | ||
| 41 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | ||
| 42 | + | ||
| 43 | + @Scheduled(cron = "59 59 23 ? * SUN") | ||
| 44 | + public void executeTask() { | ||
| 45 | + final int enterpriseId = 449; | ||
| 46 | + final var today = LocalDate.now(); | ||
| 47 | + final var thisWeekStart = today.with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE); | ||
| 48 | + final var thisWeekEnd = today.with(DayOfWeek.SUNDAY).atTime(LocalTime.MAX).atZone(DateUtil.CHINA_ZONE); | ||
| 49 | + final var nextWeekStart = today.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).atStartOfDay().atZone(DateUtil.CHINA_ZONE); | ||
| 50 | + | ||
| 51 | + // 查询本周已订餐学生 ID | ||
| 52 | + final var mealOrders = mealOrderServiceRpcClient.queryMealOrdersByCondition(enterpriseId, null, thisWeekStart.toInstant().toEpochMilli(), thisWeekEnd.toInstant().toEpochMilli()); | ||
| 53 | + final var dinerIds = mealOrders.stream().map(SingleMealOrderRpcResponse::getDinerId).collect(Collectors.toSet()); | ||
| 54 | + | ||
| 55 | + // 所有学生 & 未订餐学生 | ||
| 56 | + final var allDiners = mealOrderServiceRpcClient.queryDinersByCondition(enterpriseId, null, null, null); | ||
| 57 | + final var notReservedDiners = allDiners.stream().filter(diner -> !dinerIds.contains(diner.getId())).toList(); | ||
| 58 | + if (notReservedDiners.isEmpty()) { | ||
| 59 | + log.info("无未订餐学生,跳过自动订餐任务"); | ||
| 60 | + return; | ||
| 61 | + } | ||
| 62 | + // 所需关联数据查询 | ||
| 63 | + final var clientIds = notReservedDiners.stream().map(SingleDinerRpcResponse::getClientId).distinct().toList(); | ||
| 64 | + final var classIds = notReservedDiners.stream().map(SingleDinerRpcResponse::getClassId).distinct().toList(); | ||
| 65 | + final var clientMap = clientInventoryServiceRpcClient.getClientsByIds(enterpriseId, clientIds).getClientsList().stream().collect(Collectors.toMap(SingleClientRpcResponse::getId, Function.identity())); | ||
| 66 | + final var gradeClassMap = mealOrderServiceRpcClient.getGradeClassesByIds(enterpriseId, classIds).stream().collect(Collectors.toMap(SingleGradeClassRpcResponse::getId, Function.identity())); | ||
| 67 | + final var latestMealMenuRecordMap = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(enterpriseId, clientIds).stream().collect(Collectors.toMap(SingleMealMenuRecordRpcResponse::getClientId, Function.identity())); | ||
| 68 | + // 构建创建请求 | ||
| 69 | + final var creations = notReservedDiners.stream().map(diner -> toMealOrderCreation(diner, clientMap, gradeClassMap, latestMealMenuRecordMap, nextWeekStart)).filter(Objects::nonNull).toList(); | ||
| 70 | + if (creations.isEmpty()) { | ||
| 71 | + log.info("无可创建自动订餐项,跳过任务"); | ||
| 72 | + return; | ||
| 73 | + } | ||
| 74 | + final var loginInfo = LoginContextHolder.LoginInfo.builder() | ||
| 75 | + .id(0) | ||
| 76 | + .enterpriseId(enterpriseId) | ||
| 77 | + .loginSource(LoginSourceEnum.MINI_PROGRAM) | ||
| 78 | + .build(); | ||
| 79 | + mealOrderServiceRpcClient.batchCreateMealOrders(loginInfo, creations); | ||
| 80 | + log.info("本周未订餐学生已自动补单 {} 条", creations.size()); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private MealOrderCreation toMealOrderCreation(SingleDinerRpcResponse diner, | ||
| 84 | + Map<Integer, SingleClientRpcResponse> clientMap, | ||
| 85 | + Map<Integer, SingleGradeClassRpcResponse> classMap, | ||
| 86 | + Map<Integer, SingleMealMenuRecordRpcResponse> menuMap, | ||
| 87 | + ZonedDateTime startOfNextWeek) { | ||
| 88 | + final var menu = menuMap.get(diner.getClientId()); | ||
| 89 | + final var client = clientMap.get(diner.getClientId()); | ||
| 90 | + final var gradeClass = classMap.get(diner.getClassId()); | ||
| 91 | + if (menu == null || client == null || gradeClass == null) return null; | ||
| 92 | + return MealOrderCreation.newBuilder() | ||
| 93 | + .setClientId(diner.getClientId()) | ||
| 94 | + .setMenuId(menu.getId()) | ||
| 95 | + .setAccountId(0) | ||
| 96 | + .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_SYSTEM) | ||
| 97 | + .setDinerId(diner.getId()) | ||
| 98 | + .setDinerName(diner.getName()) | ||
| 99 | + .setClientName(client.getName()) | ||
| 100 | + .setGradeName(gradeClass.getGradeName()) | ||
| 101 | + .setClassName(gradeClass.getClassName()) | ||
| 102 | + .setStudentNo(diner.getStudentNo()) | ||
| 103 | + .setReserveDate(Instant.now().toEpochMilli()) | ||
| 104 | + .addAllMeals(buildNextWeekMeals(startOfNextWeek)) | ||
| 105 | + .build(); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + private List<MenuSchedule> buildNextWeekMeals(ZonedDateTime nextWeekStart) { | ||
| 109 | + return IntStream.range(0, 5) | ||
| 110 | + .mapToObj(i -> MenuSchedule.newBuilder() | ||
| 111 | + .setDate(nextWeekStart.plusDays(i).format(DateUtil.YYYY_MM_DD_LEFT_SYMBOL)) | ||
| 112 | + .setMenu("A") | ||
| 113 | + .build()) | ||
| 114 | + .toList(); | ||
| 115 | + } | ||
| 116 | +} |
| ... | @@ -10,7 +10,7 @@ import java.util.List; | ... | @@ -10,7 +10,7 @@ import java.util.List; |
| 10 | 10 | ||
| 11 | @Data | 11 | @Data |
| 12 | @ApiModel(description = "院区DTO") | 12 | @ApiModel(description = "院区DTO") |
| 13 | -public class InventoryDbDTO { | 13 | +public class ClientInventoryDbDTO { |
| 14 | 14 | ||
| 15 | @Data | 15 | @Data |
| 16 | @Builder | 16 | @Builder |
| ... | @@ -30,7 +30,7 @@ public class InventoryDbDTO { | ... | @@ -30,7 +30,7 @@ public class InventoryDbDTO { |
| 30 | private Integer allowedPaid; | 30 | private Integer allowedPaid; |
| 31 | private Integer regionId; | 31 | private Integer regionId; |
| 32 | private ClientType type; | 32 | private ClientType type; |
| 33 | - CustomerSource customerSource; | 33 | + private CustomerSource customerSource; |
| 34 | private boolean isDelivery; | 34 | private boolean isDelivery; |
| 35 | } | 35 | } |
| 36 | 36 | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import javax.validation.constraints.NotEmpty; | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | + | ||
| 10 | +@Data | ||
| 11 | +@ApiModel(description = "就餐人DTO") | ||
| 12 | +public class DinerDTO { | ||
| 13 | + | ||
| 14 | + @Data | ||
| 15 | + @ApiModel(description = "查询唯一就餐人") | ||
| 16 | + public static class QueryUniqueDinerDTO { | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "学号") | ||
| 19 | + @NotEmpty(message = "学号不能为空") | ||
| 20 | + private String studentNo; | ||
| 21 | + | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + @Data | ||
| 26 | + @ApiModel(description = "添加就餐人") | ||
| 27 | + public static class CreateDinerDTO { | ||
| 28 | + | ||
| 29 | + @ApiModelProperty(value = "学校编码") | ||
| 30 | + @NotEmpty(message = "学校编码不能为空") | ||
| 31 | + private String clientCode; | ||
| 32 | + | ||
| 33 | + @ApiModelProperty(value = "班级") | ||
| 34 | + @NotNull(message = "班级不能为空") | ||
| 35 | + private Integer classId; | ||
| 36 | + | ||
| 37 | + @ApiModelProperty(value = "学号") | ||
| 38 | + @NotEmpty(message = "学号不能为空") | ||
| 39 | + private String studentNo; | ||
| 40 | + | ||
| 41 | + @ApiModelProperty(value = "姓名") | ||
| 42 | + @NotEmpty(message = "姓名不能为空") | ||
| 43 | + private String name; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Data | ||
| 47 | + @ApiModel(description = "修改就餐人") | ||
| 48 | + public static class UpdateDinerDTO { | ||
| 49 | + | ||
| 50 | + @ApiModelProperty(value = "学校编码") | ||
| 51 | + @NotEmpty(message = "学校编码不能为空") | ||
| 52 | + private String clientCode; | ||
| 53 | + | ||
| 54 | + @ApiModelProperty(value = "班级") | ||
| 55 | + @NotNull(message = "班级不能为空") | ||
| 56 | + private Integer classId; | ||
| 57 | + | ||
| 58 | + @ApiModelProperty(value = "学号") | ||
| 59 | + private String studentNo; | ||
| 60 | + | ||
| 61 | + @ApiModelProperty(value = "姓名") | ||
| 62 | + private String name; | ||
| 63 | + } | ||
| 64 | +} |
| ... | @@ -2,7 +2,7 @@ package com.infoloop.tianting.model.dto; | ... | @@ -2,7 +2,7 @@ package com.infoloop.tianting.model.dto; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 3 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | 4 | import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 6 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto; | 6 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerDetailDto; |
| 7 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | 7 | import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; |
| 8 | import io.swagger.annotations.ApiModel; | 8 | import io.swagger.annotations.ApiModel; | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.annotation.RequestKeyParam; | ||
| 4 | +import com.infoloop.tianting.enums.QueryMealOrderStatusEnum; | ||
| 5 | +import io.swagger.annotations.ApiModel; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import javax.validation.Valid; | ||
| 9 | +import javax.validation.constraints.NotEmpty; | ||
| 10 | +import javax.validation.constraints.NotNull; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +@Data | ||
| 14 | +@ApiModel(description = "订餐DTO") | ||
| 15 | +public class MealOrderDTO { | ||
| 16 | + | ||
| 17 | + @Data | ||
| 18 | + @ApiModel(description = "查询订餐记录") | ||
| 19 | + public static class QueryMealOrderDTO { | ||
| 20 | + | ||
| 21 | + @NotNull(message = "status不能为空") | ||
| 22 | + private QueryMealOrderStatusEnum status; | ||
| 23 | + | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Data | ||
| 27 | + @ApiModel(description = "创建订餐记录") | ||
| 28 | + public static class CreateMealOrderDTO { | ||
| 29 | + | ||
| 30 | + @NotNull(message = "就餐人 ID 不能为空") | ||
| 31 | + @RequestKeyParam | ||
| 32 | + private Integer dinerId; | ||
| 33 | + | ||
| 34 | + @NotEmpty(message = "订餐详情不能为空") | ||
| 35 | + @NotNull(message = "订餐详情不能为空") | ||
| 36 | + @Valid | ||
| 37 | + private List<CreateMeals> meals; | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Data | ||
| 42 | + @ApiModel(description = "创建订餐记录详情") | ||
| 43 | + public static class CreateMeals { | ||
| 44 | + | ||
| 45 | + @NotEmpty(message = "日期不能为空") | ||
| 46 | + private String date; | ||
| 47 | + | ||
| 48 | + @NotEmpty(message = "菜单不能为空") | ||
| 49 | + private String menu; | ||
| 50 | + } | ||
| 51 | +} |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MpAccountGenderEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(description = "小程序用户DTO") | ||
| 10 | +public class MpAccountDTO { | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + @Data | ||
| 14 | + @ApiModel(description = "修改小程序用户") | ||
| 15 | + public static class ModifyMpAccountDTO { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "昵称") | ||
| 18 | + private String nickName; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "头像") | ||
| 21 | + private String avatarUrl; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "性别") | ||
| 24 | + private MpAccountGenderEnum gender; | ||
| 25 | + } | ||
| 26 | +} |
| ... | @@ -27,6 +27,10 @@ public class PermissionDTO { | ... | @@ -27,6 +27,10 @@ public class PermissionDTO { |
| 27 | @Builder.Default | 27 | @Builder.Default |
| 28 | private String openCode = ""; | 28 | private String openCode = ""; |
| 29 | @Builder.Default | 29 | @Builder.Default |
| 30 | + private boolean shouldLoginWithOpenId = false; | ||
| 31 | + @Builder.Default | ||
| 32 | + private String openId = ""; | ||
| 33 | + @Builder.Default | ||
| 30 | private boolean shouldLoginWithKdsEmail = false; | 34 | private boolean shouldLoginWithKdsEmail = false; |
| 31 | @Builder.Default | 35 | @Builder.Default |
| 32 | private String email = ""; | 36 | private String email = ""; | ... | ... |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "订餐规则") | ||
| 10 | +@Builder | ||
| 11 | +public class DeliveryRuleVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "订餐开始时间") | ||
| 14 | + private String startTime; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "订餐结束时间") | ||
| 17 | + private String endTime; | ||
| 18 | + | ||
| 19 | + private Boolean monday; | ||
| 20 | + private Boolean tuesday; | ||
| 21 | + private Boolean wednesday; | ||
| 22 | + private Boolean thursday; | ||
| 23 | + private Boolean friday; | ||
| 24 | + private Boolean saturday; | ||
| 25 | + private Boolean sunday; | ||
| 26 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "就餐人信息") | ||
| 10 | +@Builder | ||
| 11 | +public class DinerVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "就餐人 ID") | ||
| 14 | + private int id; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "企业 ID") | ||
| 17 | + private int enterpriseId; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty(value = "就餐人学校 ID") | ||
| 20 | + private int clientId; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty(value = "就餐人学校代码") | ||
| 23 | + private String clientCode; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "就餐人学校名称") | ||
| 26 | + private String clientName; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty(value = "就餐人班级 ID") | ||
| 29 | + private int classId; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty(value = "就餐人年级名称") | ||
| 32 | + private String gradeName; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty(value = "就餐人班级名称") | ||
| 35 | + private String className; | ||
| 36 | + | ||
| 37 | + @ApiModelProperty(value = "就餐人学号") | ||
| 38 | + private String studentNo; | ||
| 39 | + | ||
| 40 | + @ApiModelProperty(value = "就餐人姓名") | ||
| 41 | + private String name; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty(value = "是否已预定") | ||
| 44 | + private boolean isReserve; | ||
| 45 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "班级年级信息") | ||
| 10 | +@Builder | ||
| 11 | +public class GradeClassVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty("ID") | ||
| 14 | + private Integer id; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("企业 ID") | ||
| 17 | + private Integer enterpriseId; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty("年级") | ||
| 20 | + private String gradeName; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty("班级") | ||
| 23 | + private String className; | ||
| 24 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MealOrderOrderMethodEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Builder; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@Data | ||
| 12 | +@Builder | ||
| 13 | +@ApiModel(value = "订餐记录信息") | ||
| 14 | +public class MealOrderVO { | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("ID") | ||
| 17 | + private int id; | ||
| 18 | + | ||
| 19 | + @ApiModelProperty("项目点ID") | ||
| 20 | + private int clientId; | ||
| 21 | + | ||
| 22 | + @ApiModelProperty("餐单ID") | ||
| 23 | + private int menuId; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty("用户ID") | ||
| 26 | + private int accountId; | ||
| 27 | + | ||
| 28 | + @ApiModelProperty("订餐方式") | ||
| 29 | + private MealOrderOrderMethodEnum orderMethod; | ||
| 30 | + | ||
| 31 | + @ApiModelProperty("就餐人 id") | ||
| 32 | + private int dinerId; | ||
| 33 | + | ||
| 34 | + @ApiModelProperty("就餐人名称") | ||
| 35 | + private String dinerName; | ||
| 36 | + | ||
| 37 | + @ApiModelProperty("项目点名称") | ||
| 38 | + private String clientName; | ||
| 39 | + | ||
| 40 | + @ApiModelProperty("年级名称") | ||
| 41 | + private String gradeName; | ||
| 42 | + | ||
| 43 | + @ApiModelProperty("班级名称") | ||
| 44 | + private String className; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty("学生学号") | ||
| 47 | + private String studentNo; | ||
| 48 | + | ||
| 49 | + @ApiModelProperty("订餐时间") | ||
| 50 | + private String reserveDate; | ||
| 51 | + | ||
| 52 | + @ApiModelProperty("订餐餐单") | ||
| 53 | + private List<Meals> meals; | ||
| 54 | + | ||
| 55 | + @Data | ||
| 56 | + @Builder | ||
| 57 | + @ApiModel(description = "订餐信息") | ||
| 58 | + public static class Meals { | ||
| 59 | + | ||
| 60 | + @ApiModelProperty("订餐日期") | ||
| 61 | + private String date; | ||
| 62 | + | ||
| 63 | + @ApiModelProperty("订餐餐单") | ||
| 64 | + private String menu; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + | ||
| 69 | +} |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.MpAccountGenderEnum; | ||
| 4 | +import io.swagger.annotations.ApiModel; | ||
| 5 | +import io.swagger.annotations.ApiModelProperty; | ||
| 6 | +import lombok.Builder; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +@Data | ||
| 10 | +@ApiModel(value = "小程序账号信息") | ||
| 11 | +@Builder | ||
| 12 | +public class MpAccountVO { | ||
| 13 | + | ||
| 14 | + @ApiModelProperty("ID") | ||
| 15 | + private Integer id; | ||
| 16 | + | ||
| 17 | + @ApiModelProperty("企业 ID") | ||
| 18 | + private Integer enterpriseId; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty("openId") | ||
| 21 | + private String openId; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty("unionId") | ||
| 24 | + private String unionId; | ||
| 25 | + | ||
| 26 | + @ApiModelProperty("昵称") | ||
| 27 | + private String nickname; | ||
| 28 | + | ||
| 29 | + @ApiModelProperty("头像地址") | ||
| 30 | + private String avatarUrl; | ||
| 31 | + | ||
| 32 | + @ApiModelProperty("性别") | ||
| 33 | + private MpAccountGenderEnum gender; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty("手机号") | ||
| 36 | + private String phoneNumber; | ||
| 37 | +} |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +import com.aliyun.oss.OSS; | ||
| 4 | +import com.aliyun.oss.OSSClientBuilder; | ||
| 5 | +import com.aliyun.oss.model.GetObjectRequest; | ||
| 6 | + | ||
| 7 | +import java.io.ByteArrayInputStream; | ||
| 8 | +import java.io.File; | ||
| 9 | +import java.io.InputStream; | ||
| 10 | + | ||
| 11 | +public class OssStorageService implements StorageService{ | ||
| 12 | + private final OSS ossClient; | ||
| 13 | + | ||
| 14 | + public OssStorageService(String endpoint, String accessKeyId, String accessKeySecret) { | ||
| 15 | + this.ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + @Override | ||
| 19 | + public void putObject(String bucketName, String key, byte[] data) { | ||
| 20 | + ossClient.putObject(bucketName, key, new ByteArrayInputStream(data)); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public void putObject(String bucketName, String key, File file) { | ||
| 25 | + ossClient.putObject(bucketName, key, file); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public void putObject(String bucketName, String key, InputStream stream) { | ||
| 30 | + ossClient.putObject(bucketName, key, stream); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public InputStream getObjectInputStream(String bucketName, String key) { | ||
| 35 | + return ossClient.getObject(new GetObjectRequest(bucketName, key)).getObjectContent(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public void close() throws Exception { | ||
| 40 | + ossClient.shutdown(); | ||
| 41 | + } | ||
| 42 | +} |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.io.InputStream; | ||
| 5 | + | ||
| 6 | +public interface StorageService extends AutoCloseable { | ||
| 7 | + | ||
| 8 | + void putObject(String bucketName, String key, byte[] data) throws Exception; | ||
| 9 | + | ||
| 10 | + void putObject(String bucketName, String key, File file) throws Exception; | ||
| 11 | + | ||
| 12 | + void putObject(String bucketName, String key, InputStream stream) throws Exception; | ||
| 13 | + | ||
| 14 | + InputStream getObjectInputStream(String bucketName, String key); | ||
| 15 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.infoloop.tianting.server; | ||
| 2 | + | ||
| 3 | +public class StorageServiceFactory { | ||
| 4 | + public static StorageService createStorageService(String endpoint, String accessKey, String accessSecret) { | ||
| 5 | + if (endpoint.contains("aliyuncs.com")) { | ||
| 6 | + return new OssStorageService(endpoint, accessKey, accessSecret); | ||
| 7 | + } else { | ||
| 8 | + throw new IllegalArgumentException("Unsupported storage type: " + endpoint); | ||
| 9 | + } | ||
| 10 | + } | ||
| 11 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; | ||
| 4 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; | ||
| 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; | ||
| 6 | + | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +public interface ClientInventoryService { | ||
| 10 | + | ||
| 11 | + ClientDto getClientById(Integer enterpriseId, Integer clientId); | ||
| 12 | + | ||
| 13 | + List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId); | ||
| 14 | + | ||
| 15 | + List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto); | ||
| 16 | + | ||
| 17 | + List<ClientDto> getClientsByCodes(List<String> codes); | ||
| 18 | +} |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 6 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 7 | +import com.infoloop.tianting.model.dto.DinerDTO; | ||
| 8 | +import com.infoloop.tianting.model.vo.DinerVO; | ||
| 9 | +import com.infoloop.tianting.model.vo.GradeClassVO; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +public interface DinerService { | ||
| 14 | + | ||
| 15 | + List<DinerVO> getMpAccountDiners(); | ||
| 16 | + | ||
| 17 | + CreatedResult<DinerVO> createMpAccountDiner(DinerDTO.CreateDinerDTO createDinerDTO); | ||
| 18 | + | ||
| 19 | + List<GradeClassVO> getClientGradeClasses(SingleClientRpcResponse client); | ||
| 20 | + | ||
| 21 | + void updateMpAccountDiner(SingleDinerRpcResponse diner, DinerDTO.UpdateDinerDTO updateDinerDTO); | ||
| 22 | + | ||
| 23 | + void deleteMpAccountDiner(SingleDinerRpcResponse diner); | ||
| 24 | + | ||
| 25 | + DinerVO getClientClassDiner(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo); | ||
| 26 | +} |
| 1 | -package com.infoloop.tianting.service; | ||
| 2 | - | ||
| 3 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | ||
| 4 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | ||
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | ||
| 6 | - | ||
| 7 | -import java.util.List; | ||
| 8 | - | ||
| 9 | -public interface InventoryService { | ||
| 10 | - | ||
| 11 | - ClientDto getClientById(Integer enterpriseId, Integer clientId); | ||
| 12 | - | ||
| 13 | - List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId); | ||
| 14 | - | ||
| 15 | - List<ClientTableCodeDto> queryClientTableCodesByCondition( | ||
| 16 | - TableCodeQueryConditionDto tableCodeQueryConditionDto); | ||
| 17 | - | ||
| 18 | -} |
| 1 | package com.infoloop.tianting.service; | 1 | package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | import cn.dev33.satoken.stp.SaTokenInfo; | 3 | import cn.dev33.satoken.stp.SaTokenInfo; |
| 4 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 5 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 4 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; | 6 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; |
| 7 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 5 | 8 | ||
| 6 | import java.security.NoSuchAlgorithmException; | 9 | import java.security.NoSuchAlgorithmException; |
| 7 | 10 | ||
| 8 | public interface LoginService { | 11 | public interface LoginService { |
| 9 | SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException; | 12 | SaTokenInfo login(LoginDto loginDto) throws NoSuchAlgorithmException; |
| 13 | + | ||
| 14 | + MpAccountVO getMpAccountByOpenId(String openId); | ||
| 15 | + | ||
| 16 | + void updateMpAccount(SingleMpAccountRpcResponse mpAccount, MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO); | ||
| 10 | } | 17 | } | ... | ... |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 4 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 5 | +import com.infoloop.tianting.model.dto.MealOrderDTO; | ||
| 6 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 7 | +import com.infoloop.tianting.model.vo.MealOrderVO; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +public interface MealOrderService { | ||
| 12 | + | ||
| 13 | + List<MealOrderVO> queryMealOrders(MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO); | ||
| 14 | + | ||
| 15 | + CreatedResult<MealOrderVO> createMealOrder(MealOrderDTO.CreateMealOrderDTO createMealOrderDTO); | ||
| 16 | + | ||
| 17 | + MealOrderVO getMealOrderById(SingleMealOrderRpcResponse mealOrder); | ||
| 18 | + | ||
| 19 | + DeliveryRuleVO getDeliveryRule(); | ||
| 20 | +} |
| 1 | package com.infoloop.tianting.service; | 1 | package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; | 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; |
| 5 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; | 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsResponseDto; |
| 6 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDetailDto; | 7 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDetailDto; |
| ... | @@ -24,4 +25,6 @@ public interface MenuService { | ... | @@ -24,4 +25,6 @@ public interface MenuService { |
| 24 | BatchCreateMenuRefsResponseDto batchCreateMenuRefs(BatchCreateMenuRefsDto batchCreateMenuRefsDto); | 25 | BatchCreateMenuRefsResponseDto batchCreateMenuRefs(BatchCreateMenuRefsDto batchCreateMenuRefsDto); |
| 25 | 26 | ||
| 26 | List<Integer> queryMenuSkuIdsByStallId(int enterpriseId, int stallId); | 27 | List<Integer> queryMenuSkuIdsByStallId(int enterpriseId, int stallId); |
| 28 | + | ||
| 29 | + String queryClientLatestMealMenuRecord(SingleClientRpcResponse client); | ||
| 27 | } | 30 | } | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service.client; | ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcRequest; | 3 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcRequest; |
| 4 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcResponse; | 4 | import com.infoloop.tianting.clientinventoryservice.GetClientByIdRpcResponse; |
| 5 | +import com.infoloop.tianting.clientinventoryservice.GetClientsByCodesRpcRequest; | ||
| 5 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcRequest; | 6 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcRequest; |
| 6 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcResponse; | 7 | import com.infoloop.tianting.clientinventoryservice.GetClientsByIdsRpcResponse; |
| 7 | import com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcRequest; | 8 | import com.infoloop.tianting.clientinventoryservice.GetStallsByClientIdRpcRequest; |
| ... | @@ -10,8 +11,9 @@ import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcRequest; | ... | @@ -10,8 +11,9 @@ import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcRequest; |
| 10 | import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcResponse; | 11 | import com.infoloop.tianting.clientinventoryservice.GetStallsByIdsRpcResponse; |
| 11 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcRequest; | 12 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcRequest; |
| 12 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse; | 13 | import com.infoloop.tianting.clientinventoryservice.QueryClientTableCodesByConditionRpcResponse; |
| 14 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 13 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; | 15 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; |
| 14 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 16 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 15 | import lombok.RequiredArgsConstructor; | 17 | import lombok.RequiredArgsConstructor; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| ... | @@ -20,7 +22,7 @@ import java.util.List; | ... | @@ -20,7 +22,7 @@ import java.util.List; |
| 20 | 22 | ||
| 21 | @Service | 23 | @Service |
| 22 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 24 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 23 | -public class InventoryServiceRpcClient { | 25 | +public class ClientInventoryServiceRpcClient { |
| 24 | 26 | ||
| 25 | private final TiantingClientInventoryServiceRpcGrpc.TiantingClientInventoryServiceRpcBlockingStub | 27 | private final TiantingClientInventoryServiceRpcGrpc.TiantingClientInventoryServiceRpcBlockingStub |
| 26 | inventoryServiceRpcBlockingStub; | 28 | inventoryServiceRpcBlockingStub; |
| ... | @@ -43,6 +45,15 @@ public class InventoryServiceRpcClient { | ... | @@ -43,6 +45,15 @@ public class InventoryServiceRpcClient { |
| 43 | return inventoryServiceRpcBlockingStub.getClientsByIds(request); | 45 | return inventoryServiceRpcBlockingStub.getClientsByIds(request); |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 48 | + public List<SingleClientRpcResponse> getClientsByCodes(Integer enterpriseId, List<String> codes) { | ||
| 49 | + final var request = GetClientsByCodesRpcRequest.newBuilder() | ||
| 50 | + .setEnterpriseId(enterpriseId) | ||
| 51 | + .addAllCodes(codes) | ||
| 52 | + .setIncludeDeleted(false) | ||
| 53 | + .build(); | ||
| 54 | + return inventoryServiceRpcBlockingStub.getClientsByCodes(request).getClientsList(); | ||
| 55 | + } | ||
| 56 | + | ||
| 46 | public GetStallsByIdsRpcResponse getStallsByIds(Integer enterpriseId, List<Integer> stallIds) { | 57 | public GetStallsByIdsRpcResponse getStallsByIds(Integer enterpriseId, List<Integer> stallIds) { |
| 47 | final var request = GetStallsByIdsRpcRequest.newBuilder() | 58 | final var request = GetStallsByIdsRpcRequest.newBuilder() |
| 48 | .setEnterpriseId(enterpriseId) | 59 | .setEnterpriseId(enterpriseId) | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.deliveryruleservice.DeliveryTemplateTypeEnum; | ||
| 3 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; | 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; |
| 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; | 5 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; |
| 6 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcRequest; | ||
| 7 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcResponse; | ||
| 5 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; | 8 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; |
| 6 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; | 9 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; |
| 7 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 10 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { | ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { |
| 40 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); | 43 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); |
| 41 | } | 44 | } |
| 42 | 45 | ||
| 46 | + public GetDefaultDeliveryTemplateAndRuleRpcResponse getDefaultDeliveryTemplateAndRule(int enterpriseId) { | ||
| 47 | + final var request = GetDefaultDeliveryTemplateAndRuleRpcRequest | ||
| 48 | + .newBuilder() | ||
| 49 | + .setEnterpriseId(enterpriseId) | ||
| 50 | + .setType(DeliveryTemplateTypeEnum.DELIVERY_TEMPLATE_TYPE_DELIVERY) | ||
| 51 | + .build(); | ||
| 52 | + return deliveryRuleServiceRpcBlockingStub.getDefaultDeliveryTemplateAndRule(request); | ||
| 53 | + } | ||
| 54 | + | ||
| 43 | 55 | ||
| 44 | } | 56 | } | ... | ... |
| 1 | +package com.infoloop.tianting.service.client; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 4 | +import com.infoloop.tianting.enums.LoginSourceEnum; | ||
| 5 | +import com.infoloop.tianting.mealorderservice.BatchCreateMealOrdersRpcRequest; | ||
| 6 | +import com.infoloop.tianting.mealorderservice.BatchCreateMealOrdersRpcResponse; | ||
| 7 | +import com.infoloop.tianting.mealorderservice.CreateDinerRpcRequest; | ||
| 8 | +import com.infoloop.tianting.mealorderservice.CreateDinerRpcResponse; | ||
| 9 | +import com.infoloop.tianting.mealorderservice.CreateMealOrderRpcRequest; | ||
| 10 | +import com.infoloop.tianting.mealorderservice.CreateMealOrderRpcResponse; | ||
| 11 | +import com.infoloop.tianting.mealorderservice.CreateMpAccountDinerRefRpcRequest; | ||
| 12 | +import com.infoloop.tianting.mealorderservice.CreateMpAccountDinerRefRpcResponse; | ||
| 13 | +import com.infoloop.tianting.mealorderservice.CreateMpAccountRpcRequest; | ||
| 14 | +import com.infoloop.tianting.mealorderservice.CreateMpAccountRpcResponse; | ||
| 15 | +import com.infoloop.tianting.mealorderservice.DeleteDinersByIdsRpcRequest; | ||
| 16 | +import com.infoloop.tianting.mealorderservice.DeleteMpAccountDinerRefsByIdsRpcRequest; | ||
| 17 | +import com.infoloop.tianting.mealorderservice.DinerCreation; | ||
| 18 | +import com.infoloop.tianting.mealorderservice.DinerModification; | ||
| 19 | +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcRequest; | ||
| 20 | +import com.infoloop.tianting.mealorderservice.GetDinerByIdRpcResponse; | ||
| 21 | +import com.infoloop.tianting.mealorderservice.GetDinersByIdsRpcRequest; | ||
| 22 | +import com.infoloop.tianting.mealorderservice.GetGradeClassByIdRpcRequest; | ||
| 23 | +import com.infoloop.tianting.mealorderservice.GetGradeClassesByIdsRpcRequest; | ||
| 24 | +import com.infoloop.tianting.mealorderservice.GetMealOrderByIdRpcRequest; | ||
| 25 | +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcRequest; | ||
| 26 | +import com.infoloop.tianting.mealorderservice.GetMpAccountByIdRpcResponse; | ||
| 27 | +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcRequest; | ||
| 28 | +import com.infoloop.tianting.mealorderservice.GetMpAccountByOpenIdRpcResponse; | ||
| 29 | +import com.infoloop.tianting.mealorderservice.MealOrderCreation; | ||
| 30 | +import com.infoloop.tianting.mealorderservice.MealOrderServiceRpcGrpc; | ||
| 31 | +import com.infoloop.tianting.mealorderservice.MpAccountCreation; | ||
| 32 | +import com.infoloop.tianting.mealorderservice.MpAccountDinerRefCreation; | ||
| 33 | +import com.infoloop.tianting.mealorderservice.MpAccountModification; | ||
| 34 | +import com.infoloop.tianting.mealorderservice.QueryDinersByConditionRpcRequest; | ||
| 35 | +import com.infoloop.tianting.mealorderservice.QueryGradeClassesByConditionRpcRequest; | ||
| 36 | +import com.infoloop.tianting.mealorderservice.QueryLatestMealMenuRecordsByClientIdsRpcRequest; | ||
| 37 | +import com.infoloop.tianting.mealorderservice.QueryMealOrdersByConditionRpcRequest; | ||
| 38 | +import com.infoloop.tianting.mealorderservice.QueryMpAccountDinerRefsByConditionRpcRequest; | ||
| 39 | +import com.infoloop.tianting.mealorderservice.QueryReserveMealOrdersByDinerIdsRpcRequest; | ||
| 40 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 41 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 42 | +import com.infoloop.tianting.mealorderservice.SingleMealMenuRecordRpcResponse; | ||
| 43 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 44 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountDinerRefRpcResponse; | ||
| 45 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 46 | +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcRequest; | ||
| 47 | +import com.infoloop.tianting.mealorderservice.UpdateDinerRpcResponse; | ||
| 48 | +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcRequest; | ||
| 49 | +import com.infoloop.tianting.mealorderservice.UpdateMpAccountRpcResponse; | ||
| 50 | +import lombok.RequiredArgsConstructor; | ||
| 51 | +import org.apache.commons.collections4.CollectionUtils; | ||
| 52 | +import org.apache.commons.lang3.StringUtils; | ||
| 53 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 54 | +import org.springframework.stereotype.Service; | ||
| 55 | + | ||
| 56 | +import javax.annotation.Nullable; | ||
| 57 | +import java.util.Collections; | ||
| 58 | +import java.util.List; | ||
| 59 | + | ||
| 60 | +@Service | ||
| 61 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 62 | +public class MealOrderServiceRpcClient { | ||
| 63 | + | ||
| 64 | + private final MealOrderServiceRpcGrpc.MealOrderServiceRpcBlockingStub mealOrderServiceRpcBlockingStub; | ||
| 65 | + | ||
| 66 | + @Nullable | ||
| 67 | + public SingleMpAccountRpcResponse getMpAccountByOpenId(String openId) { | ||
| 68 | + final GetMpAccountByOpenIdRpcResponse mpAccountByOpenId = mealOrderServiceRpcBlockingStub.getMpAccountByOpenId(GetMpAccountByOpenIdRpcRequest.newBuilder().setOpenId(openId).build()); | ||
| 69 | + if (!mpAccountByOpenId.hasResponse()) { | ||
| 70 | + return null; | ||
| 71 | + } | ||
| 72 | + return mpAccountByOpenId.getResponse(); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public CreateMpAccountRpcResponse createMpAccount(int enterpriseId, MpAccountCreation mpAccountCreation) { | ||
| 76 | + return mealOrderServiceRpcBlockingStub.createMpAccount(CreateMpAccountRpcRequest.newBuilder() | ||
| 77 | + .setEnterpriseId(enterpriseId) | ||
| 78 | + .setCreatedBy(0) | ||
| 79 | + .setCreationSource(LoginSourceEnum.MINI_PROGRAM.getValue()) | ||
| 80 | + .setCreation(mpAccountCreation) | ||
| 81 | + .build()); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + @Nullable | ||
| 85 | + public SingleMpAccountRpcResponse getMpAccountById(Integer enterpriseId, Integer id) { | ||
| 86 | + final GetMpAccountByIdRpcResponse mpAccountById = mealOrderServiceRpcBlockingStub.getMpAccountById(GetMpAccountByIdRpcRequest.newBuilder() | ||
| 87 | + .setEnterpriseId(enterpriseId) | ||
| 88 | + .setId(id) | ||
| 89 | + .build()); | ||
| 90 | + if (!mpAccountById.hasResponse()) { | ||
| 91 | + return null; | ||
| 92 | + } | ||
| 93 | + return mpAccountById.getResponse(); | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public UpdateMpAccountRpcResponse updateMpAccount(LoginContextHolder.LoginInfo loginInfo, MpAccountModification mpAccountModification) { | ||
| 97 | + return mealOrderServiceRpcBlockingStub.updateMpAccount(UpdateMpAccountRpcRequest.newBuilder() | ||
| 98 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 99 | + .setUpdatedBy(loginInfo.getId()) | ||
| 100 | + .setUpdateSource(loginInfo.getLoginSource().getValue()) | ||
| 101 | + .setModification(mpAccountModification) | ||
| 102 | + .build()); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public List<SingleMpAccountDinerRefRpcResponse> queryMpAccountDinerRefsByCondition(int enterpriseId, List<Integer> mpAccountIds, List<Integer> dinerIds) { | ||
| 106 | + return mealOrderServiceRpcBlockingStub.queryMpAccountDinerRefsByCondition(QueryMpAccountDinerRefsByConditionRpcRequest.newBuilder() | ||
| 107 | + .setEnterpriseId(enterpriseId) | ||
| 108 | + .setShouldFilterAccountIds(!mpAccountIds.isEmpty()).addAllAccountIds(mpAccountIds) | ||
| 109 | + .setShouldFilterDinerIds(!dinerIds.isEmpty()).addAllDinerIds(dinerIds) | ||
| 110 | + .build()).getResponsesList(); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Nullable | ||
| 114 | + public SingleDinerRpcResponse getDinerById(int enterpriseId, int dinerId) { | ||
| 115 | + final GetDinerByIdRpcResponse dinerById = mealOrderServiceRpcBlockingStub.getDinerById(GetDinerByIdRpcRequest.newBuilder() | ||
| 116 | + .setEnterpriseId(enterpriseId) | ||
| 117 | + .setId(dinerId) | ||
| 118 | + .build()); | ||
| 119 | + if (!dinerById.hasResponse()) { | ||
| 120 | + return null; | ||
| 121 | + } | ||
| 122 | + return dinerById.getResponse(); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public List<SingleDinerRpcResponse> getDinersByIds(int enterpriseId, List<Integer> dinerIds) { | ||
| 126 | + if (CollectionUtils.isEmpty(dinerIds)) { | ||
| 127 | + return Collections.emptyList(); | ||
| 128 | + } | ||
| 129 | + return mealOrderServiceRpcBlockingStub.getDinersByIds(GetDinersByIdsRpcRequest.newBuilder() | ||
| 130 | + .setEnterpriseId(enterpriseId) | ||
| 131 | + .addAllIds(dinerIds) | ||
| 132 | + .build()).getResponsesList(); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public List<SingleDinerRpcResponse> queryDinersByCondition(int enterpriseId, List<Integer> clientIds, List<Integer> gradeClassIds, @Nullable String studentNo) { | ||
| 136 | + return mealOrderServiceRpcBlockingStub.queryDinersByCondition(QueryDinersByConditionRpcRequest.newBuilder() | ||
| 137 | + .setEnterpriseId(enterpriseId) | ||
| 138 | + .setShouldFilterClientIds(CollectionUtils.isNotEmpty(clientIds)).addAllClientIds(CollectionUtils.isEmpty(clientIds) ? Collections.emptyList() : clientIds) | ||
| 139 | + .setShouldFilterClassIds(CollectionUtils.isNotEmpty(gradeClassIds)).addAllClassIds(CollectionUtils.isNotEmpty(gradeClassIds) ? gradeClassIds : Collections.emptyList()) | ||
| 140 | + .setShouldFilterStudentNo(StringUtils.isNotEmpty(studentNo)).setStudentNo(StringUtils.isNotEmpty(studentNo) ? studentNo : "") | ||
| 141 | + .build()).getResponsesList(); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public boolean deleteDinersByIds(LoginContextHolder.LoginInfo loginInfo, List<Integer> ids) { | ||
| 145 | + return mealOrderServiceRpcBlockingStub.deleteDinersByIds(DeleteDinersByIdsRpcRequest.newBuilder() | ||
| 146 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 147 | + .addAllIds(ids) | ||
| 148 | + .setUpdatedBy(loginInfo.getId()) | ||
| 149 | + .setUpdateSource(loginInfo.getLoginSource().getValue()) | ||
| 150 | + .build()).getIsDeleted(); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + public List<SingleGradeClassRpcResponse> getGradeClassesByIds(int enterpriseId, List<Integer> gradeClassIds) { | ||
| 154 | + if (CollectionUtils.isEmpty(gradeClassIds)) { | ||
| 155 | + return Collections.emptyList(); | ||
| 156 | + } | ||
| 157 | + return mealOrderServiceRpcBlockingStub.getGradeClassesByIds(GetGradeClassesByIdsRpcRequest.newBuilder() | ||
| 158 | + .setEnterpriseId(enterpriseId) | ||
| 159 | + .addAllIds(gradeClassIds) | ||
| 160 | + .build()).getResponsesList(); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + @Nullable | ||
| 164 | + public SingleGradeClassRpcResponse getGradeClassById(int enterpriseId, int id) { | ||
| 165 | + final var response = mealOrderServiceRpcBlockingStub.getGradeClassById(GetGradeClassByIdRpcRequest.newBuilder() | ||
| 166 | + .setEnterpriseId(enterpriseId) | ||
| 167 | + .setId(id) | ||
| 168 | + .build()); | ||
| 169 | + if (!response.hasResponse()) { | ||
| 170 | + return null; | ||
| 171 | + } | ||
| 172 | + return response.getResponse(); | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + public List<SingleMealOrderRpcResponse> queryReserveMealOrdersByDinerIds(int enterpriseId, List<Integer> dinerIds) { | ||
| 176 | + if (CollectionUtils.isEmpty(dinerIds)) { | ||
| 177 | + return Collections.emptyList(); | ||
| 178 | + } | ||
| 179 | + return mealOrderServiceRpcBlockingStub.queryReserveMealOrdersByDinerIds(QueryReserveMealOrdersByDinerIdsRpcRequest.newBuilder() | ||
| 180 | + .setEnterpriseId(enterpriseId) | ||
| 181 | + .addAllDinerIds(dinerIds) | ||
| 182 | + .build()).getResponsesList(); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + public CreateDinerRpcResponse createDiner(LoginContextHolder.LoginInfo loginInfo, DinerCreation dinerCreation) { | ||
| 186 | + return mealOrderServiceRpcBlockingStub.createDiner(CreateDinerRpcRequest.newBuilder() | ||
| 187 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 188 | + .setCreatedBy(loginInfo.getId()) | ||
| 189 | + .setCreationSource(loginInfo.getLoginSource().getValue()) | ||
| 190 | + .setCreation(dinerCreation) | ||
| 191 | + .build()); | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + public UpdateDinerRpcResponse updateDiner(LoginContextHolder.LoginInfo loginInfo, DinerModification dinerModification) { | ||
| 195 | + return mealOrderServiceRpcBlockingStub.updateDiner(UpdateDinerRpcRequest.newBuilder() | ||
| 196 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 197 | + .setUpdatedBy(loginInfo.getId()) | ||
| 198 | + .setUpdateSource(loginInfo.getLoginSource().getValue()) | ||
| 199 | + .setModification(dinerModification) | ||
| 200 | + .build()); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + public CreateMpAccountDinerRefRpcResponse createMpAccountDinerRef(LoginContextHolder.LoginInfo loginInfo, MpAccountDinerRefCreation dinerCreation) { | ||
| 204 | + return mealOrderServiceRpcBlockingStub.createMpAccountDinerRef(CreateMpAccountDinerRefRpcRequest.newBuilder() | ||
| 205 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 206 | + .setCreatedBy(loginInfo.getId()) | ||
| 207 | + .setCreationSource(loginInfo.getLoginSource().getValue()) | ||
| 208 | + .setCreation(dinerCreation) | ||
| 209 | + .build()); | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + public boolean deleteMpAccountDinerRefsByIds(int enterpriseId, List<Integer> ids) { | ||
| 213 | + if (CollectionUtils.isEmpty(ids)) { | ||
| 214 | + return false; | ||
| 215 | + } | ||
| 216 | + return mealOrderServiceRpcBlockingStub.deleteMpAccountDinerRefsByIds(DeleteMpAccountDinerRefsByIdsRpcRequest.newBuilder() | ||
| 217 | + .setEnterpriseId(enterpriseId) | ||
| 218 | + .addAllIds(ids) | ||
| 219 | + .build()).getIsDeleted(); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public List<SingleGradeClassRpcResponse> queryGradeClassesByCondition(int enterpriseId, List<Integer> clientIds) { | ||
| 223 | + return mealOrderServiceRpcBlockingStub.queryGradeClassesByCondition(QueryGradeClassesByConditionRpcRequest.newBuilder() | ||
| 224 | + .setEnterpriseId(enterpriseId) | ||
| 225 | + .setShouldFilterClientIds(!clientIds.isEmpty()).addAllClientIds(clientIds) | ||
| 226 | + .build()).getResponsesList(); | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + public List<SingleMealMenuRecordRpcResponse> queryLatestMealMenuRecordsByClientIds(int enterpriseId, List<Integer> ids) { | ||
| 230 | + if (CollectionUtils.isEmpty(ids)) { | ||
| 231 | + return Collections.emptyList(); | ||
| 232 | + } | ||
| 233 | + return mealOrderServiceRpcBlockingStub.queryLatestMealMenuRecordsByClientIds(QueryLatestMealMenuRecordsByClientIdsRpcRequest.newBuilder() | ||
| 234 | + .setEnterpriseId(enterpriseId) | ||
| 235 | + .addAllClientId(ids) | ||
| 236 | + .build()).getResponsesList(); | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + @Nullable | ||
| 240 | + public SingleMealOrderRpcResponse getMealOrderById(int enterpriseId, int id) { | ||
| 241 | + final var mealOrderById = mealOrderServiceRpcBlockingStub.getMealOrderById(GetMealOrderByIdRpcRequest.newBuilder() | ||
| 242 | + .setEnterpriseId(enterpriseId) | ||
| 243 | + .setId(id) | ||
| 244 | + .build()); | ||
| 245 | + if (!mealOrderById.hasResponse()) { | ||
| 246 | + return null; | ||
| 247 | + } | ||
| 248 | + return mealOrderById.getResponse(); | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + public CreateMealOrderRpcResponse createMealOrder(LoginContextHolder.LoginInfo loginInfo, MealOrderCreation mealOrderCreation) { | ||
| 252 | + return mealOrderServiceRpcBlockingStub.createMealOrder(CreateMealOrderRpcRequest.newBuilder() | ||
| 253 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 254 | + .setCreatedBy(loginInfo.getId()) | ||
| 255 | + .setCreationSource(loginInfo.getLoginSource().getValue()) | ||
| 256 | + .setCreation(mealOrderCreation) | ||
| 257 | + .build()); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + public BatchCreateMealOrdersRpcResponse batchCreateMealOrders(LoginContextHolder.LoginInfo loginInfo, List<MealOrderCreation> mealOrderCreations) { | ||
| 261 | + return mealOrderServiceRpcBlockingStub.batchCreateMealOrders(BatchCreateMealOrdersRpcRequest.newBuilder() | ||
| 262 | + .setEnterpriseId(loginInfo.getEnterpriseId()) | ||
| 263 | + .setCreatedBy(loginInfo.getId()) | ||
| 264 | + .setCreationSource(loginInfo.getLoginSource().getValue()) | ||
| 265 | + .addAllCreations(mealOrderCreations) | ||
| 266 | + .build()); | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + public List<SingleMealOrderRpcResponse> queryMealOrdersByCondition(int enterpriseId, Integer accountId, Long reserveDateStart, Long reserveDateEnd) { | ||
| 270 | + return mealOrderServiceRpcBlockingStub.queryMealOrdersByCondition(QueryMealOrdersByConditionRpcRequest.newBuilder() | ||
| 271 | + .setEnterpriseId(enterpriseId) | ||
| 272 | + .setShouldFilterAccountIds(accountId != null).addAccountIds(accountId == null ? 0 : accountId) | ||
| 273 | + .setShouldFilterReserveDateStart(reserveDateStart != null).setReserveDateStart(reserveDateStart == null ? 0 : reserveDateStart) | ||
| 274 | + .setShouldFilterReserveDateEnd(reserveDateEnd != null).setReserveDateEnd(reserveDateEnd == null ? 0 : reserveDateEnd) | ||
| 275 | + .build()).getResponsesList(); | ||
| 276 | + } | ||
| 277 | +} |
| 1 | package com.infoloop.tianting.service.impl; | 1 | package com.infoloop.tianting.service.impl; |
| 2 | 2 | ||
| 3 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 3 | +import com.infoloop.tianting.context.LoginContextHolder; |
| 4 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientTableCodeDto; | 4 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 5 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.TableCodeQueryConditionDto; | 5 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientTableCodeDto; |
| 6 | -import com.infoloop.tianting.service.InventoryService; | 6 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.TableCodeQueryConditionDto; |
| 7 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | 7 | +import com.infoloop.tianting.service.ClientInventoryService; |
| 8 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 8 | import com.infoloop.tianting.utils.DateUtil; | 9 | import com.infoloop.tianting.utils.DateUtil; |
| 9 | import lombok.RequiredArgsConstructor; | 10 | import lombok.RequiredArgsConstructor; |
| 10 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| ... | @@ -17,13 +18,13 @@ import java.util.stream.Collectors; | ... | @@ -17,13 +18,13 @@ import java.util.stream.Collectors; |
| 17 | @Slf4j | 18 | @Slf4j |
| 18 | @Service | 19 | @Service |
| 19 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 20 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 20 | -public class InventoryServiceImpl implements InventoryService { | 21 | +public class ClientClientInventoryServiceImpl implements ClientInventoryService { |
| 21 | 22 | ||
| 22 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 23 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 23 | 24 | ||
| 24 | @Override | 25 | @Override |
| 25 | public ClientDto getClientById(Integer enterpriseId, Integer clientId) { | 26 | public ClientDto getClientById(Integer enterpriseId, Integer clientId) { |
| 26 | - final var response = inventoryServiceRpcClient.getClientById(enterpriseId, clientId); | 27 | + final var response = clientInventoryServiceRpcClient.getClientById(enterpriseId, clientId); |
| 27 | return ClientDto.builder() | 28 | return ClientDto.builder() |
| 28 | .id(response.getClient().getId()) | 29 | .id(response.getClient().getId()) |
| 29 | .address(response.getClient().getAddress()) | 30 | .address(response.getClient().getAddress()) |
| ... | @@ -46,7 +47,7 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -46,7 +47,7 @@ public class InventoryServiceImpl implements InventoryService { |
| 46 | 47 | ||
| 47 | @Override | 48 | @Override |
| 48 | public List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId) { | 49 | public List<ClientDto> getStallsByClientId(Integer enterpriseId, Integer clientId) { |
| 49 | - final var response = inventoryServiceRpcClient.getStallsByClientId(enterpriseId, clientId); | 50 | + final var response = clientInventoryServiceRpcClient.getStallsByClientId(enterpriseId, clientId); |
| 50 | return response.getStallsList().stream().map(stall -> | 51 | return response.getStallsList().stream().map(stall -> |
| 51 | ClientDto.builder() | 52 | ClientDto.builder() |
| 52 | .id(stall.getId()) | 53 | .id(stall.getId()) |
| ... | @@ -69,7 +70,7 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -69,7 +70,7 @@ public class InventoryServiceImpl implements InventoryService { |
| 69 | 70 | ||
| 70 | @Override | 71 | @Override |
| 71 | public List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto) { | 72 | public List<ClientTableCodeDto> queryClientTableCodesByCondition(TableCodeQueryConditionDto tableCodeQueryConditionDto) { |
| 72 | - final var response = inventoryServiceRpcClient.queryClientTableCodesByCondition(tableCodeQueryConditionDto); | 73 | + final var response = clientInventoryServiceRpcClient.queryClientTableCodesByCondition(tableCodeQueryConditionDto); |
| 73 | return response.getResponsesList().stream().map(tableCode -> | 74 | return response.getResponsesList().stream().map(tableCode -> |
| 74 | ClientTableCodeDto.builder() | 75 | ClientTableCodeDto.builder() |
| 75 | .id(tableCode.getId()) | 76 | .id(tableCode.getId()) |
| ... | @@ -87,4 +88,28 @@ public class InventoryServiceImpl implements InventoryService { | ... | @@ -87,4 +88,28 @@ public class InventoryServiceImpl implements InventoryService { |
| 87 | .updateSource(tableCode.getUpdateSource()) | 88 | .updateSource(tableCode.getUpdateSource()) |
| 88 | .build()).collect(Collectors.toList()); | 89 | .build()).collect(Collectors.toList()); |
| 89 | } | 90 | } |
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public List<ClientDto> getClientsByCodes(List<String> codes) { | ||
| 94 | + final var response = clientInventoryServiceRpcClient.getClientsByCodes(LoginContextHolder.getEnterpriseId(), codes); | ||
| 95 | + return response.stream().map(client -> | ||
| 96 | + ClientDto.builder() | ||
| 97 | + .id(client.getId()) | ||
| 98 | + .address(client.getAddress()) | ||
| 99 | + .area(client.getArea()) | ||
| 100 | + .province(client.getProvince()) | ||
| 101 | + .city(client.getCity()) | ||
| 102 | + .code(client.getCode()) | ||
| 103 | + .customerSource(client.getCustomerSource()) | ||
| 104 | + .enterpriseId(client.getEnterpriseId()) | ||
| 105 | + .operatorName(client.getOperatorName()) | ||
| 106 | + .parentId(client.getParentId()) | ||
| 107 | + .status(client.getStatus()) | ||
| 108 | + .regionId(client.getRegionId()) | ||
| 109 | + .type(client.getType()) | ||
| 110 | + .name(client.getName()) | ||
| 111 | + .isDelivery(client.getIsDelivery()) | ||
| 112 | + .build()).collect(Collectors.toList()); | ||
| 113 | + } | ||
| 114 | + | ||
| 90 | } | 115 | } | ... | ... |
| 1 | +package com.infoloop.tianting.service.impl; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 4 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 5 | +import com.infoloop.tianting.exception.ClientEndExceptions; | ||
| 6 | +import com.infoloop.tianting.exception.ErrorCodeEnum; | ||
| 7 | +import com.infoloop.tianting.mealorderservice.DinerCreation; | ||
| 8 | +import com.infoloop.tianting.mealorderservice.DinerModification; | ||
| 9 | +import com.infoloop.tianting.mealorderservice.MpAccountDinerRefCreation; | ||
| 10 | +import com.infoloop.tianting.mealorderservice.SingleDinerRpcResponse; | ||
| 11 | +import com.infoloop.tianting.mealorderservice.SingleGradeClassRpcResponse; | ||
| 12 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 13 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountDinerRefRpcResponse; | ||
| 14 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 15 | +import com.infoloop.tianting.model.dto.DinerDTO; | ||
| 16 | +import com.infoloop.tianting.model.vo.DinerVO; | ||
| 17 | +import com.infoloop.tianting.model.vo.GradeClassVO; | ||
| 18 | +import com.infoloop.tianting.service.DinerService; | ||
| 19 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 20 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 21 | +import lombok.RequiredArgsConstructor; | ||
| 22 | +import lombok.extern.slf4j.Slf4j; | ||
| 23 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 24 | +import org.springframework.stereotype.Service; | ||
| 25 | + | ||
| 26 | +import java.util.Collections; | ||
| 27 | +import java.util.List; | ||
| 28 | +import java.util.function.Function; | ||
| 29 | +import java.util.stream.Collectors; | ||
| 30 | + | ||
| 31 | +@Slf4j | ||
| 32 | +@Service | ||
| 33 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 34 | +public class DinerServiceImpl implements DinerService { | ||
| 35 | + | ||
| 36 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 37 | + | ||
| 38 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public List<DinerVO> getMpAccountDiners() { | ||
| 42 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 43 | + final var mpAccountDinerRefRpcResponseList = mealOrderServiceRpcClient.queryMpAccountDinerRefsByCondition(loginInfo.getEnterpriseId(), List.of(loginInfo.getId()), Collections.emptyList()); | ||
| 44 | + final var dinerIds = mpAccountDinerRefRpcResponseList.stream().map(SingleMpAccountDinerRefRpcResponse::getDinerId).toList(); | ||
| 45 | + if (dinerIds.isEmpty()) { | ||
| 46 | + return Collections.emptyList(); | ||
| 47 | + } | ||
| 48 | + final var dinersByIds = mealOrderServiceRpcClient.getDinersByIds(loginInfo.getEnterpriseId(), dinerIds); | ||
| 49 | + final var clientIds = dinersByIds.stream().map(SingleDinerRpcResponse::getClientId).distinct().toList(); | ||
| 50 | + final var gradeClassIds = dinersByIds.stream().map(SingleDinerRpcResponse::getClassId).distinct().toList(); | ||
| 51 | + final var clientMap = clientInventoryServiceRpcClient.getClientsByIds(loginInfo.getEnterpriseId(), clientIds).getClientsList().stream().collect(Collectors.toMap(SingleClientRpcResponse::getId, Function.identity())); | ||
| 52 | + final var gradeClassMap = mealOrderServiceRpcClient.getGradeClassesByIds(loginInfo.getEnterpriseId(), gradeClassIds).stream().collect(Collectors.toMap(SingleGradeClassRpcResponse::getId, Function.identity())); | ||
| 53 | + final var reserveDinerMealOrderMap = mealOrderServiceRpcClient.queryReserveMealOrdersByDinerIds(loginInfo.getEnterpriseId(), dinerIds).stream().collect(Collectors.toMap(SingleMealOrderRpcResponse::getDinerId, Function.identity())); | ||
| 54 | + return dinersByIds.stream().map(e -> DinerVO.builder() | ||
| 55 | + .id(e.getId()) | ||
| 56 | + .enterpriseId(e.getEnterpriseId()) | ||
| 57 | + .clientId(e.getClientId()) | ||
| 58 | + .clientCode(clientMap.get(e.getClientId()).getCode()) | ||
| 59 | + .clientName(clientMap.get(e.getClientId()).getName()) | ||
| 60 | + .classId(e.getClassId()) | ||
| 61 | + .gradeName(gradeClassMap.get(e.getClassId()).getGradeName()) | ||
| 62 | + .className(gradeClassMap.get(e.getClassId()).getClassName()) | ||
| 63 | + .isReserve(reserveDinerMealOrderMap.get(e.getId()) != null) | ||
| 64 | + .studentNo(e.getStudentNo()) | ||
| 65 | + .name(e.getName()) | ||
| 66 | + .build()).toList(); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public CreatedResult<DinerVO> createMpAccountDiner(DinerDTO.CreateDinerDTO createDinerDTO) { | ||
| 71 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 72 | + final var clientsByCodes = clientInventoryServiceRpcClient.getClientsByCodes(loginInfo.getEnterpriseId(), List.of(createDinerDTO.getClientCode())); | ||
| 73 | + if (clientsByCodes.size() != 1) { | ||
| 74 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_CODE_NOT_EXISTS); | ||
| 75 | + } | ||
| 76 | + final var singleClientRpcResponse = clientsByCodes.get(0); | ||
| 77 | + final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(createDinerDTO.getClassId()), createDinerDTO.getStudentNo()); | ||
| 78 | + if (!diners.isEmpty()) { | ||
| 79 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_ALREADY_EXISTS); | ||
| 80 | + } | ||
| 81 | + final var dinerCreation = DinerCreation.newBuilder() | ||
| 82 | + .setClientId(singleClientRpcResponse.getId()) | ||
| 83 | + .setClassId(createDinerDTO.getClassId()) | ||
| 84 | + .setStudentNo(createDinerDTO.getStudentNo()) | ||
| 85 | + .setName(createDinerDTO.getName()) | ||
| 86 | + .build(); | ||
| 87 | + final var dinerResponse = mealOrderServiceRpcClient.createDiner(loginInfo, dinerCreation); | ||
| 88 | + if (dinerResponse.getIsCreated()) { | ||
| 89 | + final var mpAccountDinerRefCreation = MpAccountDinerRefCreation.newBuilder() | ||
| 90 | + .setDinerId(dinerResponse.getId()) | ||
| 91 | + .setAccountId(loginInfo.getId()) | ||
| 92 | + .build(); | ||
| 93 | + final var mpAccountDinerRef = mealOrderServiceRpcClient.createMpAccountDinerRef(loginInfo, mpAccountDinerRefCreation); | ||
| 94 | + log.info("createMpAccountDiner dinerId:{} mpAccountDinerRefId:{}", dinerResponse.getId(), mpAccountDinerRef.getId()); | ||
| 95 | + } | ||
| 96 | + return CreatedResult.<DinerVO>builder().id(dinerResponse.getId()).isCreated(dinerResponse.getIsCreated()).build(); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Override | ||
| 100 | + public List<GradeClassVO> getClientGradeClasses(SingleClientRpcResponse client) { | ||
| 101 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 102 | + final var gradeClasses = mealOrderServiceRpcClient.queryGradeClassesByCondition(loginInfo.getEnterpriseId(), List.of(client.getId())); | ||
| 103 | + return gradeClasses.stream().map(e -> GradeClassVO.builder() | ||
| 104 | + .id(e.getId()) | ||
| 105 | + .enterpriseId(e.getEnterpriseId()) | ||
| 106 | + .gradeName(e.getGradeName()) | ||
| 107 | + .className(e.getClassName()) | ||
| 108 | + .build()).toList(); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public void updateMpAccountDiner(SingleDinerRpcResponse diner, DinerDTO.UpdateDinerDTO updateDinerDTO) { | ||
| 113 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 114 | + final var clientsByCodes = clientInventoryServiceRpcClient.getClientsByCodes(loginInfo.getEnterpriseId(), List.of(updateDinerDTO.getClientCode())); | ||
| 115 | + if (clientsByCodes.size() != 1) { | ||
| 116 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_CODE_NOT_EXISTS); | ||
| 117 | + } | ||
| 118 | + final var singleClientRpcResponse = clientsByCodes.get(0); | ||
| 119 | + if (diner.getClientId() == singleClientRpcResponse.getId() && diner.getClassId() == updateDinerDTO.getClassId() && diner.getStudentNo().equals(updateDinerDTO.getStudentNo()) && !diner.getName().equals(updateDinerDTO.getName())) { | ||
| 120 | + mealOrderServiceRpcClient.updateDiner(loginInfo, DinerModification.newBuilder().setId(diner.getId()).setShouldUpdateName(true).setName(updateDinerDTO.getName()).build()); | ||
| 121 | + return; | ||
| 122 | + } | ||
| 123 | + final var diners = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(singleClientRpcResponse.getId()), List.of(updateDinerDTO.getClassId()), updateDinerDTO.getStudentNo()); | ||
| 124 | + if (!diners.isEmpty()) { | ||
| 125 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_ALREADY_EXISTS); | ||
| 126 | + } | ||
| 127 | + mealOrderServiceRpcClient.updateDiner(loginInfo, DinerModification.newBuilder() | ||
| 128 | + .setId(diner.getId()) | ||
| 129 | + .setShouldUpdateClientId(true).setClientId(singleClientRpcResponse.getId()) | ||
| 130 | + .setShouldUpdateClassId(updateDinerDTO.getClassId() != null).setClassId(updateDinerDTO.getClassId() == null ? diner.getClassId() : updateDinerDTO.getClassId()) | ||
| 131 | + .setShouldUpdateName(updateDinerDTO.getName() != null).setName(updateDinerDTO.getName() == null ? diner.getName() : updateDinerDTO.getName()) | ||
| 132 | + .setShouldUpdateStudentNo(updateDinerDTO.getStudentNo() != null).setStudentNo(updateDinerDTO.getStudentNo() == null ? diner.getStudentNo() : updateDinerDTO.getStudentNo()) | ||
| 133 | + .build()); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + @Override | ||
| 137 | + public void deleteMpAccountDiner(SingleDinerRpcResponse diner) { | ||
| 138 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 139 | + final var mpAccountDinerRefRpcResponseList = mealOrderServiceRpcClient.queryMpAccountDinerRefsByCondition(loginInfo.getEnterpriseId(), List.of(loginInfo.getId()), List.of(diner.getId())); | ||
| 140 | + mealOrderServiceRpcClient.deleteDinersByIds(loginInfo, List.of(diner.getId())); | ||
| 141 | + if (!mpAccountDinerRefRpcResponseList.isEmpty()) { | ||
| 142 | + mealOrderServiceRpcClient.deleteMpAccountDinerRefsByIds(loginInfo.getEnterpriseId(), mpAccountDinerRefRpcResponseList.stream().map(SingleMpAccountDinerRefRpcResponse::getId).toList()); | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + @Override | ||
| 147 | + public DinerVO getClientClassDiner(SingleClientRpcResponse client, SingleGradeClassRpcResponse gradeClass, String studentNo) { | ||
| 148 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 149 | + final var diner = mealOrderServiceRpcClient.queryDinersByCondition(loginInfo.getEnterpriseId(), List.of(client.getId()), List.of(gradeClass.getId()), studentNo); | ||
| 150 | + return DinerVO.builder() | ||
| 151 | + .id(diner.get(0).getId()) | ||
| 152 | + .enterpriseId(diner.get(0).getEnterpriseId()) | ||
| 153 | + .clientId(diner.get(0).getClientId()) | ||
| 154 | + .clientCode(client.getCode()) | ||
| 155 | + .clientName(client.getName()) | ||
| 156 | + .classId(diner.get(0).getClassId()) | ||
| 157 | + .gradeName(gradeClass.getGradeName()) | ||
| 158 | + .className(gradeClass.getClassName()) | ||
| 159 | + .studentNo(diner.get(0).getStudentNo()) | ||
| 160 | + .name(diner.get(0).getName()) | ||
| 161 | + .build(); | ||
| 162 | + } | ||
| 163 | +} |
| ... | @@ -6,7 +6,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ... | @@ -6,7 +6,7 @@ import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; |
| 6 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 6 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 7 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 7 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 8 | import com.infoloop.tianting.context.LoginContextHolder; | 8 | import com.infoloop.tianting.context.LoginContextHolder; |
| 9 | -import com.infoloop.tianting.model.dto.InventoryDbDTO.ClientDto; | 9 | +import com.infoloop.tianting.model.dto.ClientInventoryDbDTO.ClientDto; |
| 10 | import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto; | 10 | import com.infoloop.tianting.model.dto.KdsDTO.KdsMealDetailDto; |
| 11 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto; | 11 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDetailDto; |
| 12 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; | 12 | import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderLocationDto; |
| ... | @@ -19,8 +19,8 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; | ... | @@ -19,8 +19,8 @@ import com.infoloop.tianting.model.dto.OrderDbDTO.CustomerNotice; |
| 19 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 19 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| 20 | import com.infoloop.tianting.service.KdsService; | 20 | import com.infoloop.tianting.service.KdsService; |
| 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 22 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 22 | import com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.EnterpriseResourceServiceRpcClient; |
| 23 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | ||
| 24 | import com.infoloop.tianting.service.client.MealServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.MealServiceRpcClient; |
| 25 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| 26 | import com.infoloop.tianting.service.client.SkuServiceRpcClient; | 26 | import com.infoloop.tianting.service.client.SkuServiceRpcClient; |
| ... | @@ -47,7 +47,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -47,7 +47,7 @@ public class KdsServiceImpl implements KdsService { |
| 47 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; | 47 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; |
| 48 | private final MealServiceRpcClient mealServiceRpcClient; | 48 | private final MealServiceRpcClient mealServiceRpcClient; |
| 49 | private final SkuServiceRpcClient skuServiceRpcClient; | 49 | private final SkuServiceRpcClient skuServiceRpcClient; |
| 50 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 50 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 51 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | 51 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| ... | @@ -87,14 +87,14 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -87,14 +87,14 @@ public class KdsServiceImpl implements KdsService { |
| 87 | .map(SingleClientCustomerOrderRpcResponse::getClientId) | 87 | .map(SingleClientCustomerOrderRpcResponse::getClientId) |
| 88 | .distinct() | 88 | .distinct() |
| 89 | .collect(Collectors.toList()); | 89 | .collect(Collectors.toList()); |
| 90 | - final var clients = inventoryServiceRpcClient.getClientsByIds( | 90 | + final var clients = clientInventoryServiceRpcClient.getClientsByIds( |
| 91 | operator.getEnterpriseId(), clientIds); | 91 | operator.getEnterpriseId(), clientIds); |
| 92 | 92 | ||
| 93 | final var orderStallIds = orderList.stream() | 93 | final var orderStallIds = orderList.stream() |
| 94 | .map(SingleClientCustomerOrderRpcResponse::getStallId) | 94 | .map(SingleClientCustomerOrderRpcResponse::getStallId) |
| 95 | .distinct() | 95 | .distinct() |
| 96 | .collect(Collectors.toList()); | 96 | .collect(Collectors.toList()); |
| 97 | - final var stalls = inventoryServiceRpcClient.getStallsByIds( | 97 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds( |
| 98 | operator.getEnterpriseId(), orderStallIds); | 98 | operator.getEnterpriseId(), orderStallIds); |
| 99 | 99 | ||
| 100 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | 100 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); |
| ... | @@ -321,14 +321,14 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -321,14 +321,14 @@ public class KdsServiceImpl implements KdsService { |
| 321 | .map(SingleClientCustomerOrderRpcResponse::getClientId) | 321 | .map(SingleClientCustomerOrderRpcResponse::getClientId) |
| 322 | .distinct() | 322 | .distinct() |
| 323 | .collect(Collectors.toList()); | 323 | .collect(Collectors.toList()); |
| 324 | - final var clients = inventoryServiceRpcClient.getClientsByIds( | 324 | + final var clients = clientInventoryServiceRpcClient.getClientsByIds( |
| 325 | operator.getEnterpriseId(), clientIds); | 325 | operator.getEnterpriseId(), clientIds); |
| 326 | 326 | ||
| 327 | final var orderStallIds = orderList.stream() | 327 | final var orderStallIds = orderList.stream() |
| 328 | .map(SingleClientCustomerOrderRpcResponse::getStallId) | 328 | .map(SingleClientCustomerOrderRpcResponse::getStallId) |
| 329 | .distinct() | 329 | .distinct() |
| 330 | .collect(Collectors.toList()); | 330 | .collect(Collectors.toList()); |
| 331 | - final var stalls = inventoryServiceRpcClient.getStallsByIds( | 331 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds( |
| 332 | operator.getEnterpriseId(), orderStallIds); | 332 | operator.getEnterpriseId(), orderStallIds); |
| 333 | 333 | ||
| 334 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | 334 | final var customerIds = orderList.stream().map(SingleClientCustomerOrderRpcResponse::getCustomerId).collect(Collectors.toList()); | ... | ... |
| ... | @@ -7,11 +7,19 @@ import com.infoloop.rpc.meizhongyiheservice.HospitalStatus; | ... | @@ -7,11 +7,19 @@ import com.infoloop.rpc.meizhongyiheservice.HospitalStatus; |
| 7 | import com.infoloop.tianting.WOperatorStatus; | 7 | import com.infoloop.tianting.WOperatorStatus; |
| 8 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; | 8 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; |
| 9 | import com.infoloop.tianting.constant.CommonConstants; | 9 | import com.infoloop.tianting.constant.CommonConstants; |
| 10 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 10 | import com.infoloop.tianting.exception.ClientEndExceptions; | 11 | import com.infoloop.tianting.exception.ClientEndExceptions; |
| 11 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 12 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| 13 | +import com.infoloop.tianting.mealorderservice.MpAccountCreation; | ||
| 14 | +import com.infoloop.tianting.mealorderservice.MpAccountModification; | ||
| 15 | +import com.infoloop.tianting.mealorderservice.MpAccountStatusEnum; | ||
| 16 | +import com.infoloop.tianting.mealorderservice.SingleMpAccountRpcResponse; | ||
| 17 | +import com.infoloop.tianting.model.dto.MpAccountDTO; | ||
| 12 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; | 18 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; |
| 19 | +import com.infoloop.tianting.model.vo.MpAccountVO; | ||
| 13 | import com.infoloop.tianting.service.LoginService; | 20 | import com.infoloop.tianting.service.LoginService; |
| 14 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 21 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 22 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 15 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; | 23 | import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient; |
| 16 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 17 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; | 25 | import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; |
| ... | @@ -20,6 +28,7 @@ import lombok.RequiredArgsConstructor; | ... | @@ -20,6 +28,7 @@ import lombok.RequiredArgsConstructor; |
| 20 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
| 21 | import org.springframework.beans.factory.annotation.Autowired; | 29 | import org.springframework.beans.factory.annotation.Autowired; |
| 22 | import org.springframework.stereotype.Service; | 30 | import org.springframework.stereotype.Service; |
| 31 | +import org.springframework.util.Assert; | ||
| 23 | 32 | ||
| 24 | import java.security.MessageDigest; | 33 | import java.security.MessageDigest; |
| 25 | import java.security.NoSuchAlgorithmException; | 34 | import java.security.NoSuchAlgorithmException; |
| ... | @@ -30,6 +39,7 @@ import java.security.NoSuchAlgorithmException; | ... | @@ -30,6 +39,7 @@ import java.security.NoSuchAlgorithmException; |
| 30 | public class LoginServiceImpl implements LoginService { | 39 | public class LoginServiceImpl implements LoginService { |
| 31 | 40 | ||
| 32 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | 41 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; |
| 42 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 33 | private final OperatorServiceRpcClient operatorServiceRpcClient; | 43 | private final OperatorServiceRpcClient operatorServiceRpcClient; |
| 34 | private final WxMiniProgramHttpClient wxMiniProgramHttpClient; | 44 | private final WxMiniProgramHttpClient wxMiniProgramHttpClient; |
| 35 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; | 45 | private final WOperatorServiceRpcClient wOperatorServiceRpcClient; |
| ... | @@ -44,6 +54,25 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -44,6 +54,25 @@ public class LoginServiceImpl implements LoginService { |
| 44 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 54 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 45 | .build()); | 55 | .build()); |
| 46 | return StpUtil.getTokenInfo(); | 56 | return StpUtil.getTokenInfo(); |
| 57 | + } else if (loginDto.isShouldLoginWithOpenId()){ | ||
| 58 | + final var mpAccountByOpenId = mealOrderServiceRpcClient.getMpAccountByOpenId(loginDto.getOpenId()); | ||
| 59 | + int mpAccountId; | ||
| 60 | + if (mpAccountByOpenId == null) { | ||
| 61 | + mpAccountId = mealOrderServiceRpcClient.createMpAccount(loginDto.getEnterpriseId(), MpAccountCreation.newBuilder() | ||
| 62 | + .setOpenId(loginDto.getOpenId()) | ||
| 63 | + .setStatus(MpAccountStatusEnum.MP_ACCOUNT_STATUS_ENABLE) | ||
| 64 | + .setPhoneNumber(loginDto.getOperatorPhone() != null ? loginDto.getOperatorPhone() : "") | ||
| 65 | + .build()).getId(); | ||
| 66 | + } else { | ||
| 67 | + mpAccountId = mpAccountByOpenId.getId(); | ||
| 68 | + } | ||
| 69 | + Assert.isTrue(mpAccountId != 0, "创建小程序账号失败"); | ||
| 70 | + StpUtil.login(loginDto.getOpenId(), SaLoginModel.create() | ||
| 71 | + .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) | ||
| 72 | + .setExtra(CommonConstants.USER_ID, mpAccountId) | ||
| 73 | + .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | ||
| 74 | + .build()); | ||
| 75 | + return StpUtil.getTokenInfo(); | ||
| 47 | } else if (loginDto.isShouldLoginWithHisCustomerNo()) { | 76 | } else if (loginDto.isShouldLoginWithHisCustomerNo()) { |
| 48 | var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(loginDto.getHisCustomerNo()).getResponse(); | 77 | var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerNo(loginDto.getHisCustomerNo()).getResponse(); |
| 49 | if (customer.getId() == 0) { | 78 | if (customer.getId() == 0) { |
| ... | @@ -110,6 +139,37 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -110,6 +139,37 @@ public class LoginServiceImpl implements LoginService { |
| 110 | } | 139 | } |
| 111 | } | 140 | } |
| 112 | 141 | ||
| 142 | + @Override | ||
| 143 | + public MpAccountVO getMpAccountByOpenId(String openId) { | ||
| 144 | + final var mpAccountByOpenId = mealOrderServiceRpcClient.getMpAccountByOpenId(openId); | ||
| 145 | + if (mpAccountByOpenId == null) { | ||
| 146 | + return null; | ||
| 147 | + } | ||
| 148 | + return MpAccountVO.builder() | ||
| 149 | + .id(mpAccountByOpenId.getId()) | ||
| 150 | + .enterpriseId(mpAccountByOpenId.getEnterpriseId()) | ||
| 151 | + .openId(mpAccountByOpenId.getOpenId()) | ||
| 152 | + .unionId(mpAccountByOpenId.getUnionId()) | ||
| 153 | + .nickname(mpAccountByOpenId.getNickname()) | ||
| 154 | + .avatarUrl(mpAccountByOpenId.getAvatarUrl()) | ||
| 155 | + .gender(mpAccountByOpenId.getGender()) | ||
| 156 | + .phoneNumber(mpAccountByOpenId.getPhoneNumber()) | ||
| 157 | + .build(); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + @Override | ||
| 161 | + public void updateMpAccount(SingleMpAccountRpcResponse mpAccount, MpAccountDTO.ModifyMpAccountDTO modifyMpAccountDTO) { | ||
| 162 | + mealOrderServiceRpcClient.updateMpAccount(LoginContextHolder.getLoginInfo(), MpAccountModification.newBuilder() | ||
| 163 | + .setId(mpAccount.getId()) | ||
| 164 | + .setShouldUpdateNickname(modifyMpAccountDTO.getNickName() != null) | ||
| 165 | + .setNickname(modifyMpAccountDTO.getNickName() != null ? modifyMpAccountDTO.getNickName() : mpAccount.getNickname()) | ||
| 166 | + .setShouldUpdateAvatarUrl(modifyMpAccountDTO.getAvatarUrl() != null) | ||
| 167 | + .setAvatarUrl(modifyMpAccountDTO.getAvatarUrl() != null ? modifyMpAccountDTO.getAvatarUrl() : mpAccount.getAvatarUrl()) | ||
| 168 | + .setShouldUpdateGender(modifyMpAccountDTO.getGender() != null) | ||
| 169 | + .setGender(modifyMpAccountDTO.getGender() != null ? modifyMpAccountDTO.getGender() : mpAccount.getGender()) | ||
| 170 | + .build()); | ||
| 171 | + } | ||
| 172 | + | ||
| 113 | public static String sha1Hash(String input) throws NoSuchAlgorithmException { | 173 | public static String sha1Hash(String input) throws NoSuchAlgorithmException { |
| 114 | MessageDigest md = MessageDigest.getInstance("SHA-1"); | 174 | MessageDigest md = MessageDigest.getInstance("SHA-1"); |
| 115 | md.update(input.getBytes()); | 175 | md.update(input.getBytes()); | ... | ... |
| 1 | +package com.infoloop.tianting.service.impl; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 4 | +import com.infoloop.tianting.enums.QueryMealOrderStatusEnum; | ||
| 5 | +import com.infoloop.tianting.exception.ClientEndExceptions; | ||
| 6 | +import com.infoloop.tianting.exception.ErrorCodeEnum; | ||
| 7 | +import com.infoloop.tianting.mealorderservice.MealOrderCreation; | ||
| 8 | +import com.infoloop.tianting.mealorderservice.MealOrderOrderMethodEnum; | ||
| 9 | +import com.infoloop.tianting.mealorderservice.MenuSchedule; | ||
| 10 | +import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | ||
| 11 | +import com.infoloop.tianting.model.common.CreatedResult; | ||
| 12 | +import com.infoloop.tianting.model.dto.MealOrderDTO; | ||
| 13 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 14 | +import com.infoloop.tianting.model.vo.MealOrderVO; | ||
| 15 | +import com.infoloop.tianting.service.MealOrderService; | ||
| 16 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | ||
| 17 | +import com.infoloop.tianting.service.client.DeliveryRuleServiceRpcClient; | ||
| 18 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 19 | +import com.infoloop.tianting.utils.DateUtil; | ||
| 20 | +import lombok.RequiredArgsConstructor; | ||
| 21 | +import lombok.extern.slf4j.Slf4j; | ||
| 22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 23 | +import org.springframework.stereotype.Service; | ||
| 24 | + | ||
| 25 | +import java.time.DayOfWeek; | ||
| 26 | +import java.time.LocalDate; | ||
| 27 | +import java.time.LocalDateTime; | ||
| 28 | +import java.time.LocalTime; | ||
| 29 | +import java.time.temporal.TemporalAdjusters; | ||
| 30 | +import java.util.ArrayList; | ||
| 31 | +import java.util.Collections; | ||
| 32 | +import java.util.List; | ||
| 33 | + | ||
| 34 | +@Slf4j | ||
| 35 | +@Service | ||
| 36 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 37 | +public class MealOrderServiceImpl implements MealOrderService { | ||
| 38 | + | ||
| 39 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 40 | + | ||
| 41 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | ||
| 42 | + | ||
| 43 | + private final DeliveryRuleServiceRpcClient deliveryRuleServiceRpcClient; | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public List<MealOrderVO> queryMealOrders(MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) { | ||
| 47 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 48 | + var mealOrderRpcResponses = mealOrderServiceRpcClient.queryMealOrdersByCondition(loginInfo.getEnterpriseId(), loginInfo.getId(), null, null); | ||
| 49 | + final var today = LocalDate.now(); | ||
| 50 | + final var lastWeekStart = today.minusWeeks(1).with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli(); | ||
| 51 | + final var lastWeekEnd = today.minusWeeks(1).with(DayOfWeek.SUNDAY).atTime(LocalTime.MAX).atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli(); | ||
| 52 | + final var thisWeekStart = today.with(DayOfWeek.MONDAY).atStartOfDay().atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli(); | ||
| 53 | + if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.COMPLETED) { | ||
| 54 | + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() < lastWeekStart).toList(); | ||
| 55 | + } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.UNDER_WAY) { | ||
| 56 | + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() >= lastWeekStart && e.getReserveDate() <= lastWeekEnd).toList(); | ||
| 57 | + } else if (queryMealOrderDTO.getStatus() == QueryMealOrderStatusEnum.BE_BOOKED) { | ||
| 58 | + mealOrderRpcResponses = mealOrderRpcResponses.stream().filter(e -> e.getReserveDate() > thisWeekStart).toList(); | ||
| 59 | + } | ||
| 60 | + return mealOrderRpcResponses.stream().map(this::getMealOrderById).toList(); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public CreatedResult<MealOrderVO> createMealOrder(MealOrderDTO.CreateMealOrderDTO createMealOrderDTO) { | ||
| 65 | + final var loginInfo = LoginContextHolder.getLoginInfo(); | ||
| 66 | + final var deliveryRule = this.getDeliveryRule(); | ||
| 67 | + final var now = LocalDateTime.now(); | ||
| 68 | + final var nowWithinRange = isNowWithinRange(deliveryRule, now); | ||
| 69 | + if (!nowWithinRange) { | ||
| 70 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.MEAL_ORDER_TIME_NOT_IN_RANGE); | ||
| 71 | + } | ||
| 72 | + final var reserveDinerMealOrders = mealOrderServiceRpcClient.queryReserveMealOrdersByDinerIds(loginInfo.getEnterpriseId(), Collections.singletonList(createMealOrderDTO.getDinerId())); | ||
| 73 | + if (!reserveDinerMealOrders.isEmpty()) { | ||
| 74 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_ALREADY_RESERVED); | ||
| 75 | + } | ||
| 76 | + final var dinerById = mealOrderServiceRpcClient.getDinerById(loginInfo.getEnterpriseId(), createMealOrderDTO.getDinerId()); | ||
| 77 | + if (dinerById == null) { | ||
| 78 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.DINER_NOT_FOUND); | ||
| 79 | + } | ||
| 80 | + final var clientById = clientInventoryServiceRpcClient.getClientById(loginInfo.getEnterpriseId(), dinerById.getClientId()); | ||
| 81 | + if (clientById == null) { | ||
| 82 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_NOT_FOUND); | ||
| 83 | + } | ||
| 84 | + if (clientById.getClient().getStatus() != 1) { | ||
| 85 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.CLIENT_NOT_ENABLED); | ||
| 86 | + } | ||
| 87 | + final var gradeClassById = mealOrderServiceRpcClient.getGradeClassById(loginInfo.getEnterpriseId(), dinerById.getClassId()); | ||
| 88 | + if (gradeClassById == null) { | ||
| 89 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.GRADE_CLASS_NOT_FOUND); | ||
| 90 | + } | ||
| 91 | + final var latestMealMenuRecords = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(loginInfo.getEnterpriseId(), Collections.singletonList(dinerById.getClientId())); | ||
| 92 | + if (latestMealMenuRecords.isEmpty()) { | ||
| 93 | + throw ClientEndExceptions.IncorrectRequestValue.build(ErrorCodeEnum.MEAL_MENU_NOT_FOUND); | ||
| 94 | + } | ||
| 95 | + final var mealOrder = mealOrderServiceRpcClient.createMealOrder(loginInfo, MealOrderCreation.newBuilder() | ||
| 96 | + .setClientId(dinerById.getClientId()) | ||
| 97 | + .setMenuId(latestMealMenuRecords.get(0).getId()) | ||
| 98 | + .setAccountId(loginInfo.getId()) | ||
| 99 | + .setOrderMethod(MealOrderOrderMethodEnum.MEAL_ORDER_METHOD_MICRO) | ||
| 100 | + .setDinerId(createMealOrderDTO.getDinerId()) | ||
| 101 | + .setDinerName(dinerById.getName()) | ||
| 102 | + .setClientName(clientById.getClient().getName()) | ||
| 103 | + .setGradeName(gradeClassById.getGradeName()) | ||
| 104 | + .setClassName(gradeClassById.getClassName()) | ||
| 105 | + .setStudentNo(dinerById.getStudentNo()) | ||
| 106 | + .setReserveDate(now.atZone(DateUtil.CHINA_ZONE).toInstant().toEpochMilli()) | ||
| 107 | + .addAllMeals(createMealOrderDTO.getMeals().stream().map(e -> MenuSchedule.newBuilder() | ||
| 108 | + .setDate(e.getDate()) | ||
| 109 | + .setMenu(e.getMenu()) | ||
| 110 | + .build()).toList()) | ||
| 111 | + .build()); | ||
| 112 | + return CreatedResult.<MealOrderVO>builder().id(mealOrder.getId()).isCreated(mealOrder.getIsCreated()).build(); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 116 | + public MealOrderVO getMealOrderById(SingleMealOrderRpcResponse mealOrder) { | ||
| 117 | + return MealOrderVO.builder() | ||
| 118 | + .id(mealOrder.getId()) | ||
| 119 | + .clientId(mealOrder.getClientId()) | ||
| 120 | + .menuId(mealOrder.getMenuId()) | ||
| 121 | + .accountId(mealOrder.getAccountId()) | ||
| 122 | + .orderMethod(mealOrder.getOrderMethod()) | ||
| 123 | + .dinerId(mealOrder.getDinerId()) | ||
| 124 | + .dinerName(mealOrder.getDinerName()) | ||
| 125 | + .clientName(mealOrder.getClientName()) | ||
| 126 | + .gradeName(mealOrder.getGradeName()) | ||
| 127 | + .className(mealOrder.getClassName()) | ||
| 128 | + .studentNo(mealOrder.getStudentNo()) | ||
| 129 | + .reserveDate(DateUtil.formatDate(mealOrder.getReserveDate())) | ||
| 130 | + .meals(mealOrder.getMealsList().stream().map(e -> MealOrderVO.Meals.builder().date(e.getDate()).menu(e.getMenu()).build()).toList()) | ||
| 131 | + .build(); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + @Override | ||
| 135 | + public DeliveryRuleVO getDeliveryRule() { | ||
| 136 | + final var rule = deliveryRuleServiceRpcClient.getDefaultDeliveryTemplateAndRule(LoginContextHolder.getEnterpriseId()).getRule(); | ||
| 137 | + if (rule.getConfigJson().getRulesList().isEmpty()) { | ||
| 138 | + return DeliveryRuleVO.builder().build(); | ||
| 139 | + } | ||
| 140 | + return DeliveryRuleVO.builder() | ||
| 141 | + .startTime(rule.getConfigJson().getRules(0).getStartTime()) | ||
| 142 | + .endTime(rule.getConfigJson().getRules(0).getEndTime()) | ||
| 143 | + .monday(rule.getConfigJson().getRules(0).getMonday()) | ||
| 144 | + .tuesday(rule.getConfigJson().getRules(0).getTuesday()) | ||
| 145 | + .wednesday(rule.getConfigJson().getRules(0).getWednesday()) | ||
| 146 | + .thursday(rule.getConfigJson().getRules(0).getThursday()) | ||
| 147 | + .friday(rule.getConfigJson().getRules(0).getFriday()) | ||
| 148 | + .saturday(rule.getConfigJson().getRules(0).getSaturday()) | ||
| 149 | + .sunday(rule.getConfigJson().getRules(0).getSunday()) | ||
| 150 | + .build(); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + private static boolean isNowWithinRange(DeliveryRuleVO rule, LocalDateTime now) { | ||
| 154 | + if (rule == null || rule.getStartTime() == null || rule.getEndTime() == null) { | ||
| 155 | + return false; | ||
| 156 | + } | ||
| 157 | + final var startTime = LocalTime.parse(rule.getStartTime(), DateUtil.HH_MM_SS); | ||
| 158 | + final var endTime = LocalTime.parse(rule.getEndTime(), DateUtil.HH_MM_SS); | ||
| 159 | + final var enabledDays = new ArrayList<DayOfWeek>(); | ||
| 160 | + if (Boolean.TRUE.equals(rule.getMonday())) enabledDays.add(DayOfWeek.MONDAY); | ||
| 161 | + if (Boolean.TRUE.equals(rule.getTuesday())) enabledDays.add(DayOfWeek.TUESDAY); | ||
| 162 | + if (Boolean.TRUE.equals(rule.getWednesday())) enabledDays.add(DayOfWeek.WEDNESDAY); | ||
| 163 | + if (Boolean.TRUE.equals(rule.getThursday())) enabledDays.add(DayOfWeek.THURSDAY); | ||
| 164 | + if (Boolean.TRUE.equals(rule.getFriday())) enabledDays.add(DayOfWeek.FRIDAY); | ||
| 165 | + if (Boolean.TRUE.equals(rule.getSaturday())) enabledDays.add(DayOfWeek.SATURDAY); | ||
| 166 | + if (Boolean.TRUE.equals(rule.getSunday())) enabledDays.add(DayOfWeek.SUNDAY); | ||
| 167 | + if (enabledDays.isEmpty()) { | ||
| 168 | + return false; | ||
| 169 | + } | ||
| 170 | + final var minDay = Collections.min(enabledDays); | ||
| 171 | + final var maxDay = Collections.max(enabledDays); | ||
| 172 | + final var today = now.toLocalDate(); | ||
| 173 | + final var startDateTime = today.with(TemporalAdjusters.previousOrSame(minDay)).atTime(startTime); | ||
| 174 | + final var endDateTime = today.with(TemporalAdjusters.nextOrSame(maxDay)).atTime(endTime); | ||
| 175 | + return !now.isBefore(startDateTime) && !now.isAfter(endDateTime); | ||
| 176 | + } | ||
| 177 | +} |
| 1 | package com.infoloop.tianting.service.impl; | 1 | package com.infoloop.tianting.service.impl; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.clientinventoryservice.SingleClientRpcResponse; | ||
| 3 | import com.infoloop.tianting.context.LoginContextHolder; | 4 | import com.infoloop.tianting.context.LoginContextHolder; |
| 4 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; | 5 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; |
| 5 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; | 6 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; |
| ... | @@ -11,6 +12,7 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; | ... | @@ -11,6 +12,7 @@ import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; |
| 11 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuRefDto; | 12 | import com.infoloop.tianting.model.dto.MenuDbDTO.MenuRefDto; |
| 12 | import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson; | 13 | import com.infoloop.tianting.model.dto.MenuDbDTO.OrderRuleJson; |
| 13 | import com.infoloop.tianting.service.MenuService; | 14 | import com.infoloop.tianting.service.MenuService; |
| 15 | +import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | ||
| 14 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 15 | import com.infoloop.tianting.utils.DateUtil; | 17 | import com.infoloop.tianting.utils.DateUtil; |
| 16 | import lombok.RequiredArgsConstructor; | 18 | import lombok.RequiredArgsConstructor; |
| ... | @@ -29,6 +31,8 @@ public class MenuServiceImpl implements MenuService { | ... | @@ -29,6 +31,8 @@ public class MenuServiceImpl implements MenuService { |
| 29 | 31 | ||
| 30 | private final MenuServiceRpcClient menuServiceRpcClient; | 32 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 31 | 33 | ||
| 34 | + private final MealOrderServiceRpcClient mealOrderServiceRpcClient; | ||
| 35 | + | ||
| 32 | @Override | 36 | @Override |
| 33 | public List<MenuDto> queryMiniProgramPublishedMenusByStallId(Integer enterpriseId, Integer stallId) { | 37 | public List<MenuDto> queryMiniProgramPublishedMenusByStallId(Integer enterpriseId, Integer stallId) { |
| 34 | final var response = menuServiceRpcClient.queryMiniProgramPublishedMenusByStallId(enterpriseId, stallId); | 38 | final var response = menuServiceRpcClient.queryMiniProgramPublishedMenusByStallId(enterpriseId, stallId); |
| ... | @@ -209,4 +213,11 @@ public class MenuServiceImpl implements MenuService { | ... | @@ -209,4 +213,11 @@ public class MenuServiceImpl implements MenuService { |
| 209 | return menuServiceRpcClient.queryMenuDetailsByMenuIds(LoginContextHolder.getEnterpriseId(), menuIds).getResponsesList().stream().map(SingleMenuDetailRpcResponse::getSkuId).distinct().collect(Collectors.toList()); | 213 | return menuServiceRpcClient.queryMenuDetailsByMenuIds(LoginContextHolder.getEnterpriseId(), menuIds).getResponsesList().stream().map(SingleMenuDetailRpcResponse::getSkuId).distinct().collect(Collectors.toList()); |
| 210 | } | 214 | } |
| 211 | 215 | ||
| 216 | + @Override | ||
| 217 | + public String queryClientLatestMealMenuRecord(SingleClientRpcResponse client) { | ||
| 218 | + final var singleMealMenuRecordRpcResponses = mealOrderServiceRpcClient.queryLatestMealMenuRecordsByClientIds(LoginContextHolder.getEnterpriseId(), List.of(client.getId())); | ||
| 219 | + return singleMealMenuRecordRpcResponses.isEmpty() ? "" : singleMealMenuRecordRpcResponses.get(0).getImageUrl(); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + | ||
| 212 | } | 223 | } | ... | ... |
| ... | @@ -18,7 +18,7 @@ import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuMealDto; | ... | @@ -18,7 +18,7 @@ import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuMealDto; |
| 18 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; | 18 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; |
| 19 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | 19 | import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; |
| 20 | import com.infoloop.tianting.service.SettlementService; | 20 | import com.infoloop.tianting.service.SettlementService; |
| 21 | -import com.infoloop.tianting.service.client.InventoryServiceRpcClient; | 21 | +import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; |
| 22 | import com.infoloop.tianting.service.client.MealServiceRpcClient; | 22 | import com.infoloop.tianting.service.client.MealServiceRpcClient; |
| 23 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; | 23 | import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 24 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 24 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| ... | @@ -55,7 +55,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -55,7 +55,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 55 | private final OrderServiceRpcClient orderServiceRpcClient; | 55 | private final OrderServiceRpcClient orderServiceRpcClient; |
| 56 | private final MenuServiceRpcClient menuServiceRpcClient; | 56 | private final MenuServiceRpcClient menuServiceRpcClient; |
| 57 | private final SkuServiceRpcClient skuServiceRpcClient; | 57 | private final SkuServiceRpcClient skuServiceRpcClient; |
| 58 | - private final InventoryServiceRpcClient inventoryServiceRpcClient; | 58 | + private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 59 | private final MealServiceRpcClient mealServiceRpcClient; | 59 | private final MealServiceRpcClient mealServiceRpcClient; |
| 60 | 60 | ||
| 61 | public static ByteArrayOutputStream writeToExcelBySku(SettlementDataDto settlementDataDto) | 61 | public static ByteArrayOutputStream writeToExcelBySku(SettlementDataDto settlementDataDto) |
| ... | @@ -403,7 +403,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -403,7 +403,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 403 | 403 | ||
| 404 | } | 404 | } |
| 405 | } | 405 | } |
| 406 | - final var stalls = inventoryServiceRpcClient.getStallsByIds(enterpriseId, settlementRequest.getStallIds()).getClientsList(); | 406 | + final var stalls = clientInventoryServiceRpcClient.getStallsByIds(enterpriseId, settlementRequest.getStallIds()).getClientsList(); |
| 407 | final var stallNames = stalls.stream() | 407 | final var stallNames = stalls.stream() |
| 408 | .filter(s -> settlementRequest.getStallIds().contains(s.getId())) | 408 | .filter(s -> settlementRequest.getStallIds().contains(s.getId())) |
| 409 | .map(SingleClientRpcResponse::getName).collect(Collectors.toList()); | 409 | .map(SingleClientRpcResponse::getName).collect(Collectors.toList()); |
| ... | @@ -525,7 +525,7 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -525,7 +525,7 @@ public class SettlementServiceImpl implements SettlementService { |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | } | 527 | } |
| 528 | - final var client = inventoryServiceRpcClient.getClientById(enterpriseId, | 528 | + final var client = clientInventoryServiceRpcClient.getClientById(enterpriseId, |
| 529 | settlementRequest.getClientId()).getClient(); | 529 | settlementRequest.getClientId()).getClient(); |
| 530 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() | 530 | final var settlementDataByMealDto = SettlementDataByMealDto.builder() |
| 531 | .classifyOrders(classifyOrders) | 531 | .classifyOrders(classifyOrders) | ... | ... |
| ... | @@ -115,14 +115,12 @@ public class SkuServiceImpl implements SkuService { | ... | @@ -115,14 +115,12 @@ public class SkuServiceImpl implements SkuService { |
| 115 | if (querySkuSellQuantityDTO.getStatus() != SkuSellQuantityStatus.ALL) { | 115 | if (querySkuSellQuantityDTO.getStatus() != SkuSellQuantityStatus.ALL) { |
| 116 | responses = responses.stream() | 116 | responses = responses.stream() |
| 117 | .filter(e -> { | 117 | .filter(e -> { |
| 118 | - switch (querySkuSellQuantityDTO.getStatus()) { | 118 | + if (querySkuSellQuantityDTO.getStatus() == SkuSellQuantityStatus.SOLD_OUT) { |
| 119 | - case SOLD_OUT: | 119 | + return e.getMaxSellQuantity() == e.getTodaySellQuantity(); |
| 120 | - return e.getMaxSellQuantity() == e.getTodaySellQuantity(); | 120 | + } else if (querySkuSellQuantityDTO.getStatus() == SkuSellQuantityStatus.ON_SALE) { |
| 121 | - case ON_SALE: | 121 | + return e.getMaxSellQuantity() != e.getTodaySellQuantity(); |
| 122 | - return e.getMaxSellQuantity() != e.getTodaySellQuantity(); | ||
| 123 | - default: | ||
| 124 | - return true; | ||
| 125 | } | 122 | } |
| 123 | + return true; | ||
| 126 | }) | 124 | }) |
| 127 | .collect(Collectors.toList()); | 125 | .collect(Collectors.toList()); |
| 128 | } | 126 | } | ... | ... |
| ... | @@ -4,11 +4,22 @@ import com.infoloop.tianting.model.common.OrderPageResult; | ... | @@ -4,11 +4,22 @@ import com.infoloop.tianting.model.common.OrderPageResult; |
| 4 | import com.infoloop.tianting.model.common.PageResult; | 4 | import com.infoloop.tianting.model.common.PageResult; |
| 5 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; | 5 | import com.infoloop.tianting.model.dto.OrderDbDTO.OrderCountByStatusDto; |
| 6 | 6 | ||
| 7 | +import java.lang.reflect.InvocationTargetException; | ||
| 7 | import java.util.LinkedList; | 8 | import java.util.LinkedList; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| 10 | public class PageUtil { | 11 | public class PageUtil { |
| 11 | 12 | ||
| 13 | + public static <T> PageResult<T> buildEmpty(Class<T> clazz) { | ||
| 14 | + T instance; | ||
| 15 | + try { | ||
| 16 | + instance = clazz.getDeclaredConstructor().newInstance(); | ||
| 17 | + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | ||
| 18 | + throw new RuntimeException(e); | ||
| 19 | + } | ||
| 20 | + return buildEmpty(instance); | ||
| 21 | + } | ||
| 22 | + | ||
| 12 | public static <T> PageResult<T> buildEmpty(T t) { | 23 | public static <T> PageResult<T> buildEmpty(T t) { |
| 13 | PageResult<T> pageRet = new PageResult<>(); | 24 | PageResult<T> pageRet = new PageResult<>(); |
| 14 | pageRet.setTotalCount(0); | 25 | pageRet.setTotalCount(0); | ... | ... |
src/main/proto/MealOrderService.proto
0 → 100644
| 1 | +syntax = "proto3"; | ||
| 2 | + | ||
| 3 | +option java_multiple_files = true; | ||
| 4 | +option java_package = "com.infoloop.tianting.mealorderservice"; | ||
| 5 | +option java_outer_classname = "MealOrderServiceProto"; | ||
| 6 | +option objc_class_prefix = "OP"; | ||
| 7 | + | ||
| 8 | +package com.infoloop.tianting.mealorderservice; | ||
| 9 | + | ||
| 10 | +service MealOrderServiceRpc { | ||
| 11 | + rpc GetMealOrderById (GetMealOrderByIdRpcRequest) returns (GetMealOrderByIdRpcResponse) {} | ||
| 12 | + rpc GetMealOrdersByIds (GetMealOrdersByIdsRpcRequest) returns (GetMealOrdersByIdsRpcResponse) {} | ||
| 13 | + rpc QueryMealOrdersByCondition (QueryMealOrdersByConditionRpcRequest) returns (QueryMealOrdersByConditionRpcResponse) {} | ||
| 14 | + rpc QueryReserveMealOrdersByDinerIds (QueryReserveMealOrdersByDinerIdsRpcRequest) returns (QueryReserveMealOrdersByDinerIdsRpcResponse) {} | ||
| 15 | + rpc CreateMealOrder (CreateMealOrderRpcRequest) returns (CreateMealOrderRpcResponse) {} | ||
| 16 | + rpc BatchCreateMealOrders (BatchCreateMealOrdersRpcRequest) returns (BatchCreateMealOrdersRpcResponse) {} | ||
| 17 | + rpc DeleteMealOrdersByIds (DeleteMealOrdersByIdsRpcRequest) returns (DeleteMealOrdersRpcResponse) {} | ||
| 18 | + | ||
| 19 | + rpc GetMpAccountById (GetMpAccountByIdRpcRequest) returns (GetMpAccountByIdRpcResponse) {} | ||
| 20 | + rpc GetMpAccountByOpenId (GetMpAccountByOpenIdRpcRequest) returns (GetMpAccountByOpenIdRpcResponse) {} | ||
| 21 | + rpc GetMpAccountsByIds (GetMpAccountsByIdsRpcRequest) returns (GetMpAccountsByIdsRpcResponse) {} | ||
| 22 | + rpc QueryMpAccountsByCondition (QueryMpAccountsByConditionRpcRequest) returns (QueryMpAccountsByConditionRpcResponse) {} | ||
| 23 | + rpc CreateMpAccount (CreateMpAccountRpcRequest) returns (CreateMpAccountRpcResponse) {} | ||
| 24 | + rpc UpdateMpAccount (UpdateMpAccountRpcRequest) returns (UpdateMpAccountRpcResponse) {} | ||
| 25 | + rpc DeleteMpAccountsByIds (DeleteMpAccountsByIdsRpcRequest) returns (DeleteMpAccountsRpcResponse) {} | ||
| 26 | + | ||
| 27 | + rpc GetDinerById (GetDinerByIdRpcRequest) returns (GetDinerByIdRpcResponse) {} | ||
| 28 | + rpc GetDinersByIds (GetDinersByIdsRpcRequest) returns (GetDinersByIdsRpcResponse) {} | ||
| 29 | + rpc QueryDinersByCondition (QueryDinersByConditionRpcRequest) returns (QueryDinersByConditionRpcResponse) {} | ||
| 30 | + rpc CreateDiner (CreateDinerRpcRequest) returns (CreateDinerRpcResponse) {} | ||
| 31 | + rpc UpdateDiner (UpdateDinerRpcRequest) returns (UpdateDinerRpcResponse) {} | ||
| 32 | + rpc BatchSaveOrUpdateDiners (BatchSaveOrUpdateDinersRpcRequest) returns (BatchSaveOrUpdateDinersRpcResponse) {} | ||
| 33 | + rpc DeleteDinersByIds (DeleteDinersByIdsRpcRequest) returns (DeleteDinersRpcResponse) {} | ||
| 34 | + | ||
| 35 | + rpc GetMpAccountDinerRefsByIds (GetMpAccountDinerRefsByIdsRpcRequest) returns (GetMpAccountDinerRefsByIdsRpcResponse) {} | ||
| 36 | + rpc QueryMpAccountDinerRefsByCondition (QueryMpAccountDinerRefsByConditionRpcRequest) returns (QueryMpAccountDinerRefsByConditionRpcResponse) {} | ||
| 37 | + rpc CreateMpAccountDinerRef (CreateMpAccountDinerRefRpcRequest) returns (CreateMpAccountDinerRefRpcResponse) {} | ||
| 38 | + rpc DeleteMpAccountDinerRefsByIds (DeleteMpAccountDinerRefsByIdsRpcRequest) returns (DeleteMpAccountDinerRefsRpcResponse) {} | ||
| 39 | + | ||
| 40 | + rpc GetGradeClassById (GetGradeClassByIdRpcRequest) returns (GetGradeClassByIdRpcResponse) {} | ||
| 41 | + rpc GetGradeClassesByIds (GetGradeClassesByIdsRpcRequest) returns (GetGradeClassesByIdsRpcResponse) {} | ||
| 42 | + rpc QueryGradeClassesByCondition (QueryGradeClassesByConditionRpcRequest) returns (QueryGradeClassesByConditionRpcResponse) {} | ||
| 43 | + rpc CreateGradeClass (CreateGradeClassRpcRequest) returns (CreateGradeClassRpcResponse) {} | ||
| 44 | + rpc BatchCreateGradeClasses (BatchCreateGradeClassesRpcRequest) returns (BatchCreateGradeClassesRpcResponse) {} | ||
| 45 | + rpc UpdateGradeClass (UpdateGradeClassRpcRequest) returns (UpdateGradeClassRpcResponse) {} | ||
| 46 | + rpc BatchSaveOrUpdateGradeClasses (BatchSaveOrUpdateGradeClassesRpcRequest) returns (BatchSaveOrUpdateGradeClassesRpcResponse) {} | ||
| 47 | + rpc DeleteGradeClassesByIds (DeleteGradeClassesByIdsRpcRequest) returns (DeleteGradeClassesRpcResponse) {} | ||
| 48 | + rpc DeleteGradeClassesAndDinersByClientIds (DeleteGradeClassesAndDinersByClientIdsRpcRequest) returns (DeleteGradeClassesAndDinersByClientIdsRpcResponse) {} | ||
| 49 | + | ||
| 50 | + rpc GetMealMenuRecordById (GetMealMenuRecordByIdRpcRequest) returns (GetMealMenuRecordByIdRpcResponse) {} | ||
| 51 | + rpc GetMealMenuRecordsByIds (GetMealMenuRecordsByIdsRpcRequest) returns (GetMealMenuRecordsByIdsRpcResponse) {} | ||
| 52 | + rpc QueryMealMenuRecordsByCondition (QueryMealMenuRecordsByConditionRpcRequest) returns (QueryMealMenuRecordsByConditionRpcResponse) {} | ||
| 53 | + rpc CreateMealMenuRecord (CreateMealMenuRecordRpcRequest) returns (CreateMealMenuRecordRpcResponse) {} | ||
| 54 | + rpc QueryLatestMealMenuRecordsByClientIds (QueryLatestMealMenuRecordsByClientIdsRpcRequest) returns (QueryLatestMealMenuRecordsByClientIdsRpcResponse) {} | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +enum MealOrderOrderMethodEnum { | ||
| 58 | + MEAL_ORDER_METHOD_SYSTEM = 0; | ||
| 59 | + MEAL_ORDER_METHOD_MICRO = 1; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +message SingleMealOrderRpcResponse { | ||
| 63 | + int32 id = 1; | ||
| 64 | + int32 enterpriseId = 2; | ||
| 65 | + int32 clientId = 3; | ||
| 66 | + int32 menuId = 4; | ||
| 67 | + int32 accountId = 5; | ||
| 68 | + MealOrderOrderMethodEnum orderMethod = 6; | ||
| 69 | + int32 dinerId = 7; | ||
| 70 | + string dinerName = 8; | ||
| 71 | + string clientName = 9; | ||
| 72 | + string gradeName = 10; | ||
| 73 | + string className = 11; | ||
| 74 | + string studentNo = 12; | ||
| 75 | + int64 reserveDate = 13; | ||
| 76 | + repeated MenuSchedule meals = 14; | ||
| 77 | + int32 createdBy = 15; | ||
| 78 | + int64 createdAt = 16; | ||
| 79 | + int32 creationSource = 17; | ||
| 80 | + int32 updatedBy = 18; | ||
| 81 | + int64 updatedAt = 19; | ||
| 82 | + int32 updateSource = 20; | ||
| 83 | + bool isDeleted = 21; | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +message GetMealOrderByIdRpcRequest { | ||
| 87 | + int32 id = 1; | ||
| 88 | + int32 enterpriseId = 2; | ||
| 89 | + bool includeDeleted = 3; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +message GetMealOrderByIdRpcResponse { | ||
| 93 | + SingleMealOrderRpcResponse response = 1; | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +message GetMealOrdersByIdsRpcRequest { | ||
| 97 | + repeated int32 ids = 1; | ||
| 98 | + int32 enterpriseId = 2; | ||
| 99 | + bool includeDeleted = 3; | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +message GetMealOrdersByIdsRpcResponse { | ||
| 103 | + repeated SingleMealOrderRpcResponse responses = 1; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +message QueryMealOrdersByConditionRpcRequest { | ||
| 107 | + int32 enterpriseId = 1; | ||
| 108 | + bool shouldFilterClientIds = 2; | ||
| 109 | + repeated int32 clientIds = 3; | ||
| 110 | + bool shouldFilterMenuIds = 4; | ||
| 111 | + repeated int32 menuIds = 5; | ||
| 112 | + bool shouldFilterAccountIds = 6; | ||
| 113 | + repeated int32 accountIds = 7; | ||
| 114 | + bool shouldFilterOrderMethod = 8; | ||
| 115 | + MealOrderOrderMethodEnum orderMethod = 9; | ||
| 116 | + bool shouldFilterDinerIds = 10; | ||
| 117 | + repeated int32 dinerIds = 11; | ||
| 118 | + bool shouldFilterReserveDateStart = 12; | ||
| 119 | + int64 reserveDateStart = 13; | ||
| 120 | + bool shouldFilterReserveDateEnd = 14; | ||
| 121 | + int64 reserveDateEnd = 15; | ||
| 122 | + bool includeDeleted = 16; | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +message QueryMealOrdersByConditionRpcResponse { | ||
| 126 | + repeated SingleMealOrderRpcResponse responses = 1; | ||
| 127 | +} | ||
| 128 | + | ||
| 129 | +message QueryReserveMealOrdersByDinerIdsRpcRequest { | ||
| 130 | + int32 enterpriseId = 1; | ||
| 131 | + repeated int32 dinerIds = 2; | ||
| 132 | +} | ||
| 133 | + | ||
| 134 | +message QueryReserveMealOrdersByDinerIdsRpcResponse { | ||
| 135 | + repeated SingleMealOrderRpcResponse responses = 1; | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | +message MealOrderCreation{ | ||
| 139 | + int32 clientId = 1; | ||
| 140 | + int32 menuId = 2; | ||
| 141 | + int32 accountId = 3; | ||
| 142 | + MealOrderOrderMethodEnum orderMethod = 4; | ||
| 143 | + int32 dinerId = 5; | ||
| 144 | + string dinerName = 6; | ||
| 145 | + string clientName = 7; | ||
| 146 | + string gradeName = 8; | ||
| 147 | + string className = 9; | ||
| 148 | + string studentNo = 10; | ||
| 149 | + int64 reserveDate = 11; | ||
| 150 | + repeated MenuSchedule meals = 12; | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +message MenuSchedule { | ||
| 154 | + string date = 1; // 日期字段,类型是 string | ||
| 155 | + string menu = 2; // 菜单字段,类型是 string | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +message CreateMealOrderRpcRequest { | ||
| 159 | + MealOrderCreation creation = 1; | ||
| 160 | + int32 enterpriseId = 2; | ||
| 161 | + int32 createdBy = 3; | ||
| 162 | + int32 creationSource = 4; | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +message CreateMealOrderRpcResponse { | ||
| 166 | + int32 id = 1; | ||
| 167 | + bool isCreated = 2; | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | +message BatchCreateMealOrdersRpcRequest { | ||
| 171 | + repeated MealOrderCreation creations = 1; | ||
| 172 | + int32 enterpriseId = 2; | ||
| 173 | + int32 createdBy = 3; | ||
| 174 | + int32 creationSource = 4; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +message BatchCreateMealOrdersRpcResponse { | ||
| 178 | + repeated int32 ids = 1; | ||
| 179 | + bool isCreated = 2; | ||
| 180 | +} | ||
| 181 | + | ||
| 182 | +message MealOrderModification { | ||
| 183 | + int32 id = 1; | ||
| 184 | + bool shouldUpdateClientId = 2; | ||
| 185 | + int32 clientId = 3; | ||
| 186 | + bool shouldUpdateMenuId = 4; | ||
| 187 | + int32 menuId = 5; | ||
| 188 | + bool shouldUpdateAccountId = 6; | ||
| 189 | + int32 accountId = 7; | ||
| 190 | + bool shouldUpdateOrderMethod = 8; | ||
| 191 | + MealOrderOrderMethodEnum orderMethod = 9; | ||
| 192 | + bool shouldUpdateDinerId = 10; | ||
| 193 | + int32 dinerId = 11; | ||
| 194 | + bool shouldUpdateDinerName = 12; | ||
| 195 | + string dinerName = 13; | ||
| 196 | + bool shouldUpdateClientName = 14; | ||
| 197 | + string clientName = 15; | ||
| 198 | + bool shouldUpdateGradeName = 16; | ||
| 199 | + string gradeName = 17; | ||
| 200 | + bool shouldUpdateClassName = 18; | ||
| 201 | + string className = 19; | ||
| 202 | + bool shouldUpdateStudentNo = 20; | ||
| 203 | + string studentNo = 21; | ||
| 204 | + bool shouldUpdateReserveDate = 22; | ||
| 205 | + int64 reserveDate = 23; | ||
| 206 | + bool shouldUpdateMeals = 24; | ||
| 207 | + repeated MenuSchedule meals = 25; | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +message UpdateMealOrderRpcRequest { | ||
| 211 | + MealOrderModification modification = 1; | ||
| 212 | + int32 enterpriseId = 2; | ||
| 213 | + int32 updatedBy = 3; | ||
| 214 | + int32 updateSource = 4; | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +message UpdateMealOrderRpcResponse { | ||
| 218 | + bool isUpdated = 1; | ||
| 219 | +} | ||
| 220 | + | ||
| 221 | +message BatchUpdateMealOrdersRpcRequest { | ||
| 222 | + repeated MealOrderModification modifications = 1; | ||
| 223 | + int32 enterpriseId = 2; | ||
| 224 | + int32 updatedBy = 3; | ||
| 225 | + int32 updateSource = 4; | ||
| 226 | +} | ||
| 227 | + | ||
| 228 | +message BatchUpdateMealOrdersRpcResponse { | ||
| 229 | + bool isUpdated = 1; | ||
| 230 | +} | ||
| 231 | + | ||
| 232 | +message DeleteMealOrdersByIdsRpcRequest { | ||
| 233 | + repeated int32 ids = 1; | ||
| 234 | + int32 enterpriseId = 2; | ||
| 235 | + int32 updatedBy = 3; | ||
| 236 | + int32 updateSource = 4; | ||
| 237 | +} | ||
| 238 | + | ||
| 239 | +message DeleteMealOrdersRpcResponse { | ||
| 240 | + bool isDeleted = 1; | ||
| 241 | +} | ||
| 242 | + | ||
| 243 | +message SingleDinerRpcResponse { | ||
| 244 | + int32 id = 1; | ||
| 245 | + int32 enterpriseId = 2; | ||
| 246 | + int32 clientId = 3; | ||
| 247 | + int32 classId = 4; | ||
| 248 | + string studentNo = 5; | ||
| 249 | + string name = 6; | ||
| 250 | + int32 createdBy = 7; | ||
| 251 | + int64 createdAt = 8; | ||
| 252 | + int32 creationSource = 9; | ||
| 253 | + int32 updatedBy = 10; | ||
| 254 | + int64 updatedAt = 11; | ||
| 255 | + int32 updateSource = 12; | ||
| 256 | + bool isDeleted = 13; | ||
| 257 | +} | ||
| 258 | + | ||
| 259 | +message GetDinerByIdRpcRequest { | ||
| 260 | + int32 id = 1; | ||
| 261 | + int32 enterpriseId = 2; | ||
| 262 | + bool includeDeleted = 3; | ||
| 263 | +} | ||
| 264 | + | ||
| 265 | +message GetDinerByIdRpcResponse { | ||
| 266 | + SingleDinerRpcResponse response = 1; | ||
| 267 | +} | ||
| 268 | + | ||
| 269 | +message GetDinersByIdsRpcRequest { | ||
| 270 | + repeated int32 ids = 1; | ||
| 271 | + int32 enterpriseId = 2; | ||
| 272 | + bool includeDeleted = 3; | ||
| 273 | +} | ||
| 274 | + | ||
| 275 | +message GetDinersByIdsRpcResponse { | ||
| 276 | + repeated SingleDinerRpcResponse responses = 1; | ||
| 277 | +} | ||
| 278 | + | ||
| 279 | +message QueryDinersByConditionRpcRequest { | ||
| 280 | + int32 enterpriseId = 1; | ||
| 281 | + bool shouldFilterClientIds = 2; | ||
| 282 | + repeated int32 clientIds = 3; | ||
| 283 | + bool shouldFilterClassIds = 4; | ||
| 284 | + repeated int32 classIds = 5; | ||
| 285 | + bool shouldFilterStudentNo = 6; | ||
| 286 | + string studentNo = 7; | ||
| 287 | + bool shouldFilterName = 8; | ||
| 288 | + string name = 9; | ||
| 289 | + bool includeDeleted = 10; | ||
| 290 | +} | ||
| 291 | + | ||
| 292 | +message QueryDinersByConditionRpcResponse { | ||
| 293 | + repeated SingleDinerRpcResponse responses = 1; | ||
| 294 | +} | ||
| 295 | + | ||
| 296 | +message DinerCreation{ | ||
| 297 | + int32 clientId = 1; | ||
| 298 | + int32 classId = 2; | ||
| 299 | + string studentNo = 3; | ||
| 300 | + string name = 4; | ||
| 301 | +} | ||
| 302 | + | ||
| 303 | +message CreateDinerRpcRequest { | ||
| 304 | + DinerCreation creation = 1; | ||
| 305 | + int32 enterpriseId = 2; | ||
| 306 | + int32 createdBy = 3; | ||
| 307 | + int32 creationSource = 4; | ||
| 308 | +} | ||
| 309 | + | ||
| 310 | +message CreateDinerRpcResponse { | ||
| 311 | + int32 id = 1; | ||
| 312 | + bool isCreated = 2; | ||
| 313 | +} | ||
| 314 | + | ||
| 315 | +message DinerModification { | ||
| 316 | + int32 id = 1; | ||
| 317 | + bool shouldUpdateClientId = 2; | ||
| 318 | + int32 clientId = 3; | ||
| 319 | + bool shouldUpdateClassId = 4; | ||
| 320 | + int32 classId = 5; | ||
| 321 | + bool shouldUpdateStudentNo = 6; | ||
| 322 | + string studentNo = 7; | ||
| 323 | + bool shouldUpdateName = 8; | ||
| 324 | + string name = 9; | ||
| 325 | +} | ||
| 326 | + | ||
| 327 | +message UpdateDinerRpcRequest { | ||
| 328 | + DinerModification modification = 1; | ||
| 329 | + int32 enterpriseId = 2; | ||
| 330 | + int32 updatedBy = 3; | ||
| 331 | + int32 updateSource = 4; | ||
| 332 | +} | ||
| 333 | + | ||
| 334 | +message UpdateDinerRpcResponse { | ||
| 335 | + bool isUpdated = 1; | ||
| 336 | +} | ||
| 337 | + | ||
| 338 | +message BatchSaveOrUpdateDinersRpcRequest { | ||
| 339 | + repeated DinerModification modifications = 1; | ||
| 340 | + int32 enterpriseId = 2; | ||
| 341 | + int32 updatedBy = 3; | ||
| 342 | + int32 updateSource = 4; | ||
| 343 | +} | ||
| 344 | + | ||
| 345 | +message BatchSaveOrUpdateDinersRpcResponse { | ||
| 346 | + bool isUpdated = 1; | ||
| 347 | +} | ||
| 348 | + | ||
| 349 | +message DeleteDinersByIdsRpcRequest { | ||
| 350 | + repeated int32 ids = 1; | ||
| 351 | + int32 enterpriseId = 2; | ||
| 352 | + int32 updatedBy = 3; | ||
| 353 | + int32 updateSource = 4; | ||
| 354 | +} | ||
| 355 | + | ||
| 356 | +message DeleteDinersRpcResponse { | ||
| 357 | + bool isDeleted = 1; | ||
| 358 | +} | ||
| 359 | + | ||
| 360 | +enum MpAccountGenderEnum { | ||
| 361 | + MP_ACCOUNT_GENDER_MAN = 0; | ||
| 362 | + MP_ACCOUNT_GENDER_WOMAN = 1; | ||
| 363 | +} | ||
| 364 | +enum MpAccountStatusEnum { | ||
| 365 | + MP_ACCOUNT_STATUS_ENABLE = 0; | ||
| 366 | + MP_ACCOUNT_STATUS_DISABLE = 1; | ||
| 367 | +} | ||
| 368 | + | ||
| 369 | +message SingleMpAccountRpcResponse { | ||
| 370 | + int32 id = 1; | ||
| 371 | + int32 enterpriseId = 2; | ||
| 372 | + string openId = 3; | ||
| 373 | + string unionId = 4; | ||
| 374 | + string nickname = 5; | ||
| 375 | + string avatarUrl = 6; | ||
| 376 | + MpAccountGenderEnum gender = 7; | ||
| 377 | + string phoneNumber = 8; | ||
| 378 | + MpAccountStatusEnum status = 9; | ||
| 379 | + int32 createdBy = 10; | ||
| 380 | + int64 createdAt = 11; | ||
| 381 | + int32 creationSource = 12; | ||
| 382 | + int32 updatedBy = 13; | ||
| 383 | + int64 updatedAt = 14; | ||
| 384 | + int32 updateSource = 15; | ||
| 385 | + bool isDeleted = 16; | ||
| 386 | +} | ||
| 387 | + | ||
| 388 | +message GetMpAccountByIdRpcRequest { | ||
| 389 | + int32 id = 1; | ||
| 390 | + int32 enterpriseId = 2; | ||
| 391 | + bool includeDeleted = 3; | ||
| 392 | +} | ||
| 393 | + | ||
| 394 | +message GetMpAccountByIdRpcResponse { | ||
| 395 | + SingleMpAccountRpcResponse response = 1; | ||
| 396 | +} | ||
| 397 | + | ||
| 398 | +message GetMpAccountByOpenIdRpcRequest { | ||
| 399 | + string openId = 1; | ||
| 400 | +} | ||
| 401 | + | ||
| 402 | +message GetMpAccountByOpenIdRpcResponse { | ||
| 403 | + SingleMpAccountRpcResponse response = 1; | ||
| 404 | +} | ||
| 405 | + | ||
| 406 | +message GetMpAccountsByIdsRpcRequest { | ||
| 407 | + repeated int32 ids = 1; | ||
| 408 | + int32 enterpriseId = 2; | ||
| 409 | + bool includeDeleted = 3; | ||
| 410 | +} | ||
| 411 | + | ||
| 412 | +message GetMpAccountsByIdsRpcResponse { | ||
| 413 | + repeated SingleMpAccountRpcResponse responses = 1; | ||
| 414 | +} | ||
| 415 | + | ||
| 416 | +message QueryMpAccountsByConditionRpcRequest { | ||
| 417 | + int32 enterpriseId = 1; | ||
| 418 | + bool shouldFilterOpenId = 2; | ||
| 419 | + string openId = 3; | ||
| 420 | + bool shouldFilterUnionId = 4; | ||
| 421 | + string unionId = 5; | ||
| 422 | + bool shouldFilterPhoneNumber = 6; | ||
| 423 | + string phoneNumber = 7; | ||
| 424 | + bool shouldFilterStatus = 8; | ||
| 425 | + MpAccountStatusEnum status = 9; | ||
| 426 | + bool includeDeleted = 10; | ||
| 427 | +} | ||
| 428 | + | ||
| 429 | +message QueryMpAccountsByConditionRpcResponse { | ||
| 430 | + repeated SingleMpAccountRpcResponse responses = 1; | ||
| 431 | +} | ||
| 432 | + | ||
| 433 | +message MpAccountCreation{ | ||
| 434 | + string openId = 1; | ||
| 435 | + bool shouldCreateUnionId = 2; | ||
| 436 | + string unionId = 3; | ||
| 437 | + bool shouldCreateNickname = 4; | ||
| 438 | + string nickname = 5; | ||
| 439 | + bool shouldCreateAvatarUrl = 6; | ||
| 440 | + string avatarUrl = 7; | ||
| 441 | + MpAccountGenderEnum gender = 8; | ||
| 442 | + string phoneNumber = 9; | ||
| 443 | + MpAccountStatusEnum status = 10; | ||
| 444 | +} | ||
| 445 | + | ||
| 446 | +message CreateMpAccountRpcRequest { | ||
| 447 | + MpAccountCreation creation = 1; | ||
| 448 | + int32 enterpriseId = 2; | ||
| 449 | + int32 createdBy = 3; | ||
| 450 | + int32 creationSource = 4; | ||
| 451 | +} | ||
| 452 | + | ||
| 453 | +message CreateMpAccountRpcResponse { | ||
| 454 | + int32 id = 1; | ||
| 455 | + bool isCreated = 2; | ||
| 456 | +} | ||
| 457 | + | ||
| 458 | +message MpAccountModification { | ||
| 459 | + int32 id = 1; | ||
| 460 | + bool shouldUpdateOpenId = 2; | ||
| 461 | + string openId = 3; | ||
| 462 | + bool shouldUpdateUnionId = 4; | ||
| 463 | + string unionId = 5; | ||
| 464 | + bool shouldUpdateNickname = 6; | ||
| 465 | + string nickname = 7; | ||
| 466 | + bool shouldUpdateAvatarUrl = 8; | ||
| 467 | + string avatarUrl = 9; | ||
| 468 | + bool shouldUpdateGender = 10; | ||
| 469 | + MpAccountGenderEnum gender = 11; | ||
| 470 | + bool shouldUpdatePhoneNumber = 12; | ||
| 471 | + string phoneNumber = 13; | ||
| 472 | + bool shouldUpdateStatus = 14; | ||
| 473 | + MpAccountStatusEnum status = 15; | ||
| 474 | +} | ||
| 475 | + | ||
| 476 | +message UpdateMpAccountRpcRequest { | ||
| 477 | + MpAccountModification modification = 1; | ||
| 478 | + int32 enterpriseId = 2; | ||
| 479 | + int32 updatedBy = 3; | ||
| 480 | + int32 updateSource = 4; | ||
| 481 | +} | ||
| 482 | + | ||
| 483 | +message UpdateMpAccountRpcResponse { | ||
| 484 | + bool isUpdated = 1; | ||
| 485 | +} | ||
| 486 | + | ||
| 487 | +message DeleteMpAccountsByIdsRpcRequest { | ||
| 488 | + repeated int32 ids = 1; | ||
| 489 | + int32 enterpriseId = 2; | ||
| 490 | + int32 updatedBy = 3; | ||
| 491 | + int32 updateSource = 4; | ||
| 492 | +} | ||
| 493 | + | ||
| 494 | +message DeleteMpAccountsRpcResponse { | ||
| 495 | + bool isDeleted = 1; | ||
| 496 | +} | ||
| 497 | + | ||
| 498 | +message SingleMpAccountDinerRefRpcResponse { | ||
| 499 | + int32 id = 1; | ||
| 500 | + int32 enterpriseId = 2; | ||
| 501 | + int32 accountId = 3; | ||
| 502 | + int32 dinerId = 4; | ||
| 503 | + int32 createdBy = 5; | ||
| 504 | + int64 createdAt = 6; | ||
| 505 | + int32 creationSource = 7; | ||
| 506 | +} | ||
| 507 | + | ||
| 508 | +message GetMpAccountDinerRefsByIdsRpcRequest { | ||
| 509 | + repeated int32 ids = 1; | ||
| 510 | + int32 enterpriseId = 2; | ||
| 511 | +} | ||
| 512 | + | ||
| 513 | +message GetMpAccountDinerRefsByIdsRpcResponse { | ||
| 514 | + repeated SingleMpAccountDinerRefRpcResponse responses = 1; | ||
| 515 | +} | ||
| 516 | + | ||
| 517 | +message QueryMpAccountDinerRefsByConditionRpcRequest { | ||
| 518 | + int32 enterpriseId = 1; | ||
| 519 | + bool shouldFilterAccountIds = 2; | ||
| 520 | + repeated int32 accountIds = 3; | ||
| 521 | + bool shouldFilterDinerIds = 4; | ||
| 522 | + repeated int32 dinerIds = 5; | ||
| 523 | +} | ||
| 524 | + | ||
| 525 | +message QueryMpAccountDinerRefsByConditionRpcResponse { | ||
| 526 | + repeated SingleMpAccountDinerRefRpcResponse responses = 1; | ||
| 527 | +} | ||
| 528 | + | ||
| 529 | +message MpAccountDinerRefCreation{ | ||
| 530 | + int32 accountId = 1; | ||
| 531 | + int32 dinerId = 2; | ||
| 532 | +} | ||
| 533 | + | ||
| 534 | +message CreateMpAccountDinerRefRpcRequest { | ||
| 535 | + MpAccountDinerRefCreation creation = 1; | ||
| 536 | + int32 enterpriseId = 2; | ||
| 537 | + int32 createdBy = 3; | ||
| 538 | + int32 creationSource = 4; | ||
| 539 | +} | ||
| 540 | + | ||
| 541 | +message CreateMpAccountDinerRefRpcResponse { | ||
| 542 | + int32 id = 1; | ||
| 543 | + bool isCreated = 2; | ||
| 544 | +} | ||
| 545 | + | ||
| 546 | +message BatchCreateMpAccountDinerRefsRpcRequest { | ||
| 547 | + repeated MpAccountDinerRefCreation creations = 1; | ||
| 548 | + int32 enterpriseId = 2; | ||
| 549 | + int32 createdBy = 3; | ||
| 550 | + int32 creationSource = 4; | ||
| 551 | +} | ||
| 552 | + | ||
| 553 | +message BatchCreateMpAccountDinerRefsRpcResponse { | ||
| 554 | + repeated int32 ids = 1; | ||
| 555 | + bool isCreated = 2; | ||
| 556 | +} | ||
| 557 | + | ||
| 558 | +message DeleteMpAccountDinerRefsByIdsRpcRequest { | ||
| 559 | + repeated int32 ids = 1; | ||
| 560 | + int32 enterpriseId = 2; | ||
| 561 | +} | ||
| 562 | + | ||
| 563 | +message DeleteMpAccountDinerRefsRpcResponse { | ||
| 564 | + bool isDeleted = 1; | ||
| 565 | +} | ||
| 566 | + | ||
| 567 | +message SingleGradeClassRpcResponse { | ||
| 568 | + int32 id = 1; | ||
| 569 | + int32 enterpriseId = 2; | ||
| 570 | + int32 clientId = 3; | ||
| 571 | + string gradeName = 4; | ||
| 572 | + string className = 5; | ||
| 573 | + string fullName = 6; | ||
| 574 | + int32 createdBy = 7; | ||
| 575 | + int64 createdAt = 8; | ||
| 576 | + int32 creationSource = 9; | ||
| 577 | + int32 updatedBy = 10; | ||
| 578 | + int64 updatedAt = 11; | ||
| 579 | + int32 updateSource = 12; | ||
| 580 | + bool isDeleted = 13; | ||
| 581 | +} | ||
| 582 | + | ||
| 583 | +message GetGradeClassByIdRpcRequest { | ||
| 584 | + int32 id = 1; | ||
| 585 | + int32 enterpriseId = 2; | ||
| 586 | + bool includeDeleted = 3; | ||
| 587 | +} | ||
| 588 | + | ||
| 589 | +message GetGradeClassByIdRpcResponse { | ||
| 590 | + SingleGradeClassRpcResponse response = 1; | ||
| 591 | +} | ||
| 592 | + | ||
| 593 | +message GetGradeClassesByIdsRpcRequest { | ||
| 594 | + repeated int32 ids = 1; | ||
| 595 | + int32 enterpriseId = 2; | ||
| 596 | + bool includeDeleted = 3; | ||
| 597 | +} | ||
| 598 | + | ||
| 599 | +message GetGradeClassesByIdsRpcResponse { | ||
| 600 | + repeated SingleGradeClassRpcResponse responses = 1; | ||
| 601 | +} | ||
| 602 | + | ||
| 603 | +message GetAllGradeClassesRpcRequest { | ||
| 604 | + int32 enterpriseId = 1; | ||
| 605 | + bool includeDeleted = 2; | ||
| 606 | +} | ||
| 607 | + | ||
| 608 | +message GetAllGradeClassesRpcResponse { | ||
| 609 | + repeated SingleGradeClassRpcResponse responses = 1; | ||
| 610 | +} | ||
| 611 | + | ||
| 612 | +message QueryGradeClassesByConditionRpcRequest { | ||
| 613 | + int32 enterpriseId = 1; | ||
| 614 | + bool shouldFilterClientIds = 2; | ||
| 615 | + repeated int32 clientIds = 3; | ||
| 616 | + bool shouldFilterGradeName = 4; | ||
| 617 | + string gradeName = 5; | ||
| 618 | + bool includeDeleted = 6; | ||
| 619 | +} | ||
| 620 | + | ||
| 621 | +message QueryGradeClassesByConditionRpcResponse { | ||
| 622 | + repeated SingleGradeClassRpcResponse responses = 1; | ||
| 623 | +} | ||
| 624 | + | ||
| 625 | +message GradeClassCreation{ | ||
| 626 | + int32 clientId = 1; | ||
| 627 | + string gradeName = 2; | ||
| 628 | + string className = 3; | ||
| 629 | + bool shouldCreateFullName = 4; | ||
| 630 | + string fullName = 5; | ||
| 631 | +} | ||
| 632 | + | ||
| 633 | +message CreateGradeClassRpcRequest { | ||
| 634 | + GradeClassCreation creation = 1; | ||
| 635 | + int32 enterpriseId = 2; | ||
| 636 | + int32 createdBy = 3; | ||
| 637 | + int32 creationSource = 4; | ||
| 638 | +} | ||
| 639 | + | ||
| 640 | +message CreateGradeClassRpcResponse { | ||
| 641 | + int32 id = 1; | ||
| 642 | + bool isCreated = 2; | ||
| 643 | +} | ||
| 644 | + | ||
| 645 | +message BatchCreateGradeClassesRpcRequest { | ||
| 646 | + repeated GradeClassCreation creations = 1; | ||
| 647 | + int32 enterpriseId = 2; | ||
| 648 | + int32 createdBy = 3; | ||
| 649 | + int32 creationSource = 4; | ||
| 650 | +} | ||
| 651 | + | ||
| 652 | +message BatchCreateGradeClassesRpcResponse { | ||
| 653 | + repeated int32 ids = 1; | ||
| 654 | + bool isCreated = 2; | ||
| 655 | +} | ||
| 656 | + | ||
| 657 | +message GradeClassModification { | ||
| 658 | + int32 id = 1; | ||
| 659 | + bool shouldUpdateClientId = 2; | ||
| 660 | + int32 clientId = 3; | ||
| 661 | + bool shouldUpdateGradeName = 4; | ||
| 662 | + string gradeName = 5; | ||
| 663 | + bool shouldUpdateClassName = 6; | ||
| 664 | + string className = 7; | ||
| 665 | + bool shouldUpdateFullName = 8; | ||
| 666 | + string fullName = 9; | ||
| 667 | +} | ||
| 668 | + | ||
| 669 | +message UpdateGradeClassRpcRequest { | ||
| 670 | + GradeClassModification modification = 1; | ||
| 671 | + int32 enterpriseId = 2; | ||
| 672 | + int32 updatedBy = 3; | ||
| 673 | + int32 updateSource = 4; | ||
| 674 | +} | ||
| 675 | + | ||
| 676 | +message UpdateGradeClassRpcResponse { | ||
| 677 | + bool isUpdated = 1; | ||
| 678 | +} | ||
| 679 | + | ||
| 680 | +message BatchSaveOrUpdateGradeClassesRpcRequest { | ||
| 681 | + repeated GradeClassModification modifications = 1; | ||
| 682 | + int32 enterpriseId = 2; | ||
| 683 | + int32 updatedBy = 3; | ||
| 684 | + int32 updateSource = 4; | ||
| 685 | +} | ||
| 686 | + | ||
| 687 | +message BatchSaveOrUpdateGradeClassesRpcResponse { | ||
| 688 | + bool isUpdated = 1; | ||
| 689 | +} | ||
| 690 | + | ||
| 691 | +message BatchUpdateGradeClassesRpcRequest { | ||
| 692 | + repeated GradeClassModification modifications = 1; | ||
| 693 | + int32 enterpriseId = 2; | ||
| 694 | + int32 updatedBy = 3; | ||
| 695 | + int32 updateSource = 4; | ||
| 696 | +} | ||
| 697 | + | ||
| 698 | +message BatchUpdateGradeClassesRpcResponse { | ||
| 699 | + bool isUpdated = 1; | ||
| 700 | +} | ||
| 701 | + | ||
| 702 | +message DeleteGradeClassesByIdsRpcRequest { | ||
| 703 | + repeated int32 ids = 1; | ||
| 704 | + int32 enterpriseId = 2; | ||
| 705 | + int32 updatedBy = 3; | ||
| 706 | + int32 updateSource = 4; | ||
| 707 | +} | ||
| 708 | + | ||
| 709 | +message DeleteGradeClassesRpcResponse { | ||
| 710 | + bool isDeleted = 1; | ||
| 711 | +} | ||
| 712 | + | ||
| 713 | +message DeleteGradeClassesAndDinersByClientIdsRpcRequest { | ||
| 714 | + repeated int32 clientIds = 1; | ||
| 715 | + int32 enterpriseId = 2; | ||
| 716 | + int32 updatedBy = 3; | ||
| 717 | + int32 updateSource = 4; | ||
| 718 | +} | ||
| 719 | + | ||
| 720 | +message DeleteGradeClassesAndDinersByClientIdsRpcResponse { | ||
| 721 | + bool isDeleted = 1; | ||
| 722 | +} | ||
| 723 | + | ||
| 724 | +message SingleMealMenuRecordRpcResponse { | ||
| 725 | + int32 id = 1; | ||
| 726 | + int32 enterpriseId = 2; | ||
| 727 | + int32 clientId = 3; | ||
| 728 | + string name = 4; | ||
| 729 | + string imageUrl = 5; | ||
| 730 | + int32 createdBy = 6; | ||
| 731 | + int64 createdAt = 7; | ||
| 732 | + int32 creationSource = 8; | ||
| 733 | + int32 updatedBy = 9; | ||
| 734 | + int64 updatedAt = 10; | ||
| 735 | + int32 updateSource = 11; | ||
| 736 | + bool isDeleted = 12; | ||
| 737 | +} | ||
| 738 | + | ||
| 739 | +message GetMealMenuRecordByIdRpcRequest { | ||
| 740 | + int32 id = 1; | ||
| 741 | + int32 enterpriseId = 2; | ||
| 742 | + bool includeDeleted = 3; | ||
| 743 | +} | ||
| 744 | + | ||
| 745 | +message GetMealMenuRecordByIdRpcResponse { | ||
| 746 | + SingleMealMenuRecordRpcResponse response = 1; | ||
| 747 | +} | ||
| 748 | + | ||
| 749 | +message GetMealMenuRecordsByIdsRpcRequest { | ||
| 750 | + repeated int32 ids = 1; | ||
| 751 | + int32 enterpriseId = 2; | ||
| 752 | + bool includeDeleted = 3; | ||
| 753 | +} | ||
| 754 | + | ||
| 755 | +message GetMealMenuRecordsByIdsRpcResponse { | ||
| 756 | + repeated SingleMealMenuRecordRpcResponse responses = 1; | ||
| 757 | +} | ||
| 758 | + | ||
| 759 | +message QueryMealMenuRecordsByConditionRpcRequest { | ||
| 760 | + int32 enterpriseId = 1; | ||
| 761 | + bool shouldFilterClientIds = 2; | ||
| 762 | + repeated int32 clientIds = 3; | ||
| 763 | + bool shouldFilterName = 4; | ||
| 764 | + string name = 5; | ||
| 765 | + bool includeDeleted = 6; | ||
| 766 | +} | ||
| 767 | + | ||
| 768 | +message QueryMealMenuRecordsByConditionRpcResponse { | ||
| 769 | + repeated SingleMealMenuRecordRpcResponse responses = 1; | ||
| 770 | +} | ||
| 771 | + | ||
| 772 | +message MealMenuRecordCreation{ | ||
| 773 | + int32 clientId = 1; | ||
| 774 | + string name = 2; | ||
| 775 | + bool shouldCreateImageUrl = 3; | ||
| 776 | + string imageUrl = 4; | ||
| 777 | +} | ||
| 778 | + | ||
| 779 | +message CreateMealMenuRecordRpcRequest { | ||
| 780 | + MealMenuRecordCreation creation = 1; | ||
| 781 | + int32 enterpriseId = 2; | ||
| 782 | + int32 createdBy = 3; | ||
| 783 | + int32 creationSource = 4; | ||
| 784 | +} | ||
| 785 | + | ||
| 786 | +message CreateMealMenuRecordRpcResponse { | ||
| 787 | + int32 id = 1; | ||
| 788 | + bool isCreated = 2; | ||
| 789 | +} | ||
| 790 | + | ||
| 791 | +message QueryLatestMealMenuRecordsByClientIdsRpcRequest { | ||
| 792 | + int32 enterpriseId = 1; | ||
| 793 | + repeated int32 clientId = 2; | ||
| 794 | +} | ||
| 795 | + | ||
| 796 | +message QueryLatestMealMenuRecordsByClientIdsRpcResponse { | ||
| 797 | + repeated SingleMealMenuRecordRpcResponse responses = 1; | ||
| 798 | +} |
| ... | @@ -76,10 +76,10 @@ grpc.meizhongyihe-service.port=3040 | ... | @@ -76,10 +76,10 @@ grpc.meizhongyihe-service.port=3040 |
| 76 | miniprogram.appId=wx40ec496d73b58ec6 | 76 | miniprogram.appId=wx40ec496d73b58ec6 |
| 77 | miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3 | 77 | miniprogram.appSecret=5b309517bf918abf760b2195e91b99f3 |
| 78 | 78 | ||
| 79 | -business-config.hisCustomerQueryUrl = https://nutri.amcare.com.cn/v3/hiscustomers/current/query | 79 | +business-config.hisCustomerQueryUrl = http://localhost:8903/hiscustomers/current/query |
| 80 | -business-config.clientCustomerQueryUrl = https://nutri.amcare.com.cn/v3/clientcustomers/current/query | 80 | +business-config.clientCustomerQueryUrl = http://localhost:8903/clientcustomers/current/query |
| 81 | -business-config.payUrl = http://10.2.5.162:21051/API/Microapp/CreateOrder?appid={0} | 81 | +business-config.payUrl = http://36.110.128.86:21051/API/Microapp/CreateOrder?appid={0} |
| 82 | -business-config.payClientId = Order | 82 | +business-config.payClientId = Order00001 |
| 83 | business-config.cancelPayUrl = http://10.2.5.162:21051/frame/requestbase64 | 83 | business-config.cancelPayUrl = http://10.2.5.162:21051/frame/requestbase64 |
| 84 | business-config.refundSecurityKey = 0987654321 | 84 | business-config.refundSecurityKey = 0987654321 |
| 85 | 85 | ||
| ... | @@ -104,6 +104,12 @@ sa-token.sign.secret-key=4Jk2giMQw8D7lHJcU8fv8CXjSOhjp5Ee | ... | @@ -104,6 +104,12 @@ sa-token.sign.secret-key=4Jk2giMQw8D7lHJcU8fv8CXjSOhjp5Ee |
| 104 | ##\u65E5\u5FD7\u914D\u7F6E | 104 | ##\u65E5\u5FD7\u914D\u7F6E |
| 105 | logging.config=classpath:logback-spring.xml | 105 | logging.config=classpath:logback-spring.xml |
| 106 | 106 | ||
| 107 | +aliyun.oss.endPoint=oss-cn-shanghai.aliyuncs.com | ||
| 108 | +aliyun.oss.host=infoloop-public-qa.oss-cn-shanghai.aliyuncs.com | ||
| 109 | +aliyun.oss.accessKeyId=LTAIo9gcY5sjIZdN | ||
| 110 | +aliyun.oss.accessKeySecret=gOOkVY4Euj3MSbPyg1tZvPbZbUssj5 | ||
| 111 | +aliyun.oss.bucket=infoloop-public-qa | ||
| 112 | + | ||
| 107 | ##\u77ED\u4FE1\u914D\u7F6E | 113 | ##\u77ED\u4FE1\u914D\u7F6E |
| 108 | sms-config.accessKeyId= | 114 | sms-config.accessKeyId= |
| 109 | sms-config.accessKeySecret= | 115 | sms-config.accessKeySecret= | ... | ... |
| 1 | package com.infoloop.tianting; | 1 | package com.infoloop.tianting; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import org.junit.runner.RunWith; | 4 | +import org.junit.jupiter.api.Test; |
| 5 | +import org.junit.jupiter.api.extension.ExtendWith; | ||
| 5 | import org.springframework.boot.test.context.SpringBootTest; | 6 | import org.springframework.boot.test.context.SpringBootTest; |
| 6 | -import org.springframework.test.context.junit4.SpringRunner; | 7 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 7 | 8 | ||
| 8 | -@SpringBootTest(classes = App.class) | 9 | +@ExtendWith(SpringExtension.class) |
| 9 | -@RunWith(SpringRunner.class) | 10 | +@SpringBootTest |
| 10 | public class AppTest { | 11 | public class AppTest { |
| 11 | 12 | ||
| 13 | + @Test | ||
| 14 | + void testSomething() { | ||
| 15 | + System.out.println("test"); | ||
| 16 | + } | ||
| 12 | 17 | ||
| 13 | } | 18 | } | ... | ... |
-
Please register or login to post a comment