Showing
18 changed files
with
628 additions
and
49 deletions
| ... | @@ -4,6 +4,7 @@ import com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc; | ... | @@ -4,6 +4,7 @@ import com.infoloop.rpc.meizhongyiheservice.MeiZhongYiHeServiceRpcGrpc; |
| 4 | import com.infoloop.tianting.COperatorServiceProtoRpcGrpc; | 4 | import com.infoloop.tianting.COperatorServiceProtoRpcGrpc; |
| 5 | import com.infoloop.tianting.CategoriesServiceProtoRpcGrpc; | 5 | import com.infoloop.tianting.CategoriesServiceProtoRpcGrpc; |
| 6 | import com.infoloop.tianting.SkuServiceProtoRpcGrpc; | 6 | import com.infoloop.tianting.SkuServiceProtoRpcGrpc; |
| 7 | +import com.infoloop.tianting.WOperatorServiceProtoRpcGrpc; | ||
| 7 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServiceRpcGrpc; | 8 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderServiceRpcGrpc; |
| 8 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; | 9 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerServiceRpcGrpc; |
| 9 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; | 10 | import com.infoloop.tianting.clientinventoryservice.TiantingClientInventoryServiceRpcGrpc; |
| ... | @@ -59,6 +60,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.ORDER_SERVICE_RPC_U | ... | @@ -59,6 +60,9 @@ import static com.infoloop.tianting.constant.ConfigConstants.ORDER_SERVICE_RPC_U |
| 59 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_CHANNEL; | 60 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_CHANNEL; |
| 60 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_RPC_PORT; | 61 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_RPC_PORT; |
| 61 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_RPC_URL; | 62 | import static com.infoloop.tianting.constant.ConfigConstants.SKU_SERVICE_RPC_URL; |
| 63 | +import static com.infoloop.tianting.constant.ConfigConstants.WOPERATOR_SERVICE_CHANNEL; | ||
| 64 | +import static com.infoloop.tianting.constant.ConfigConstants.WOPERATOR_SERVICE_RPC_PORT; | ||
| 65 | +import static com.infoloop.tianting.constant.ConfigConstants.WOPERATOR_SERVICE_RPC_URL; | ||
| 62 | 66 | ||
| 63 | @Configuration | 67 | @Configuration |
| 64 | public class GrpcConfig { | 68 | public class GrpcConfig { |
| ... | @@ -235,6 +239,23 @@ public class GrpcConfig { | ... | @@ -235,6 +239,23 @@ public class GrpcConfig { |
| 235 | return COperatorServiceProtoRpcGrpc.newBlockingStub(channel); | 239 | return COperatorServiceProtoRpcGrpc.newBlockingStub(channel); |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 242 | + @Bean(WOPERATOR_SERVICE_CHANNEL) | ||
| 243 | + public ManagedChannel woperatorServiceChannel(@Value(WOPERATOR_SERVICE_RPC_URL) final String url, | ||
| 244 | + @Value(WOPERATOR_SERVICE_RPC_PORT) final int port, | ||
| 245 | + @Autowired final ClientInterceptor clientInterceptor) { | ||
| 246 | + return NettyChannelBuilder.forAddress(url, port) | ||
| 247 | + .idleTimeout(DEFAULT_TIMEOUT_DAYS, TimeUnit.DAYS) | ||
| 248 | + .intercept(clientInterceptor) | ||
| 249 | + .usePlaintext() | ||
| 250 | + .maxInboundMessageSize(Integer.MAX_VALUE) | ||
| 251 | + .build(); | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + @Bean | ||
| 255 | + public WOperatorServiceProtoRpcGrpc.WOperatorServiceProtoRpcBlockingStub woperatorServiceRpcBlockingStub(@Autowired @Qualifier(WOPERATOR_SERVICE_CHANNEL) final ManagedChannel channel) { | ||
| 256 | + return WOperatorServiceProtoRpcGrpc.newBlockingStub(channel); | ||
| 257 | + } | ||
| 258 | + | ||
| 238 | @Bean(MEIZHONGYIHE_SERVICE_CHANNEL) | 259 | @Bean(MEIZHONGYIHE_SERVICE_CHANNEL) |
| 239 | public ManagedChannel meiZhongYiHeServiceChannel(@Value(MEIZHONGYIHE_SERVICE_RPC_URL) final String url, | 260 | public ManagedChannel meiZhongYiHeServiceChannel(@Value(MEIZHONGYIHE_SERVICE_RPC_URL) final String url, |
| 240 | @Value(MEIZHONGYIHE_SERVICE_RPC_PORT) final int port, | 261 | @Value(MEIZHONGYIHE_SERVICE_RPC_PORT) final int port, | ... | ... |
| ... | @@ -64,6 +64,10 @@ public interface ConfigConstants { | ... | @@ -64,6 +64,10 @@ public interface ConfigConstants { |
| 64 | String OPERATOR_SERVICE_RPC_PORT = "${grpc.operator-service.port}"; | 64 | String OPERATOR_SERVICE_RPC_PORT = "${grpc.operator-service.port}"; |
| 65 | String OPERATOR_SERVICE_CHANNEL = "operator-service-channel"; | 65 | String OPERATOR_SERVICE_CHANNEL = "operator-service-channel"; |
| 66 | 66 | ||
| 67 | + String WOPERATOR_SERVICE_RPC_URL = "${grpc.woperator-service.url}"; | ||
| 68 | + String WOPERATOR_SERVICE_RPC_PORT = "${grpc.woperator-service.port}"; | ||
| 69 | + String WOPERATOR_SERVICE_CHANNEL = "woperator-service-channel"; | ||
| 70 | + | ||
| 67 | String MEIZHONGYIHE_SERVICE_RPC_URL = "${grpc.meizhongyihe-service.url}"; | 71 | String MEIZHONGYIHE_SERVICE_RPC_URL = "${grpc.meizhongyihe-service.url}"; |
| 68 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; | 72 | String MEIZHONGYIHE_SERVICE_RPC_PORT = "${grpc.meizhongyihe-service.port}"; |
| 69 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; | 73 | String MEIZHONGYIHE_SERVICE_CHANNEL = "meizhongyihe-service-channel"; | ... | ... |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import io.swagger.annotations.Api; | ||
| 5 | +import lombok.RequiredArgsConstructor; | ||
| 6 | +import lombok.extern.slf4j.Slf4j; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.validation.annotation.Validated; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +@Api(tags = "KDS") | ||
| 12 | +@ApiSupport(order = -1) | ||
| 13 | +@Slf4j | ||
| 14 | +@Validated | ||
| 15 | +@RestController | ||
| 16 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 17 | +public class KdsController { | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +} |
| 1 | +package com.infoloop.tianting.controller; | ||
| 2 | + | ||
| 3 | +import com.github.xiaoymin.knife4j.annotations.ApiSupport; | ||
| 4 | +import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | ||
| 5 | +import com.infoloop.tianting.service.SettlementService; | ||
| 6 | +import io.swagger.annotations.Api; | ||
| 7 | +import io.swagger.annotations.ApiOperation; | ||
| 8 | +import java.io.ByteArrayOutputStream; | ||
| 9 | +import javax.validation.Valid; | ||
| 10 | +import lombok.RequiredArgsConstructor; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.http.HttpHeaders; | ||
| 14 | +import org.springframework.http.HttpStatus; | ||
| 15 | +import org.springframework.http.MediaType; | ||
| 16 | +import org.springframework.http.ResponseEntity; | ||
| 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.RequestBody; | ||
| 21 | +import org.springframework.web.bind.annotation.ResponseStatus; | ||
| 22 | +import org.springframework.web.bind.annotation.RestController; | ||
| 23 | + | ||
| 24 | +@Api(tags = "结算") | ||
| 25 | +@ApiSupport(order = 0) | ||
| 26 | +@Slf4j | ||
| 27 | +@Validated | ||
| 28 | +@RestController | ||
| 29 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 30 | +public class SettlementController { | ||
| 31 | + private final SettlementService settlementService; | ||
| 32 | + | ||
| 33 | + @ApiOperation(value = "结算账单生成excel") | ||
| 34 | + @PostMapping("/settlement/generate-excel") | ||
| 35 | + @ResponseStatus(HttpStatus.OK) | ||
| 36 | + public ResponseEntity<byte[]> settlementGenerateExcel( | ||
| 37 | + @Valid @RequestBody SettlementRequestDto settlementRequestDto) { | ||
| 38 | + ByteArrayOutputStream outputStream = settlementService.generateOrderSettlementExcel( | ||
| 39 | + settlementRequestDto); | ||
| 40 | + HttpHeaders headers = new HttpHeaders(); | ||
| 41 | + headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | ||
| 42 | + headers.setContentDispositionFormData("attachment", "订单数据.xlsx"); | ||
| 43 | + | ||
| 44 | + return ResponseEntity.ok() | ||
| 45 | + .headers(headers) | ||
| 46 | + .body(outputStream.toByteArray()); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
| ... | @@ -24,6 +24,7 @@ public enum ErrorCodeEnum implements BaseEnum { | ... | @@ -24,6 +24,7 @@ public enum ErrorCodeEnum implements BaseEnum { |
| 24 | UPDATE_DATA_ERROR(406000002, "修改数据失败"), | 24 | UPDATE_DATA_ERROR(406000002, "修改数据失败"), |
| 25 | DELETE_DATA_ERROR(406000003, "删除数据失败"), | 25 | DELETE_DATA_ERROR(406000003, "删除数据失败"), |
| 26 | 26 | ||
| 27 | + GENERATE_EXCEL_ERROR(406000004, "生成excel失败"), | ||
| 27 | 28 | ||
| 28 | ; | 29 | ; |
| 29 | private final int code; | 30 | private final int code; | ... | ... |
| 1 | +package com.infoloop.tianting.model.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.models.auth.In; | ||
| 5 | +import java.util.List; | ||
| 6 | +import lombok.AllArgsConstructor; | ||
| 7 | +import lombok.Builder; | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.NoArgsConstructor; | ||
| 10 | + | ||
| 11 | +@Data | ||
| 12 | +@ApiModel(description = "kds DTO") | ||
| 13 | +public class KdsDTO { | ||
| 14 | + | ||
| 15 | + @Data | ||
| 16 | + @Builder | ||
| 17 | + @AllArgsConstructor | ||
| 18 | + @NoArgsConstructor | ||
| 19 | + @ApiModel(description = "KdsOrderDto") | ||
| 20 | + public static class KdsOrderDto { | ||
| 21 | + private Integer orderId; | ||
| 22 | + private Integer orderDetailId; | ||
| 23 | + private String tableCode; | ||
| 24 | + private Integer count; | ||
| 25 | + private String roomNo; | ||
| 26 | + private String remark; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Data | ||
| 30 | + @Builder | ||
| 31 | + @AllArgsConstructor | ||
| 32 | + @NoArgsConstructor | ||
| 33 | + @ApiModel(description = "KdsOrderSkuDto") | ||
| 34 | + public static class KdsOrderSkuDto { | ||
| 35 | + private String showName; | ||
| 36 | + private Integer totalCount; | ||
| 37 | + private List<KdsOrderDto> orderList; | ||
| 38 | + } | ||
| 39 | +} |
| ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.model.dto; | ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.model.dto; |
| 3 | import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType; | 3 | import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; | 4 | import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum; |
| 5 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; | 5 | import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum; |
| 6 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 6 | import com.infoloop.tianting.menuservice.CloseTimeTypeEnum; | 7 | import com.infoloop.tianting.menuservice.CloseTimeTypeEnum; |
| 7 | import com.infoloop.tianting.model.common.PageInfo; | 8 | import com.infoloop.tianting.model.common.PageInfo; |
| 8 | import io.swagger.annotations.ApiModel; | 9 | import io.swagger.annotations.ApiModel; |
| ... | @@ -481,8 +482,8 @@ public class OrderDbDTO { | ... | @@ -481,8 +482,8 @@ public class OrderDbDTO { |
| 481 | @ApiModelProperty(value = "是否删除;0:未删除,1:已删除") | 482 | @ApiModelProperty(value = "是否删除;0:未删除,1:已删除") |
| 482 | private Boolean isDeleted; | 483 | private Boolean isDeleted; |
| 483 | 484 | ||
| 484 | - @ApiModelProperty(value = "是否不出餐: 默认出餐=0; 不出餐=1") | 485 | + @ApiModelProperty(value = "出餐状态: 默认未出餐=1; 不出餐=2; 已出餐=3") |
| 485 | - private Boolean notServe; | 486 | + private ServeStatusEnum serveStatus; |
| 486 | 487 | ||
| 487 | @ApiModelProperty(value = "调整配料备注") | 488 | @ApiModelProperty(value = "调整配料备注") |
| 488 | private String adjustSkuRemark; | 489 | private String adjustSkuRemark; |
| ... | @@ -529,9 +530,6 @@ public class OrderDbDTO { | ... | @@ -529,9 +530,6 @@ public class OrderDbDTO { |
| 529 | @ApiModelProperty(value = "菜品价格,以分为单位") | 530 | @ApiModelProperty(value = "菜品价格,以分为单位") |
| 530 | private Integer price; | 531 | private Integer price; |
| 531 | 532 | ||
| 532 | - @ApiModelProperty(value = "是否不出餐: 默认出餐=0; 不出餐=1") | ||
| 533 | - private Boolean notServe; | ||
| 534 | - | ||
| 535 | @ApiModelProperty(value = "调整配料备注") | 533 | @ApiModelProperty(value = "调整配料备注") |
| 536 | private String adjustSkuRemark; | 534 | private String adjustSkuRemark; |
| 537 | } | 535 | } |
| ... | @@ -596,11 +594,11 @@ public class OrderDbDTO { | ... | @@ -596,11 +594,11 @@ public class OrderDbDTO { |
| 596 | @ApiModelProperty(value = "菜品详情,菜品主料、口味、能量、脂肪、蛋白质、碳水化合物、忌口、医嘱等") | 594 | @ApiModelProperty(value = "菜品详情,菜品主料、口味、能量、脂肪、蛋白质、碳水化合物、忌口、医嘱等") |
| 597 | private MealDetailDto mealDetailJson; | 595 | private MealDetailDto mealDetailJson; |
| 598 | 596 | ||
| 599 | - @ApiModelProperty(value = "需要修改不出餐") | 597 | + @ApiModelProperty(value = "需要修改出餐状态") |
| 600 | - private Boolean shouldUpdateNotServe; | 598 | + private Boolean shouldUpdateServeStatus; |
| 601 | 599 | ||
| 602 | - @ApiModelProperty(value = "是否不出餐: 默认出餐=0; 不出餐=1") | 600 | + @ApiModelProperty(value = "出餐状态: 默认未出餐=1; 不出餐=2; 已出餐=3") |
| 603 | - private Boolean notServe; | 601 | + private ServeStatusEnum serveStatus; |
| 604 | } | 602 | } |
| 605 | 603 | ||
| 606 | @Data | 604 | @Data | ... | ... |
| ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.model.dto; | ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.model.dto; |
| 3 | import com.infoloop.tianting.enums.LoginSourceEnum; | 3 | import com.infoloop.tianting.enums.LoginSourceEnum; |
| 4 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 5 | import lombok.Builder; | 5 | import lombok.Builder; |
| 6 | +import lombok.Builder.Default; | ||
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| 7 | 8 | ||
| 8 | @Data | 9 | @Data |
| ... | @@ -14,13 +15,26 @@ public class PermissionDTO { | ... | @@ -14,13 +15,26 @@ public class PermissionDTO { |
| 14 | @ApiModel(description = "Login DTO") | 15 | @ApiModel(description = "Login DTO") |
| 15 | public static class LoginDto { | 16 | public static class LoginDto { |
| 16 | private LoginSourceEnum loginSourceEnum; | 17 | private LoginSourceEnum loginSourceEnum; |
| 17 | - private boolean shouldLoginWithHisCustomerId; | 18 | + @Builder.Default |
| 18 | - private String hisCustomerId; | 19 | + private boolean shouldLoginWithHisCustomerId = false; |
| 19 | - private boolean shouldLoginWithOperatorPhone; | 20 | + @Builder.Default |
| 20 | - private String operatorPhone; | 21 | + private String hisCustomerId = ""; |
| 21 | - private boolean shouldLoginWithOpenCode; | 22 | + @Builder.Default |
| 22 | - private String openCode; | 23 | + private boolean shouldLoginWithOperatorPhone = false; |
| 23 | - private Integer enterpriseId; | 24 | + @Builder.Default |
| 25 | + private String operatorPhone = ""; | ||
| 26 | + @Builder.Default | ||
| 27 | + private boolean shouldLoginWithOpenCode = false; | ||
| 28 | + @Builder.Default | ||
| 29 | + private String openCode = ""; | ||
| 30 | + @Builder.Default | ||
| 31 | + private boolean shouldLoginWithKdsEmail = false; | ||
| 32 | + @Builder.Default | ||
| 33 | + private String kdsEmail = ""; | ||
| 34 | + @Builder.Default | ||
| 35 | + private String kdsPassword = ""; | ||
| 36 | + @Builder.Default | ||
| 37 | + private Integer enterpriseId = 0; | ||
| 24 | } | 38 | } |
| 25 | 39 | ||
| 26 | } | 40 | } | ... | ... |
| ... | @@ -23,6 +23,7 @@ import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; | ... | @@ -23,6 +23,7 @@ import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum; |
| 23 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcRequest; | 23 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcRequest; |
| 24 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcRequest; | 24 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcRequest; |
| 25 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcResponse; | 25 | import com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcResponse; |
| 26 | +import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; | ||
| 26 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 27 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 27 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 28 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 28 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; | 29 | import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; |
| ... | @@ -154,9 +155,9 @@ public class OrderServiceRpcClient { | ... | @@ -154,9 +155,9 @@ public class OrderServiceRpcClient { |
| 154 | 155 | ||
| 155 | } | 156 | } |
| 156 | 157 | ||
| 157 | - Boolean notServe = false; | 158 | + ServeStatusEnum serveStatus = ServeStatusEnum.UNKNOWN_SERVE_STATUS; |
| 158 | - if (d.getShouldUpdateNotServe()) { | 159 | + if (d.getShouldUpdateServeStatus()) { |
| 159 | - notServe = true; | 160 | + serveStatus = d.getServeStatus(); |
| 160 | } | 161 | } |
| 161 | Integer count = 0; | 162 | Integer count = 0; |
| 162 | if (d.getShouldUpdateCount()) { | 163 | if (d.getShouldUpdateCount()) { |
| ... | @@ -176,8 +177,8 @@ public class OrderServiceRpcClient { | ... | @@ -176,8 +177,8 @@ public class OrderServiceRpcClient { |
| 176 | .setSkuId(skuId) | 177 | .setSkuId(skuId) |
| 177 | .setShouldUpdateShowName(d.getShouldUpdateMenuDetailId()) | 178 | .setShouldUpdateShowName(d.getShouldUpdateMenuDetailId()) |
| 178 | .setShowName(showName) | 179 | .setShowName(showName) |
| 179 | - .setShouldUpdateNotServe(d.getShouldUpdateNotServe()) | 180 | + .setShouldUpdateServeStatus(d.getShouldUpdateServeStatus()) |
| 180 | - .setNotServe(notServe) | 181 | + .setServeStatus(serveStatus) |
| 181 | .setShouldUpdateMealDetailJson(d.getShouldUpdateMenuDetailId()) | 182 | .setShouldUpdateMealDetailJson(d.getShouldUpdateMenuDetailId()) |
| 182 | .setMealDetailJson(mealDetail) | 183 | .setMealDetailJson(mealDetail) |
| 183 | .build(); | 184 | .build(); |
| ... | @@ -221,10 +222,6 @@ public class OrderServiceRpcClient { | ... | @@ -221,10 +222,6 @@ public class OrderServiceRpcClient { |
| 221 | .addAllOrderIds(orderIds) | 222 | .addAllOrderIds(orderIds) |
| 222 | .build()).getResponsesList(); | 223 | .build()).getResponsesList(); |
| 223 | } | 224 | } |
| 224 | -// public GetOrdersByOpenIdRpcResponse queryOrdersByOpenId(Integer openId) { | ||
| 225 | -// return orderServiceRpcBlockingStub.getOrdersByCustomerId( | ||
| 226 | -// GetOrdersByOpenIdRpcRequest.newBuilder().setOpenId(openId).build()); | ||
| 227 | -// } | ||
| 228 | 225 | ||
| 229 | public CreateOrderResponse createOrder(CreateOrderDto createOrderDto) { | 226 | public CreateOrderResponse createOrder(CreateOrderDto createOrderDto) { |
| 230 | final var orderDetails = new ArrayList<ClientCustomerOrderDetailCreation>(); | 227 | final var orderDetails = new ArrayList<ClientCustomerOrderDetailCreation>(); |
| ... | @@ -254,7 +251,7 @@ public class OrderServiceRpcClient { | ... | @@ -254,7 +251,7 @@ public class OrderServiceRpcClient { |
| 254 | .setPrice(orderDetailDto.getPrice()) | 251 | .setPrice(orderDetailDto.getPrice()) |
| 255 | .setMealDetailJson(mealDetail) | 252 | .setMealDetailJson(mealDetail) |
| 256 | // .setAdjustSkuRemark(orderDetailDto.getAdjustSkuRemark()) | 253 | // .setAdjustSkuRemark(orderDetailDto.getAdjustSkuRemark()) |
| 257 | - .setNotServe(orderDetailDto.getNotServe()) | 254 | + .setServeStatus(ServeStatusEnum.SERVE_NOT_START) |
| 258 | .setShouldCreateAdjustSkuRemark(true) | 255 | .setShouldCreateAdjustSkuRemark(true) |
| 259 | .setShouldCreatePrice(true) | 256 | .setShouldCreatePrice(true) |
| 260 | .setShouldCreateMealDetailJson(true) | 257 | .setShouldCreateMealDetailJson(true) | ... | ... |
| 1 | +package com.infoloop.tianting.service.client; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.COperatorServiceProtoRpcGrpc; | ||
| 4 | +import com.infoloop.tianting.GetWOperatorByEmailRpcRequest; | ||
| 5 | +import com.infoloop.tianting.GetWOperatorByEmailRpcResponse; | ||
| 6 | +import com.infoloop.tianting.WOperatorServiceProtoRpcGrpc; | ||
| 7 | +import lombok.RequiredArgsConstructor; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | + | ||
| 11 | +@Service | ||
| 12 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 13 | +public class WOperatorServiceRpcClient { | ||
| 14 | + | ||
| 15 | + private final WOperatorServiceProtoRpcGrpc.WOperatorServiceProtoRpcBlockingStub | ||
| 16 | + wOperatorServiceProtoRpcBlockingStub; | ||
| 17 | + | ||
| 18 | + public GetWOperatorByEmailRpcResponse getWOperatorByEmail(String email) { | ||
| 19 | + final var request = GetWOperatorByEmailRpcRequest.newBuilder() | ||
| 20 | + .setEmail(email) | ||
| 21 | + .build(); | ||
| 22 | + return wOperatorServiceProtoRpcBlockingStub.getWOperatorByEmail(request); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | +} |
| 1 | +package com.infoloop.tianting.service.impl; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | ||
| 4 | +import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | ||
| 5 | +import com.infoloop.tianting.context.LoginContextHolder; | ||
| 6 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderDto; | ||
| 7 | +import com.infoloop.tianting.model.dto.KdsDTO.KdsOrderSkuDto; | ||
| 8 | +import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | ||
| 9 | +import com.infoloop.tianting.service.KdsService; | ||
| 10 | +import com.infoloop.tianting.service.client.MenuServiceRpcClient; | ||
| 11 | +import com.infoloop.tianting.service.client.OrderServiceRpcClient; | ||
| 12 | +import java.time.LocalDate; | ||
| 13 | +import java.time.LocalDateTime; | ||
| 14 | +import java.util.ArrayList; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.stream.Collectors; | ||
| 17 | +import lombok.RequiredArgsConstructor; | ||
| 18 | +import lombok.extern.slf4j.Slf4j; | ||
| 19 | +import org.apache.poi.hssf.record.DVALRecord; | ||
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 21 | +import org.springframework.stereotype.Service; | ||
| 22 | + | ||
| 23 | +@Slf4j | ||
| 24 | +@Service | ||
| 25 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 26 | +public class KdsServiceImpl implements KdsService { | ||
| 27 | + | ||
| 28 | + private final OrderServiceRpcClient orderServiceRpcClient; | ||
| 29 | + private final MenuServiceRpcClient menuServiceRpcClient; | ||
| 30 | + | ||
| 31 | + public void getOrderDetailBySku() { | ||
| 32 | + | ||
| 33 | + // 获取当日所有的订单 和 订单明细 | ||
| 34 | + LocalDate today = LocalDate.now(); | ||
| 35 | + LocalDateTime todayZero = today.atStartOfDay(); | ||
| 36 | + LocalDate tomorrow = today.plusDays(1); | ||
| 37 | + LocalDateTime tomorrowZero = tomorrow.atStartOfDay(); | ||
| 38 | + | ||
| 39 | + final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | ||
| 40 | + final var queryOrderDto = QueryOrderByConditionDto.builder() | ||
| 41 | + .enterpriseId(operatorLoginInfo.getEnterpriseId()) | ||
| 42 | + .shouldFilterCreatedAtTimeStart(true) | ||
| 43 | + .createdAtTimeStart(todayZero) | ||
| 44 | + .shouldFilterCreatedAtTimeEnd(true) | ||
| 45 | + .createdAtTimeEnd(tomorrowZero) | ||
| 46 | + .build(); | ||
| 47 | + final var orderList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); | ||
| 48 | + List<Integer> orderIds = orderList.stream() | ||
| 49 | + .map(SingleClientCustomerOrderRpcResponse::getId) | ||
| 50 | + .distinct() | ||
| 51 | + .collect(Collectors.toList()); | ||
| 52 | + final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | ||
| 53 | + | ||
| 54 | + //在所有的orderDetail里找出所有所有不同的menuDetailId,然后根据menuDetailId进行分类 | ||
| 55 | + final var menuDetailIds = orderDetailList.stream() | ||
| 56 | + .map(SingleClientCustomerOrderDetailRpcResponse::getMenuDetailId) | ||
| 57 | + .distinct() | ||
| 58 | + .collect(Collectors.toList()); | ||
| 59 | + List<KdsOrderSkuDto> kdsOrderSkuList = new ArrayList<>(); | ||
| 60 | + for (Integer menuDetailId: menuDetailIds) { | ||
| 61 | + // 找出该menuDetailId 的所有orderDetail | ||
| 62 | + final var curOrderDetails = orderDetailList.stream() | ||
| 63 | + .filter(d-> d.getMenuDetailId() == menuDetailId) | ||
| 64 | + .collect(Collectors.toList()); | ||
| 65 | + final var totalCount = curOrderDetails.stream() | ||
| 66 | + .mapToInt(SingleClientCustomerOrderDetailRpcResponse::getCount) | ||
| 67 | + .sum(); | ||
| 68 | + List<KdsOrderDto> kdsOrders = new ArrayList<>(); | ||
| 69 | + for(SingleClientCustomerOrderDetailRpcResponse detail: curOrderDetails) { | ||
| 70 | + final var order = orderList.stream() | ||
| 71 | + .filter(o -> o.getId() == detail.getOrderId()) | ||
| 72 | + .findFirst(); | ||
| 73 | + if (order.isEmpty()) { | ||
| 74 | + continue; | ||
| 75 | + } | ||
| 76 | + final var kdsOrder = KdsOrderDto.builder() | ||
| 77 | + .count(detail.getCount()) | ||
| 78 | + .orderDetailId(detail.getId()) | ||
| 79 | + .remark(order.get().getRemark()) | ||
| 80 | + .orderId(order.get().getId()) | ||
| 81 | + .roomNo(order.get().getRoomNo()) | ||
| 82 | + .tableCode(order.get().getTableCode()) | ||
| 83 | + .build(); | ||
| 84 | + kdsOrders.add(kdsOrder); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + final var kdsOrderSku = KdsOrderSkuDto.builder() | ||
| 88 | + .showName(curOrderDetails.get(0).getShowName()) | ||
| 89 | + .totalCount(totalCount) | ||
| 90 | + .orderList(kdsOrders) | ||
| 91 | + .build(); | ||
| 92 | + kdsOrderSkuList.add(kdsOrderSku); | ||
| 93 | + | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + | ||
| 102 | +} |
| ... | @@ -16,6 +16,7 @@ import com.infoloop.tianting.service.LoginService; | ... | @@ -16,6 +16,7 @@ import com.infoloop.tianting.service.LoginService; |
| 16 | import com.infoloop.tianting.service.WxMiniProgramService; | 16 | import com.infoloop.tianting.service.WxMiniProgramService; |
| 17 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; | 17 | import com.infoloop.tianting.service.client.ClientCustomerServiceRpcClient; |
| 18 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; | 18 | import com.infoloop.tianting.service.client.OperatorServiceRpcClient; |
| 19 | +import com.infoloop.tianting.service.client.WOperatorServiceRpcClient; | ||
| 19 | import com.infoloop.tianting.service.client.WxMiniProgramClient; | 20 | import com.infoloop.tianting.service.client.WxMiniProgramClient; |
| 20 | import lombok.RequiredArgsConstructor; | 21 | import lombok.RequiredArgsConstructor; |
| 21 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
| ... | @@ -30,55 +31,83 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -30,55 +31,83 @@ public class LoginServiceImpl implements LoginService { |
| 30 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; | 31 | private final ClientCustomerServiceRpcClient clientCustomerServiceRpcClient; |
| 31 | private final OperatorServiceRpcClient operatorServiceRpcClient; | 32 | private final OperatorServiceRpcClient operatorServiceRpcClient; |
| 32 | private final WxMiniProgramClient wxMiniProgramClient; | 33 | private final WxMiniProgramClient wxMiniProgramClient; |
| 34 | + private final WOperatorServiceRpcClient wOperatorServiceRpcClient; | ||
| 33 | 35 | ||
| 34 | @Override | 36 | @Override |
| 35 | public SaTokenInfo login(LoginDto loginDto) { | 37 | public SaTokenInfo login(LoginDto loginDto) { |
| 36 | if (loginDto.isShouldLoginWithOpenCode()) { | 38 | if (loginDto.isShouldLoginWithOpenCode()) { |
| 37 | final var wxUserOpenIdDto = wxMiniProgramClient.getUserOpenIdByCode(loginDto.getOpenCode()); | 39 | final var wxUserOpenIdDto = wxMiniProgramClient.getUserOpenIdByCode(loginDto.getOpenCode()); |
| 38 | - StpUtil.login(wxUserOpenIdDto.getOpenid(), SaLoginModel.create() | 40 | + StpUtil.login( |
| 41 | + wxUserOpenIdDto.getOpenid(), | ||
| 42 | + SaLoginModel.create() | ||
| 39 | .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) | 43 | .setExtra(CommonConstants.ENTERPRISE_ID, loginDto.getEnterpriseId()) |
| 40 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 44 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 41 | .build()); | 45 | .build()); |
| 42 | return StpUtil.getTokenInfo(); | 46 | return StpUtil.getTokenInfo(); |
| 43 | - } | 47 | + } else if (loginDto.isShouldLoginWithHisCustomerId()) { |
| 44 | - else if (loginDto.isShouldLoginWithHisCustomerId()){ | 48 | + var customer = |
| 45 | - var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId( | 49 | + clientCustomerServiceRpcClient |
| 46 | - loginDto.getHisCustomerId()).getResponse(); | 50 | + .getClientCustomerByHISCustomerId(loginDto.getHisCustomerId()) |
| 51 | + .getResponse(); | ||
| 47 | if (customer.getId() == 0) { | 52 | if (customer.getId() == 0) { |
| 48 | // 根据hisCustomerId拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户 | 53 | // 根据hisCustomerId拿不到用户的话再去根据合同号去his查一次,即认为是月子中心客户 |
| 49 | - customer = clientCustomerServiceRpcClient.getClientCustomerByContactNo(loginDto.getHisCustomerId()).getResponse(); | 54 | + customer = |
| 55 | + clientCustomerServiceRpcClient | ||
| 56 | + .getClientCustomerByContactNo(loginDto.getHisCustomerId()) | ||
| 57 | + .getResponse(); | ||
| 50 | if (customer.getId() == 0) { | 58 | if (customer.getId() == 0) { |
| 51 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | 59 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); |
| 52 | } else { | 60 | } else { |
| 53 | - var record = clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId( | 61 | + var record = |
| 62 | + clientCustomerServiceRpcClient.getClientCustomerHospitalRecordsByCustomerId( | ||
| 54 | customer.getEnterpriseId(), customer.getId()); | 63 | customer.getEnterpriseId(), customer.getId()); |
| 55 | - if (!record.hasResponse() || record.getResponse().getHospitalStatus() != | 64 | + if (!record.hasResponse() |
| 56 | - ClientCustomerHospitalRecordHospitalStatusEnum.CURRENT) { | 65 | + || record.getResponse().getHospitalStatus() |
| 57 | - throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | 66 | + != ClientCustomerHospitalRecordHospitalStatusEnum.CURRENT) { |
| 67 | + throw ClientEndExceptions.AuthenticationFailure.build( | ||
| 68 | + ErrorCodeEnum.UNAUTHORIZED.name()); | ||
| 58 | } | 69 | } |
| 59 | } | 70 | } |
| 60 | } else { | 71 | } else { |
| 61 | 72 | ||
| 62 | } | 73 | } |
| 63 | - StpUtil.login(customer.getId(), SaLoginModel.create() | 74 | + StpUtil.login( |
| 75 | + customer.getId(), | ||
| 76 | + SaLoginModel.create() | ||
| 64 | .setExtra(CommonConstants.ENTERPRISE_ID, customer.getEnterpriseId()) | 77 | .setExtra(CommonConstants.ENTERPRISE_ID, customer.getEnterpriseId()) |
| 65 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 78 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 66 | .build()); | 79 | .build()); |
| 67 | return StpUtil.getTokenInfo(); | 80 | return StpUtil.getTokenInfo(); |
| 81 | + } else if (loginDto.isShouldLoginWithOperatorPhone()) { | ||
| 82 | + final var operator = | ||
| 83 | + operatorServiceRpcClient.getCOperatorByMobileOrEmail(loginDto.getOperatorPhone()); | ||
| 84 | + if (operator.getId() == 0) { | ||
| 85 | + throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | ||
| 68 | } | 86 | } |
| 69 | - else { | 87 | + StpUtil.login( |
| 70 | - final var operator = operatorServiceRpcClient.getCOperatorByMobileOrEmail( | 88 | + operator.getId(), |
| 71 | - loginDto.getOperatorPhone()); | 89 | + SaLoginModel.create() |
| 90 | + .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId()) | ||
| 91 | + .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | ||
| 92 | + .build()); | ||
| 93 | + return StpUtil.getTokenInfo(); | ||
| 94 | + } else { | ||
| 95 | + final var operator = | ||
| 96 | + wOperatorServiceRpcClient.getWOperatorByEmail(loginDto.getKdsEmail()).getResponse(); | ||
| 72 | if (operator.getId() == 0) { | 97 | if (operator.getId() == 0) { |
| 73 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | 98 | throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); |
| 74 | } | 99 | } |
| 75 | - StpUtil.login(operator.getId(), SaLoginModel.create() | 100 | + if (!operator.getPassword().equals(loginDto.getKdsPassword())) { |
| 101 | + throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.VALIDATE_FAILED.name()); | ||
| 102 | + } | ||
| 103 | + StpUtil.login( | ||
| 104 | + operator.getId(), | ||
| 105 | + SaLoginModel.create() | ||
| 76 | .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId()) | 106 | .setExtra(CommonConstants.ENTERPRISE_ID, operator.getEnterpriseId()) |
| 77 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 107 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 78 | .build()); | 108 | .build()); |
| 79 | return StpUtil.getTokenInfo(); | 109 | return StpUtil.getTokenInfo(); |
| 80 | } | 110 | } |
| 81 | } | 111 | } |
| 82 | - | ||
| 83 | } | 112 | } |
| 84 | 113 | ... | ... |
| ... | @@ -167,7 +167,6 @@ public class OrderServiceImpl implements OrderService { | ... | @@ -167,7 +167,6 @@ public class OrderServiceImpl implements OrderService { |
| 167 | final var createOrderDetail = CreateOrderDetailDto | 167 | final var createOrderDetail = CreateOrderDetailDto |
| 168 | .builder() | 168 | .builder() |
| 169 | .count(orderDetail.getCount()) | 169 | .count(orderDetail.getCount()) |
| 170 | - .notServe(false) | ||
| 171 | .menuDetailId(orderDetail.getMenuDetailId()) | 170 | .menuDetailId(orderDetail.getMenuDetailId()) |
| 172 | .categoryId(optionalTargetMenuDetail.get().getCategoryId()) | 171 | .categoryId(optionalTargetMenuDetail.get().getCategoryId()) |
| 173 | .mealId(optionalTargetMenuDetail.get().getMealId()) | 172 | .mealId(optionalTargetMenuDetail.get().getMealId()) |
| ... | @@ -230,7 +229,7 @@ public class OrderServiceImpl implements OrderService { | ... | @@ -230,7 +229,7 @@ public class OrderServiceImpl implements OrderService { |
| 230 | .adjustSkuRemark(d.getAdjustSkuRemark()) | 229 | .adjustSkuRemark(d.getAdjustSkuRemark()) |
| 231 | .enterpriseId(d.getEnterpriseId()) | 230 | .enterpriseId(d.getEnterpriseId()) |
| 232 | .skuId(d.getSkuId()) | 231 | .skuId(d.getSkuId()) |
| 233 | - .notServe(d.getNotServe()) | 232 | + .serveStatus(d.getServeStatus()) |
| 234 | .creationSource(d.getCreationSource().getNumber()) | 233 | .creationSource(d.getCreationSource().getNumber()) |
| 235 | .createdBy(d.getCreatedBy()) | 234 | .createdBy(d.getCreatedBy()) |
| 236 | .createdAt(DateUtil.formatDate(d.getCreatedAt())) | 235 | .createdAt(DateUtil.formatDate(d.getCreatedAt())) |
| ... | @@ -302,7 +301,7 @@ public class OrderServiceImpl implements OrderService { | ... | @@ -302,7 +301,7 @@ public class OrderServiceImpl implements OrderService { |
| 302 | .adjustSkuRemark(d.getAdjustSkuRemark()) | 301 | .adjustSkuRemark(d.getAdjustSkuRemark()) |
| 303 | .enterpriseId(d.getEnterpriseId()) | 302 | .enterpriseId(d.getEnterpriseId()) |
| 304 | .skuId(d.getSkuId()) | 303 | .skuId(d.getSkuId()) |
| 305 | - .notServe(d.getNotServe()) | 304 | + .s(d.getNotServe()) |
| 306 | .creationSource(d.getCreationSource().getNumber()) | 305 | .creationSource(d.getCreationSource().getNumber()) |
| 307 | .createdBy(d.getCreatedBy()) | 306 | .createdBy(d.getCreatedBy()) |
| 308 | .createdAt(DateUtil.formatDate(d.getCreatedAt())) | 307 | .createdAt(DateUtil.formatDate(d.getCreatedAt())) | ... | ... |
| ... | @@ -3,6 +3,8 @@ package com.infoloop.tianting.service.impl; | ... | @@ -3,6 +3,8 @@ package com.infoloop.tianting.service.impl; |
| 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; | 3 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; | 4 | import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse; |
| 5 | import com.infoloop.tianting.context.LoginContextHolder; | 5 | import com.infoloop.tianting.context.LoginContextHolder; |
| 6 | +import com.infoloop.tianting.exception.ClientEndExceptions.BusinessException; | ||
| 7 | +import com.infoloop.tianting.exception.ErrorCodeEnum; | ||
| 6 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; | 8 | import com.infoloop.tianting.menuservice.SingleMenuDetailRpcResponse; |
| 7 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; | 9 | import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; |
| 8 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | 10 | import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; |
| ... | @@ -14,6 +16,8 @@ import com.infoloop.tianting.service.client.MenuServiceRpcClient; | ... | @@ -14,6 +16,8 @@ import com.infoloop.tianting.service.client.MenuServiceRpcClient; |
| 14 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.OrderServiceRpcClient; |
| 15 | import com.infoloop.tianting.utils.DateUtil; | 17 | import com.infoloop.tianting.utils.DateUtil; |
| 16 | import java.io.ByteArrayOutputStream; | 18 | import java.io.ByteArrayOutputStream; |
| 19 | +import java.io.FileOutputStream; | ||
| 20 | +import java.io.IOException; | ||
| 17 | import java.time.format.DateTimeFormatter; | 21 | import java.time.format.DateTimeFormatter; |
| 18 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 19 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| ... | @@ -22,6 +26,12 @@ import java.util.Map; | ... | @@ -22,6 +26,12 @@ import java.util.Map; |
| 22 | import java.util.stream.Collectors; | 26 | import java.util.stream.Collectors; |
| 23 | import lombok.RequiredArgsConstructor; | 27 | import lombok.RequiredArgsConstructor; |
| 24 | import lombok.extern.slf4j.Slf4j; | 28 | import lombok.extern.slf4j.Slf4j; |
| 29 | +import org.apache.poi.ss.usermodel.Cell; | ||
| 30 | +import org.apache.poi.ss.usermodel.Row; | ||
| 31 | +import org.apache.poi.ss.usermodel.Sheet; | ||
| 32 | +import org.apache.poi.ss.usermodel.Workbook; | ||
| 33 | +import org.apache.poi.ss.util.CellRangeAddress; | ||
| 34 | +import org.apache.poi.xssf.usermodel.XSSFWorkbook; | ||
| 25 | import org.springframework.beans.factory.annotation.Autowired; | 35 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | import org.springframework.stereotype.Service; | 36 | import org.springframework.stereotype.Service; |
| 27 | 37 | ||
| ... | @@ -122,6 +132,79 @@ public class SettlementServiceImpl implements SettlementService { | ... | @@ -122,6 +132,79 @@ public class SettlementServiceImpl implements SettlementService { |
| 122 | 132 | ||
| 123 | } | 133 | } |
| 124 | } | 134 | } |
| 135 | + | ||
| 136 | + try { | ||
| 137 | + final var bytes = writeToExcel(classifyOrders); | ||
| 138 | + return bytes; | ||
| 139 | + } catch (IOException e) { | ||
| 140 | + throw BusinessException.build(ErrorCodeEnum.GENERATE_EXCEL_ERROR); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public static ByteArrayOutputStream writeToExcel(Map<String, Map<Integer, List<SettlementMenuSkuDto>>> classifyOrders) | ||
| 146 | + throws IOException { | ||
| 147 | + Workbook workbook = new XSSFWorkbook(); | ||
| 148 | + Sheet sheet = workbook.createSheet("订单数据"); | ||
| 149 | + | ||
| 150 | + int rowNum = 0; | ||
| 151 | + for (Map.Entry<String, Map<Integer, List<SettlementMenuSkuDto>>> outerEntry : classifyOrders.entrySet()) { | ||
| 152 | + String orderDate = outerEntry.getKey(); | ||
| 153 | + Map<Integer, List<SettlementMenuSkuDto>> innerMap = outerEntry.getValue(); | ||
| 154 | + | ||
| 155 | + // 写入日期列并合并单元格 | ||
| 156 | + int startRowForDate = rowNum; | ||
| 157 | + for (int i = 0; i < innerMap.size() * 2; i++) { | ||
| 158 | + Row dateRow = sheet.createRow(rowNum++); | ||
| 159 | + Cell dateCell = dateRow.createCell(0); | ||
| 160 | + dateCell.setCellValue(orderDate); | ||
| 161 | + } | ||
| 162 | + int endRowForDate = rowNum - 1; | ||
| 163 | + if (endRowForDate >= startRowForDate) { | ||
| 164 | + CellRangeAddress region = new CellRangeAddress(startRowForDate, endRowForDate, 0, 0); | ||
| 165 | + sheet.addMergedRegion(region); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + for (Map.Entry<Integer, List<SettlementMenuSkuDto>> innerEntry : innerMap.entrySet()) { | ||
| 169 | + int menuId = innerEntry.getKey(); | ||
| 170 | + List<SettlementMenuSkuDto> skuList = innerEntry.getValue(); | ||
| 171 | + | ||
| 172 | + // 写入菜单ID列并合并单元格 | ||
| 173 | + int startRowForMenu = rowNum; | ||
| 174 | + for (int i = 0; i < skuList.size(); i++) { | ||
| 175 | + Row menuRow = sheet.createRow(rowNum++); | ||
| 176 | + Cell menuCell = menuRow.createCell(1); | ||
| 177 | + menuCell.setCellValue(menuId); | ||
| 178 | + } | ||
| 179 | + int endRowForMenu = rowNum - 1; | ||
| 180 | + if (endRowForMenu >= startRowForMenu) { | ||
| 181 | + CellRangeAddress region = new CellRangeAddress(startRowForMenu, endRowForMenu, 1, 1); | ||
| 182 | + sheet.addMergedRegion(region); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + // 写入SKU列 | ||
| 186 | + for (SettlementMenuSkuDto skuDto : skuList) { | ||
| 187 | + Row skuRow = sheet.createRow(rowNum++); | ||
| 188 | + Cell skuCell = skuRow.createCell(2); | ||
| 189 | + skuCell.setCellValue(skuDto.getShowName()); | ||
| 190 | + skuCell.setCellValue(skuDto.getPrice()); | ||
| 191 | + skuCell.setCellValue(skuDto.getCount()); | ||
| 192 | + skuCell.setCellValue(skuDto.getTotalPrice()); | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + // 自动调整列宽 | ||
| 198 | + for (int i = 0; i < 6; i++) { | ||
| 199 | + sheet.autoSizeColumn(i); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + // 将工作簿内容写入字节数组输出流 | ||
| 203 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
| 204 | + workbook.write(outputStream); | ||
| 205 | + workbook.close(); | ||
| 206 | + | ||
| 207 | + return outputStream; | ||
| 125 | } | 208 | } |
| 126 | 209 | ||
| 127 | } | 210 | } | ... | ... |
| ... | @@ -72,6 +72,13 @@ enum CloseTimeType { | ... | @@ -72,6 +72,13 @@ enum CloseTimeType { |
| 72 | RESERVATION = 1; | 72 | RESERVATION = 1; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | +enum ServeStatusEnum { | ||
| 76 | + UNKNOWN_SERVE_STATUS = 0; | ||
| 77 | + SERVE_NOT_START = 1; | ||
| 78 | + SERVE_REJECT = 2; | ||
| 79 | + SERVE_FINISHED = 3; | ||
| 80 | +} | ||
| 81 | + | ||
| 75 | message CustomerNotice { | 82 | message CustomerNotice { |
| 76 | repeated string avoids = 1; | 83 | repeated string avoids = 1; |
| 77 | repeated string doctors = 2; | 84 | repeated string doctors = 2; |
| ... | @@ -403,7 +410,7 @@ message SingleClientCustomerOrderDetailRpcResponse { | ... | @@ -403,7 +410,7 @@ message SingleClientCustomerOrderDetailRpcResponse { |
| 403 | int64 updatedAt = 16; | 410 | int64 updatedAt = 16; |
| 404 | OrderSourceEnum updateSource = 17; | 411 | OrderSourceEnum updateSource = 17; |
| 405 | bool isDeleted = 18; | 412 | bool isDeleted = 18; |
| 406 | - bool notServe = 19; | 413 | + ServeStatusEnum serveStatus = 19; |
| 407 | int32 enterpriseId = 20; | 414 | int32 enterpriseId = 20; |
| 408 | } | 415 | } |
| 409 | 416 | ||
| ... | @@ -450,7 +457,7 @@ message ClientCustomerOrderDetailCreation{ | ... | @@ -450,7 +457,7 @@ message ClientCustomerOrderDetailCreation{ |
| 450 | int32 price = 13; | 457 | int32 price = 13; |
| 451 | bool shouldCreateAdjustSkuRemark = 14; | 458 | bool shouldCreateAdjustSkuRemark = 14; |
| 452 | string adjustSkuRemark = 15; | 459 | string adjustSkuRemark = 15; |
| 453 | - bool notServe = 16; | 460 | + ServeStatusEnum serveStatus= 16; |
| 454 | } | 461 | } |
| 455 | 462 | ||
| 456 | message CreateClientCustomerOrderDetailRpcRequest { | 463 | message CreateClientCustomerOrderDetailRpcRequest { |
| ... | @@ -497,8 +504,8 @@ message ClientCustomerOrderDetailModification { | ... | @@ -497,8 +504,8 @@ message ClientCustomerOrderDetailModification { |
| 497 | int32 price = 17; | 504 | int32 price = 17; |
| 498 | bool shouldUpdateAdjustSkuRemark = 18; | 505 | bool shouldUpdateAdjustSkuRemark = 18; |
| 499 | string adjustSkuRemark = 19; | 506 | string adjustSkuRemark = 19; |
| 500 | - bool shouldUpdateNotServe = 20; | 507 | + bool shouldUpdateServeStatus = 20; |
| 501 | - bool notServe = 21; | 508 | + ServeStatusEnum serveStatus = 21; |
| 502 | } | 509 | } |
| 503 | 510 | ||
| 504 | message UpdateClientCustomerOrderDetailRpcRequest { | 511 | message UpdateClientCustomerOrderDetailRpcRequest { | ... | ... |
| 1 | +syntax = "proto3"; | ||
| 2 | + | ||
| 3 | +option java_multiple_files = true; | ||
| 4 | +option java_package = "com.infoloop.tianting"; | ||
| 5 | +option java_outer_classname = "WOperatorsServiceProto"; | ||
| 6 | +option objc_class_prefix = "OP"; | ||
| 7 | + | ||
| 8 | +package com.infoloop.tianting; | ||
| 9 | + | ||
| 10 | +service WOperatorServiceProtoRpc { | ||
| 11 | + rpc GetWOperators(GetWOperatorsRpcRequest) returns (GetWOperatorsRpcResponse) {} | ||
| 12 | + rpc GetWOperatorById(GetWOperatorByIdRpcRequest) returns (GetWOperatorByIdRpcResponse) {} | ||
| 13 | + rpc GetWOperatorsByIds(GetWOperatorsByIdsRpcRequest) returns (GetWOperatorsByIdsRpcResponse) {} | ||
| 14 | + rpc SetWOperatorIsInfoloopOperatorById(SetWOperatorIsInfoloopOperatorByIdRpcRequest) returns (SetWOperatorIsInfoloopOperatorByIdRpcResponse) {} | ||
| 15 | + rpc BatchUpdateWOperatorPasswordByIds(BatchUpdateWOperatorPasswordByIdsRpcRequest) returns (BatchUpdateWOperatorPasswordByIdsRpcResponse) {} | ||
| 16 | + rpc GetWOperatorByEmail(GetWOperatorByEmailRpcRequest) returns (GetWOperatorByEmailRpcResponse) {} | ||
| 17 | + rpc GetOperatorByMobile(GetOperatorByMobileRpcRequest) returns (GetOperatorByMobileRpcResponse) {} | ||
| 18 | + rpc DeleteOperatorById(OperatorByIdDeleteRpcRequest) returns (OperatorByIdDeleteRpcResponse) {} | ||
| 19 | + rpc DeleteOperatorByAccount (OperatorByAccountDeleteRpcRequest) returns (OperatorByAccountDeleteRpcResponse) {} | ||
| 20 | + rpc CreateOperator (OperatorCreateRpcRequest) returns (OperatorCreateRpcResponse) {} | ||
| 21 | + rpc GetOperatorsByEnterpriseId (GetOperatorsByEnterpriseIdRpcRequest) returns (GetOperatorsByEnterpriseIdRpcResponse) {} | ||
| 22 | + rpc UpdateWOperatorStatusByIds (UpdateWOperatorStatusByIdsRpcRequest) returns (UpdateWOperatorStatusByIdsRpcResponse) {} | ||
| 23 | + rpc GetOperatorsByCondition (OperatorsGetByConditionRpcRequest) returns (OperatorsGetByConditionRpcResponse) {} | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +message UpdateWOperatorStatusByIdsRpcRequest { | ||
| 27 | + repeated int32 ids = 1; | ||
| 28 | + WOperatorStatus status = 2; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +message UpdateWOperatorStatusByIdsRpcResponse { | ||
| 32 | + bool isUpdated = 1; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +message GetOperatorsByEnterpriseIdRpcRequest { | ||
| 36 | + int32 enterpriseId = 1; | ||
| 37 | + bool includeDeleted = 2; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +message GetOperatorsByEnterpriseIdRpcResponse { | ||
| 41 | + repeated WOperatorResponse response = 1; | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +message OperatorCreateRpcRequest { | ||
| 45 | + int32 enterpriseId = 2; | ||
| 46 | + string code = 3; | ||
| 47 | + bool isEmailSet = 15; | ||
| 48 | + string email = 4; | ||
| 49 | + string name = 5; | ||
| 50 | + string password = 6; | ||
| 51 | + bool isMobileSet = 16; | ||
| 52 | + string mobile = 7; | ||
| 53 | + string note = 8; | ||
| 54 | + WOperatorStatus status = 9; | ||
| 55 | + string openId = 13; | ||
| 56 | + string telephone = 14; | ||
| 57 | +} | ||
| 58 | +message OperatorCreateRpcResponse { | ||
| 59 | + int32 id = 1; | ||
| 60 | + bool isCreated = 2; | ||
| 61 | + string errorMessage = 3; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +message OperatorByIdDeleteRpcRequest { | ||
| 65 | + int32 id = 1; | ||
| 66 | + int64 deletedAt = 2; | ||
| 67 | + int32 enterpriseId = 3; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +message OperatorByIdDeleteRpcResponse { | ||
| 71 | + bool isDeleted = 1; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +message OperatorByAccountDeleteRpcRequest { | ||
| 75 | + bool isEmailSet = 1; | ||
| 76 | + string email = 2; | ||
| 77 | + bool isMobileSet = 3; | ||
| 78 | + string mobile = 4; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +message OperatorByAccountDeleteRpcResponse { | ||
| 82 | + bool isDeleted = 1; | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +message GetOperatorByMobileRpcRequest { | ||
| 86 | + string mobile = 1; | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +message GetOperatorByMobileRpcResponse { | ||
| 90 | + WOperatorResponse response = 1; | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +message GetWOperatorsRpcRequest { | ||
| 94 | + bool includeDeleted = 1; | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +message GetWOperatorByIdRpcRequest { | ||
| 98 | + int32 id = 1; | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +message GetWOperatorsByIdsRpcRequest { | ||
| 102 | + repeated int32 ids = 1; | ||
| 103 | + bool includeDeleted = 2; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +message GetWOperatorByEmailRpcRequest { | ||
| 107 | + string email = 1; | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +message SetWOperatorIsInfoloopOperatorByIdRpcRequest { | ||
| 111 | + int32 id = 1; | ||
| 112 | + bool isInfoloopOperator = 2; | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +message BatchUpdateWOperatorPasswordByIdsRpcRequest { | ||
| 116 | + repeated SingleUpdateWOperator request = 1; | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +message SingleUpdateWOperator { | ||
| 120 | + int32 id = 1; | ||
| 121 | + string password = 2; | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +enum WOperatorStatus { | ||
| 125 | + UN_KNOW = 0; | ||
| 126 | + SHOW = 1; | ||
| 127 | + HIDE = 2; | ||
| 128 | + DELETED = 3; | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +message WOperatorResponse { | ||
| 132 | + int32 id = 1; | ||
| 133 | + int32 enterpriseId = 2; | ||
| 134 | + string code = 3; | ||
| 135 | + string email = 4; | ||
| 136 | + string name = 5; | ||
| 137 | + string password = 6; | ||
| 138 | + string mobile = 7; | ||
| 139 | + string note = 8; | ||
| 140 | + WOperatorStatus status = 9; | ||
| 141 | + int64 createdAt = 10; | ||
| 142 | + int64 updatedAt = 11; | ||
| 143 | + bool isSuper = 12; | ||
| 144 | + string openId = 13; | ||
| 145 | + string telephone = 14; | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +message GetWOperatorsRpcResponse { | ||
| 149 | + repeated WOperatorResponse responses = 1; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +message GetWOperatorByIdRpcResponse { | ||
| 153 | + WOperatorResponse response = 1; | ||
| 154 | +} | ||
| 155 | + | ||
| 156 | +message GetWOperatorsByIdsRpcResponse { | ||
| 157 | + repeated WOperatorResponse responses = 1; | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +message GetWOperatorByEmailRpcResponse { | ||
| 161 | + WOperatorResponse response = 1; | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +message SetWOperatorIsInfoloopOperatorByIdRpcResponse { | ||
| 165 | + | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +message BatchUpdateWOperatorPasswordByIdsRpcResponse { | ||
| 169 | + | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +message OperatorsGetByConditionRpcRequest { | ||
| 173 | + int32 enterpriseId = 1; | ||
| 174 | + bool includeDeleted = 2; | ||
| 175 | + bool shouldFilterNameKeyword = 3; | ||
| 176 | + string nameKeyword = 4; | ||
| 177 | +} | ||
| 178 | + | ||
| 179 | +message OperatorsGetByConditionRpcResponse { | ||
| 180 | + repeated WOperatorResponse responses = 1; | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | + |
| ... | @@ -64,6 +64,9 @@ grpc.delivery-service.port=3017 | ... | @@ -64,6 +64,9 @@ grpc.delivery-service.port=3017 |
| 64 | grpc.operator-service.url=47.101.193.136 | 64 | grpc.operator-service.url=47.101.193.136 |
| 65 | grpc.operator-service.port=3031 | 65 | grpc.operator-service.port=3031 |
| 66 | 66 | ||
| 67 | +grpc.woperator-service.url=47.101.193.136 | ||
| 68 | +grpc.woperator-service.port=3028 | ||
| 69 | + | ||
| 67 | grpc.meizhongyihe-service.url=47.101.193.136 | 70 | grpc.meizhongyihe-service.url=47.101.193.136 |
| 68 | grpc.meizhongyihe-service.port=3040 | 71 | grpc.meizhongyihe-service.port=3040 |
| 69 | 72 | ... | ... |
-
Please register or login to post a comment