Showing
4 changed files
with
60 additions
and
37 deletions
| ... | @@ -72,7 +72,7 @@ public class OrderController { | ... | @@ -72,7 +72,7 @@ public class OrderController { |
| 72 | return orderService.createOrder(createOrderDto); | 72 | return orderService.createOrder(createOrderDto); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | - @ApiOperation(value = "创建订单") | 75 | + @ApiOperation(value = "院区端创建订单") |
| 76 | @PostMapping("/operator/orders") | 76 | @PostMapping("/operator/orders") |
| 77 | @ResponseStatus(HttpStatus.OK) | 77 | @ResponseStatus(HttpStatus.OK) |
| 78 | public CreateOrderResponse createOrderByOperator( | 78 | public CreateOrderResponse createOrderByOperator( | ... | ... |
| ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRp | ... | @@ -7,6 +7,8 @@ import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRp |
| 7 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcResponse; | 7 | import com.infoloop.tianting.menuservice.GetClientCustomerMenuRefsByCustomerIdRpcResponse; |
| 8 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcRequest; | 8 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcRequest; |
| 9 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcResponse; | 9 | import com.infoloop.tianting.menuservice.GetMenuByIdRpcResponse; |
| 10 | +import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcRequest; | ||
| 11 | +import com.infoloop.tianting.menuservice.GetMenuDetailByIdRpcResponse; | ||
| 10 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcRequest; | 12 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcRequest; |
| 11 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcResponse; | 13 | import com.infoloop.tianting.menuservice.GetMenuDetailsByMenuIdsRpcResponse; |
| 12 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcRequest; | 14 | import com.infoloop.tianting.menuservice.GetMicroPublishedMenusByStallIdsRpcRequest; |
| ... | @@ -16,6 +18,7 @@ import com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcResponse; | ... | @@ -16,6 +18,7 @@ import com.infoloop.tianting.menuservice.GetPublishedMenusByStallIdsRpcResponse; |
| 16 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; | 18 | import com.infoloop.tianting.menuservice.MenuServiceRpcGrpc; |
| 17 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; | 19 | import com.infoloop.tianting.model.dto.MenuDbDTO.BatchCreateMenuRefsDto; |
| 18 | import com.infoloop.tianting.utils.DateUtil; | 20 | import com.infoloop.tianting.utils.DateUtil; |
| 21 | +import io.swagger.models.auth.In; | ||
| 19 | import java.time.LocalDateTime; | 22 | import java.time.LocalDateTime; |
| 20 | import java.time.ZoneOffset; | 23 | import java.time.ZoneOffset; |
| 21 | import java.util.List; | 24 | import java.util.List; |
| ... | @@ -57,6 +60,15 @@ public class MenuServiceRpcClient { | ... | @@ -57,6 +60,15 @@ public class MenuServiceRpcClient { |
| 57 | return menuServiceRpcBlockingStub.getMenuById(request); | 60 | return menuServiceRpcBlockingStub.getMenuById(request); |
| 58 | } | 61 | } |
| 59 | 62 | ||
| 63 | + public GetMenuDetailByIdRpcResponse getMenuDetailById(Integer enterpriseId, Integer id) { | ||
| 64 | + final var request = GetMenuDetailByIdRpcRequest.newBuilder() | ||
| 65 | + .setEnterpriseId(enterpriseId) | ||
| 66 | + .setId(id) | ||
| 67 | + .setIncludeDeleted(false) | ||
| 68 | + .build(); | ||
| 69 | + return menuServiceRpcBlockingStub.getMenuDetailById(request); | ||
| 70 | + } | ||
| 71 | + | ||
| 60 | public GetMenuDetailsByMenuIdsRpcResponse queryMenuDetailsByMenuId( | 72 | public GetMenuDetailsByMenuIdsRpcResponse queryMenuDetailsByMenuId( |
| 61 | Integer enterpriseId, Integer menuId) { | 73 | Integer enterpriseId, Integer menuId) { |
| 62 | final var request = GetMenuDetailsByMenuIdsRpcRequest.newBuilder() | 74 | final var request = GetMenuDetailsByMenuIdsRpcRequest.newBuilder() | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.SingleResponse; | ||
| 4 | +import com.infoloop.tianting.SingleSpecialResponse; | ||
| 3 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; | 5 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest; |
| 4 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; | 6 | import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse; |
| 5 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; | 7 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; |
| ... | @@ -48,6 +50,8 @@ import org.springframework.stereotype.Service; | ... | @@ -48,6 +50,8 @@ import org.springframework.stereotype.Service; |
| 48 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) | 50 | @RequiredArgsConstructor(onConstructor = @__(@Autowired)) |
| 49 | public class OrderServiceRpcClient { | 51 | public class OrderServiceRpcClient { |
| 50 | private final ClientCustomerOrderServiceRpcGrpc.ClientCustomerOrderServiceRpcBlockingStub orderServiceRpcBlockingStub; | 52 | private final ClientCustomerOrderServiceRpcGrpc.ClientCustomerOrderServiceRpcBlockingStub orderServiceRpcBlockingStub; |
| 53 | + private final MenuServiceRpcClient menuServiceRpcClient; | ||
| 54 | + private final SkuServiceRpcClient skuServiceRpcClient; | ||
| 51 | 55 | ||
| 52 | public List<SingleClientCustomerOrderRpcResponse> getOrdersByCustomerId(Integer customerId) { | 56 | public List<SingleClientCustomerOrderRpcResponse> getOrdersByCustomerId(Integer customerId) { |
| 53 | return orderServiceRpcBlockingStub.getClientCustomerOrdersByCustomerId( | 57 | return orderServiceRpcBlockingStub.getClientCustomerOrdersByCustomerId( |
| ... | @@ -100,52 +104,54 @@ public class OrderServiceRpcClient { | ... | @@ -100,52 +104,54 @@ public class OrderServiceRpcClient { |
| 100 | public BatchUpdateClientCustomerOrderDetailsRpcResponse batchUpdateClientCustomerOrderDetails( | 104 | public BatchUpdateClientCustomerOrderDetailsRpcResponse batchUpdateClientCustomerOrderDetails( |
| 101 | OrderDetailBatchUpdateDto orderDetailBatchUpdateDto) { | 105 | OrderDetailBatchUpdateDto orderDetailBatchUpdateDto) { |
| 102 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map( d-> { | 106 | final var modifications = orderDetailBatchUpdateDto.getDetails().stream().map( d-> { |
| 103 | - MealDetail mealDetail; | 107 | + MealDetail mealDetail = MealDetail.newBuilder().build();; |
| 104 | - if(d.getShouldUpdateMealDetailJson()) { | ||
| 105 | - mealDetail = MealDetail.newBuilder() | ||
| 106 | - .setBasicMaterials(d.getMealDetailJson().getBasicMaterials()) | ||
| 107 | - .addAllTastes(d.getMealDetailJson().getTastes()) | ||
| 108 | - .addAllEfficacies(d.getMealDetailJson().getEfficacies()) | ||
| 109 | - .addAllDockers(d.getMealDetailJson().getDockers()) | ||
| 110 | - .setEnergy(d.getMealDetailJson().getEnergy()) | ||
| 111 | - .setFat(d.getMealDetailJson().getFat()) | ||
| 112 | - .setProtein(d.getMealDetailJson().getProtein()) | ||
| 113 | - .setCarbohydrate(d.getMealDetailJson().getCarbohydrate()) | ||
| 114 | - .addAllAllergies(d.getMealDetailJson().getAllergies()) | ||
| 115 | - .addAllAvoids(d.getMealDetailJson().getAvoids()) | ||
| 116 | - .addAllSkus(d.getMealDetailJson().getSkus()) | ||
| 117 | - .build(); | ||
| 118 | - } else { | ||
| 119 | - mealDetail = MealDetail.newBuilder().build(); | ||
| 120 | - } | ||
| 121 | Integer menuDetailId = 0; | 108 | Integer menuDetailId = 0; |
| 122 | - if (d.getShouldUpdateMenuDetailId()) { | ||
| 123 | - menuDetailId = d.getMenuDetailId(); | ||
| 124 | - } | ||
| 125 | - Integer count = 0; | ||
| 126 | - if (d.getShouldUpdateCount()) { | ||
| 127 | - count = d.getCount(); | ||
| 128 | - } | ||
| 129 | Integer mealId = 0; | 109 | Integer mealId = 0; |
| 130 | - if (d.getShouldUpdateMealId()) { | ||
| 131 | - mealId = d.getMealId(); | ||
| 132 | - } | ||
| 133 | Integer categoryId = 0; | 110 | Integer categoryId = 0; |
| 134 | - if (d.getShouldUpdateCategoryId()) { | ||
| 135 | - categoryId = d.getCategoryId(); | ||
| 136 | - } | ||
| 137 | Integer skuId = 0; | 111 | Integer skuId = 0; |
| 138 | - if (d.getShouldUpdateSkuId()) { | ||
| 139 | - skuId = d.getSkuId(); | ||
| 140 | - } | ||
| 141 | String showName = ""; | 112 | String showName = ""; |
| 142 | - if (d.getShouldUpdateShowName()) { | 113 | + if (d.getShouldUpdateMenuDetailId()) { |
| 143 | - showName = d.getShowName(); | 114 | + menuDetailId = d.getMenuDetailId(); |
| 115 | + final var menuDetail = menuServiceRpcClient.getMenuDetailById( | ||
| 116 | + orderDetailBatchUpdateDto.getEnterpriseId(), menuDetailId).getResponse(); | ||
| 117 | + mealId = menuDetail.getMealId(); | ||
| 118 | + categoryId = menuDetail.getCategoryId(); | ||
| 119 | + skuId = menuDetail.getSkuId(); | ||
| 120 | + showName = menuDetail.getShowName(); | ||
| 121 | + final var rpcSkus = skuServiceRpcClient.getDishSkusByIds(List.of(skuId)).getResponseList(); | ||
| 122 | + if (!rpcSkus.isEmpty()) { | ||
| 123 | + final var skus = rpcSkus.get(0).getSkusList().stream().map(SingleResponse::getName).collect(Collectors.toList()); | ||
| 124 | + final var skuAvoids = rpcSkus.get(0).getAvoidsList().stream().map(SingleResponse::getName).collect(Collectors.toList()); | ||
| 125 | + final var tastes = rpcSkus.get(0).getTastesList().stream().map(SingleResponse::getName).collect(Collectors.toList()); | ||
| 126 | + final var efficacies = rpcSkus.get(0).getEfficaciesList().stream().map(SingleResponse::getName).collect(Collectors.toList()); | ||
| 127 | + final var allergies = rpcSkus.get(0).getAllergiesList().stream().map( | ||
| 128 | + SingleSpecialResponse::getName).collect(Collectors.toList()); | ||
| 129 | + final var skuDoctors = rpcSkus.get(0).getDoctorsList().stream().map(SingleSpecialResponse::getName).collect(Collectors.toList()); | ||
| 130 | + mealDetail = MealDetail.newBuilder() | ||
| 131 | + .setBasicMaterials(rpcSkus.get(0).getBasicMaterials()) | ||
| 132 | + .addAllTastes(tastes) | ||
| 133 | + .addAllEfficacies(efficacies) | ||
| 134 | + .addAllDockers(skuDoctors) | ||
| 135 | + .setEnergy(rpcSkus.get(0).getEnergy()) | ||
| 136 | + .setFat(rpcSkus.get(0).getFat()) | ||
| 137 | + .setProtein(rpcSkus.get(0).getProtein()) | ||
| 138 | + .setCarbohydrate(rpcSkus.get(0).getCarbohydrate()) | ||
| 139 | + .addAllAllergies(allergies) | ||
| 140 | + .addAllAvoids(skuAvoids) | ||
| 141 | + .addAllSkus(skus) | ||
| 142 | + .build(); | ||
| 143 | + } | ||
| 144 | + | ||
| 144 | } | 145 | } |
| 146 | + | ||
| 145 | Boolean notServe = false; | 147 | Boolean notServe = false; |
| 146 | if (d.getShouldUpdateNotServe()) { | 148 | if (d.getShouldUpdateNotServe()) { |
| 147 | notServe = true; | 149 | notServe = true; |
| 148 | } | 150 | } |
| 151 | + Integer count = 0; | ||
| 152 | + if (d.getShouldUpdateCount()) { | ||
| 153 | + count = d.getCount(); | ||
| 154 | + } | ||
| 149 | final var detail = ClientCustomerOrderDetailModification.newBuilder() | 155 | final var detail = ClientCustomerOrderDetailModification.newBuilder() |
| 150 | .setId(d.getId()) | 156 | .setId(d.getId()) |
| 151 | .setShouldUpdateMenuDetailId(d.getShouldUpdateMenuDetailId()) | 157 | .setShouldUpdateMenuDetailId(d.getShouldUpdateMenuDetailId()) | ... | ... |
-
Please register or login to post a comment