zhuyifan

fix

...@@ -10,8 +10,6 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome ...@@ -10,8 +10,6 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome
10 import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest; 10 import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest;
11 import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation; 11 import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation;
12 import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest; 12 import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest;
13 -import com.infoloop.tianting.clientcustomerorderservice.OnlinePayEnum;
14 -import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum;
15 import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum; 13 import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum;
16 import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest; 14 import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest;
17 import com.tianting.infoloop.mapper.OrderDbMapper; 15 import com.tianting.infoloop.mapper.OrderDbMapper;
...@@ -20,13 +18,13 @@ import com.tianting.infoloop.model.db.OrderDetailDb; ...@@ -20,13 +18,13 @@ import com.tianting.infoloop.model.db.OrderDetailDb;
20 import com.tianting.infoloop.model.dto.CustomerNoticeDto; 18 import com.tianting.infoloop.model.dto.CustomerNoticeDto;
21 import com.tianting.infoloop.model.dto.MealDetailJson; 19 import com.tianting.infoloop.model.dto.MealDetailJson;
22 import com.tianting.infoloop.service.OrderDbService; 20 import com.tianting.infoloop.service.OrderDbService;
23 -import com.tianting.infoloop.service.OrderDetailDbService;
24 import com.tianting.infoloop.utils.exception.ErrorCodeConstants; 21 import com.tianting.infoloop.utils.exception.ErrorCodeConstants;
25 import com.tianting.infoloop.utils.exception.ServiceExceptionUtil; 22 import com.tianting.infoloop.utils.exception.ServiceExceptionUtil;
26 import lombok.RequiredArgsConstructor; 23 import lombok.RequiredArgsConstructor;
27 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
28 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
27 +import org.springframework.transaction.annotation.Transactional;
30 28
31 import java.time.Instant; 29 import java.time.Instant;
32 import java.time.LocalDateTime; 30 import java.time.LocalDateTime;
...@@ -41,154 +39,146 @@ import java.util.stream.Collectors; ...@@ -41,154 +39,146 @@ import java.util.stream.Collectors;
41 @Service 39 @Service
42 @RequiredArgsConstructor(onConstructor_ = @Autowired) 40 @RequiredArgsConstructor(onConstructor_ = @Autowired)
43 public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> implements OrderDbService { 41 public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> implements OrderDbService {
44 - private final OrderDbMapper orderDbMapper; 42 + private final OrderDbMapper orderDbMapper;
45 - private final OrderDetailDbService orderDetailDbService;
46 43
47 - @Override 44 + @Override
48 - public OrderDb createOrderDb(CreateClientCustomerOrderRpcRequest createOrderRpcRequest) { 45 + @Transactional(rollbackFor = Exception.class)
49 - OrderDb orderDb = new OrderDb(); 46 + public OrderDb createOrderDb(CreateClientCustomerOrderRpcRequest createOrderRpcRequest) {
50 - //生成分布式唯一值 47 + OrderDb orderDb = new OrderDb();
51 - String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr(); 48 + //生成分布式唯一值
52 - orderDb.setOrderCode(orderCode); 49 + String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
53 - orderDb.setEnterpriseId(createOrderRpcRequest.getEnterpriseId()); 50 + orderDb.setOrderCode(orderCode);
54 - orderDb.setClientId(createOrderRpcRequest.getCreation().getClientId()); 51 + orderDb.setEnterpriseId(createOrderRpcRequest.getEnterpriseId());
55 - orderDb.setStallId(createOrderRpcRequest.getCreation().getStallId()); 52 + orderDb.setClientId(createOrderRpcRequest.getCreation().getClientId());
56 - if (createOrderRpcRequest.getCreation().getShouldCreateCustomerId()) { 53 + orderDb.setStallId(createOrderRpcRequest.getCreation().getStallId());
57 - orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId()); 54 + if (createOrderRpcRequest.getCreation().getShouldCreateCustomerId()) {
58 - } 55 + orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
59 - if (createOrderRpcRequest.getCreation().getShouldCreateOpenId()) { 56 + }
60 - orderDb.setOpenId(createOrderRpcRequest.getCreation().getOpenId()); 57 + if (createOrderRpcRequest.getCreation().getShouldCreateOpenId()) {
61 - } 58 + orderDb.setOpenId(createOrderRpcRequest.getCreation().getOpenId());
62 - if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) { 59 + }
63 - orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId()); 60 + if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
64 - } 61 + orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
65 - orderDb.setStatus(createOrderRpcRequest.getCreation().getStatusValue()); 62 + }
66 - orderDb.setMenuId(createOrderRpcRequest.getCreation().getMenuId()); 63 + orderDb.setStatus(createOrderRpcRequest.getCreation().getStatusValue());
67 - orderDb.setTotalNum(createOrderRpcRequest.getCreation().getTotalNum()); 64 + orderDb.setMenuId(createOrderRpcRequest.getCreation().getMenuId());
68 - if (createOrderRpcRequest.getCreation().getShouldCreatePayPrice()) { 65 + orderDb.setTotalNum(createOrderRpcRequest.getCreation().getTotalNum());
69 - orderDb.setPayPrice(createOrderRpcRequest.getCreation().getPayPrice()); 66 + if (createOrderRpcRequest.getCreation().getShouldCreatePayPrice()) {
70 - } 67 + orderDb.setPayPrice(createOrderRpcRequest.getCreation().getPayPrice());
71 - if (createOrderRpcRequest.getCreation().getShouldCreatePayTime()) { 68 + }
72 - orderDb.setPayTime(Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getPayTime()) 69 + if (createOrderRpcRequest.getCreation().getShouldCreatePayTime()) {
73 - .atZone(ZoneId.systemDefault()) 70 + orderDb.setPayTime(Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getPayTime()).atZone(ZoneId.systemDefault()).toLocalDateTime());
74 - .toLocalDateTime()); 71 + }
75 - } 72 + if (createOrderRpcRequest.getCreation().getShouldCreateOnlinePay()) {
76 - if (createOrderRpcRequest.getCreation().getShouldCreateOnlinePay()) { 73 + orderDb.setOnlinePay(createOrderRpcRequest.getCreation().getOnlinePayValue());
77 - orderDb.setOnlinePay(createOrderRpcRequest.getCreation().getOnlinePayValue()); 74 + }
78 - } 75 + if (createOrderRpcRequest.getCreation().getShouldCreatePayStatus()) {
79 - if (createOrderRpcRequest.getCreation().getShouldCreatePayStatus()) { 76 + orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue());
80 - orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue()); 77 + }
81 - } 78 + if (createOrderRpcRequest.getCreation().getShouldCreateTransactionId()) {
82 - if (createOrderRpcRequest.getCreation().getShouldCreateTransactionId()) { 79 + orderDb.setTransactionId(createOrderRpcRequest.getCreation().getTransactionId());
83 - orderDb.setTransactionId(createOrderRpcRequest.getCreation().getTransactionId()); 80 + }
84 - } 81 + if (createOrderRpcRequest.getCreation().getShouldCreateErrorMsg()) {
85 - if (createOrderRpcRequest.getCreation().getShouldCreateErrorMsg()) { 82 + orderDb.setErrorMsg(createOrderRpcRequest.getCreation().getErrorMsg());
86 - orderDb.setErrorMsg(createOrderRpcRequest.getCreation().getErrorMsg()); 83 + }
87 - } 84 + if (createOrderRpcRequest.getCreation().getShouldCreateAddress()) {
88 - if (createOrderRpcRequest.getCreation().getShouldCreateAddress()) { 85 + orderDb.setAddress(createOrderRpcRequest.getCreation().getAddress());
89 - orderDb.setAddress(createOrderRpcRequest.getCreation().getAddress()); 86 + }
90 - } 87 + if (createOrderRpcRequest.getCreation().getShouldCreateRoomNo()) {
91 - if (createOrderRpcRequest.getCreation().getShouldCreateRoomNo()) { 88 + orderDb.setRoomNo(createOrderRpcRequest.getCreation().getRoomNo());
92 - orderDb.setRoomNo(createOrderRpcRequest.getCreation().getRoomNo()); 89 + }
93 - } 90 + if (createOrderRpcRequest.getCreation().getShouldCreateTableCode()) {
94 - if (createOrderRpcRequest.getCreation().getShouldCreateTableCode()) { 91 + orderDb.setTableCode(createOrderRpcRequest.getCreation().getTableCode());
95 - orderDb.setTableCode(createOrderRpcRequest.getCreation().getTableCode()); 92 + }
96 - } 93 + if (createOrderRpcRequest.getCreation().getShouldCreatePickupCode()) {
97 - if (createOrderRpcRequest.getCreation().getShouldCreatePickupCode()) { 94 + orderDb.setPickupCode(createOrderRpcRequest.getCreation().getPickupCode());
98 - orderDb.setPickupCode(createOrderRpcRequest.getCreation().getPickupCode()); 95 + }
99 - } 96 + if (createOrderRpcRequest.getCreation().getShouldCreateOrderType()) {
100 - if (createOrderRpcRequest.getCreation().getShouldCreateOrderType()) { 97 + orderDb.setOrderType(createOrderRpcRequest.getCreation().getOrderTypeValue());
101 - orderDb.setOrderType(createOrderRpcRequest.getCreation().getOrderTypeValue()); 98 + }
102 - } 99 + if (createOrderRpcRequest.getCreation().getShouldCreateRemark()) {
103 - if (createOrderRpcRequest.getCreation().getShouldCreateRemark()) { 100 + orderDb.setRemark(createOrderRpcRequest.getCreation().getRemark());
104 - orderDb.setRemark(createOrderRpcRequest.getCreation().getRemark()); 101 + }
105 - } 102 + ObjectMapper objectMapper = new ObjectMapper();
106 - ObjectMapper objectMapper = new ObjectMapper(); 103 + if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
107 - if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) { 104 + JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder()
108 - JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder() 105 + .avoids(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getAvoidsList())
109 - .avoids(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getAvoidsList()) 106 + .doctors(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getDoctorsList())
110 - .doctors(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getDoctorsList()) 107 + .build());
111 - .build()); 108 + orderDb.setCustomerNoticeJson(notice);
112 - orderDb.setCustomerNoticeJson(notice); 109 + }
113 - } 110 + LocalDateTime mealTime = Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getMealTime()).atOffset(ZoneOffset.UTC).toLocalDateTime();
114 - LocalDateTime mealTime = Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getMealTime()) 111 + orderDb.setMealTime(mealTime);
115 -// .atZone(ZoneId.systemDefault()) 112 + orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue());
116 - .atOffset(ZoneOffset.UTC) 113 + orderDb.setCreatedBy(createOrderRpcRequest.getCreatedBy());
117 - .toLocalDateTime(); 114 + orderDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue());
118 - orderDb.setMealTime(mealTime); 115 + orderDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy());
119 - orderDb.setPayStatus(createOrderRpcRequest.getCreation().getOnlinePay() == OnlinePayEnum.ONLINE ? PayStatusEnum.TO_PAY_VALUE : PayStatusEnum.SUCCEED_VALUE); 116 + orderDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue());
120 - orderDb.setCreatedBy(createOrderRpcRequest.getCreatedBy()); 117 + orderDb.setCloseTimeType(createOrderRpcRequest.getCreation().getCloseTimeTypeValue());
121 - orderDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue()); 118 + orderDb.setIsRead(createOrderRpcRequest.getCreation().getIsRead());
122 - orderDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy()); 119 + orderDb.setIsDeleted(false);
123 - orderDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue()); 120 + orderDb.setIsConfirm(false);
124 - orderDb.setCloseTimeType(createOrderRpcRequest.getCreation().getCloseTimeTypeValue()); 121 + orderDb.setIsAllocation(false);
125 - orderDb.setIsRead(createOrderRpcRequest.getCreation().getIsRead()); 122 + boolean res = this.save(orderDb);
126 - orderDb.setIsDeleted(false); 123 + if (!res) {
127 - orderDb.setIsConfirm(false); 124 + throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
128 - orderDb.setIsAllocation(false); 125 + }
129 - 126 + if (createOrderRpcRequest.getCreation().getShouldCreateOrderDetails()) {
130 - boolean res = this.save(orderDb); 127 + var detailList = createOrderRpcRequest.getCreation().getOrderDetailsList().stream()
131 - if (!res) { 128 + .map(detailCreation -> {
132 - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL); 129 + OrderDetailDb orderDetailDb = new OrderDetailDb();
133 - } 130 + orderDetailDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue());
134 - if (createOrderRpcRequest.getCreation().getShouldCreateOrderDetails()) { 131 + orderDetailDb.setCreatedBy(createOrderRpcRequest.getCreatedBy());
135 - var detailList = createOrderRpcRequest.getCreation().getOrderDetailsList().stream() 132 + orderDetailDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue());
136 - .map(detailCreation -> { 133 + orderDetailDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy());
137 - OrderDetailDb orderDetailDb = new OrderDetailDb(); 134 + orderDetailDb.setOrderId(orderDb.getId());
138 - orderDetailDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue()); 135 + orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
139 - orderDetailDb.setCreatedBy(createOrderRpcRequest.getCreatedBy()); 136 + orderDetailDb.setCount(detailCreation.getCount());
140 - orderDetailDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue()); 137 + orderDetailDb.setMealId(detailCreation.getMealId());
141 - orderDetailDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy()); 138 + orderDetailDb.setCategoryId(detailCreation.getCategoryId());
142 - orderDetailDb.setOrderId(orderDb.getId()); 139 + orderDetailDb.setSkuId(detailCreation.getSkuId());
143 - orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId()); 140 + orderDetailDb.setEnterpriseId(orderDb.getEnterpriseId());
144 - orderDetailDb.setCount(detailCreation.getCount()); 141 + orderDetailDb.setIsDeleted(false);
145 - orderDetailDb.setMealId(detailCreation.getMealId()); 142 + if (detailCreation.getShouldCreateShowName()) {
146 - orderDetailDb.setCategoryId(detailCreation.getCategoryId()); 143 + orderDetailDb.setShowName(detailCreation.getShowName());
147 - orderDetailDb.setSkuId(detailCreation.getSkuId()); 144 + }
148 - orderDetailDb.setEnterpriseId(orderDb.getEnterpriseId()); 145 + if (detailCreation.getShouldCreatePrice()) {
149 - orderDetailDb.setIsDeleted(false); 146 + orderDetailDb.setPrice(detailCreation.getPrice());
150 - if (detailCreation.getShouldCreateShowName()) { 147 + }
151 - orderDetailDb.setShowName(detailCreation.getShowName()); 148 + if (detailCreation.getShouldCreateAdjustSkuRemark()) {
152 - } 149 + orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
153 - if (detailCreation.getShouldCreatePrice()) { 150 + }
154 - orderDetailDb.setPrice(detailCreation.getPrice()); 151 + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
155 - } 152 + if (detailCreation.getShouldCreateMealDetailJson()) {
156 - if (detailCreation.getShouldCreateAdjustSkuRemark()) { 153 + orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
157 - orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); 154 + .allergies(detailCreation.getMealDetailJson().getAllergiesList())
158 - } 155 + .avoids(detailCreation.getMealDetailJson().getAvoidsList())
159 - orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); 156 + .basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
160 - if (detailCreation.getShouldCreateMealDetailJson()) { 157 + .carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
161 - orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() 158 + .dockers(detailCreation.getMealDetailJson().getDockersList())
162 - .allergies(detailCreation.getMealDetailJson().getAllergiesList()) 159 + .efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
163 - .avoids(detailCreation.getMealDetailJson().getAvoidsList()) 160 + .energy(detailCreation.getMealDetailJson().getEnergy())
164 - .basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials()) 161 + .fat(detailCreation.getMealDetailJson().getFat())
165 - .carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate()) 162 + .protein(detailCreation.getMealDetailJson().getProtein())
166 - .dockers(detailCreation.getMealDetailJson().getDockersList()) 163 + .skus(detailCreation.getMealDetailJson().getSkusList())
167 - .efficacies(detailCreation.getMealDetailJson().getEfficaciesList()) 164 + .tastes(detailCreation.getMealDetailJson().getTastesList())
168 - .energy(detailCreation.getMealDetailJson().getEnergy()) 165 + .build()));
169 - .fat(detailCreation.getMealDetailJson().getFat()) 166 + }
170 - .protein(detailCreation.getMealDetailJson().getProtein()) 167 + return orderDetailDb;
171 - .skus(detailCreation.getMealDetailJson().getSkusList()) 168 + })
172 - .tastes(detailCreation.getMealDetailJson().getTastesList()) 169 + .collect(Collectors.toList());
173 - .build()));//detailCreation.getMealDetailJson() 170 + List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class).saveBatch(detailList) ? detailList : Collections.emptyList();
174 - } 171 + if (resOrderDetails.size() != createOrderRpcRequest.getCreation().getOrderDetailsCount()) {
175 - return orderDetailDb; 172 + throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
176 - }) 173 + }
177 - .collect(Collectors.toList()); 174 + }
178 - List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class) 175 + return orderDb;
179 - .saveBatch(detailList) ? detailList : Collections.emptyList();
180 -
181 - if (resOrderDetails.size() != createOrderRpcRequest.getCreation().getOrderDetailsCount()) {
182 - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
183 - }
184 } 176 }
185 - return orderDb;
186 - }
187 177
188 - @Override 178 + @Override
189 - public List<OrderDb> batchCreateOrderDbs( 179 + public List<OrderDb> batchCreateOrderDbs(
190 - BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest) { 180 + BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest) {
191 - ObjectMapper objectMapper = new ObjectMapper(); 181 + ObjectMapper objectMapper = new ObjectMapper();
192 // var orderList = batchCreateOrdersRequest.getCreationsList().stream() 182 // var orderList = batchCreateOrdersRequest.getCreationsList().stream()
193 // .map(creation ->{ 183 // .map(creation ->{
194 // OrderDb orderDb = new OrderDb(); 184 // OrderDb orderDb = new OrderDb();
...@@ -272,356 +262,355 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl ...@@ -272,356 +262,355 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
272 // if (resOrders.size() != batchCreateOrdersRequest.getCreationsCount()) { 262 // if (resOrders.size() != batchCreateOrdersRequest.getCreationsCount()) {
273 // throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL); 263 // throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
274 // } 264 // }
275 - List<OrderDb> resOrders = new ArrayList<>(); 265 + List<OrderDb> resOrders = new ArrayList<>();
276 - for(ClientCustomerOrderCreation creation: batchCreateOrdersRequest.getCreationsList()){ 266 + for (ClientCustomerOrderCreation creation : batchCreateOrdersRequest.getCreationsList()) {
277 - OrderDb orderDb = new OrderDb(); 267 + OrderDb orderDb = new OrderDb();
278 - String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr(); 268 + String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
279 - orderDb.setOrderCode(orderCode); 269 + orderDb.setOrderCode(orderCode);
280 - orderDb.setEnterpriseId(batchCreateOrdersRequest.getEnterpriseId()); 270 + orderDb.setEnterpriseId(batchCreateOrdersRequest.getEnterpriseId());
281 - orderDb.setClientId(creation.getClientId()); 271 + orderDb.setClientId(creation.getClientId());
282 - orderDb.setStallId(creation.getStallId()); 272 + orderDb.setStallId(creation.getStallId());
283 - if (creation.getShouldCreateOpenId()) { 273 + if (creation.getShouldCreateOpenId()) {
284 - orderDb.setOpenId(creation.getOpenId()); 274 + orderDb.setOpenId(creation.getOpenId());
285 - } 275 + }
286 - if (creation.getShouldCreateCustomerNoticeJson()) 276 + if (creation.getShouldCreateCustomerNoticeJson()) {
287 - { 277 + orderDb.setCustomerId(creation.getCustomerId());
288 - orderDb.setCustomerId(creation.getCustomerId()); 278 + }
289 - } 279 + orderDb.setStatus(creation.getStatusValue());
290 - orderDb.setStatus(creation.getStatusValue()); 280 + orderDb.setMenuId(creation.getMenuId());
291 - orderDb.setMenuId(creation.getMenuId()); 281 + orderDb.setTotalNum(creation.getTotalNum());
292 - orderDb.setTotalNum(creation.getTotalNum()); 282 + if (creation.getShouldCreatePayPrice()) {
293 - if (creation.getShouldCreatePayPrice()) { 283 + orderDb.setPayPrice(creation.getPayPrice());
294 - orderDb.setPayPrice(creation.getPayPrice()); 284 + }
295 - } 285 + if (creation.getShouldCreatePayTime()) {
296 - if (creation.getShouldCreatePayTime()) { 286 + orderDb.setPayTime(Instant.ofEpochMilli(creation.getPayTime())
297 - orderDb.setPayTime(Instant.ofEpochMilli(creation.getPayTime()) 287 + .atZone(ZoneId.systemDefault())
298 - .atZone(ZoneId.systemDefault()) 288 + .toLocalDateTime());
299 - .toLocalDateTime()); 289 + }
300 - } 290 + if (creation.getShouldCreateOnlinePay()) {
301 - if (creation.getShouldCreateOnlinePay()) { 291 + orderDb.setOnlinePay(creation.getOnlinePayValue());
302 - orderDb.setOnlinePay(creation.getOnlinePayValue()); 292 + }
303 - } 293 + if (creation.getShouldCreatePayStatus()) {
304 - if (creation.getShouldCreatePayStatus()) { 294 + orderDb.setPayStatus(creation.getPayStatusValue());
305 - orderDb.setPayStatus(creation.getPayStatusValue()); 295 + }
306 - } 296 + if (creation.getShouldCreateTransactionId()) {
307 - if (creation.getShouldCreateTransactionId()) { 297 + orderDb.setTransactionId(creation.getTransactionId());
308 - orderDb.setTransactionId(creation.getTransactionId()); 298 + }
309 - } 299 + if (creation.getShouldCreateErrorMsg()) {
310 - if (creation.getShouldCreateErrorMsg()) { 300 + orderDb.setErrorMsg(creation.getErrorMsg());
311 - orderDb.setErrorMsg(creation.getErrorMsg()); 301 + }
312 - } 302 + if (creation.getShouldCreateAddress()) {
313 - if (creation.getShouldCreateAddress()) { 303 + orderDb.setAddress(creation.getAddress());
314 - orderDb.setAddress(creation.getAddress()); 304 + }
315 - } 305 + if (creation.getShouldCreateRoomNo()) {
316 - if (creation.getShouldCreateRoomNo()) { 306 + orderDb.setRoomNo(creation.getRoomNo());
317 - orderDb.setRoomNo(creation.getRoomNo()); 307 + }
318 - } 308 + if (creation.getShouldCreateTableCode()) {
319 - if (creation.getShouldCreateTableCode()) { 309 + orderDb.setTableCode(creation.getTableCode());
320 - orderDb.setTableCode(creation.getTableCode()); 310 + }
321 - } 311 + if (creation.getShouldCreatePickupCode()) {
322 - if (creation.getShouldCreatePickupCode()) { 312 + orderDb.setPickupCode(creation.getPickupCode());
323 - orderDb.setPickupCode(creation.getPickupCode()); 313 + }
324 - } 314 + if (creation.getShouldCreateOrderType()) {
325 - if (creation.getShouldCreateOrderType()) { 315 + orderDb.setOrderType(creation.getOrderTypeValue());
326 - orderDb.setOrderType(creation.getOrderTypeValue()); 316 + }
327 - } 317 + if (creation.getShouldCreateRemark()) {
328 - if (creation.getShouldCreateRemark()) { 318 + orderDb.setRemark(creation.getRemark());
329 - orderDb.setRemark(creation.getRemark()); 319 + }
330 - } 320 + if (creation.getShouldCreateCustomerNoticeJson()) {
331 - if (creation.getShouldCreateCustomerNoticeJson()) { 321 + JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder()
332 - JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder() 322 + .avoids(creation.getCustomerNoticeJson().getAvoidsList())
333 - .avoids(creation.getCustomerNoticeJson().getAvoidsList()) 323 + .doctors(creation.getCustomerNoticeJson().getDoctorsList())
334 - .doctors(creation.getCustomerNoticeJson().getDoctorsList()) 324 + .build());
335 - .build()); 325 + orderDb.setCustomerNoticeJson(notice);
336 - orderDb.setCustomerNoticeJson(notice); 326 + }
337 - } 327 + LocalDateTime mealTime = Instant.ofEpochMilli(creation.getMealTime())
338 - LocalDateTime mealTime = Instant.ofEpochMilli(creation.getMealTime()) 328 + .atZone(ZoneId.systemDefault())
339 - .atZone(ZoneId.systemDefault()) 329 + .toLocalDateTime();
340 - .toLocalDateTime(); 330 + orderDb.setMealTime(mealTime);
341 - orderDb.setMealTime(mealTime); 331 + orderDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy());
342 - orderDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy()); 332 + orderDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue());
343 - orderDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue()); 333 + orderDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy());
344 - orderDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy()); 334 + orderDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue());
345 - orderDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue()); 335 + orderDb.setCloseTimeType(creation.getCloseTimeTypeValue());
346 - orderDb.setCloseTimeType(creation.getCloseTimeTypeValue()); 336 + orderDb.setIsRead(creation.getIsRead());
347 - orderDb.setIsRead(creation.getIsRead()); 337 + orderDb.setIsDeleted(false);
348 - orderDb.setIsDeleted(false); 338 + orderDb.setIsConfirm(false);
349 - orderDb.setIsConfirm(false); 339 + orderDb.setIsAllocation(false);
350 - orderDb.setIsAllocation(false); 340 + boolean res = this.save(orderDb);
351 - boolean res = this.save(orderDb); 341 + if (!res) {
352 - if (!res) { 342 + throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
353 - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL); 343 + }
354 - } 344 + resOrders.add(orderDb);
355 - resOrders.add(orderDb);
356 345
357 - if (creation.getShouldCreateOrderDetails()) { 346 + if (creation.getShouldCreateOrderDetails()) {
358 - var detailList = creation.getOrderDetailsList().stream() 347 + var detailList = creation.getOrderDetailsList().stream()
359 - .map(detailCreation -> { 348 + .map(detailCreation -> {
360 - OrderDetailDb orderDetailDb = new OrderDetailDb(); 349 + OrderDetailDb orderDetailDb = new OrderDetailDb();
361 - orderDetailDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue()); 350 + orderDetailDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue());
362 - orderDetailDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy()); 351 + orderDetailDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy());
363 - orderDetailDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue()); 352 + orderDetailDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue());
364 - orderDetailDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy()); 353 + orderDetailDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy());
365 - orderDetailDb.setOrderId(orderDb.getId()); 354 + orderDetailDb.setOrderId(orderDb.getId());
366 - orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId()); 355 + orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
367 - orderDetailDb.setCount(detailCreation.getCount()); 356 + orderDetailDb.setCount(detailCreation.getCount());
368 - orderDetailDb.setMealId(detailCreation.getMealId()); 357 + orderDetailDb.setMealId(detailCreation.getMealId());
369 - orderDetailDb.setCategoryId(detailCreation.getCategoryId()); 358 + orderDetailDb.setCategoryId(detailCreation.getCategoryId());
370 - orderDetailDb.setSkuId(detailCreation.getSkuId()); 359 + orderDetailDb.setSkuId(detailCreation.getSkuId());
371 - orderDetailDb.setIsDeleted(false); 360 + orderDetailDb.setIsDeleted(false);
372 - if (detailCreation.getShouldCreateShowName()) { 361 + if (detailCreation.getShouldCreateShowName()) {
373 - orderDetailDb.setShowName(detailCreation.getShowName()); 362 + orderDetailDb.setShowName(detailCreation.getShowName());
374 - } 363 + }
375 - if (detailCreation.getShouldCreatePrice()) { 364 + if (detailCreation.getShouldCreatePrice()) {
376 - orderDetailDb.setPrice(detailCreation.getPrice()); 365 + orderDetailDb.setPrice(detailCreation.getPrice());
377 - } 366 + }
378 - if (detailCreation.getShouldCreateAdjustSkuRemark()) { 367 + if (detailCreation.getShouldCreateAdjustSkuRemark()) {
379 - orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark()); 368 + orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
380 - } 369 + }
381 - orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE); 370 + orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
382 - if (detailCreation.getShouldCreateMealDetailJson()) { 371 + if (detailCreation.getShouldCreateMealDetailJson()) {
383 - orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder() 372 + orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
384 - .allergies(detailCreation.getMealDetailJson().getAllergiesList()) 373 + .allergies(detailCreation.getMealDetailJson().getAllergiesList())
385 - .avoids(detailCreation.getMealDetailJson().getAvoidsList()) 374 + .avoids(detailCreation.getMealDetailJson().getAvoidsList())
386 - .basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials()) 375 + .basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
387 - .carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate()) 376 + .carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
388 - .dockers(detailCreation.getMealDetailJson().getDockersList()) 377 + .dockers(detailCreation.getMealDetailJson().getDockersList())
389 - .efficacies(detailCreation.getMealDetailJson().getEfficaciesList()) 378 + .efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
390 - .energy(detailCreation.getMealDetailJson().getEnergy()) 379 + .energy(detailCreation.getMealDetailJson().getEnergy())
391 - .fat(detailCreation.getMealDetailJson().getFat()) 380 + .fat(detailCreation.getMealDetailJson().getFat())
392 - .protein(detailCreation.getMealDetailJson().getProtein()) 381 + .protein(detailCreation.getMealDetailJson().getProtein())
393 - .skus(detailCreation.getMealDetailJson().getSkusList()) 382 + .skus(detailCreation.getMealDetailJson().getSkusList())
394 - .tastes(detailCreation.getMealDetailJson().getTastesList()) 383 + .tastes(detailCreation.getMealDetailJson().getTastesList())
395 - .build())); 384 + .build()));
396 - } 385 + }
397 - return orderDetailDb; 386 + return orderDetailDb;
398 - }) 387 + })
399 - .collect(Collectors.toList()); 388 + .collect(Collectors.toList());
400 - List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class) 389 + List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
401 - .saveBatch(detailList) ? detailList : Collections.emptyList(); 390 + .saveBatch(detailList) ? detailList : Collections.emptyList();
402 391
403 - if (resOrderDetails.size() != creation.getOrderDetailsCount()) { 392 + if (resOrderDetails.size() != creation.getOrderDetailsCount()) {
404 - throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL); 393 + throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
394 + }
395 + }
405 } 396 }
406 - } 397 + return resOrders;
407 } 398 }
408 - return resOrders;
409 - }
410 399
411 - @Override 400 + @Override
412 - public List<OrderDb> getOrdersByCustomerId(Integer customerId) { 401 + public List<OrderDb> getOrdersByCustomerId(Integer customerId) {
413 - QueryWrapper<OrderDb> wrapper = new QueryWrapper<>(); 402 + QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
414 - wrapper.eq("customerId", customerId) 403 + wrapper.eq("customerId", customerId)
415 - .orderByDesc("createdAt"); 404 + .orderByDesc("createdAt");
416 - final var res = orderDbMapper.selectList(wrapper); 405 + final var res = orderDbMapper.selectList(wrapper);
417 - return res; 406 + return res;
418 - } 407 + }
419 408
420 - @Override 409 + @Override
421 - public Boolean updateOrderDb(UpdateClientCustomerOrderRpcRequest updateOrderRequest) { 410 + public Boolean updateOrderDb(UpdateClientCustomerOrderRpcRequest updateOrderRequest) {
422 - var orderDb = new OrderDb(); 411 + var orderDb = new OrderDb();
423 - orderDb.setId(updateOrderRequest.getModification().getId()); 412 + orderDb.setId(updateOrderRequest.getModification().getId());
424 - orderDb.setEnterpriseId(updateOrderRequest.getEnterpriseId()); 413 + orderDb.setEnterpriseId(updateOrderRequest.getEnterpriseId());
425 - orderDb.setUpdatedBy(updateOrderRequest.getUpdatedBy()); 414 + orderDb.setUpdatedBy(updateOrderRequest.getUpdatedBy());
426 - orderDb.setUpdateSource(updateOrderRequest.getUpdateSourceValue()); 415 + orderDb.setUpdateSource(updateOrderRequest.getUpdateSourceValue());
427 416
428 - if (updateOrderRequest.getModification().getShouldUpdateOrderCode()) { 417 + if (updateOrderRequest.getModification().getShouldUpdateOrderCode()) {
429 - orderDb.setOrderCode(updateOrderRequest.getModification().getOrderCode()); 418 + orderDb.setOrderCode(updateOrderRequest.getModification().getOrderCode());
430 - } 419 + }
431 - if (updateOrderRequest.getModification().getShouldUpdateClientId()) { 420 + if (updateOrderRequest.getModification().getShouldUpdateClientId()) {
432 - orderDb.setClientId(updateOrderRequest.getModification().getClientId()); 421 + orderDb.setClientId(updateOrderRequest.getModification().getClientId());
433 - } 422 + }
434 - if (updateOrderRequest.getModification().getShouldUpdateStallId()) { 423 + if (updateOrderRequest.getModification().getShouldUpdateStallId()) {
435 - orderDb.setStallId(updateOrderRequest.getModification().getStallId()); 424 + orderDb.setStallId(updateOrderRequest.getModification().getStallId());
436 - } 425 + }
437 - if (updateOrderRequest.getModification().getShouldUpdateCustomerId()) { 426 + if (updateOrderRequest.getModification().getShouldUpdateCustomerId()) {
438 - orderDb.setCustomerId(updateOrderRequest.getModification().getCustomerId()); 427 + orderDb.setCustomerId(updateOrderRequest.getModification().getCustomerId());
439 - } 428 + }
440 - if (updateOrderRequest.getModification().getShouldUpdateOpenId()) { 429 + if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
441 - orderDb.setOpenId(updateOrderRequest.getModification().getOpenId()); 430 + orderDb.setOpenId(updateOrderRequest.getModification().getOpenId());
442 - } 431 + }
443 - if (updateOrderRequest.getModification().getShouldUpdateStatus()) { 432 + if (updateOrderRequest.getModification().getShouldUpdateStatus()) {
444 - orderDb.setStatus(updateOrderRequest.getModification().getStatusValue()); // 假设OrderStatusEnum有getValue方法获取对应整数值 433 + orderDb.setStatus(updateOrderRequest.getModification().getStatusValue()); // 假设OrderStatusEnum有getValue方法获取对应整数值
445 - } 434 + }
446 - if (updateOrderRequest.getModification().getShouldUpdateMenuId()) { 435 + if (updateOrderRequest.getModification().getShouldUpdateMenuId()) {
447 - orderDb.setMenuId(updateOrderRequest.getModification().getMenuId()); 436 + orderDb.setMenuId(updateOrderRequest.getModification().getMenuId());
448 - } 437 + }
449 - if (updateOrderRequest.getModification().getShouldUpdateCloseTimeType()) { 438 + if (updateOrderRequest.getModification().getShouldUpdateCloseTimeType()) {
450 - orderDb.setCloseTimeType(updateOrderRequest.getModification().getCloseTimeTypeValue()); // 假设CloseTimeType有getValue方法获取对应整数值 439 + orderDb.setCloseTimeType(updateOrderRequest.getModification().getCloseTimeTypeValue()); // 假设CloseTimeType有getValue方法获取对应整数值
451 - } 440 + }
452 - if (updateOrderRequest.getModification().getShouldUpdateTotalNum()) { 441 + if (updateOrderRequest.getModification().getShouldUpdateTotalNum()) {
453 - orderDb.setTotalNum(updateOrderRequest.getModification().getTotalNum()); 442 + orderDb.setTotalNum(updateOrderRequest.getModification().getTotalNum());
454 - } 443 + }
455 - if (updateOrderRequest.getModification().getShouldUpdatePayPrice()) { 444 + if (updateOrderRequest.getModification().getShouldUpdatePayPrice()) {
456 - orderDb.setPayPrice(updateOrderRequest.getModification().getPayPrice()); 445 + orderDb.setPayPrice(updateOrderRequest.getModification().getPayPrice());
457 - } 446 + }
458 - if (updateOrderRequest.getModification().getShouldUpdateOnlinePay()) { 447 + if (updateOrderRequest.getModification().getShouldUpdateOnlinePay()) {
459 - orderDb.setOnlinePay(updateOrderRequest.getModification().getOnlinePayValue()); 448 + orderDb.setOnlinePay(updateOrderRequest.getModification().getOnlinePayValue());
460 - } 449 + }
461 - if (updateOrderRequest.getModification().getShouldUpdatePayTime()) { 450 + if (updateOrderRequest.getModification().getShouldUpdatePayTime()) {
462 - orderDb.setPayTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getPayTime()) 451 + orderDb.setPayTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getPayTime())
463 - .atZone(ZoneId.systemDefault()) 452 + .atZone(ZoneId.systemDefault())
464 - .toLocalDateTime()); 453 + .toLocalDateTime());
465 - } 454 + }
466 - if (updateOrderRequest.getModification().getShouldUpdatePayStatus()) { 455 + if (updateOrderRequest.getModification().getShouldUpdatePayStatus()) {
467 - orderDb.setPayStatus(updateOrderRequest.getModification().getPayStatusValue()); // 假设PayStatusEnum有getValue方法获取对应整数值 456 + orderDb.setPayStatus(updateOrderRequest.getModification().getPayStatusValue()); // 假设PayStatusEnum有getValue方法获取对应整数值
468 - } 457 + }
469 - if (updateOrderRequest.getModification().getShouldUpdateErrorMsg()) { 458 + if (updateOrderRequest.getModification().getShouldUpdateErrorMsg()) {
470 - orderDb.setErrorMsg(updateOrderRequest.getModification().getErrorMsg()); 459 + orderDb.setErrorMsg(updateOrderRequest.getModification().getErrorMsg());
471 - } 460 + }
472 - if (updateOrderRequest.getModification().getShouldUpdateTransactionId()) { 461 + if (updateOrderRequest.getModification().getShouldUpdateTransactionId()) {
473 - orderDb.setTransactionId(updateOrderRequest.getModification().getTransactionId()); 462 + orderDb.setTransactionId(updateOrderRequest.getModification().getTransactionId());
474 - } 463 + }
475 - if (updateOrderRequest.getModification().getShouldUpdateMealTime()) { 464 + if (updateOrderRequest.getModification().getShouldUpdateMealTime()) {
476 - orderDb.setMealTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getMealTime()) 465 + orderDb.setMealTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getMealTime())
477 - .atZone(ZoneId.systemDefault()) 466 + .atZone(ZoneId.systemDefault())
478 - .toLocalDateTime()); 467 + .toLocalDateTime());
479 - } 468 + }
480 - if (updateOrderRequest.getModification().getShouldUpdateAddress()) { 469 + if (updateOrderRequest.getModification().getShouldUpdateAddress()) {
481 - orderDb.setAddress(updateOrderRequest.getModification().getAddress()); 470 + orderDb.setAddress(updateOrderRequest.getModification().getAddress());
482 - } 471 + }
483 - if (updateOrderRequest.getModification().getShouldUpdateRoomNo()) { 472 + if (updateOrderRequest.getModification().getShouldUpdateRoomNo()) {
484 - orderDb.setRoomNo(updateOrderRequest.getModification(). 473 + orderDb.setRoomNo(updateOrderRequest.getModification().
485 - getRoomNo()); 474 + getRoomNo());
486 - } 475 + }
487 - if (updateOrderRequest.getModification().getShouldUpdateTableCode()) { 476 + if (updateOrderRequest.getModification().getShouldUpdateTableCode()) {
488 - orderDb.setTableCode(updateOrderRequest.getModification().getTableCode()); 477 + orderDb.setTableCode(updateOrderRequest.getModification().getTableCode());
489 - } 478 + }
490 - if (updateOrderRequest.getModification().getShouldUpdatePickupCode()) { 479 + if (updateOrderRequest.getModification().getShouldUpdatePickupCode()) {
491 - orderDb.setPickupCode(updateOrderRequest.getModification().getPickupCode()); 480 + orderDb.setPickupCode(updateOrderRequest.getModification().getPickupCode());
492 - } 481 + }
493 - if (updateOrderRequest.getModification().getShouldUpdateOrderType()) { 482 + if (updateOrderRequest.getModification().getShouldUpdateOrderType()) {
494 - orderDb.setOrderType(updateOrderRequest.getModification().getOrderTypeValue()); 483 + orderDb.setOrderType(updateOrderRequest.getModification().getOrderTypeValue());
495 - } 484 + }
496 - if (updateOrderRequest.getModification().getShouldUpdateRemark()) { 485 + if (updateOrderRequest.getModification().getShouldUpdateRemark()) {
497 - orderDb.setRemark(updateOrderRequest.getModification().getRemark()); 486 + orderDb.setRemark(updateOrderRequest.getModification().getRemark());
498 - } 487 + }
499 - ObjectMapper objectMapper = new ObjectMapper(); 488 + ObjectMapper objectMapper = new ObjectMapper();
500 - if (updateOrderRequest.getModification().getShouldUpdateCustomerNoticeJson()) { 489 + if (updateOrderRequest.getModification().getShouldUpdateCustomerNoticeJson()) {
501 - orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder() 490 + orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
502 - .avoids(updateOrderRequest.getModification().getCustomerNoticeJson().getAvoidsList()) 491 + .avoids(updateOrderRequest.getModification().getCustomerNoticeJson().getAvoidsList())
503 - .doctors(updateOrderRequest.getModification().getCustomerNoticeJson().getDoctorsList()) 492 + .doctors(updateOrderRequest.getModification().getCustomerNoticeJson().getDoctorsList())
504 - .build())); 493 + .build()));
505 - } 494 + }
506 - if (updateOrderRequest.getModification().getShouldUpdateIsRead()) { 495 + if (updateOrderRequest.getModification().getShouldUpdateIsRead()) {
507 - orderDb.setIsRead(updateOrderRequest.getModification().getIsRead()); 496 + orderDb.setIsRead(updateOrderRequest.getModification().getIsRead());
508 - } 497 + }
509 - if (updateOrderRequest.getModification().getShouldUpdateOpenId()) { 498 + if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
510 - orderDb.setIsConfirm(updateOrderRequest.getModification().getIsConfirm()); 499 + orderDb.setIsConfirm(updateOrderRequest.getModification().getIsConfirm());
511 - } 500 + }
512 - if (updateOrderRequest.getModification().getShouldUpdateIsAllocation()) { 501 + if (updateOrderRequest.getModification().getShouldUpdateIsAllocation()) {
513 - orderDb.setIsAllocation(updateOrderRequest.getModification().getIsAllocation()); 502 + orderDb.setIsAllocation(updateOrderRequest.getModification().getIsAllocation());
503 + }
504 + return orderDbMapper.updateById(orderDb) > 0;
514 } 505 }
515 - return orderDbMapper.updateById(orderDb) > 0;
516 - }
517 506
518 - @Override 507 + @Override
519 - public Boolean batchUpdateOrderDbs( 508 + public Boolean batchUpdateOrderDbs(
520 - BatchUpdateClientCustomerOrdersRpcRequest batchUpdateOrdersRequest) { 509 + BatchUpdateClientCustomerOrdersRpcRequest batchUpdateOrdersRequest) {
521 - final var list = batchUpdateOrdersRequest.getModificationsList().stream().map(modification -> { 510 + final var list = batchUpdateOrdersRequest.getModificationsList().stream().map(modification -> {
522 - var orderDb = new OrderDb(); 511 + var orderDb = new OrderDb();
523 - orderDb.setId(modification.getId()); 512 + orderDb.setId(modification.getId());
524 - orderDb.setEnterpriseId(batchUpdateOrdersRequest.getEnterpriseId()); 513 + orderDb.setEnterpriseId(batchUpdateOrdersRequest.getEnterpriseId());
525 - orderDb.setUpdatedBy(batchUpdateOrdersRequest.getUpdatedBy()); 514 + orderDb.setUpdatedBy(batchUpdateOrdersRequest.getUpdatedBy());
526 - orderDb.setUpdateSource(batchUpdateOrdersRequest.getUpdateSourceValue()); 515 + orderDb.setUpdateSource(batchUpdateOrdersRequest.getUpdateSourceValue());
527 - if (modification.getShouldUpdateOrderCode()) { 516 + if (modification.getShouldUpdateOrderCode()) {
528 - orderDb.setOrderCode(modification.getOrderCode()); 517 + orderDb.setOrderCode(modification.getOrderCode());
529 - } 518 + }
530 - if (modification.getShouldUpdateClientId()) { 519 + if (modification.getShouldUpdateClientId()) {
531 - orderDb.setClientId(modification.getClientId()); 520 + orderDb.setClientId(modification.getClientId());
532 - } 521 + }
533 - if (modification.getShouldUpdateStallId()) { 522 + if (modification.getShouldUpdateStallId()) {
534 - orderDb.setStallId(modification.getStallId()); 523 + orderDb.setStallId(modification.getStallId());
535 - } 524 + }
536 - if (modification.getShouldUpdateCustomerId()) { 525 + if (modification.getShouldUpdateCustomerId()) {
537 - orderDb.setCustomerId(modification.getCustomerId()); 526 + orderDb.setCustomerId(modification.getCustomerId());
538 - } 527 + }
539 - if (modification.getShouldUpdateOpenId()) { 528 + if (modification.getShouldUpdateOpenId()) {
540 - orderDb.setOpenId(modification.getOpenId()); 529 + orderDb.setOpenId(modification.getOpenId());
541 - } 530 + }
542 - if (modification.getShouldUpdateStatus()) { 531 + if (modification.getShouldUpdateStatus()) {
543 - orderDb.setStatus(modification.getStatusValue()); 532 + orderDb.setStatus(modification.getStatusValue());
544 - } 533 + }
545 - if (modification.getShouldUpdateMenuId()) { 534 + if (modification.getShouldUpdateMenuId()) {
546 - orderDb.setMenuId(modification.getMenuId()); 535 + orderDb.setMenuId(modification.getMenuId());
547 - } 536 + }
548 - if (modification.getShouldUpdateCloseTimeType()) { 537 + if (modification.getShouldUpdateCloseTimeType()) {
549 - orderDb.setCloseTimeType(modification.getCloseTimeTypeValue()); 538 + orderDb.setCloseTimeType(modification.getCloseTimeTypeValue());
550 - } 539 + }
551 - if (modification.getShouldUpdateTotalNum()) { 540 + if (modification.getShouldUpdateTotalNum()) {
552 - orderDb.setTotalNum(modification.getTotalNum()); 541 + orderDb.setTotalNum(modification.getTotalNum());
553 - } 542 + }
554 - if (modification.getShouldUpdatePayPrice()) { 543 + if (modification.getShouldUpdatePayPrice()) {
555 - orderDb.setPayPrice(modification.getPayPrice()); 544 + orderDb.setPayPrice(modification.getPayPrice());
556 - } 545 + }
557 - if (modification.getShouldUpdateOnlinePay()) { 546 + if (modification.getShouldUpdateOnlinePay()) {
558 - orderDb.setOnlinePay(modification.getOnlinePayValue()); 547 + orderDb.setOnlinePay(modification.getOnlinePayValue());
559 - } 548 + }
560 - if (modification.getShouldUpdatePayTime()) { 549 + if (modification.getShouldUpdatePayTime()) {
561 - orderDb.setPayTime(Instant.ofEpochMilli(modification.getPayTime()) 550 + orderDb.setPayTime(Instant.ofEpochMilli(modification.getPayTime())
562 - .atZone(ZoneId.systemDefault()) 551 + .atZone(ZoneId.systemDefault())
563 - .toLocalDateTime()); 552 + .toLocalDateTime());
564 - } 553 + }
565 - if (modification.getShouldUpdatePayStatus()) { 554 + if (modification.getShouldUpdatePayStatus()) {
566 - orderDb.setPayStatus(modification.getPayStatusValue()); 555 + orderDb.setPayStatus(modification.getPayStatusValue());
567 - } 556 + }
568 - if (modification.getShouldUpdateErrorMsg()) { 557 + if (modification.getShouldUpdateErrorMsg()) {
569 - orderDb.setErrorMsg(modification.getErrorMsg()); 558 + orderDb.setErrorMsg(modification.getErrorMsg());
570 - } 559 + }
571 - if (modification.getShouldUpdateTransactionId()) { 560 + if (modification.getShouldUpdateTransactionId()) {
572 - orderDb.setTransactionId(modification.getTransactionId()); 561 + orderDb.setTransactionId(modification.getTransactionId());
573 - } 562 + }
574 - if (modification.getShouldUpdateMealTime()) { 563 + if (modification.getShouldUpdateMealTime()) {
575 - orderDb.setMealTime(Instant.ofEpochMilli(modification.getMealTime()) 564 + orderDb.setMealTime(Instant.ofEpochMilli(modification.getMealTime())
576 - .atZone(ZoneId.systemDefault()) 565 + .atZone(ZoneId.systemDefault())
577 - .toLocalDateTime()); 566 + .toLocalDateTime());
578 - } 567 + }
579 - if (modification.getShouldUpdateAddress()) { 568 + if (modification.getShouldUpdateAddress()) {
580 - orderDb.setAddress(modification.getAddress()); 569 + orderDb.setAddress(modification.getAddress());
581 - } 570 + }
582 - if (modification.getShouldUpdateRoomNo()) { 571 + if (modification.getShouldUpdateRoomNo()) {
583 - orderDb.setRoomNo(modification.getRoomNo()); 572 + orderDb.setRoomNo(modification.getRoomNo());
584 - } 573 + }
585 - if (modification.getShouldUpdateTableCode()) { 574 + if (modification.getShouldUpdateTableCode()) {
586 - orderDb.setTableCode(modification.getTableCode()); 575 + orderDb.setTableCode(modification.getTableCode());
587 - } 576 + }
588 - if (modification.getShouldUpdatePickupCode()) { 577 + if (modification.getShouldUpdatePickupCode()) {
589 - orderDb.setPickupCode(modification.getPickupCode()); 578 + orderDb.setPickupCode(modification.getPickupCode());
590 - } 579 + }
591 - if (modification.getShouldUpdateOrderType()) { 580 + if (modification.getShouldUpdateOrderType()) {
592 - orderDb.setOrderType(modification.getOrderTypeValue()); 581 + orderDb.setOrderType(modification.getOrderTypeValue());
593 - } 582 + }
594 - if (modification.getShouldUpdateRemark()) { 583 + if (modification.getShouldUpdateRemark()) {
595 - orderDb.setRemark(modification.getRemark()); 584 + orderDb.setRemark(modification.getRemark());
596 - } 585 + }
597 - ObjectMapper objectMapper = new ObjectMapper(); 586 + ObjectMapper objectMapper = new ObjectMapper();
598 - if (modification.getShouldUpdateCustomerNoticeJson()) { 587 + if (modification.getShouldUpdateCustomerNoticeJson()) {
599 - orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder() 588 + orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
600 - .avoids(modification.getCustomerNoticeJson().getAvoidsList()) 589 + .avoids(modification.getCustomerNoticeJson().getAvoidsList())
601 - .doctors(modification.getCustomerNoticeJson().getDoctorsList()) 590 + .doctors(modification.getCustomerNoticeJson().getDoctorsList())
602 - .build())); 591 + .build()));
603 - } 592 + }
604 - if (modification.getShouldUpdateIsRead()) { 593 + if (modification.getShouldUpdateIsRead()) {
605 - orderDb.setIsRead(modification.getIsRead()); 594 + orderDb.setIsRead(modification.getIsRead());
606 - } 595 + }
607 - if (modification.getShouldUpdateIsConfirm()) { 596 + if (modification.getShouldUpdateIsConfirm()) {
608 - orderDb.setIsConfirm(modification.getIsConfirm()); 597 + orderDb.setIsConfirm(modification.getIsConfirm());
609 - } 598 + }
610 - if (modification.getShouldUpdateIsAllocation()) { 599 + if (modification.getShouldUpdateIsAllocation()) {
611 - orderDb.setIsAllocation(modification.getIsAllocation()); 600 + orderDb.setIsAllocation(modification.getIsAllocation());
612 - } 601 + }
613 - return orderDb; 602 + return orderDb;
614 - }).collect(Collectors.toList()); 603 + }).collect(Collectors.toList());
615 - return SpringUtil.getBean(OrderDbServiceImpl.class).updateBatchById(list); 604 + return SpringUtil.getBean(OrderDbServiceImpl.class).updateBatchById(list);
616 - } 605 + }
617 606
618 - @Override 607 + @Override
619 - public List<OrderDb> getOrdersByOpenId(Integer openId) { 608 + public List<OrderDb> getOrdersByOpenId(Integer openId) {
620 - QueryWrapper<OrderDb> wrapper = new QueryWrapper<>(); 609 + QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
621 - wrapper.eq("openId", openId) 610 + wrapper.eq("openId", openId)
622 - .orderByDesc("createdAt"); 611 + .orderByDesc("createdAt");
623 - return orderDbMapper.selectList(wrapper); 612 + return orderDbMapper.selectList(wrapper);
624 - } 613 + }
625 614
626 // @Override 615 // @Override
627 // public List<OrderDb> batchCreateOrdersAndDetails( 616 // public List<OrderDb> batchCreateOrdersAndDetails(
......