Showing
4 changed files
with
86 additions
and
78 deletions
| ... | @@ -14,7 +14,12 @@ public class PermissionDTO { | ... | @@ -14,7 +14,12 @@ public class PermissionDTO { |
| 14 | @ApiModel(description = "Login DTO") | 14 | @ApiModel(description = "Login DTO") |
| 15 | public static class LoginDto { | 15 | public static class LoginDto { |
| 16 | private LoginSourceEnum loginSourceEnum; | 16 | private LoginSourceEnum loginSourceEnum; |
| 17 | + private boolean shouldLoginWithHisCustomerId; | ||
| 17 | private String hisCustomerId; | 18 | private String hisCustomerId; |
| 19 | + private boolean shouldLoginWithCustomerId; | ||
| 20 | + private Integer customerId; | ||
| 21 | + private boolean shouldLoginWithOpenId; | ||
| 22 | + private String openId; | ||
| 18 | } | 23 | } |
| 19 | 24 | ||
| 20 | } | 25 | } | ... | ... |
| 1 | package com.infoloop.tianting.service.client; | 1 | package com.infoloop.tianting.service.client; |
| 2 | 2 | ||
| 3 | -import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest; | 3 | +//import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest; |
| 4 | -import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcResponse; | 4 | +//import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcResponse; |
| 5 | import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcRequest; | 5 | import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcRequest; |
| 6 | import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcResponse; | 6 | import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcResponse; |
| 7 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; | 7 | import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; |
| ... | @@ -65,41 +65,6 @@ public class OrderServiceRpcClient { | ... | @@ -65,41 +65,6 @@ public class OrderServiceRpcClient { |
| 65 | // } | 65 | // } |
| 66 | 66 | ||
| 67 | public CreateOrderResponse createOrder(CreateOrderDto createOrderDto) { | 67 | public CreateOrderResponse createOrder(CreateOrderDto createOrderDto) { |
| 68 | - final var customerNotice = CustomerNotice.newBuilder() | ||
| 69 | - .addAllAvoids(createOrderDto.getCustomerNoticeJson().getAvoids()) | ||
| 70 | - .addAllDoctors(createOrderDto.getCustomerNoticeJson().getDoctors()) | ||
| 71 | - .build(); | ||
| 72 | - | ||
| 73 | - final var creation = ClientCustomerOrderCreation.newBuilder() | ||
| 74 | - .setShouldCreateCustomerId(true) | ||
| 75 | - .setCustomerId(createOrderDto.getCustomerId()) | ||
| 76 | - .setStallId(createOrderDto.getStallId()) | ||
| 77 | - .setAddress(createOrderDto.getAddress()) | ||
| 78 | - .setClientId(createOrderDto.getClientId()) | ||
| 79 | - .setShouldCreateOpenId(!createOrderDto.getOpenId().isEmpty()) | ||
| 80 | - .setOpenId(createOrderDto.getOpenId()) | ||
| 81 | - .setShouldCreateRoomNo(!createOrderDto.getRoomNo().isEmpty()) | ||
| 82 | - .setRoomNo(createOrderDto.getRoomNo()) | ||
| 83 | - .setShouldCreateTableCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue())) | ||
| 84 | - .setTableCode(createOrderDto.getTableCode()) | ||
| 85 | - .setOnlinePay(createOrderDto.getOnlinePay()) | ||
| 86 | - .setMenuId(createOrderDto.getMenuId()) | ||
| 87 | - .setTotalNum(createOrderDto.getTotalNum()) | ||
| 88 | - .setPayPrice(createOrderDto.getPayPrice()) | ||
| 89 | - .setMealTime(createOrderDto.getMealTime().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 90 | - .setShouldCreatePickupCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue())) | ||
| 91 | - .setPickupCode(createOrderDto.getPickupCode()) | ||
| 92 | - .setRemark(createOrderDto.getRemark()) | ||
| 93 | - .setCustomerNoticeJson(customerNotice) | ||
| 94 | - .build(); | ||
| 95 | - CreateClientCustomerOrderRpcResponse orderResponse = orderServiceRpcBlockingStub | ||
| 96 | - .createClientCustomerOrder(CreateClientCustomerOrderRpcRequest.newBuilder() | ||
| 97 | - .setCreation(creation) | ||
| 98 | - .setCreationSource(OrderSourceEnum.forNumber(createOrderDto.getCreationSource())) | ||
| 99 | - .setEnterpriseId(createOrderDto.getEnterpriseId()) | ||
| 100 | - .setCreatedBy(createOrderDto.getCreatedBy()) | ||
| 101 | - .build()); | ||
| 102 | - | ||
| 103 | final var orderDetails = new ArrayList<ClientCustomerOrderDetailCreation>(); | 68 | final var orderDetails = new ArrayList<ClientCustomerOrderDetailCreation>(); |
| 104 | for (CreateOrderDetailDto orderDetailDto: createOrderDto.getOrderDetailDtos()) { | 69 | for (CreateOrderDetailDto orderDetailDto: createOrderDto.getOrderDetailDtos()) { |
| 105 | final var mealDetail = MealDetail.newBuilder() | 70 | final var mealDetail = MealDetail.newBuilder() |
| ... | @@ -116,8 +81,9 @@ public class OrderServiceRpcClient { | ... | @@ -116,8 +81,9 @@ public class OrderServiceRpcClient { |
| 116 | .addAllSkus(orderDetailDto.getMealDetailJson().getSkus()) | 81 | .addAllSkus(orderDetailDto.getMealDetailJson().getSkus()) |
| 117 | .build(); | 82 | .build(); |
| 118 | final var orderDetail = ClientCustomerOrderDetailCreation.newBuilder() | 83 | final var orderDetail = ClientCustomerOrderDetailCreation.newBuilder() |
| 119 | - .setOrderId(orderResponse.getId()) | ||
| 120 | .setMenuDetailId(orderDetailDto.getMenuDetailId()) | 84 | .setMenuDetailId(orderDetailDto.getMenuDetailId()) |
| 85 | + .setShouldCreateOrderId(false) | ||
| 86 | + .setOrderId(0) | ||
| 121 | .setCount(orderDetailDto.getCount()) | 87 | .setCount(orderDetailDto.getCount()) |
| 122 | .setMealId(orderDetailDto.getMealId()) | 88 | .setMealId(orderDetailDto.getMealId()) |
| 123 | .setCategoryId(orderDetailDto.getCategoryId()) | 89 | .setCategoryId(orderDetailDto.getCategoryId()) |
| ... | @@ -134,12 +100,48 @@ public class OrderServiceRpcClient { | ... | @@ -134,12 +100,48 @@ public class OrderServiceRpcClient { |
| 134 | .build(); | 100 | .build(); |
| 135 | orderDetails.add(orderDetail); | 101 | orderDetails.add(orderDetail); |
| 136 | } | 102 | } |
| 137 | - BatchCreateClientCustomerOrderDetailsRpcResponse orderDetailsRpcResponse = orderServiceRpcBlockingStub.batchCreateClientCustomerOrderDetails( | 103 | + final var customerNotice = CustomerNotice.newBuilder() |
| 138 | - BatchCreateClientCustomerOrderDetailsRpcRequest.newBuilder() | 104 | + .addAllAvoids(createOrderDto.getCustomerNoticeJson().getAvoids()) |
| 139 | - .addAllCreations(orderDetails) | 105 | + .addAllDoctors(createOrderDto.getCustomerNoticeJson().getDoctors()) |
| 140 | - .setCreatedBy(createOrderDto.getCreatedBy()) | 106 | + .build(); |
| 107 | + | ||
| 108 | + final var creation = ClientCustomerOrderCreation.newBuilder() | ||
| 109 | + .setShouldCreateCustomerId(true) | ||
| 110 | + .setCustomerId(createOrderDto.getCustomerId()) | ||
| 111 | + .setStallId(createOrderDto.getStallId()) | ||
| 112 | + .setAddress(createOrderDto.getAddress()) | ||
| 113 | + .setClientId(createOrderDto.getClientId()) | ||
| 114 | + .setShouldCreateOpenId(!createOrderDto.getOpenId().isEmpty()) | ||
| 115 | + .setOpenId(createOrderDto.getOpenId()) | ||
| 116 | + .setShouldCreateRoomNo(!createOrderDto.getRoomNo().isEmpty()) | ||
| 117 | + .setRoomNo(createOrderDto.getRoomNo()) | ||
| 118 | + .setShouldCreateTableCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue())) | ||
| 119 | + .setTableCode(createOrderDto.getTableCode()) | ||
| 120 | + .setOnlinePay(createOrderDto.getOnlinePay()) | ||
| 121 | + .setMenuId(createOrderDto.getMenuId()) | ||
| 122 | + .setTotalNum(createOrderDto.getTotalNum()) | ||
| 123 | + .setPayPrice(createOrderDto.getPayPrice()) | ||
| 124 | + .setMealTime(createOrderDto.getMealTime().toInstant(ZoneOffset.UTC).toEpochMilli()) | ||
| 125 | + .setShouldCreatePickupCode(createOrderDto.getOrderType().equals(OrderTypeEnum.DINE_IN.getValue())) | ||
| 126 | + .setPickupCode(createOrderDto.getPickupCode()) | ||
| 127 | + .setRemark(createOrderDto.getRemark()) | ||
| 128 | + .setCustomerNoticeJson(customerNotice) | ||
| 129 | + .setShouldCreateOrderDetails(true) | ||
| 130 | + .addAllOrderDetails(orderDetails) | ||
| 131 | + .build(); | ||
| 132 | + CreateClientCustomerOrderRpcResponse orderResponse = orderServiceRpcBlockingStub | ||
| 133 | + .createClientCustomerOrder(CreateClientCustomerOrderRpcRequest.newBuilder() | ||
| 134 | + .setCreation(creation) | ||
| 135 | + .setCreationSource(OrderSourceEnum.forNumber(createOrderDto.getCreationSource())) | ||
| 141 | .setEnterpriseId(createOrderDto.getEnterpriseId()) | 136 | .setEnterpriseId(createOrderDto.getEnterpriseId()) |
| 142 | - .setCreationSource(OrderSourceEnum.forNumber(createOrderDto.getCreationSource())).build()); | 137 | + .setCreatedBy(createOrderDto.getCreatedBy()) |
| 138 | + .build()); | ||
| 139 | +// BatchCreateClientCustomerOrderDetailsRpcResponse orderDetailsRpcResponse = orderServiceRpcBlockingStub.batchCreateClientCustomerOrderDetails( | ||
| 140 | +// BatchCreateClientCustomerOrderDetailsRpcRequest.newBuilder() | ||
| 141 | +// .addAllCreations(orderDetails) | ||
| 142 | +// .setCreatedBy(createOrderDto.getCreatedBy()) | ||
| 143 | +// .setEnterpriseId(createOrderDto.getEnterpriseId()) | ||
| 144 | +// .setCreationSource(OrderSourceEnum.forNumber(createOrderDto.getCreationSource())).build()); | ||
| 143 | return CreateOrderResponse.builder().id(orderResponse.getId()).isCreated(true).build(); | 145 | return CreateOrderResponse.builder().id(orderResponse.getId()).isCreated(true).build(); |
| 144 | } | 146 | } |
| 145 | 147 | ... | ... |
| ... | @@ -3,6 +3,8 @@ package com.infoloop.tianting.service.impl; | ... | @@ -3,6 +3,8 @@ package com.infoloop.tianting.service.impl; |
| 3 | import cn.dev33.satoken.stp.SaLoginModel; | 3 | import cn.dev33.satoken.stp.SaLoginModel; |
| 4 | import cn.dev33.satoken.stp.SaTokenInfo; | 4 | import cn.dev33.satoken.stp.SaTokenInfo; |
| 5 | import cn.dev33.satoken.stp.StpUtil; | 5 | import cn.dev33.satoken.stp.StpUtil; |
| 6 | +import com.infoloop.tianting.clientcustomerservice.GetClientCustomerByIdRpcRequest; | ||
| 7 | +import com.infoloop.tianting.clientcustomerservice.SingleClientCustomerRpcResponse; | ||
| 6 | import com.infoloop.tianting.constant.CommonConstants; | 8 | import com.infoloop.tianting.constant.CommonConstants; |
| 7 | import com.infoloop.tianting.exception.ClientEndExceptions; | 9 | import com.infoloop.tianting.exception.ClientEndExceptions; |
| 8 | import com.infoloop.tianting.exception.ErrorCodeEnum; | 10 | import com.infoloop.tianting.exception.ErrorCodeEnum; |
| ... | @@ -24,16 +26,27 @@ public class LoginServiceImpl implements LoginService { | ... | @@ -24,16 +26,27 @@ public class LoginServiceImpl implements LoginService { |
| 24 | 26 | ||
| 25 | @Override | 27 | @Override |
| 26 | public SaTokenInfo login(LoginDto loginDto) { | 28 | public SaTokenInfo login(LoginDto loginDto) { |
| 27 | - final var customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId(loginDto.getHisCustomerId()); | 29 | + if (loginDto.isShouldLoginWithOpenId()) { |
| 28 | - if (customer.getResponse().getId() == 0) { | 30 | + return StpUtil.getTokenInfo(); |
| 29 | - throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); | 31 | + } |
| 32 | + else { | ||
| 33 | + final SingleClientCustomerRpcResponse customer; | ||
| 34 | + if (loginDto.isShouldLoginWithHisCustomerId()){ | ||
| 35 | + customer = clientCustomerServiceRpcClient.getClientCustomerByHISCustomerId(loginDto.getHisCustomerId()).getResponse(); | ||
| 36 | + } else { | ||
| 37 | + customer = clientCustomerServiceRpcClient.getClientCustomerById(loginDto.getCustomerId()).getResponse(); | ||
| 30 | } | 38 | } |
| 31 | 39 | ||
| 32 | - StpUtil.login(customer.getResponse().getId(), SaLoginModel.create() | 40 | + if (customer.getId() == 0) { |
| 33 | - .setExtra(CommonConstants.ENTERPRISE_ID, customer.getResponse().getEnterpriseId()) | 41 | + throw ClientEndExceptions.AuthenticationFailure.build(ErrorCodeEnum.UNAUTHORIZED.name()); |
| 42 | + } | ||
| 43 | + StpUtil.login(customer.getId(), SaLoginModel.create() | ||
| 44 | + .setExtra(CommonConstants.ENTERPRISE_ID, customer.getEnterpriseId()) | ||
| 34 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) | 45 | .setExtra(CommonConstants.LOGIN_SOURCE, loginDto.getLoginSourceEnum().getValue()) |
| 35 | .build()); | 46 | .build()); |
| 36 | return StpUtil.getTokenInfo(); | 47 | return StpUtil.getTokenInfo(); |
| 37 | } | 48 | } |
| 49 | + } | ||
| 50 | + | ||
| 38 | } | 51 | } |
| 39 | 52 | ... | ... |
| ... | @@ -18,7 +18,6 @@ service ClientCustomerOrderServiceRpc { | ... | @@ -18,7 +18,6 @@ service ClientCustomerOrderServiceRpc { |
| 18 | rpc UpdateClientCustomerOrder (UpdateClientCustomerOrderRpcRequest) returns (UpdateClientCustomerOrderRpcResponse) {} | 18 | rpc UpdateClientCustomerOrder (UpdateClientCustomerOrderRpcRequest) returns (UpdateClientCustomerOrderRpcResponse) {} |
| 19 | rpc BatchUpdateClientCustomerOrders (BatchUpdateClientCustomerOrdersRpcRequest) returns (BatchUpdateClientCustomerOrdersRpcResponse) {} | 19 | rpc BatchUpdateClientCustomerOrders (BatchUpdateClientCustomerOrdersRpcRequest) returns (BatchUpdateClientCustomerOrdersRpcResponse) {} |
| 20 | rpc DeleteClientCustomerOrdersByIds (DeleteClientCustomerOrdersByIdsRpcRequest) returns (DeleteClientCustomerOrdersRpcResponse) {} | 20 | rpc DeleteClientCustomerOrdersByIds (DeleteClientCustomerOrdersByIdsRpcRequest) returns (DeleteClientCustomerOrdersRpcResponse) {} |
| 21 | - rpc BatchCreateClientCustomerOrderAndDetails (BatchCreateClientCustomerOrderAndDetailsRpcRequest) returns (BatchCreateClientCustomerOrderAndDetailsRpcResponse) {} | ||
| 22 | 21 | ||
| 23 | //订单明细 | 22 | //订单明细 |
| 24 | rpc GetClientCustomerOrderDetailById (GetClientCustomerOrderDetailByIdRpcRequest) returns (GetClientCustomerOrderDetailByIdRpcResponse) {} | 23 | rpc GetClientCustomerOrderDetailById (GetClientCustomerOrderDetailByIdRpcRequest) returns (GetClientCustomerOrderDetailByIdRpcResponse) {} |
| ... | @@ -232,6 +231,8 @@ message ClientCustomerOrderCreation{ | ... | @@ -232,6 +231,8 @@ message ClientCustomerOrderCreation{ |
| 232 | bool shouldCreateCustomerNoticeJson = 37; | 231 | bool shouldCreateCustomerNoticeJson = 37; |
| 233 | CustomerNotice customerNoticeJson = 38; | 232 | CustomerNotice customerNoticeJson = 38; |
| 234 | bool isRead = 39; | 233 | bool isRead = 39; |
| 234 | + bool shouldCreateOrderDetails = 40; | ||
| 235 | + repeated ClientCustomerOrderDetailCreation orderDetails = 41; | ||
| 235 | } | 236 | } |
| 236 | 237 | ||
| 237 | message CreateClientCustomerOrderRpcRequest { | 238 | message CreateClientCustomerOrderRpcRequest { |
| ... | @@ -343,20 +344,6 @@ message DeleteClientCustomerOrdersRpcResponse { | ... | @@ -343,20 +344,6 @@ message DeleteClientCustomerOrdersRpcResponse { |
| 343 | bool isDeleted = 1; | 344 | bool isDeleted = 1; |
| 344 | } | 345 | } |
| 345 | 346 | ||
| 346 | -message BatchCreateClientCustomerOrderAndDetailsRpcRequest { | ||
| 347 | - int32 enterpriseId = 1; | ||
| 348 | - int32 createdBy = 2; | ||
| 349 | - OrderSourceEnum creationSource = 3; | ||
| 350 | - repeated ClientCustomerOrderCreation orderCreations = 4; | ||
| 351 | - repeated ClientCustomerOrderDetailCreation detailCreations = 5; | ||
| 352 | -} | ||
| 353 | - | ||
| 354 | -message BatchCreateClientCustomerOrderAndDetailsRpcResponse { | ||
| 355 | - repeated int32 orderIds = 1; | ||
| 356 | - bool isCreated = 2; | ||
| 357 | -} | ||
| 358 | - | ||
| 359 | - | ||
| 360 | message MealDetail { | 347 | message MealDetail { |
| 361 | string basicMaterials = 1; | 348 | string basicMaterials = 1; |
| 362 | repeated string tastes = 2; | 349 | repeated string tastes = 2; |
| ... | @@ -422,21 +409,22 @@ message GetClientCustomerOrderDetailsByOrderIdsRpcResponse { | ... | @@ -422,21 +409,22 @@ message GetClientCustomerOrderDetailsByOrderIdsRpcResponse { |
| 422 | } | 409 | } |
| 423 | 410 | ||
| 424 | message ClientCustomerOrderDetailCreation{ | 411 | message ClientCustomerOrderDetailCreation{ |
| 425 | - int32 orderId = 1; | 412 | + bool shouldCreateOrderId = 1; |
| 426 | - int32 menuDetailId = 2; | 413 | + int32 orderId = 2; |
| 427 | - int32 count = 3; | 414 | + int32 menuDetailId = 3; |
| 428 | - int32 mealId = 4; | 415 | + int32 count = 4; |
| 429 | - int32 categoryId = 5; | 416 | + int32 mealId = 5; |
| 430 | - int32 skuId = 6; | 417 | + int32 categoryId = 6; |
| 431 | - bool shouldCreateShowName = 7; | 418 | + int32 skuId = 7; |
| 432 | - string showName = 8; | 419 | + bool shouldCreateShowName = 8; |
| 433 | - bool shouldCreateMealDetailJson = 9; | 420 | + string showName = 9; |
| 434 | - MealDetail mealDetailJson = 10; | 421 | + bool shouldCreateMealDetailJson = 10; |
| 435 | - bool shouldCreatePrice = 11; | 422 | + MealDetail mealDetailJson = 11; |
| 436 | - int32 price = 12; | 423 | + bool shouldCreatePrice = 12; |
| 437 | - bool shouldCreateAdjustSkuRemark = 13; | 424 | + int32 price = 13; |
| 438 | - string adjustSkuRemark = 14; | 425 | + bool shouldCreateAdjustSkuRemark = 14; |
| 439 | - bool notServe = 15; | 426 | + string adjustSkuRemark = 15; |
| 427 | + bool notServe = 16; | ||
| 440 | } | 428 | } |
| 441 | 429 | ||
| 442 | message CreateClientCustomerOrderDetailRpcRequest { | 430 | message CreateClientCustomerOrderDetailRpcRequest { | ... | ... |
-
Please register or login to post a comment