wangyingyang

update order

package com.tianting.infoloop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrdersRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest;
......@@ -16,8 +15,6 @@ public interface OrderDbService extends IService<OrderDb> {
List<OrderDb> batchCreateOrderDbs(BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest);
List<OrderDb> batchCreateOrdersAndDetails(BatchCreateClientCustomerOrderAndDetailsRpcRequest createOrdersAndDetailsRequest);
Boolean updateOrderDb(UpdateClientCustomerOrderRpcRequest updateOrderRequest);
Boolean batchUpdateOrderDbs(BatchUpdateClientCustomerOrdersRpcRequest batchUpdateOrdersRequest);
......
......@@ -7,8 +7,6 @@ import static com.tianting.infoloop.constants.ConfigConstants.DATA_SOURCE_SLAVE;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcResponse;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderDetailsRpcResponse;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrdersRpcRequest;
......@@ -333,24 +331,24 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu
responseStreamObserver.onCompleted();
}
@Override
@DS(DATA_SOURCE_MASTER)
public void batchCreateClientCustomerOrderAndDetails(
final BatchCreateClientCustomerOrderAndDetailsRpcRequest request,
final StreamObserver<BatchCreateClientCustomerOrderAndDetailsRpcResponse>
responseStreamObserver) {
final var builder = BatchCreateClientCustomerOrderAndDetailsRpcResponse.newBuilder();
try {
final var data = orderDbService.batchCreateOrdersAndDetails(request);
builder.setIsCreated(data.size() == request.getOrderCreationsCount()).addAllOrderIds(data.stream().map(
OrderDb::getId).collect(Collectors.toList()));
} catch (final Exception e) {
log.error("batchCreateClientCustomerOrderAndDetails error;", e);
responseStreamObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
}
responseStreamObserver.onNext(builder.build());
responseStreamObserver.onCompleted();
}
// @Override
// @DS(DATA_SOURCE_MASTER)
// public void batchCreateClientCustomerOrderAndDetails(
// final BatchCreateClientCustomerOrderAndDetailsRpcRequest request,
// final StreamObserver<BatchCreateClientCustomerOrderAndDetailsRpcResponse>
// responseStreamObserver) {
// final var builder = BatchCreateClientCustomerOrderAndDetailsRpcResponse.newBuilder();
// try {
// final var data = orderDbService.batchCreateOrdersAndDetails(request);
// builder.setIsCreated(data.size() == request.getOrderCreationsCount()).addAllOrderIds(data.stream().map(
// OrderDb::getId).collect(Collectors.toList()));
// } catch (final Exception e) {
// log.error("batchCreateClientCustomerOrderAndDetails error;", e);
// responseStreamObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
// }
// responseStreamObserver.onNext(builder.build());
// responseStreamObserver.onCompleted();
// }
@Override
@DS(DATA_SOURCE_MASTER)
......
......@@ -6,9 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest;
//import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrderAndDetailsRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrdersRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation;
import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum;
import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest;
......@@ -120,6 +121,43 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
if (!res) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
if (createOrderRpcRequest.getCreation().getShouldCreateOrderDetails()) {
var detailList = createOrderRpcRequest.getCreation().getOrderDetailsList().stream()
.map(detailCreation -> {
OrderDetailDb orderDetailDb = new OrderDetailDb();
orderDetailDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue());
orderDetailDb.setCreatedBy(createOrderRpcRequest.getCreatedBy());
orderDetailDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue());
orderDetailDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy());
orderDetailDb.setOrderId(detailCreation.getOrderId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setNotServe(false);
if (detailCreation.getShouldCreateMealDetailJson()) {
// orderDetailDb.setMealDetailJson(objectMapper.valueToTree(detailCreation.getMealDetailJson()));
}
return orderDetailDb;
})
.collect(Collectors.toList());
List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
.saveBatch(detailList) ? detailList : Collections.emptyList();
if (resOrderDetails.size() != createOrderRpcRequest.getCreation().getOrderDetailsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
}
}
return orderDb;
}
......@@ -127,7 +165,7 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
public List<OrderDb> batchCreateOrderDbs(
BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest) {
ObjectMapper objectMapper = new ObjectMapper();
var list = batchCreateOrdersRequest.getCreationsList().stream()
var orderList = batchCreateOrdersRequest.getCreationsList().stream()
.map(creation ->{
OrderDb orderDb = new OrderDb();
String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
......@@ -202,7 +240,127 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
}
)
.collect(Collectors.toList());
return SpringUtil.getBean(OrderDbServiceImpl.class).saveBatch(list) ? list : Collections.emptyList();
// SpringUtil.getBean(OrderDbServiceImpl.class).saveBatch(list) ? list : Collections.emptyList();
List<OrderDb> resOrders = SpringUtil.getBean(OrderDbServiceImpl.class)
.saveBatch(orderList) ? orderList : Collections.emptyList();
if (resOrders.size() != batchCreateOrdersRequest.getCreationsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
for(ClientCustomerOrderCreation creation: batchCreateOrdersRequest.getCreationsList()){
OrderDb orderDb = new OrderDb();
String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
orderDb.setOrderCode(orderCode);
orderDb.setEnterpriseId(batchCreateOrdersRequest.getEnterpriseId());
orderDb.setClientId(creation.getClientId());
orderDb.setStallId(creation.getStallId());
if (creation.getShouldCreateOpenId()) {
orderDb.setOpenId(creation.getOpenId());
}
if (creation.getShouldCreateCustomerNoticeJson())
{
orderDb.setCustomerId(creation.getCustomerId());
}
orderDb.setStatus(creation.getStatusValue());
orderDb.setMenuId(creation.getMenuId());
orderDb.setTotalNum(creation.getTotalNum());
if (creation.getShouldCreatePayPrice()) {
orderDb.setPayPrice(creation.getPayPrice());
}
if (creation.getShouldCreatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(creation.getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (creation.getShouldCreateOnlinePay()) {
orderDb.setOnlinePay(creation.getOnlinePay());
}
if (creation.getShouldCreatePayStatus()) {
orderDb.setPayStatus(creation.getPayStatusValue());
}
if (creation.getShouldCreateTransactionId()) {
orderDb.setTransactionId(creation.getTransactionId());
}
if (creation.getShouldCreateErrorMsg()) {
orderDb.setErrorMsg(creation.getErrorMsg());
}
if (creation.getShouldCreateAddress()) {
orderDb.setAddress(creation.getAddress());
}
if (creation.getShouldCreateRoomNo()) {
orderDb.setRoomNo(creation.getRoomNo());
}
if (creation.getShouldCreateTableCode()) {
orderDb.setTableCode(creation.getTableCode());
}
if (creation.getShouldCreatePickupCode()) {
orderDb.setPickupCode(creation.getPickupCode());
}
if (creation.getShouldCreateOrderType()) {
orderDb.setOrderType(creation.getOrderTypeValue());
}
if (creation.getShouldCreateRemark()) {
orderDb.setRemark(creation.getRemark());
}
if (creation.getShouldCreateCustomerNoticeJson()) {
JsonNode notice = objectMapper.valueToTree(creation.getCustomerNoticeJson());
orderDb.setCustomerNoticeJson(notice);
}
LocalDateTime mealTime = Instant.ofEpochMilli(creation.getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
orderDb.setMealTime(mealTime);
orderDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy());
orderDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue());
orderDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy());
orderDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue());
orderDb.setCloseTimeType(creation.getCloseTimeTypeValue());
orderDb.setIsRead(creation.getIsRead());
boolean res = this.save(orderDb);
if (!res) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
if (creation.getShouldCreateOrderDetails()) {
var detailList = creation.getOrderDetailsList().stream()
.map(detailCreation -> {
OrderDetailDb orderDetailDb = new OrderDetailDb();
orderDetailDb.setCreationSource(batchCreateOrdersRequest.getCreationSourceValue());
orderDetailDb.setCreatedBy(batchCreateOrdersRequest.getCreatedBy());
orderDetailDb.setUpdateSource(batchCreateOrdersRequest.getCreationSourceValue());
orderDetailDb.setUpdatedBy(batchCreateOrdersRequest.getCreatedBy());
orderDetailDb.setOrderId(detailCreation.getOrderId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setNotServe(false);
if (detailCreation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(detailCreation.getMealDetailJson()));
}
return orderDetailDb;
})
.collect(Collectors.toList());
List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
.saveBatch(detailList) ? detailList : Collections.emptyList();
if (resOrderDetails.size() != creation.getOrderDetailsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
}
}
}
return resOrders;
}
@Override
......@@ -402,129 +560,129 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
return orderDbMapper.selectList(wrapper);
}
@Override
public List<OrderDb> batchCreateOrdersAndDetails(
BatchCreateClientCustomerOrderAndDetailsRpcRequest createOrdersAndDetailsRequest) {
ObjectMapper objectMapper = new ObjectMapper();
var orderList = createOrdersAndDetailsRequest.getOrderCreationsList().stream()
.map(creation -> {
OrderDb orderDb = new OrderDb();
String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
orderDb.setOrderCode(orderCode);
orderDb.setEnterpriseId(createOrdersAndDetailsRequest.getEnterpriseId());
orderDb.setClientId(creation.getClientId());
orderDb.setStallId(creation.getStallId());
if (creation.getShouldCreateOpenId()) {
orderDb.setOpenId(creation.getOpenId());
}
if (creation.getShouldCreateCustomerNoticeJson())
{
orderDb.setCustomerId(creation.getCustomerId());
}
orderDb.setStatus(creation.getStatusValue());
orderDb.setMenuId(creation.getMenuId());
orderDb.setTotalNum(creation.getTotalNum());
if (creation.getShouldCreatePayPrice()) {
orderDb.setPayPrice(creation.getPayPrice());
}
if (creation.getShouldCreatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(creation.getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (creation.getShouldCreateOnlinePay()) {
orderDb.setOnlinePay(creation.getOnlinePay());
}
if (creation.getShouldCreatePayStatus()) {
orderDb.setPayStatus(creation.getPayStatusValue());
}
if (creation.getShouldCreateTransactionId()) {
orderDb.setTransactionId(creation.getTransactionId());
}
if (creation.getShouldCreateErrorMsg()) {
orderDb.setErrorMsg(creation.getErrorMsg());
}
if (creation.getShouldCreateAddress()) {
orderDb.setAddress(creation.getAddress());
}
if (creation.getShouldCreateRoomNo()) {
orderDb.setRoomNo(creation.getRoomNo());
}
if (creation.getShouldCreateTableCode()) {
orderDb.setTableCode(creation.getTableCode());
}
if (creation.getShouldCreatePickupCode()) {
orderDb.setPickupCode(creation.getPickupCode());
}
if (creation.getShouldCreateOrderType()) {
orderDb.setOrderType(creation.getOrderTypeValue());
}
if (creation.getShouldCreateRemark()) {
orderDb.setRemark(creation.getRemark());
}
if (creation.getShouldCreateCustomerNoticeJson()) {
JsonNode notice = objectMapper.valueToTree(creation.getCustomerNoticeJson());
orderDb.setCustomerNoticeJson(notice);
}
LocalDateTime mealTime = Instant.ofEpochMilli(creation.getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime();
orderDb.setMealTime(mealTime);
orderDb.setCreatedBy(createOrdersAndDetailsRequest.getCreatedBy());
orderDb.setCreationSource(createOrdersAndDetailsRequest.getCreationSourceValue());
orderDb.setUpdatedBy(createOrdersAndDetailsRequest.getCreatedBy());
orderDb.setUpdateSource(createOrdersAndDetailsRequest.getCreationSourceValue());
orderDb.setCloseTimeType(creation.getCloseTimeTypeValue());
orderDb.setIsRead(creation.getIsRead());
return orderDb;
}
)
.collect(Collectors.toList());
List<OrderDb> resOrders = SpringUtil.getBean(OrderDbServiceImpl.class)
.saveBatch(orderList) ? orderList : Collections.emptyList();
if (resOrders.size() != createOrdersAndDetailsRequest.getOrderCreationsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
var detailList = createOrdersAndDetailsRequest.getDetailCreationsList().stream()
.map(creation -> {
OrderDetailDb orderDetailDb = new OrderDetailDb();
orderDetailDb.setCreationSource(createOrdersAndDetailsRequest.getCreationSourceValue());
orderDetailDb.setCreatedBy(createOrdersAndDetailsRequest.getCreatedBy());
orderDetailDb.setUpdateSource(createOrdersAndDetailsRequest.getCreationSourceValue());
orderDetailDb.setUpdatedBy(createOrdersAndDetailsRequest.getCreatedBy());
orderDetailDb.setOrderId(creation.getOrderId());
orderDetailDb.setMenuDetailId(creation.getMenuDetailId());
orderDetailDb.setCount(creation.getCount());
orderDetailDb.setMealId(creation.getMealId());
orderDetailDb.setCategoryId(creation.getCategoryId());
orderDetailDb.setSkuId(creation.getSkuId());
if (creation.getShouldCreateShowName()) {
orderDetailDb.setShowName(creation.getShowName());
}
if (creation.getShouldCreatePrice()) {
orderDetailDb.setPrice(creation.getPrice());
}
if (creation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(creation.getAdjustSkuRemark());
}
orderDetailDb.setNotServe(creation.getNotServe());
if (creation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(creation.getMealDetailJson()));
}
return orderDetailDb;
})
.collect(Collectors.toList());
List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
.saveBatch(detailList) ? detailList : Collections.emptyList();
if (resOrderDetails.size() != createOrdersAndDetailsRequest.getDetailCreationsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
}
return resOrders;
}
// @Override
// public List<OrderDb> batchCreateOrdersAndDetails(
// BatchCreateClientCustomerOrderAndDetailsRpcRequest createOrdersAndDetailsRequest) {
// ObjectMapper objectMapper = new ObjectMapper();
// var orderList = createOrdersAndDetailsRequest.getOrderCreationsList().stream()
// .map(creation -> {
// OrderDb orderDb = new OrderDb();
// String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
// orderDb.setOrderCode(orderCode);
// orderDb.setEnterpriseId(createOrdersAndDetailsRequest.getEnterpriseId());
// orderDb.setClientId(creation.getClientId());
// orderDb.setStallId(creation.getStallId());
// if (creation.getShouldCreateOpenId()) {
// orderDb.setOpenId(creation.getOpenId());
// }
// if (creation.getShouldCreateCustomerNoticeJson())
// {
// orderDb.setCustomerId(creation.getCustomerId());
// }
// orderDb.setStatus(creation.getStatusValue());
// orderDb.setMenuId(creation.getMenuId());
// orderDb.setTotalNum(creation.getTotalNum());
// if (creation.getShouldCreatePayPrice()) {
// orderDb.setPayPrice(creation.getPayPrice());
// }
// if (creation.getShouldCreatePayTime()) {
// orderDb.setPayTime(Instant.ofEpochMilli(creation.getPayTime())
// .atZone(ZoneId.systemDefault())
// .toLocalDateTime());
// }
// if (creation.getShouldCreateOnlinePay()) {
// orderDb.setOnlinePay(creation.getOnlinePay());
// }
// if (creation.getShouldCreatePayStatus()) {
// orderDb.setPayStatus(creation.getPayStatusValue());
// }
// if (creation.getShouldCreateTransactionId()) {
// orderDb.setTransactionId(creation.getTransactionId());
// }
// if (creation.getShouldCreateErrorMsg()) {
// orderDb.setErrorMsg(creation.getErrorMsg());
// }
// if (creation.getShouldCreateAddress()) {
// orderDb.setAddress(creation.getAddress());
// }
// if (creation.getShouldCreateRoomNo()) {
// orderDb.setRoomNo(creation.getRoomNo());
// }
// if (creation.getShouldCreateTableCode()) {
// orderDb.setTableCode(creation.getTableCode());
// }
// if (creation.getShouldCreatePickupCode()) {
// orderDb.setPickupCode(creation.getPickupCode());
// }
// if (creation.getShouldCreateOrderType()) {
// orderDb.setOrderType(creation.getOrderTypeValue());
// }
// if (creation.getShouldCreateRemark()) {
// orderDb.setRemark(creation.getRemark());
// }
// if (creation.getShouldCreateCustomerNoticeJson()) {
// JsonNode notice = objectMapper.valueToTree(creation.getCustomerNoticeJson());
// orderDb.setCustomerNoticeJson(notice);
// }
// LocalDateTime mealTime = Instant.ofEpochMilli(creation.getMealTime())
// .atZone(ZoneId.systemDefault())
// .toLocalDateTime();
// orderDb.setMealTime(mealTime);
// orderDb.setCreatedBy(createOrdersAndDetailsRequest.getCreatedBy());
// orderDb.setCreationSource(createOrdersAndDetailsRequest.getCreationSourceValue());
// orderDb.setUpdatedBy(createOrdersAndDetailsRequest.getCreatedBy());
// orderDb.setUpdateSource(createOrdersAndDetailsRequest.getCreationSourceValue());
// orderDb.setCloseTimeType(creation.getCloseTimeTypeValue());
// orderDb.setIsRead(creation.getIsRead());
//
// return orderDb;
// }
// )
// .collect(Collectors.toList());
//
// List<OrderDb> resOrders = SpringUtil.getBean(OrderDbServiceImpl.class)
// .saveBatch(orderList) ? orderList : Collections.emptyList();
// if (resOrders.size() != createOrdersAndDetailsRequest.getOrderCreationsCount()) {
// throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
// }
//
// var detailList = createOrdersAndDetailsRequest.getDetailCreationsList().stream()
// .map(creation -> {
// OrderDetailDb orderDetailDb = new OrderDetailDb();
// orderDetailDb.setCreationSource(createOrdersAndDetailsRequest.getCreationSourceValue());
// orderDetailDb.setCreatedBy(createOrdersAndDetailsRequest.getCreatedBy());
// orderDetailDb.setUpdateSource(createOrdersAndDetailsRequest.getCreationSourceValue());
// orderDetailDb.setUpdatedBy(createOrdersAndDetailsRequest.getCreatedBy());
// orderDetailDb.setOrderId(creation.getOrderId());
// orderDetailDb.setMenuDetailId(creation.getMenuDetailId());
// orderDetailDb.setCount(creation.getCount());
// orderDetailDb.setMealId(creation.getMealId());
// orderDetailDb.setCategoryId(creation.getCategoryId());
// orderDetailDb.setSkuId(creation.getSkuId());
// if (creation.getShouldCreateShowName()) {
// orderDetailDb.setShowName(creation.getShowName());
// }
// if (creation.getShouldCreatePrice()) {
// orderDetailDb.setPrice(creation.getPrice());
// }
// if (creation.getShouldCreateAdjustSkuRemark()) {
// orderDetailDb.setAdjustSkuRemark(creation.getAdjustSkuRemark());
// }
// orderDetailDb.setNotServe(creation.getNotServe());
// if (creation.getShouldCreateMealDetailJson()) {
// orderDetailDb.setMealDetailJson(objectMapper.valueToTree(creation.getMealDetailJson()));
// }
//
// return orderDetailDb;
// })
// .collect(Collectors.toList());
// List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
// .saveBatch(detailList) ? detailList : Collections.emptyList();
//
// if (resOrderDetails.size() != createOrdersAndDetailsRequest.getDetailCreationsCount()) {
// throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
// }
// return resOrders;
// }
}
......
......@@ -43,7 +43,9 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord
CreateClientCustomerOrderDetailRpcRequest createOrderDetailRequest) {
ObjectMapper objectMapper = new ObjectMapper();
OrderDetailDb orderDetailDb = new OrderDetailDb();
orderDetailDb.setOrderId(createOrderDetailRequest.getCreation().getOrderId());
if (createOrderDetailRequest.getCreation().getShouldCreateOrderId()){
orderDetailDb.setOrderId(createOrderDetailRequest.getCreation().getOrderId());
}
orderDetailDb.setMenuDetailId(createOrderDetailRequest.getCreation().getMenuDetailId());
orderDetailDb.setCount(createOrderDetailRequest.getCreation().getCount());
orderDetailDb.setMealId(createOrderDetailRequest.getCreation().getMealId());
......@@ -63,7 +65,7 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord
if (createOrderDetailRequest.getCreation().getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(createOrderDetailRequest.getCreation().getAdjustSkuRemark());
}
orderDetailDb.setNotServe(createOrderDetailRequest.getCreation().getNotServe());
orderDetailDb.setNotServe(false);
if (createOrderDetailRequest.getCreation().getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(createOrderDetailRequest.getCreation().getMealDetailJson()));
}
......@@ -87,7 +89,6 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord
orderDetailDb.setCreatedBy(batchCreateOrderDetailsRequest.getCreatedBy());
orderDetailDb.setUpdateSource(batchCreateOrderDetailsRequest.getCreationSourceValue());
orderDetailDb.setUpdatedBy(batchCreateOrderDetailsRequest.getCreatedBy());
orderDetailDb.setOrderId(creation.getOrderId());
orderDetailDb.setMenuDetailId(creation.getMenuDetailId());
orderDetailDb.setCount(creation.getCount());
orderDetailDb.setMealId(creation.getMealId());
......@@ -96,6 +97,9 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord
orderDetailDb.setIsDeleted(false);
orderDetailDb.setNotServe(false);
orderDetailDb.setEnterpriseId(batchCreateOrderDetailsRequest.getEnterpriseId());
if (creation.getShouldCreateOrderId()) {
orderDetailDb.setOrderId(creation.getOrderId());
}
if (creation.getShouldCreateShowName()) {
orderDetailDb.setShowName(creation.getShowName());
}
......@@ -105,18 +109,15 @@ public class OrderDetailDbServiceImpl extends ServiceImpl<OrderDetailMapper, Ord
if (creation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(creation.getAdjustSkuRemark());
}
System.out.println("_______________________________");
if (creation.getShouldCreateMealDetailJson()) {
System.out.println("______________object_________________");
final JsonNode a;
try {
a = objectMapper.readTree(ProtoBeanUtil.protoToJson(creation.getMealDetailJson()));
orderDetailDb.setMealDetailJson(a);
System.out.println(a);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
System.out.println("______________object_____end____________");
// final JsonNode a;
// try {
// a = objectMapper.readTree(ProtoBeanUtil.protoToJson(creation.getMealDetailJson()));
// orderDetailDb.setMealDetailJson(a);
// System.out.println(a);
// } catch (JsonProcessingException e) {
// e.printStackTrace();
// }
}
return orderDetailDb;
})
......
......@@ -18,7 +18,6 @@ service ClientCustomerOrderServiceRpc {
rpc UpdateClientCustomerOrder (UpdateClientCustomerOrderRpcRequest) returns (UpdateClientCustomerOrderRpcResponse) {}
rpc BatchUpdateClientCustomerOrders (BatchUpdateClientCustomerOrdersRpcRequest) returns (BatchUpdateClientCustomerOrdersRpcResponse) {}
rpc DeleteClientCustomerOrdersByIds (DeleteClientCustomerOrdersByIdsRpcRequest) returns (DeleteClientCustomerOrdersRpcResponse) {}
rpc BatchCreateClientCustomerOrderAndDetails (BatchCreateClientCustomerOrderAndDetailsRpcRequest) returns (BatchCreateClientCustomerOrderAndDetailsRpcResponse) {}
//订单明细
rpc GetClientCustomerOrderDetailById (GetClientCustomerOrderDetailByIdRpcRequest) returns (GetClientCustomerOrderDetailByIdRpcResponse) {}
......@@ -232,6 +231,8 @@ message ClientCustomerOrderCreation{
bool shouldCreateCustomerNoticeJson = 37;
CustomerNotice customerNoticeJson = 38;
bool isRead = 39;
bool shouldCreateOrderDetails = 40;
repeated ClientCustomerOrderDetailCreation orderDetails = 41;
}
message CreateClientCustomerOrderRpcRequest {
......@@ -343,20 +344,6 @@ message DeleteClientCustomerOrdersRpcResponse {
bool isDeleted = 1;
}
message BatchCreateClientCustomerOrderAndDetailsRpcRequest {
int32 enterpriseId = 1;
int32 createdBy = 2;
OrderSourceEnum creationSource = 3;
repeated ClientCustomerOrderCreation orderCreations = 4;
repeated ClientCustomerOrderDetailCreation detailCreations = 5;
}
message BatchCreateClientCustomerOrderAndDetailsRpcResponse {
repeated int32 orderIds = 1;
bool isCreated = 2;
}
message MealDetail {
string basicMaterials = 1;
repeated string tastes = 2;
......@@ -422,21 +409,22 @@ message GetClientCustomerOrderDetailsByOrderIdsRpcResponse {
}
message ClientCustomerOrderDetailCreation{
int32 orderId = 1;
int32 menuDetailId = 2;
int32 count = 3;
int32 mealId = 4;
int32 categoryId = 5;
int32 skuId = 6;
bool shouldCreateShowName = 7;
string showName = 8;
bool shouldCreateMealDetailJson = 9;
MealDetail mealDetailJson = 10;
bool shouldCreatePrice = 11;
int32 price = 12;
bool shouldCreateAdjustSkuRemark = 13;
string adjustSkuRemark = 14;
bool notServe = 15;
bool shouldCreateOrderId = 1;
int32 orderId = 2;
int32 menuDetailId = 3;
int32 count = 4;
int32 mealId = 5;
int32 categoryId = 6;
int32 skuId = 7;
bool shouldCreateShowName = 8;
string showName = 9;
bool shouldCreateMealDetailJson = 10;
MealDetail mealDetailJson = 11;
bool shouldCreatePrice = 12;
int32 price = 13;
bool shouldCreateAdjustSkuRemark = 14;
string adjustSkuRemark = 15;
bool notServe = 16;
}
message CreateClientCustomerOrderDetailRpcRequest {
......
......@@ -26,5 +26,5 @@ mybatis-plus.global-config.db-config.logic-not-delete-value=0
mybatis-plus.global-config.db-config.logic-delete-field=isDeleted
mybatis-plus.mapper-locations=classpath*:mapper/*.xml
mybatis-plus.typeAliasesPackage=com.tianting.infoloop.model.db
tenant.enable=false
tenant.enable=true
tenant.column=enterpriseId
......