Showing
23 changed files
with
325 additions
and
25 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
src/main/java/.DS_Store
0 → 100644
No preview for this file type
src/main/java/com/.DS_Store
0 → 100644
No preview for this file type
src/main/java/com/infoloop/.DS_Store
0 → 100644
No preview for this file type
No preview for this file type
| ... | @@ -5,6 +5,7 @@ import cn.dev33.satoken.stp.SaTokenInfo; | ... | @@ -5,6 +5,7 @@ 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.model.dto.ClientCustomerDbDTO.ClientCustomerDto; | 6 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto; |
| 7 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto; | 7 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto; |
| 8 | +import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.TodayOrderDto; | ||
| 8 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; | 9 | import com.infoloop.tianting.model.dto.PermissionDTO.LoginDto; |
| 9 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto; | 10 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto; |
| 10 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto; | 11 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserPhoneResponseDto; |
| ... | @@ -12,6 +13,7 @@ import com.infoloop.tianting.service.ClientCustomerService; | ... | @@ -12,6 +13,7 @@ import com.infoloop.tianting.service.ClientCustomerService; |
| 12 | import com.infoloop.tianting.service.LoginService; | 13 | import com.infoloop.tianting.service.LoginService; |
| 13 | import com.infoloop.tianting.service.WxMiniProgramService; | 14 | import com.infoloop.tianting.service.WxMiniProgramService; |
| 14 | import com.infoloop.tianting.service.client.ClientCustomerServiceHttpClient; | 15 | import com.infoloop.tianting.service.client.ClientCustomerServiceHttpClient; |
| 16 | +import io.lettuce.core.dynamic.annotation.Param; | ||
| 15 | import io.swagger.annotations.Api; | 17 | import io.swagger.annotations.Api; |
| 16 | import io.swagger.annotations.ApiOperation; | 18 | import io.swagger.annotations.ApiOperation; |
| 17 | import java.util.List; | 19 | import java.util.List; |
| ... | @@ -23,6 +25,7 @@ import org.springframework.http.HttpStatus; | ... | @@ -23,6 +25,7 @@ import org.springframework.http.HttpStatus; |
| 23 | import org.springframework.validation.annotation.Validated; | 25 | import org.springframework.validation.annotation.Validated; |
| 24 | import org.springframework.web.bind.annotation.GetMapping; | 26 | import org.springframework.web.bind.annotation.GetMapping; |
| 25 | import org.springframework.web.bind.annotation.PathVariable; | 27 | import org.springframework.web.bind.annotation.PathVariable; |
| 28 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 26 | import org.springframework.web.bind.annotation.ResponseStatus; | 29 | import org.springframework.web.bind.annotation.ResponseStatus; |
| 27 | import org.springframework.web.bind.annotation.RestController; | 30 | import org.springframework.web.bind.annotation.RestController; |
| 28 | 31 | ||
| ... | @@ -61,14 +64,17 @@ public class ClientCustomerController { | ... | @@ -61,14 +64,17 @@ public class ClientCustomerController { |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 63 | @ApiOperation(value = "获取今日在住") | 66 | @ApiOperation(value = "获取今日在住") |
| 64 | - @GetMapping("/clientCustomers/current") | 67 | + @GetMapping("/clientCustomers/today/statistic") |
| 65 | @ResponseStatus(HttpStatus.OK) | 68 | @ResponseStatus(HttpStatus.OK) |
| 66 | - public List<HospitalRecordDto> get(@PathVariable Integer enterpriseId, | 69 | + public TodayOrderDto getClientCustomerTodayOrderStatistic(@RequestParam String customerToken) { |
| 67 | - @PathVariable Integer customerId) { | 70 | + return clientCustomerService.getTodayOrderStatistic(customerToken, false); |
| 68 | - return clientCustomerService.getClientCustomerHospitalRecordsByCustomerId( | ||
| 69 | - enterpriseId, customerId); | ||
| 70 | } | 71 | } |
| 71 | 72 | ||
| 72 | - | 73 | + @ApiOperation(value = "获取his今日在住") |
| 74 | + @GetMapping("/hisClientCustomers/today/statistic") | ||
| 75 | + @ResponseStatus(HttpStatus.OK) | ||
| 76 | + public TodayOrderDto getHisClientCustomerTodayOrderStatistic(@RequestParam String customerToken) { | ||
| 77 | + return clientCustomerService.getTodayOrderStatistic(customerToken, true); | ||
| 78 | + } | ||
| 73 | 79 | ||
| 74 | } | 80 | } | ... | ... |
| 1 | +package com.infoloop.tianting.enums; | ||
| 2 | + | ||
| 3 | +import lombok.AllArgsConstructor; | ||
| 4 | +import lombok.Getter; | ||
| 5 | + | ||
| 6 | +@Getter | ||
| 7 | +@AllArgsConstructor | ||
| 8 | +public enum SettlementDimensionEnum { | ||
| 9 | + BY_SKU(1, "菜品"), | ||
| 10 | + BY_MEAL(2, "餐别"), | ||
| 11 | + ; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 汇总结账维度的值 | ||
| 15 | + */ | ||
| 16 | + private final Integer value; | ||
| 17 | + /** | ||
| 18 | + * 汇总结账维度的名字 | ||
| 19 | + */ | ||
| 20 | + private final String name; | ||
| 21 | +} |
| ... | @@ -2,9 +2,13 @@ package com.infoloop.tianting.model.dto; | ... | @@ -2,9 +2,13 @@ package com.infoloop.tianting.model.dto; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; | 3 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerHospitalRecordHospitalStatusEnum; |
| 4 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerSexEnum; | 4 | import com.infoloop.tianting.clientcustomerservice.ClientCustomerSexEnum; |
| 5 | +import com.infoloop.tianting.model.dto.MenuDbDTO.MenuDto; | ||
| 5 | import io.swagger.annotations.ApiModel; | 6 | import io.swagger.annotations.ApiModel; |
| 7 | +import java.util.List; | ||
| 8 | +import lombok.AllArgsConstructor; | ||
| 6 | import lombok.Builder; | 9 | import lombok.Builder; |
| 7 | import lombok.Data; | 10 | import lombok.Data; |
| 11 | +import lombok.NoArgsConstructor; | ||
| 8 | 12 | ||
| 9 | @Data | 13 | @Data |
| 10 | @ApiModel(description = "ClientCustomerDTO") | 14 | @ApiModel(description = "ClientCustomerDTO") |
| ... | @@ -68,8 +72,10 @@ public class ClientCustomerDbDTO { | ... | @@ -68,8 +72,10 @@ public class ClientCustomerDbDTO { |
| 68 | @Data | 72 | @Data |
| 69 | @Builder | 73 | @Builder |
| 70 | @ApiModel(description = "CurrentClientCustomerDto") | 74 | @ApiModel(description = "CurrentClientCustomerDto") |
| 75 | + @AllArgsConstructor | ||
| 76 | + @NoArgsConstructor | ||
| 71 | public static class CurrentClientCustomerDto { | 77 | public static class CurrentClientCustomerDto { |
| 72 | - private Integer id; | 78 | + private String id; |
| 73 | private Integer clientId; | 79 | private Integer clientId; |
| 74 | private String clientName; | 80 | private String clientName; |
| 75 | private String stallName; | 81 | private String stallName; |
| ... | @@ -77,20 +83,34 @@ public class ClientCustomerDbDTO { | ... | @@ -77,20 +83,34 @@ public class ClientCustomerDbDTO { |
| 77 | private String sex; | 83 | private String sex; |
| 78 | private Integer age; | 84 | private Integer age; |
| 79 | private Integer stallId; | 85 | private Integer stallId; |
| 86 | + private String roomNo; | ||
| 80 | } | 87 | } |
| 81 | 88 | ||
| 82 | @Data | 89 | @Data |
| 83 | @Builder | 90 | @Builder |
| 84 | - @ApiModel(description = "CurrentHisClientCustomerDto") | 91 | + @ApiModel(description = "CurrentClientCustomerListDto") |
| 85 | - public static class CurrentHisClientCustomerDto { | 92 | + @AllArgsConstructor |
| 93 | + @NoArgsConstructor | ||
| 94 | + public static class CurrentClientCustomerListDto { | ||
| 95 | + private List<CurrentClientCustomerDto> rows; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @Data | ||
| 99 | + @Builder | ||
| 100 | + @ApiModel(description = "TodayOrderDto") | ||
| 101 | + public static class NotOrderCustomerDto { | ||
| 86 | private Integer id; | 102 | private Integer id; |
| 87 | - private Integer clientId; | 103 | + private String roomNo; |
| 88 | - private String clientName; | ||
| 89 | - private String stallName; | ||
| 90 | private String name; | 104 | private String name; |
| 91 | - private String sex; | 105 | + private List<MenuDto> menuList; |
| 92 | - private Integer age; | 106 | + } |
| 93 | - private Integer stallId; | 107 | + |
| 108 | + @Data | ||
| 109 | + @Builder | ||
| 110 | + @ApiModel(description = "TodayOrderDto") | ||
| 111 | + public static class TodayOrderDto { | ||
| 112 | + private Integer totalCurrentCustomerCount; | ||
| 113 | + private List<NotOrderCustomerDto> notOrderCustomers; | ||
| 94 | } | 114 | } |
| 95 | 115 | ||
| 96 | 116 | ... | ... |
| ... | @@ -9,12 +9,14 @@ import io.swagger.annotations.ApiModel; | ... | @@ -9,12 +9,14 @@ import io.swagger.annotations.ApiModel; |
| 9 | import io.swagger.annotations.ApiModelProperty; | 9 | import io.swagger.annotations.ApiModelProperty; |
| 10 | import io.swagger.models.auth.In; | 10 | import io.swagger.models.auth.In; |
| 11 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
| 12 | +import java.util.ArrayList; | ||
| 12 | import java.util.List; | 13 | import java.util.List; |
| 13 | import java.util.Optional; | 14 | import java.util.Optional; |
| 14 | import javax.validation.Valid; | 15 | import javax.validation.Valid; |
| 15 | import jdk.jfr.StackTrace; | 16 | import jdk.jfr.StackTrace; |
| 16 | import lombok.AllArgsConstructor; | 17 | import lombok.AllArgsConstructor; |
| 17 | import lombok.Builder; | 18 | import lombok.Builder; |
| 19 | +import lombok.Builder.Default; | ||
| 18 | import lombok.Data; | 20 | import lombok.Data; |
| 19 | import lombok.NoArgsConstructor; | 21 | import lombok.NoArgsConstructor; |
| 20 | import lombok.ToString; | 22 | import lombok.ToString; |
| ... | @@ -63,8 +65,30 @@ public class OrderDbDTO { | ... | @@ -63,8 +65,30 @@ public class OrderDbDTO { |
| 63 | @ApiModel(description = "查询订单Dto") | 65 | @ApiModel(description = "查询订单Dto") |
| 64 | public static class QueryOrderByConditionDto { | 66 | public static class QueryOrderByConditionDto { |
| 65 | private Integer enterpriseId; | 67 | private Integer enterpriseId; |
| 66 | - private Boolean shouldFilterOpenId; | 68 | + @Builder.Default |
| 67 | - private String openId; | 69 | + private Boolean shouldFilterOpenId = false; |
| 70 | + @Builder.Default | ||
| 71 | + private String openId = ""; | ||
| 72 | + @Builder.Default | ||
| 73 | + private Boolean shouldFilterCustomerIds = false; | ||
| 74 | + @Builder.Default | ||
| 75 | + private List<Integer> customerIds = new ArrayList<>(); | ||
| 76 | + @Builder.Default | ||
| 77 | + private Boolean shouldFilterMealTimeStart = false; | ||
| 78 | + @Builder.Default | ||
| 79 | + private LocalDateTime mealTimeStart = LocalDateTime.now(); | ||
| 80 | + @Builder.Default | ||
| 81 | + private Boolean shouldFilterMealTimeEnd = false; | ||
| 82 | + @Builder.Default | ||
| 83 | + private LocalDateTime mealTimeEnd = LocalDateTime.now(); | ||
| 84 | + @Builder.Default | ||
| 85 | + private Boolean shouldFilterCreatedAtTimeStart = false; | ||
| 86 | + @Builder.Default | ||
| 87 | + private LocalDateTime createdAtTimeStart = LocalDateTime.now(); | ||
| 88 | + @Builder.Default | ||
| 89 | + private Boolean shouldFilterCreatedAtTimeEnd = false; | ||
| 90 | + @Builder.Default | ||
| 91 | + private LocalDateTime createdAtTimeEnd = LocalDateTime.now(); | ||
| 68 | } | 92 | } |
| 69 | 93 | ||
| 70 | @Data | 94 | @Data | ... | ... |
| 1 | package com.infoloop.tianting.model.dto; | 1 | package com.infoloop.tianting.model.dto; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.enums.SettlementDimensionEnum; | ||
| 3 | import io.swagger.annotations.ApiModel; | 4 | import io.swagger.annotations.ApiModel; |
| 5 | +import java.time.LocalDateTime; | ||
| 4 | import lombok.Builder; | 6 | import lombok.Builder; |
| 5 | import lombok.Data; | 7 | import lombok.Data; |
| 6 | 8 | ||
| 7 | @Data | 9 | @Data |
| 8 | @ApiModel(description = "统计DTO") | 10 | @ApiModel(description = "统计DTO") |
| 9 | -public class StatisticDTO { | 11 | +public class SettlementDTO { |
| 10 | 12 | ||
| 11 | @Data | 13 | @Data |
| 12 | @Builder | 14 | @Builder |
| 13 | @ApiModel(description = "SettlementRequestDto") | 15 | @ApiModel(description = "SettlementRequestDto") |
| 14 | public static class SettlementRequestDto { | 16 | public static class SettlementRequestDto { |
| 15 | 17 | ||
| 16 | - private Integer id; | 18 | + private SettlementDimensionEnum dimension; |
| 17 | 19 | ||
| 18 | - private String name; | 20 | + private LocalDateTime timeStart; |
| 21 | + | ||
| 22 | + private LocalDateTime timeEnd; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + @Data | ||
| 26 | + @Builder | ||
| 27 | + @ApiModel(description = "SettlementRequestDto") | ||
| 28 | + public static class SettlementMenuSkuDto { | ||
| 29 | + | ||
| 30 | + private String showName; | ||
| 31 | + private Integer count; | ||
| 32 | + private Integer price; | ||
| 33 | + private Integer totalPrice; | ||
| 19 | } | 34 | } |
| 20 | } | 35 | } |
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
No preview for this file type
| ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service; | ... | @@ -2,6 +2,7 @@ package com.infoloop.tianting.service; |
| 2 | 2 | ||
| 3 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto; | 3 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto; |
| 4 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto; | 4 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto; |
| 5 | +import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.TodayOrderDto; | ||
| 5 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto; | 6 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefDto; |
| 6 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefResponseDto; | 7 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefResponseDto; |
| 7 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto; | 8 | import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto; |
| ... | @@ -27,4 +28,6 @@ public interface ClientCustomerService { | ... | @@ -27,4 +28,6 @@ public interface ClientCustomerService { |
| 27 | BatchDeleteCustomerLabelRefResponseDto deleteClientCustomerLabelRefsByIds( | 28 | BatchDeleteCustomerLabelRefResponseDto deleteClientCustomerLabelRefsByIds( |
| 28 | BatchDeleteCustomerLabelRefRequestDto deleteRequestDto); | 29 | BatchDeleteCustomerLabelRefRequestDto deleteRequestDto); |
| 29 | 30 | ||
| 31 | + TodayOrderDto getTodayOrderStatistic(String token, boolean isHis); | ||
| 32 | + | ||
| 30 | } | 33 | } | ... | ... |
| 1 | +package com.infoloop.tianting.service; | ||
| 2 | + | ||
| 3 | +import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | ||
| 4 | +import java.io.ByteArrayOutputStream; | ||
| 5 | + | ||
| 6 | +public interface SettlementService { | ||
| 7 | + ByteArrayOutputStream generateOrderSettlementExcel(SettlementRequestDto settlementRequest); | ||
| 8 | +} |
| ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service.client; | ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service.client; |
| 3 | import com.fasterxml.jackson.databind.DeserializationFeature; | 3 | import com.fasterxml.jackson.databind.DeserializationFeature; |
| 4 | import com.fasterxml.jackson.databind.ObjectMapper; | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 5 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto; | 5 | import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerDto; |
| 6 | +import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.CurrentClientCustomerListDto; | ||
| 6 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto; | 7 | import com.infoloop.tianting.model.dto.WxUserDto.WxUserOpenIdDto; |
| 7 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
| 8 | import java.util.List; | 9 | import java.util.List; |
| ... | @@ -18,12 +19,19 @@ import org.springframework.stereotype.Service; | ... | @@ -18,12 +19,19 @@ import org.springframework.stereotype.Service; |
| 18 | public class ClientCustomerServiceHttpClient { | 19 | public class ClientCustomerServiceHttpClient { |
| 19 | private final OkHttpClient client = new OkHttpClient(); | 20 | private final OkHttpClient client = new OkHttpClient(); |
| 20 | 21 | ||
| 21 | - public List<CurrentClientCustomerDto> getCurrentClientCustomer() { | 22 | + public List<CurrentClientCustomerDto> getCurrentClientCustomer(String token, boolean isHis) { |
| 22 | ObjectMapper objectMapper = new ObjectMapper(); | 23 | ObjectMapper objectMapper = new ObjectMapper(); |
| 23 | try { | 24 | try { |
| 24 | - String url = "http://47.101.193.136:3031/clientcustomers/current/query"; | 25 | + String url = ""; |
| 26 | + if (isHis) { | ||
| 27 | + url = "https://nutri2.infoscm.cn/v3/hisClientcustomers/current/query"; | ||
| 28 | + } else { | ||
| 29 | + url = "https://nutri2.infoscm.cn/v3/clientcustomers/current/query"; | ||
| 30 | + } | ||
| 31 | + | ||
| 25 | Request request = new Request.Builder() | 32 | Request request = new Request.Builder() |
| 26 | .url(url) | 33 | .url(url) |
| 34 | + .addHeader("Authorization", token) | ||
| 27 | .build(); | 35 | .build(); |
| 28 | 36 | ||
| 29 | Response response = client.newCall(request).execute(); | 37 | Response response = client.newCall(request).execute(); |
| ... | @@ -31,11 +39,10 @@ public class ClientCustomerServiceHttpClient { | ... | @@ -31,11 +39,10 @@ public class ClientCustomerServiceHttpClient { |
| 31 | String jsonData = response.body().string(); | 39 | String jsonData = response.body().string(); |
| 32 | System.out.println(jsonData); | 40 | System.out.println(jsonData); |
| 33 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | 41 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
| 34 | -// return objectMapper.readValue(jsonData, WxUserOpenIdDto.class); | 42 | + return objectMapper.readValue(jsonData, CurrentClientCustomerListDto.class).getRows(); |
| 35 | - return new ArrayList<>(); | ||
| 36 | } catch (Exception e) { | 43 | } catch (Exception e) { |
| 37 | System.out.println("error"+e.getMessage()); | 44 | System.out.println("error"+e.getMessage()); |
| 38 | throw new IllegalArgumentException("获取用户openid失败"); | 45 | throw new IllegalArgumentException("获取用户openid失败"); |
| 39 | } | 46 | } |
| 40 | } | 47 | } |
| 41 | -} | 48 | +} |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -16,6 +16,8 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcR | ... | @@ -16,6 +16,8 @@ import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcR |
| 16 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcResponse; | 16 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByMobileRpcResponse; |
| 17 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcRequest; | 17 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcRequest; |
| 18 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcResponse; | 18 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomerHospitalRecordByCustomerIdRpcResponse; |
| 19 | +import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByHISCustomerIdsRpcRequest; | ||
| 20 | +import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByHISCustomerIdsRpcResponse; | ||
| 19 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcRequest; | 21 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcRequest; |
| 20 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse; | 22 | import com.infoloop.tianting.clientcustomerservice.GetClientCustomersByIdsRpcResponse; |
| 21 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest; | 23 | import com.infoloop.tianting.clientcustomerservice.QueryClientCustomerLabelRefsByConditionRpcRequest; |
| ... | @@ -45,6 +47,15 @@ public class ClientCustomerServiceRpcClient { | ... | @@ -45,6 +47,15 @@ public class ClientCustomerServiceRpcClient { |
| 45 | return clientCustomerServiceRpcBlockingStub.getClientCustomerByHISCustomerId(request); | 47 | return clientCustomerServiceRpcBlockingStub.getClientCustomerByHISCustomerId(request); |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 50 | + public GetClientCustomersByHISCustomerIdsRpcResponse getClientCustomersByHISCustomerIds( | ||
| 51 | + List<String> hisCustomerIds | ||
| 52 | + ) { | ||
| 53 | + final var request = GetClientCustomersByHISCustomerIdsRpcRequest.newBuilder() | ||
| 54 | + .addAllHISCustomerIds(hisCustomerIds) | ||
| 55 | + .build(); | ||
| 56 | + return clientCustomerServiceRpcBlockingStub.getClientCustomersByHISCustomerIds(request); | ||
| 57 | + } | ||
| 58 | + | ||
| 48 | public GetClientCustomerByContactNoRpcResponse getClientCustomerByContactNo(String contractNo) { | 59 | public GetClientCustomerByContactNoRpcResponse getClientCustomerByContactNo(String contractNo) { |
| 49 | final var request = GetClientCustomerByContactNoRpcRequest.newBuilder() | 60 | final var request = GetClientCustomerByContactNoRpcRequest.newBuilder() |
| 50 | .setContractNo(contractNo).build(); | 61 | .setContractNo(contractNo).build(); | ... | ... |
| ... | @@ -5,12 +5,16 @@ import com.infoloop.tianting.menuservice.BatchCreateClientCustomerMenuRefsRpcRes | ... | @@ -5,12 +5,16 @@ import com.infoloop.tianting.menuservice.BatchCreateClientCustomerMenuRefsRpcRes |
| 5 | import com.infoloop.tianting.menuservice.ClientCustomerMenuRefCreation; | 5 | import com.infoloop.tianting.menuservice.ClientCustomerMenuRefCreation; |
| 6 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcRequest; | 6 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcRequest; |
| 7 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcResponse; | 7 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcResponse; |
| 8 | +import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdsRpcRequest; | ||
| 9 | +import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdsRpcResponse; | ||
| 8 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcRequest; | 10 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcRequest; |
| 9 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcResponse; | 11 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcResponse; |
| 10 | import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcRequest; | 12 | import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcRequest; |
| 11 | import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcResponse; | 13 | import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcResponse; |
| 12 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcRequest; | 14 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcRequest; |
| 13 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcResponse; | 15 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcResponse; |
| 16 | +import com.infoloop.tianting.menuservice.GetMenusByIdsRpcRequest; | ||
| 17 | +import com.infoloop.tianting.menuservice.GetMenusByIdsRpcResponse; | ||
| 14 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcRequest; | 18 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcRequest; |
| 15 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcResponse; | 19 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcResponse; |
| 16 | import com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcRequest; | 20 | import com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcRequest; |
| ... | @@ -60,6 +64,15 @@ public class MenuServiceRpcClient { | ... | @@ -60,6 +64,15 @@ public class MenuServiceRpcClient { |
| 60 | return menuServiceRpcBlockingStub.getMenuById(request); | 64 | return menuServiceRpcBlockingStub.getMenuById(request); |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 67 | + public GetMenusByIdsRpcResponse getMenusByIds(Integer enterpriseId, List<Integer> ids) { | ||
| 68 | + final var request = GetMenusByIdsRpcRequest.newBuilder() | ||
| 69 | + .setEnterpriseId(enterpriseId) | ||
| 70 | + .addAllIds(ids) | ||
| 71 | + .setIncludeDeleted(false) | ||
| 72 | + .build(); | ||
| 73 | + return menuServiceRpcBlockingStub.getMenusByIds(request); | ||
| 74 | + } | ||
| 75 | + | ||
| 63 | public GetMenuDetailByIdRpcResponse getMenuDetailById(Integer enterpriseId, Integer id) { | 76 | public GetMenuDetailByIdRpcResponse getMenuDetailById(Integer enterpriseId, Integer id) { |
| 64 | final var request = GetMenuDetailByIdRpcRequest.newBuilder() | 77 | final var request = GetMenuDetailByIdRpcRequest.newBuilder() |
| 65 | .setEnterpriseId(enterpriseId) | 78 | .setEnterpriseId(enterpriseId) |
| ... | @@ -79,6 +92,16 @@ public class MenuServiceRpcClient { | ... | @@ -79,6 +92,16 @@ public class MenuServiceRpcClient { |
| 79 | return menuServiceRpcBlockingStub.getMenuDetailsByMenuIds(request); | 92 | return menuServiceRpcBlockingStub.getMenuDetailsByMenuIds(request); |
| 80 | } | 93 | } |
| 81 | 94 | ||
| 95 | + public GetMenuDetailsByMenuIdsRpcResponse queryMenuDetailsByMenuIds( | ||
| 96 | + Integer enterpriseId, List<Integer> menuIds) { | ||
| 97 | + final var request = GetMenuDetailsByMenuIdsRpcRequest.newBuilder() | ||
| 98 | + .setEnterpriseId(enterpriseId) | ||
| 99 | + .addAllMenuIds(menuIds) | ||
| 100 | + .setIncludeDeleted(false) | ||
| 101 | + .build(); | ||
| 102 | + return menuServiceRpcBlockingStub.getMenuDetailsByMenuIds(request); | ||
| 103 | + } | ||
| 104 | + | ||
| 82 | public GetClientCustomerMenuRefsByCustomerIdRpcResponse getClientCustomerMenuRefsByCustomerId( | 105 | public GetClientCustomerMenuRefsByCustomerIdRpcResponse getClientCustomerMenuRefsByCustomerId( |
| 83 | Integer enterpriseId, Integer customerId | 106 | Integer enterpriseId, Integer customerId |
| 84 | ) { | 107 | ) { |
| ... | @@ -91,6 +114,18 @@ public class MenuServiceRpcClient { | ... | @@ -91,6 +114,18 @@ public class MenuServiceRpcClient { |
| 91 | 114 | ||
| 92 | } | 115 | } |
| 93 | 116 | ||
| 117 | + public GetClientCustomerMenuRefsByCustomerIdsRpcResponse getClientCustomerMenuRefsByCustomerIds( | ||
| 118 | + Integer enterpriseId, List<Integer> customerIds | ||
| 119 | + ) { | ||
| 120 | + | ||
| 121 | + final var request = GetClientCustomerMenuRefsByCustomerIdsRpcRequest.newBuilder() | ||
| 122 | + .setEnterpriseId(enterpriseId) | ||
| 123 | + .addAllCustomerIds(customerIds) | ||
| 124 | + .build(); | ||
| 125 | + return menuServiceRpcBlockingStub.getClientCustomerMenuRefsByCustomerIds(request); | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + | ||
| 94 | public BatchCreateClientCustomerMenuRefsRpcResponse batchCreateClientCustomerMenuRefs( | 129 | public BatchCreateClientCustomerMenuRefsRpcResponse batchCreateClientCustomerMenuRefs( |
| 95 | BatchCreateMenuRefsDto batchCreateMenuRefsDto) { | 130 | BatchCreateMenuRefsDto batchCreateMenuRefsDto) { |
| 96 | final var creations = batchCreateMenuRefsDto.getCreations().stream().map(mr-> | 131 | final var creations = batchCreateMenuRefsDto.getCreations().stream().map(mr-> | ... | ... |
| ... | @@ -64,6 +64,16 @@ public class OrderServiceRpcClient { | ... | @@ -64,6 +64,16 @@ public class OrderServiceRpcClient { |
| 64 | .setEnterpriseId(queryOrderDto.getEnterpriseId()) | 64 | .setEnterpriseId(queryOrderDto.getEnterpriseId()) |
| 65 | .setShouldFilterOpenIds(queryOrderDto.getShouldFilterOpenId()) | 65 | .setShouldFilterOpenIds(queryOrderDto.getShouldFilterOpenId()) |
| 66 | .addAllOpenIds(List.of(queryOrderDto.getOpenId())) | 66 | .addAllOpenIds(List.of(queryOrderDto.getOpenId())) |
| 67 | + .setShouldFilterCustomerIds(queryOrderDto.getShouldFilterCustomerIds()) | ||
| 68 | + .addAllCustomerIds(queryOrderDto.getCustomerIds()) | ||
| 69 | + .setShouldFilterMealTimeStart(queryOrderDto.getShouldFilterMealTimeStart()) | ||
| 70 | + .setMealTimeStart(queryOrderDto.getMealTimeStart().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 71 | + .setShouldFilterMealTimeEnd(queryOrderDto.getShouldFilterMealTimeEnd()) | ||
| 72 | + .setMealTimeEnd(queryOrderDto.getMealTimeEnd().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 73 | + .setShouldFilterCreatedAtStart(queryOrderDto.getShouldFilterCreatedAtTimeStart()) | ||
| 74 | + .setCreatedAtStart(queryOrderDto.getCreatedAtTimeStart().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 75 | + .setShouldFilterCreatedAtStart(queryOrderDto.getShouldFilterCreatedAtTimeEnd()) | ||
| 76 | + .setCreatedAtEnd(queryOrderDto.getCreatedAtTimeEnd().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 67 | .build(); | 77 | .build(); |
| 68 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); | 78 | return orderServiceRpcBlockingStub.queryClientCustomerOrdersByCondition(request).getResponsesList(); |
| 69 | } | 79 | } | ... | ... |
This diff is collapsed. Click to expand it.
| 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.menuservice.SingleMenuDetailRpcResponse; | ||
| 7 | +import com.infoloop.tianting.menuservice.SingleMenuRpcResponse; | ||
| 8 | +import com.infoloop.tianting.model.dto.OrderDbDTO.QueryOrderByConditionDto; | ||
| 9 | +import com.infoloop.tianting.model.dto.SettlementDTO.SettlementMenuSkuDto; | ||
| 10 | +import com.infoloop.tianting.model.dto.SettlementDTO.SettlementRequestDto; | ||
| 11 | +import com.infoloop.tianting.service.OrderService; | ||
| 12 | +import com.infoloop.tianting.service.SettlementService; | ||
| 13 | +import com.infoloop.tianting.service.client.MenuServiceRpcClient; | ||
| 14 | +import com.infoloop.tianting.service.client.OrderServiceRpcClient; | ||
| 15 | +import com.infoloop.tianting.utils.DateUtil; | ||
| 16 | +import java.io.ByteArrayOutputStream; | ||
| 17 | +import java.time.format.DateTimeFormatter; | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.List; | ||
| 21 | +import java.util.Map; | ||
| 22 | +import java.util.stream.Collectors; | ||
| 23 | +import lombok.RequiredArgsConstructor; | ||
| 24 | +import lombok.extern.slf4j.Slf4j; | ||
| 25 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 26 | +import org.springframework.stereotype.Service; | ||
| 27 | + | ||
| 28 | +@Slf4j | ||
| 29 | +@Service | ||
| 30 | +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) | ||
| 31 | +public class SettlementServiceImpl implements SettlementService { | ||
| 32 | + private final OrderServiceRpcClient orderServiceRpcClient; | ||
| 33 | + private final MenuServiceRpcClient menuServiceRpcClient; | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public ByteArrayOutputStream generateOrderSettlementExcel(SettlementRequestDto settlementRequest) { | ||
| 37 | + | ||
| 38 | + final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | ||
| 39 | + final var queryOrderDto = QueryOrderByConditionDto.builder() | ||
| 40 | + .enterpriseId(operatorLoginInfo.getEnterpriseId()) | ||
| 41 | + .shouldFilterCreatedAtTimeStart(true) | ||
| 42 | + .createdAtTimeStart(settlementRequest.getTimeStart()) | ||
| 43 | + .shouldFilterCreatedAtTimeEnd(true) | ||
| 44 | + .createdAtTimeEnd(settlementRequest.getTimeEnd()) | ||
| 45 | + .build(); | ||
| 46 | + final var orderList = orderServiceRpcClient.getOrdersByCondition(queryOrderDto); | ||
| 47 | + List<Integer> orderIds = orderList.stream().map( | ||
| 48 | + SingleClientCustomerOrderRpcResponse::getId).distinct() | ||
| 49 | + .collect(Collectors.toList()); | ||
| 50 | + final var orderDetailList = orderServiceRpcClient.getOrderDetailsByOrderIds(orderIds); | ||
| 51 | + | ||
| 52 | + List<Integer> menuIds = orderList.stream().map( | ||
| 53 | + SingleClientCustomerOrderRpcResponse::getMenuId).distinct() | ||
| 54 | + .collect(Collectors.toList()); | ||
| 55 | + final var menuList = menuServiceRpcClient.getMenusByIds(operatorLoginInfo.getEnterpriseId(), menuIds); | ||
| 56 | + final var menuDetailList = menuServiceRpcClient.queryMenuDetailsByMenuIds( | ||
| 57 | + operatorLoginInfo.getEnterpriseId(), menuIds).getResponsesList(); | ||
| 58 | + Map<String, Map<Integer, List<SettlementMenuSkuDto>>> classifyOrders = new HashMap<>(); | ||
| 59 | + | ||
| 60 | + //找出所有需要的日期 | ||
| 61 | + final var dates = orderList.stream() | ||
| 62 | + .map(o -> DateUtil.formatDate(o.getCreatedAt(), DateUtil.YYYY_MM_DD)) | ||
| 63 | + .collect(Collectors.toList()); | ||
| 64 | + for(String date: dates) { | ||
| 65 | + | ||
| 66 | + if (!classifyOrders.containsKey(date)) { | ||
| 67 | + classifyOrders.put(date, new HashMap<>()); | ||
| 68 | + } | ||
| 69 | + final var menusMap = classifyOrders.get(date); | ||
| 70 | + | ||
| 71 | + // 找出当天所有的订单 | ||
| 72 | + final var curOrderList = orderList.stream() | ||
| 73 | + .filter(o -> DateUtil.formatDate(o.getCreatedAt(), DateUtil.YYYY_MM_DD).equals(date)) | ||
| 74 | + .collect(Collectors.toList()); | ||
| 75 | + final var curOrderIds = curOrderList.stream() | ||
| 76 | + .map(SingleClientCustomerOrderRpcResponse::getId) | ||
| 77 | + .collect(Collectors.toList()); | ||
| 78 | + | ||
| 79 | + // 找出当天已点的所有餐单 | ||
| 80 | + final var curMenuIds = curOrderList.stream() | ||
| 81 | + .map(SingleClientCustomerOrderRpcResponse::getMenuId) | ||
| 82 | + .collect(Collectors.toList()); | ||
| 83 | + for (Integer curMenuId: curMenuIds) { | ||
| 84 | + if (!menusMap.containsKey(curMenuId)) { | ||
| 85 | + menusMap.put(curMenuId, new ArrayList<>()); | ||
| 86 | + } | ||
| 87 | + final var menuSkuList = new ArrayList<SettlementMenuSkuDto>(); | ||
| 88 | + // 找出当天餐单所有的菜品 | ||
| 89 | + final var curMenuDetails = menuDetailList.stream() | ||
| 90 | + .filter(md -> md.getMenuId() == curMenuId) | ||
| 91 | + .collect(Collectors.toList()); | ||
| 92 | + | ||
| 93 | + final var curMenuDetailIds = curMenuDetails.stream() | ||
| 94 | + .map(SingleMenuDetailRpcResponse::getId) | ||
| 95 | + .collect(Collectors.toList()); | ||
| 96 | + | ||
| 97 | + //找出当天所有已点的菜品明细 | ||
| 98 | + final var curOrderDetails = orderDetailList.stream() | ||
| 99 | + .filter(d -> curOrderIds.contains(d.getOrderId())) | ||
| 100 | + .collect(Collectors.toList()); | ||
| 101 | + | ||
| 102 | + for (SingleMenuDetailRpcResponse m: curMenuDetails) { | ||
| 103 | + // 找出该餐单下该sku所点菜品的明细 | ||
| 104 | + final var curSkuOrderDetails = curOrderDetails.stream() | ||
| 105 | + .filter(rd-> rd.getMenuDetailId() == m.getId()) | ||
| 106 | + .collect(Collectors.toList()); | ||
| 107 | + final var countList = curSkuOrderDetails.stream() | ||
| 108 | + .map(SingleClientCustomerOrderDetailRpcResponse::getCount) | ||
| 109 | + .collect(Collectors.toList()); | ||
| 110 | + int countTotal = countList.stream().mapToInt(Integer::intValue).sum(); | ||
| 111 | + final var settlementMenuSku = SettlementMenuSkuDto.builder() | ||
| 112 | + .count(countTotal) | ||
| 113 | + .showName(m.getShowName()) | ||
| 114 | + .price(m.getPrice()) | ||
| 115 | + .totalPrice(m.getPrice() * countTotal) | ||
| 116 | + .build(); | ||
| 117 | + menuSkuList.add(settlementMenuSku); | ||
| 118 | + | ||
| 119 | + } | ||
| 120 | + menusMap.get(curMenuId).addAll(menuSkuList); | ||
| 121 | + | ||
| 122 | + | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | +} |
| ... | @@ -46,6 +46,7 @@ service MenuServiceRpc { | ... | @@ -46,6 +46,7 @@ service MenuServiceRpc { |
| 46 | 46 | ||
| 47 | //餐单客户关联 | 47 | //餐单客户关联 |
| 48 | rpc GetClientCustomerMenuRefsByCustomerId (GetClientCustomerMenuRefsByCustomerIdRpcRequest) returns (GetClientCustomerMenuRefsByCustomerIdRpcResponse) {} | 48 | rpc GetClientCustomerMenuRefsByCustomerId (GetClientCustomerMenuRefsByCustomerIdRpcRequest) returns (GetClientCustomerMenuRefsByCustomerIdRpcResponse) {} |
| 49 | + rpc GetClientCustomerMenuRefsByCustomerIds (GetClientCustomerMenuRefsByCustomerIdsRpcRequest) returns (GetClientCustomerMenuRefsByCustomerIdsRpcResponse) {} | ||
| 49 | rpc BatchCreateClientCustomerMenuRefs (BatchCreateClientCustomerMenuRefsRpcRequest) returns (BatchCreateClientCustomerMenuRefsRpcResponse) {} | 50 | rpc BatchCreateClientCustomerMenuRefs (BatchCreateClientCustomerMenuRefsRpcRequest) returns (BatchCreateClientCustomerMenuRefsRpcResponse) {} |
| 50 | rpc UpdateClientCustomerMenuRefTop (UpdateClientCustomerMenuRefTopRpcRequest) returns (UpdateClientCustomerMenuRefTopRpcResponse) {} | 51 | rpc UpdateClientCustomerMenuRefTop (UpdateClientCustomerMenuRefTopRpcRequest) returns (UpdateClientCustomerMenuRefTopRpcResponse) {} |
| 51 | rpc DeleteClientCustomerMenuRefsByIds (DeleteClientCustomerMenuRefsByIdsRpcRequest) returns (DeleteClientCustomerMenuRefsRpcResponse) {} | 52 | rpc DeleteClientCustomerMenuRefsByIds (DeleteClientCustomerMenuRefsByIdsRpcRequest) returns (DeleteClientCustomerMenuRefsRpcResponse) {} |
| ... | @@ -554,6 +555,15 @@ message GetClientCustomerMenuRefsByCustomerIdRpcResponse { | ... | @@ -554,6 +555,15 @@ message GetClientCustomerMenuRefsByCustomerIdRpcResponse { |
| 554 | repeated SingleClientCustomerMenuRefRpcResponse responses = 1; | 555 | repeated SingleClientCustomerMenuRefRpcResponse responses = 1; |
| 555 | } | 556 | } |
| 556 | 557 | ||
| 558 | +message GetClientCustomerMenuRefsByCustomerIdsRpcRequest { | ||
| 559 | + repeated int32 customerIds = 1; | ||
| 560 | + int32 enterpriseId = 2; | ||
| 561 | +} | ||
| 562 | + | ||
| 563 | +message GetClientCustomerMenuRefsByCustomerIdsRpcResponse { | ||
| 564 | + repeated SingleClientCustomerMenuRefRpcResponse responses = 1; | ||
| 565 | +} | ||
| 566 | + | ||
| 557 | message ClientCustomerMenuRefCreation{ | 567 | message ClientCustomerMenuRefCreation{ |
| 558 | int32 menuId = 1; | 568 | int32 menuId = 1; |
| 559 | int32 customerId = 2; | 569 | int32 customerId = 2; | ... | ... |
-
Please register or login to post a comment