Showing
5 changed files
with
72 additions
and
0 deletions
| ... | @@ -5,6 +5,7 @@ import com.infoloop.tianting.annotation.RepeatSubmit; | ... | @@ -5,6 +5,7 @@ import com.infoloop.tianting.annotation.RepeatSubmit; |
| 5 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | 5 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; |
| 6 | import com.infoloop.tianting.model.common.CreatedResult; | 6 | import com.infoloop.tianting.model.common.CreatedResult; |
| 7 | import com.infoloop.tianting.model.dto.MealOrderDTO; | 7 | import com.infoloop.tianting.model.dto.MealOrderDTO; |
| 8 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 8 | import com.infoloop.tianting.model.vo.MealOrderVO; | 9 | import com.infoloop.tianting.model.vo.MealOrderVO; |
| 9 | import com.infoloop.tianting.service.MealOrderService; | 10 | import com.infoloop.tianting.service.MealOrderService; |
| 10 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| ... | @@ -59,4 +60,11 @@ public class MealOrderController { | ... | @@ -59,4 +60,11 @@ public class MealOrderController { |
| 59 | return mealOrderService.getMealOrderById(mealOrder); | 60 | return mealOrderService.getMealOrderById(mealOrder); |
| 60 | } | 61 | } |
| 61 | 62 | ||
| 63 | + @ApiOperation(value = "订餐规则") | ||
| 64 | + @GetMapping("/deliveryrule") | ||
| 65 | + @ResponseStatus(HttpStatus.OK) | ||
| 66 | + public DeliveryRuleVO getDeliveryRule() { | ||
| 67 | + return mealOrderService.getDeliveryRule(); | ||
| 68 | + } | ||
| 69 | + | ||
| 62 | } | 70 | } | ... | ... |
| 1 | +package com.infoloop.tianting.model.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Builder; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +@ApiModel(value = "订餐规则") | ||
| 10 | +@Builder | ||
| 11 | +public class DeliveryRuleVO { | ||
| 12 | + | ||
| 13 | + @ApiModelProperty(value = "订餐开始时间") | ||
| 14 | + private String startTime; | ||
| 15 | + | ||
| 16 | + @ApiModelProperty(value = "订餐结束时间") | ||
| 17 | + private String endTime; | ||
| 18 | + | ||
| 19 | + private Boolean monday; | ||
| 20 | + private Boolean tuesday; | ||
| 21 | + private Boolean wednesday; | ||
| 22 | + private Boolean thursday; | ||
| 23 | + private Boolean friday; | ||
| 24 | + private Boolean saturday; | ||
| 25 | + private Boolean sunday; | ||
| 26 | +} |
| ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service; | ... | @@ -3,6 +3,7 @@ package com.infoloop.tianting.service; |
| 3 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | 3 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; |
| 4 | import com.infoloop.tianting.model.common.CreatedResult; | 4 | import com.infoloop.tianting.model.common.CreatedResult; |
| 5 | import com.infoloop.tianting.model.dto.MealOrderDTO; | 5 | import com.infoloop.tianting.model.dto.MealOrderDTO; |
| 6 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 6 | import com.infoloop.tianting.model.vo.MealOrderVO; | 7 | import com.infoloop.tianting.model.vo.MealOrderVO; |
| 7 | 8 | ||
| 8 | import java.util.List; | 9 | import java.util.List; |
| ... | @@ -14,4 +15,6 @@ public interface MealOrderService { | ... | @@ -14,4 +15,6 @@ public interface MealOrderService { |
| 14 | CreatedResult<MealOrderVO> createMealOrder(MealOrderDTO.CreateMealOrderDTO createMealOrderDTO); | 15 | CreatedResult<MealOrderVO> createMealOrder(MealOrderDTO.CreateMealOrderDTO createMealOrderDTO); |
| 15 | 16 | ||
| 16 | MealOrderVO getMealOrderById(SingleMealOrderRpcResponse mealOrder); | 17 | MealOrderVO getMealOrderById(SingleMealOrderRpcResponse mealOrder); |
| 18 | + | ||
| 19 | + DeliveryRuleVO getDeliveryRule(); | ||
| 17 | } | 20 | } | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | +import com.infoloop.tianting.deliveryruleservice.DeliveryTemplateTypeEnum; | ||
| 3 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; | 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcRequest; |
| 4 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; | 5 | import com.infoloop.tianting.deliveryruleservice.GetClientLabelsByIdsRpcResponse; |
| 6 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcRequest; | ||
| 7 | +import com.infoloop.tianting.deliveryruleservice.GetDefaultDeliveryTemplateAndRuleRpcResponse; | ||
| 5 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; | 8 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcRequest; |
| 6 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; | 9 | import com.infoloop.tianting.deliveryruleservice.QueryClientLabelsByConditionRpcResponse; |
| 7 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; | 10 | import com.infoloop.tianting.deliveryruleservice.TiantingDeliveryRuleServiceRpcGrpc; |
| ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { | ... | @@ -40,5 +43,14 @@ public class DeliveryRuleServiceRpcClient { |
| 40 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); | 43 | return deliveryRuleServiceRpcBlockingStub.getClientLabelsByIds(request); |
| 41 | } | 44 | } |
| 42 | 45 | ||
| 46 | + public GetDefaultDeliveryTemplateAndRuleRpcResponse getDefaultDeliveryTemplateAndRule(int enterpriseId) { | ||
| 47 | + final var request = GetDefaultDeliveryTemplateAndRuleRpcRequest | ||
| 48 | + .newBuilder() | ||
| 49 | + .setEnterpriseId(enterpriseId) | ||
| 50 | + .setType(DeliveryTemplateTypeEnum.DELIVERY_TEMPLATE_TYPE_DELIVERY) | ||
| 51 | + .build(); | ||
| 52 | + return deliveryRuleServiceRpcBlockingStub.getDefaultDeliveryTemplateAndRule(request); | ||
| 53 | + } | ||
| 54 | + | ||
| 43 | 55 | ||
| 44 | } | 56 | } | ... | ... |
| ... | @@ -10,9 +10,11 @@ import com.infoloop.tianting.mealorderservice.MenuSchedule; | ... | @@ -10,9 +10,11 @@ import com.infoloop.tianting.mealorderservice.MenuSchedule; |
| 10 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; | 10 | import com.infoloop.tianting.mealorderservice.SingleMealOrderRpcResponse; |
| 11 | import com.infoloop.tianting.model.common.CreatedResult; | 11 | import com.infoloop.tianting.model.common.CreatedResult; |
| 12 | import com.infoloop.tianting.model.dto.MealOrderDTO; | 12 | import com.infoloop.tianting.model.dto.MealOrderDTO; |
| 13 | +import com.infoloop.tianting.model.vo.DeliveryRuleVO; | ||
| 13 | import com.infoloop.tianting.model.vo.MealOrderVO; | 14 | import com.infoloop.tianting.model.vo.MealOrderVO; |
| 14 | import com.infoloop.tianting.service.MealOrderService; | 15 | import com.infoloop.tianting.service.MealOrderService; |
| 15 | import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; | 16 | import com.infoloop.tianting.service.client.ClientInventoryServiceRpcClient; |
| 17 | +import com.infoloop.tianting.service.client.DeliveryRuleServiceRpcClient; | ||
| 16 | import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; | 18 | import com.infoloop.tianting.service.client.MealOrderServiceRpcClient; |
| 17 | import com.infoloop.tianting.utils.DateUtil; | 19 | import com.infoloop.tianting.utils.DateUtil; |
| 18 | import lombok.RequiredArgsConstructor; | 20 | import lombok.RequiredArgsConstructor; |
| ... | @@ -36,6 +38,8 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -36,6 +38,8 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 36 | 38 | ||
| 37 | private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; | 39 | private final ClientInventoryServiceRpcClient clientInventoryServiceRpcClient; |
| 38 | 40 | ||
| 41 | + private final DeliveryRuleServiceRpcClient deliveryRuleServiceRpcClient; | ||
| 42 | + | ||
| 39 | @Override | 43 | @Override |
| 40 | public List<MealOrderVO> queryMealOrders(MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) { | 44 | public List<MealOrderVO> queryMealOrders(MealOrderDTO.QueryMealOrderDTO queryMealOrderDTO) { |
| 41 | final var loginInfo = LoginContextHolder.getLoginInfo(); | 45 | final var loginInfo = LoginContextHolder.getLoginInfo(); |
| ... | @@ -118,4 +122,23 @@ public class MealOrderServiceImpl implements MealOrderService { | ... | @@ -118,4 +122,23 @@ public class MealOrderServiceImpl implements MealOrderService { |
| 118 | .meals(mealOrder.getMealsList().stream().map(e -> MealOrderVO.Meals.builder().date(e.getDate()).menu(e.getMenu()).build()).toList()) | 122 | .meals(mealOrder.getMealsList().stream().map(e -> MealOrderVO.Meals.builder().date(e.getDate()).menu(e.getMenu()).build()).toList()) |
| 119 | .build(); | 123 | .build(); |
| 120 | } | 124 | } |
| 125 | + | ||
| 126 | + @Override | ||
| 127 | + public DeliveryRuleVO getDeliveryRule() { | ||
| 128 | + final var rule = deliveryRuleServiceRpcClient.getDefaultDeliveryTemplateAndRule(LoginContextHolder.getEnterpriseId()).getRule(); | ||
| 129 | + if (rule.getConfigJson().getRulesList().isEmpty()) { | ||
| 130 | + return DeliveryRuleVO.builder().build(); | ||
| 131 | + } | ||
| 132 | + return DeliveryRuleVO.builder() | ||
| 133 | + .startTime(rule.getConfigJson().getRules(0).getStartTime()) | ||
| 134 | + .endTime(rule.getConfigJson().getRules(0).getEndTime()) | ||
| 135 | + .monday(rule.getConfigJson().getRules(0).getMonday()) | ||
| 136 | + .tuesday(rule.getConfigJson().getRules(0).getTuesday()) | ||
| 137 | + .wednesday(rule.getConfigJson().getRules(0).getWednesday()) | ||
| 138 | + .thursday(rule.getConfigJson().getRules(0).getThursday()) | ||
| 139 | + .friday(rule.getConfigJson().getRules(0).getFriday()) | ||
| 140 | + .saturday(rule.getConfigJson().getRules(0).getSaturday()) | ||
| 141 | + .sunday(rule.getConfigJson().getRules(0).getSunday()) | ||
| 142 | + .build(); | ||
| 143 | + } | ||
| 121 | } | 144 | } | ... | ... |
-
Please register or login to post a comment