zhuyifan

feat(clientcustomerorderservice): 将在线支付字段改为枚举类型- 在 ClientCustomerOrderService.pr…

…oto 中定义 OnlinePayEnum 枚举类型
......@@ -7,15 +7,14 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.ibatis.type.JdbcType;
import java.io.Serializable;
import java.time.LocalDateTime;
import org.apache.ibatis.type.JdbcType;
/**
* order DB
......@@ -100,9 +99,9 @@ public class OrderDb extends Model<OrderDb> implements Serializable {
*/
private Integer payPrice;
/**
* 是否在线付费;0=未付费,1=付费
* 支付方式
*/
private Boolean onlinePay;
private Integer onlinePay;
/**
* 支付时间
*/
......
......@@ -10,7 +10,6 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome
import com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.ClientCustomerOrderCreation;
import com.infoloop.tianting.clientcustomerorderservice.CreateClientCustomerOrderRpcRequest;
import com.infoloop.tianting.clientcustomerorderservice.PayStatusEnum;
import com.infoloop.tianting.clientcustomerorderservice.ServeStatusEnum;
import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest;
import com.tianting.infoloop.mapper.OrderDbMapper;
......@@ -19,13 +18,13 @@ import com.tianting.infoloop.model.db.OrderDetailDb;
import com.tianting.infoloop.model.dto.CustomerNoticeDto;
import com.tianting.infoloop.model.dto.MealDetailJson;
import com.tianting.infoloop.service.OrderDbService;
import com.tianting.infoloop.service.OrderDetailDbService;
import com.tianting.infoloop.utils.exception.ErrorCodeConstants;
import com.tianting.infoloop.utils.exception.ServiceExceptionUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.time.LocalDateTime;
......@@ -40,154 +39,146 @@ import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> implements OrderDbService {
private final OrderDbMapper orderDbMapper;
private final OrderDetailDbService orderDetailDbService;
private final OrderDbMapper orderDbMapper;
@Override
public OrderDb createOrderDb(CreateClientCustomerOrderRpcRequest createOrderRpcRequest) {
OrderDb orderDb = new OrderDb();
//生成分布式唯一值
String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
orderDb.setOrderCode(orderCode);
orderDb.setEnterpriseId(createOrderRpcRequest.getEnterpriseId());
orderDb.setClientId(createOrderRpcRequest.getCreation().getClientId());
orderDb.setStallId(createOrderRpcRequest.getCreation().getStallId());
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerId()) {
orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOpenId()) {
orderDb.setOpenId(createOrderRpcRequest.getCreation().getOpenId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
}
orderDb.setStatus(createOrderRpcRequest.getCreation().getStatusValue());
orderDb.setMenuId(createOrderRpcRequest.getCreation().getMenuId());
orderDb.setTotalNum(createOrderRpcRequest.getCreation().getTotalNum());
if (createOrderRpcRequest.getCreation().getShouldCreatePayPrice()) {
orderDb.setPayPrice(createOrderRpcRequest.getCreation().getPayPrice());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOnlinePay()) {
orderDb.setOnlinePay(createOrderRpcRequest.getCreation().getOnlinePay());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePayStatus()) {
orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue());
}
if (createOrderRpcRequest.getCreation().getShouldCreateTransactionId()) {
orderDb.setTransactionId(createOrderRpcRequest.getCreation().getTransactionId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateErrorMsg()) {
orderDb.setErrorMsg(createOrderRpcRequest.getCreation().getErrorMsg());
}
if (createOrderRpcRequest.getCreation().getShouldCreateAddress()) {
orderDb.setAddress(createOrderRpcRequest.getCreation().getAddress());
}
if (createOrderRpcRequest.getCreation().getShouldCreateRoomNo()) {
orderDb.setRoomNo(createOrderRpcRequest.getCreation().getRoomNo());
}
if (createOrderRpcRequest.getCreation().getShouldCreateTableCode()) {
orderDb.setTableCode(createOrderRpcRequest.getCreation().getTableCode());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePickupCode()) {
orderDb.setPickupCode(createOrderRpcRequest.getCreation().getPickupCode());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOrderType()) {
orderDb.setOrderType(createOrderRpcRequest.getCreation().getOrderTypeValue());
}
if (createOrderRpcRequest.getCreation().getShouldCreateRemark()) {
orderDb.setRemark(createOrderRpcRequest.getCreation().getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getAvoidsList())
.doctors(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getDoctorsList())
.build());
orderDb.setCustomerNoticeJson(notice);
}
LocalDateTime mealTime = Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getMealTime())
// .atZone(ZoneId.systemDefault())
.atOffset(ZoneOffset.UTC)
.toLocalDateTime();
orderDb.setMealTime(mealTime);
orderDb.setPayStatus(createOrderRpcRequest.getCreation().getOnlinePay() ? PayStatusEnum.TO_PAY_VALUE : PayStatusEnum.SUCCEED_VALUE);
orderDb.setCreatedBy(createOrderRpcRequest.getCreatedBy());
orderDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue());
orderDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy());
orderDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue());
orderDb.setCloseTimeType(createOrderRpcRequest.getCreation().getCloseTimeTypeValue());
orderDb.setIsRead(createOrderRpcRequest.getCreation().getIsRead());
orderDb.setIsDeleted(false);
orderDb.setIsConfirm(false);
orderDb.setIsAllocation(false);
boolean res = this.save(orderDb);
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(orderDb.getId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
orderDetailDb.setEnterpriseId(orderDb.getEnterpriseId());
orderDetailDb.setIsDeleted(false);
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
if (detailCreation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
.allergies(detailCreation.getMealDetailJson().getAllergiesList())
.avoids(detailCreation.getMealDetailJson().getAvoidsList())
.basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
.carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
.dockers(detailCreation.getMealDetailJson().getDockersList())
.efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
.energy(detailCreation.getMealDetailJson().getEnergy())
.fat(detailCreation.getMealDetailJson().getFat())
.protein(detailCreation.getMealDetailJson().getProtein())
.skus(detailCreation.getMealDetailJson().getSkusList())
.tastes(detailCreation.getMealDetailJson().getTastesList())
.build()));//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);
}
@Override
@Transactional(rollbackFor = Exception.class)
public OrderDb createOrderDb(CreateClientCustomerOrderRpcRequest createOrderRpcRequest) {
OrderDb orderDb = new OrderDb();
//生成分布式唯一值
String orderCode = IdUtil.getSnowflake(0, 0).nextIdStr();
orderDb.setOrderCode(orderCode);
orderDb.setEnterpriseId(createOrderRpcRequest.getEnterpriseId());
orderDb.setClientId(createOrderRpcRequest.getCreation().getClientId());
orderDb.setStallId(createOrderRpcRequest.getCreation().getStallId());
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerId()) {
orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOpenId()) {
orderDb.setOpenId(createOrderRpcRequest.getCreation().getOpenId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
orderDb.setCustomerId(createOrderRpcRequest.getCreation().getCustomerId());
}
orderDb.setStatus(createOrderRpcRequest.getCreation().getStatusValue());
orderDb.setMenuId(createOrderRpcRequest.getCreation().getMenuId());
orderDb.setTotalNum(createOrderRpcRequest.getCreation().getTotalNum());
if (createOrderRpcRequest.getCreation().getShouldCreatePayPrice()) {
orderDb.setPayPrice(createOrderRpcRequest.getCreation().getPayPrice());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getPayTime()).atZone(ZoneId.systemDefault()).toLocalDateTime());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOnlinePay()) {
orderDb.setOnlinePay(createOrderRpcRequest.getCreation().getOnlinePayValue());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePayStatus()) {
orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue());
}
if (createOrderRpcRequest.getCreation().getShouldCreateTransactionId()) {
orderDb.setTransactionId(createOrderRpcRequest.getCreation().getTransactionId());
}
if (createOrderRpcRequest.getCreation().getShouldCreateErrorMsg()) {
orderDb.setErrorMsg(createOrderRpcRequest.getCreation().getErrorMsg());
}
if (createOrderRpcRequest.getCreation().getShouldCreateAddress()) {
orderDb.setAddress(createOrderRpcRequest.getCreation().getAddress());
}
if (createOrderRpcRequest.getCreation().getShouldCreateRoomNo()) {
orderDb.setRoomNo(createOrderRpcRequest.getCreation().getRoomNo());
}
if (createOrderRpcRequest.getCreation().getShouldCreateTableCode()) {
orderDb.setTableCode(createOrderRpcRequest.getCreation().getTableCode());
}
if (createOrderRpcRequest.getCreation().getShouldCreatePickupCode()) {
orderDb.setPickupCode(createOrderRpcRequest.getCreation().getPickupCode());
}
if (createOrderRpcRequest.getCreation().getShouldCreateOrderType()) {
orderDb.setOrderType(createOrderRpcRequest.getCreation().getOrderTypeValue());
}
if (createOrderRpcRequest.getCreation().getShouldCreateRemark()) {
orderDb.setRemark(createOrderRpcRequest.getCreation().getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (createOrderRpcRequest.getCreation().getShouldCreateCustomerNoticeJson()) {
JsonNode notice = objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getAvoidsList())
.doctors(createOrderRpcRequest.getCreation().getCustomerNoticeJson().getDoctorsList())
.build());
orderDb.setCustomerNoticeJson(notice);
}
LocalDateTime mealTime = Instant.ofEpochMilli(createOrderRpcRequest.getCreation().getMealTime()).atOffset(ZoneOffset.UTC).toLocalDateTime();
orderDb.setMealTime(mealTime);
orderDb.setPayStatus(createOrderRpcRequest.getCreation().getPayStatusValue());
orderDb.setCreatedBy(createOrderRpcRequest.getCreatedBy());
orderDb.setCreationSource(createOrderRpcRequest.getCreationSourceValue());
orderDb.setUpdatedBy(createOrderRpcRequest.getCreatedBy());
orderDb.setUpdateSource(createOrderRpcRequest.getCreationSourceValue());
orderDb.setCloseTimeType(createOrderRpcRequest.getCreation().getCloseTimeTypeValue());
orderDb.setIsRead(createOrderRpcRequest.getCreation().getIsRead());
orderDb.setIsDeleted(false);
orderDb.setIsConfirm(false);
orderDb.setIsAllocation(false);
boolean res = this.save(orderDb);
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(orderDb.getId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
orderDetailDb.setEnterpriseId(orderDb.getEnterpriseId());
orderDetailDb.setIsDeleted(false);
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
if (detailCreation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
.allergies(detailCreation.getMealDetailJson().getAllergiesList())
.avoids(detailCreation.getMealDetailJson().getAvoidsList())
.basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
.carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
.dockers(detailCreation.getMealDetailJson().getDockersList())
.efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
.energy(detailCreation.getMealDetailJson().getEnergy())
.fat(detailCreation.getMealDetailJson().getFat())
.protein(detailCreation.getMealDetailJson().getProtein())
.skus(detailCreation.getMealDetailJson().getSkusList())
.tastes(detailCreation.getMealDetailJson().getTastesList())
.build()));
}
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;
}
return orderDb;
}
@Override
public List<OrderDb> batchCreateOrderDbs(
BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest) {
ObjectMapper objectMapper = new ObjectMapper();
@Override
public List<OrderDb> batchCreateOrderDbs(
BatchCreateClientCustomerOrdersRpcRequest batchCreateOrdersRequest) {
ObjectMapper objectMapper = new ObjectMapper();
// var orderList = batchCreateOrdersRequest.getCreationsList().stream()
// .map(creation ->{
// OrderDb orderDb = new OrderDb();
......@@ -271,357 +262,355 @@ public class OrderDbServiceImpl extends ServiceImpl<OrderDbMapper, OrderDb> impl
// if (resOrders.size() != batchCreateOrdersRequest.getCreationsCount()) {
// throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
// }
List<OrderDb> resOrders = new ArrayList<>();
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(CustomerNoticeDto.builder()
.avoids(creation.getCustomerNoticeJson().getAvoidsList())
.doctors(creation.getCustomerNoticeJson().getDoctorsList())
.build());
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());
orderDb.setIsDeleted(false);
orderDb.setIsConfirm(false);
orderDb.setIsAllocation(false);
boolean res = this.save(orderDb);
if (!res) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
resOrders.add(orderDb);
List<OrderDb> resOrders = new ArrayList<>();
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.getOnlinePayValue());
}
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(CustomerNoticeDto.builder()
.avoids(creation.getCustomerNoticeJson().getAvoidsList())
.doctors(creation.getCustomerNoticeJson().getDoctorsList())
.build());
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());
orderDb.setIsDeleted(false);
orderDb.setIsConfirm(false);
orderDb.setIsAllocation(false);
boolean res = this.save(orderDb);
if (!res) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_GEN_FAIL);
}
resOrders.add(orderDb);
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(orderDb.getId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
orderDetailDb.setIsDeleted(false);
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
if (detailCreation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
.allergies(detailCreation.getMealDetailJson().getAllergiesList())
.avoids(detailCreation.getMealDetailJson().getAvoidsList())
.basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
.carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
.dockers(detailCreation.getMealDetailJson().getDockersList())
.efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
.energy(detailCreation.getMealDetailJson().getEnergy())
.fat(detailCreation.getMealDetailJson().getFat())
.protein(detailCreation.getMealDetailJson().getProtein())
.skus(detailCreation.getMealDetailJson().getSkusList())
.tastes(detailCreation.getMealDetailJson().getTastesList())
.build()));
}
return orderDetailDb;
})
.collect(Collectors.toList());
List<OrderDetailDb> resOrderDetails = SpringUtil.getBean(OrderDetailDbServiceImpl.class)
.saveBatch(detailList) ? detailList : Collections.emptyList();
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(orderDb.getId());
orderDetailDb.setMenuDetailId(detailCreation.getMenuDetailId());
orderDetailDb.setCount(detailCreation.getCount());
orderDetailDb.setMealId(detailCreation.getMealId());
orderDetailDb.setCategoryId(detailCreation.getCategoryId());
orderDetailDb.setSkuId(detailCreation.getSkuId());
orderDetailDb.setIsDeleted(false);
if (detailCreation.getShouldCreateShowName()) {
orderDetailDb.setShowName(detailCreation.getShowName());
}
if (detailCreation.getShouldCreatePrice()) {
orderDetailDb.setPrice(detailCreation.getPrice());
}
if (detailCreation.getShouldCreateAdjustSkuRemark()) {
orderDetailDb.setAdjustSkuRemark(detailCreation.getAdjustSkuRemark());
}
orderDetailDb.setServeStatus(ServeStatusEnum.SERVE_NOT_START_VALUE);
if (detailCreation.getShouldCreateMealDetailJson()) {
orderDetailDb.setMealDetailJson(objectMapper.valueToTree(MealDetailJson.builder()
.allergies(detailCreation.getMealDetailJson().getAllergiesList())
.avoids(detailCreation.getMealDetailJson().getAvoidsList())
.basicMaterials(detailCreation.getMealDetailJson().getBasicMaterials())
.carbohydrate(detailCreation.getMealDetailJson().getCarbohydrate())
.dockers(detailCreation.getMealDetailJson().getDockersList())
.efficacies(detailCreation.getMealDetailJson().getEfficaciesList())
.energy(detailCreation.getMealDetailJson().getEnergy())
.fat(detailCreation.getMealDetailJson().getFat())
.protein(detailCreation.getMealDetailJson().getProtein())
.skus(detailCreation.getMealDetailJson().getSkusList())
.tastes(detailCreation.getMealDetailJson().getTastesList())
.build()));
}
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);
if (resOrderDetails.size() != creation.getOrderDetailsCount()) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_DETAIL_GEN_FAIL);
}
}
}
}
return resOrders;
}
return resOrders;
}
@Override
public List<OrderDb> getOrdersByCustomerId(Integer customerId) {
QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
wrapper.eq("customerId", customerId)
.orderByDesc("createdAt");
final var res = orderDbMapper.selectList(wrapper);
return res;
}
@Override
public List<OrderDb> getOrdersByCustomerId(Integer customerId) {
QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
wrapper.eq("customerId", customerId)
.orderByDesc("createdAt");
final var res = orderDbMapper.selectList(wrapper);
return res;
}
@Override
public Boolean updateOrderDb(UpdateClientCustomerOrderRpcRequest updateOrderRequest) {
var orderDb = new OrderDb();
orderDb.setId(updateOrderRequest.getModification().getId());
orderDb.setEnterpriseId(updateOrderRequest.getEnterpriseId());
orderDb.setUpdatedBy(updateOrderRequest.getUpdatedBy());
orderDb.setUpdateSource(updateOrderRequest.getUpdateSourceValue());
@Override
public Boolean updateOrderDb(UpdateClientCustomerOrderRpcRequest updateOrderRequest) {
var orderDb = new OrderDb();
orderDb.setId(updateOrderRequest.getModification().getId());
orderDb.setEnterpriseId(updateOrderRequest.getEnterpriseId());
orderDb.setUpdatedBy(updateOrderRequest.getUpdatedBy());
orderDb.setUpdateSource(updateOrderRequest.getUpdateSourceValue());
if (updateOrderRequest.getModification().getShouldUpdateOrderCode()) {
orderDb.setOrderCode(updateOrderRequest.getModification().getOrderCode());
}
if (updateOrderRequest.getModification().getShouldUpdateClientId()) {
orderDb.setClientId(updateOrderRequest.getModification().getClientId());
}
if (updateOrderRequest.getModification().getShouldUpdateStallId()) {
orderDb.setStallId(updateOrderRequest.getModification().getStallId());
}
if (updateOrderRequest.getModification().getShouldUpdateCustomerId()) {
orderDb.setCustomerId(updateOrderRequest.getModification().getCustomerId());
}
if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
orderDb.setOpenId(updateOrderRequest.getModification().getOpenId());
}
if (updateOrderRequest.getModification().getShouldUpdateStatus()) {
orderDb.setStatus(updateOrderRequest.getModification().getStatusValue()); // 假设OrderStatusEnum有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateMenuId()) {
orderDb.setMenuId(updateOrderRequest.getModification().getMenuId());
}
if (updateOrderRequest.getModification().getShouldUpdateCloseTimeType()) {
orderDb.setCloseTimeType(updateOrderRequest.getModification().getCloseTimeTypeValue()); // 假设CloseTimeType有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateTotalNum()) {
orderDb.setTotalNum(updateOrderRequest.getModification().getTotalNum());
}
if (updateOrderRequest.getModification().getShouldUpdatePayPrice()) {
orderDb.setPayPrice(updateOrderRequest.getModification().getPayPrice());
}
if (updateOrderRequest.getModification().
getShouldUpdateOnlinePay()) {
orderDb.setOnlinePay(updateOrderRequest.getModification().getOnlinePay());
}
if (updateOrderRequest.getModification().getShouldUpdatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (updateOrderRequest.getModification().getShouldUpdatePayStatus()) {
orderDb.setPayStatus(updateOrderRequest.getModification().getPayStatusValue()); // 假设PayStatusEnum有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateErrorMsg()) {
orderDb.setErrorMsg(updateOrderRequest.getModification().getErrorMsg());
}
if (updateOrderRequest.getModification().getShouldUpdateTransactionId()) {
orderDb.setTransactionId(updateOrderRequest.getModification().getTransactionId());
}
if (updateOrderRequest.getModification().getShouldUpdateMealTime()) {
orderDb.setMealTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (updateOrderRequest.getModification().getShouldUpdateAddress()) {
orderDb.setAddress(updateOrderRequest.getModification().getAddress());
}
if (updateOrderRequest.getModification().getShouldUpdateRoomNo()) {
orderDb.setRoomNo(updateOrderRequest.getModification().
getRoomNo());
}
if (updateOrderRequest.getModification().getShouldUpdateTableCode()) {
orderDb.setTableCode(updateOrderRequest.getModification().getTableCode());
}
if (updateOrderRequest.getModification().getShouldUpdatePickupCode()) {
orderDb.setPickupCode(updateOrderRequest.getModification().getPickupCode());
}
if (updateOrderRequest.getModification().getShouldUpdateOrderType()) {
orderDb.setOrderType(updateOrderRequest.getModification().getOrderTypeValue());
}
if (updateOrderRequest.getModification().getShouldUpdateRemark()) {
orderDb.setRemark(updateOrderRequest.getModification().getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (updateOrderRequest.getModification().getShouldUpdateCustomerNoticeJson()) {
orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(updateOrderRequest.getModification().getCustomerNoticeJson().getAvoidsList())
.doctors(updateOrderRequest.getModification().getCustomerNoticeJson().getDoctorsList())
.build()));
}
if (updateOrderRequest.getModification().getShouldUpdateIsRead()) {
orderDb.setIsRead(updateOrderRequest.getModification().getIsRead());
}
if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
orderDb.setIsConfirm(updateOrderRequest.getModification().getIsConfirm());
}
if (updateOrderRequest.getModification().getShouldUpdateIsAllocation()) {
orderDb.setIsAllocation(updateOrderRequest.getModification().getIsAllocation());
if (updateOrderRequest.getModification().getShouldUpdateOrderCode()) {
orderDb.setOrderCode(updateOrderRequest.getModification().getOrderCode());
}
if (updateOrderRequest.getModification().getShouldUpdateClientId()) {
orderDb.setClientId(updateOrderRequest.getModification().getClientId());
}
if (updateOrderRequest.getModification().getShouldUpdateStallId()) {
orderDb.setStallId(updateOrderRequest.getModification().getStallId());
}
if (updateOrderRequest.getModification().getShouldUpdateCustomerId()) {
orderDb.setCustomerId(updateOrderRequest.getModification().getCustomerId());
}
if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
orderDb.setOpenId(updateOrderRequest.getModification().getOpenId());
}
if (updateOrderRequest.getModification().getShouldUpdateStatus()) {
orderDb.setStatus(updateOrderRequest.getModification().getStatusValue()); // 假设OrderStatusEnum有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateMenuId()) {
orderDb.setMenuId(updateOrderRequest.getModification().getMenuId());
}
if (updateOrderRequest.getModification().getShouldUpdateCloseTimeType()) {
orderDb.setCloseTimeType(updateOrderRequest.getModification().getCloseTimeTypeValue()); // 假设CloseTimeType有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateTotalNum()) {
orderDb.setTotalNum(updateOrderRequest.getModification().getTotalNum());
}
if (updateOrderRequest.getModification().getShouldUpdatePayPrice()) {
orderDb.setPayPrice(updateOrderRequest.getModification().getPayPrice());
}
if (updateOrderRequest.getModification().getShouldUpdateOnlinePay()) {
orderDb.setOnlinePay(updateOrderRequest.getModification().getOnlinePayValue());
}
if (updateOrderRequest.getModification().getShouldUpdatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (updateOrderRequest.getModification().getShouldUpdatePayStatus()) {
orderDb.setPayStatus(updateOrderRequest.getModification().getPayStatusValue()); // 假设PayStatusEnum有getValue方法获取对应整数值
}
if (updateOrderRequest.getModification().getShouldUpdateErrorMsg()) {
orderDb.setErrorMsg(updateOrderRequest.getModification().getErrorMsg());
}
if (updateOrderRequest.getModification().getShouldUpdateTransactionId()) {
orderDb.setTransactionId(updateOrderRequest.getModification().getTransactionId());
}
if (updateOrderRequest.getModification().getShouldUpdateMealTime()) {
orderDb.setMealTime(Instant.ofEpochMilli(updateOrderRequest.getModification().getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (updateOrderRequest.getModification().getShouldUpdateAddress()) {
orderDb.setAddress(updateOrderRequest.getModification().getAddress());
}
if (updateOrderRequest.getModification().getShouldUpdateRoomNo()) {
orderDb.setRoomNo(updateOrderRequest.getModification().
getRoomNo());
}
if (updateOrderRequest.getModification().getShouldUpdateTableCode()) {
orderDb.setTableCode(updateOrderRequest.getModification().getTableCode());
}
if (updateOrderRequest.getModification().getShouldUpdatePickupCode()) {
orderDb.setPickupCode(updateOrderRequest.getModification().getPickupCode());
}
if (updateOrderRequest.getModification().getShouldUpdateOrderType()) {
orderDb.setOrderType(updateOrderRequest.getModification().getOrderTypeValue());
}
if (updateOrderRequest.getModification().getShouldUpdateRemark()) {
orderDb.setRemark(updateOrderRequest.getModification().getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (updateOrderRequest.getModification().getShouldUpdateCustomerNoticeJson()) {
orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(updateOrderRequest.getModification().getCustomerNoticeJson().getAvoidsList())
.doctors(updateOrderRequest.getModification().getCustomerNoticeJson().getDoctorsList())
.build()));
}
if (updateOrderRequest.getModification().getShouldUpdateIsRead()) {
orderDb.setIsRead(updateOrderRequest.getModification().getIsRead());
}
if (updateOrderRequest.getModification().getShouldUpdateOpenId()) {
orderDb.setIsConfirm(updateOrderRequest.getModification().getIsConfirm());
}
if (updateOrderRequest.getModification().getShouldUpdateIsAllocation()) {
orderDb.setIsAllocation(updateOrderRequest.getModification().getIsAllocation());
}
return orderDbMapper.updateById(orderDb) > 0;
}
return orderDbMapper.updateById(orderDb) > 0;
}
@Override
public Boolean batchUpdateOrderDbs(
BatchUpdateClientCustomerOrdersRpcRequest batchUpdateOrdersRequest) {
final var list = batchUpdateOrdersRequest.getModificationsList().stream().map(modification -> {
var orderDb = new OrderDb();
orderDb.setId(modification.getId());
orderDb.setEnterpriseId(batchUpdateOrdersRequest.getEnterpriseId());
orderDb.setUpdatedBy(batchUpdateOrdersRequest.getUpdatedBy());
orderDb.setUpdateSource(batchUpdateOrdersRequest.getUpdateSourceValue());
if (modification.getShouldUpdateOrderCode()) {
orderDb.setOrderCode(modification.getOrderCode());
}
if (modification.getShouldUpdateClientId()) {
orderDb.setClientId(modification.getClientId());
}
if (modification.getShouldUpdateStallId()) {
orderDb.setStallId(modification.getStallId());
}
if (modification.getShouldUpdateCustomerId()) {
orderDb.setCustomerId(modification.getCustomerId());
}
if (modification.getShouldUpdateOpenId()) {
orderDb.setOpenId(modification.getOpenId());
}
if (modification.getShouldUpdateStatus()) {
orderDb.setStatus(modification.getStatusValue());
}
if (modification.getShouldUpdateMenuId()) {
orderDb.setMenuId(modification.getMenuId());
}
if (modification.getShouldUpdateCloseTimeType()) {
orderDb.setCloseTimeType(modification.getCloseTimeTypeValue());
}
if (modification.getShouldUpdateTotalNum()) {
orderDb.setTotalNum(modification.getTotalNum());
}
if (modification.getShouldUpdatePayPrice()) {
orderDb.setPayPrice(modification.getPayPrice());
}
if (modification.getShouldUpdateOnlinePay()) {
orderDb.setOnlinePay(modification.getOnlinePay());
}
if (modification.getShouldUpdatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(modification.getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (modification.getShouldUpdatePayStatus()) {
orderDb.setPayStatus(modification.getPayStatusValue());
}
if (modification.getShouldUpdateErrorMsg()) {
orderDb.setErrorMsg(modification.getErrorMsg());
}
if (modification.getShouldUpdateTransactionId()) {
orderDb.setTransactionId(modification.getTransactionId());
}
if (modification.getShouldUpdateMealTime()) {
orderDb.setMealTime(Instant.ofEpochMilli(modification.getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (modification.getShouldUpdateAddress()) {
orderDb.setAddress(modification.getAddress());
}
if (modification.getShouldUpdateRoomNo()) {
orderDb.setRoomNo(modification.getRoomNo());
}
if (modification.getShouldUpdateTableCode()) {
orderDb.setTableCode(modification.getTableCode());
}
if (modification.getShouldUpdatePickupCode()) {
orderDb.setPickupCode(modification.getPickupCode());
}
if (modification.getShouldUpdateOrderType()) {
orderDb.setOrderType(modification.getOrderTypeValue());
}
if (modification.getShouldUpdateRemark()) {
orderDb.setRemark(modification.getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (modification.getShouldUpdateCustomerNoticeJson()) {
orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(modification.getCustomerNoticeJson().getAvoidsList())
.doctors(modification.getCustomerNoticeJson().getDoctorsList())
.build()));
}
if (modification.getShouldUpdateIsRead()) {
orderDb.setIsRead(modification.getIsRead());
}
if (modification.getShouldUpdateIsConfirm()) {
orderDb.setIsConfirm(modification.getIsConfirm());
}
if (modification.getShouldUpdateIsAllocation()) {
orderDb.setIsAllocation(modification.getIsAllocation());
}
return orderDb;
}).collect(Collectors.toList());
return SpringUtil.getBean(OrderDbServiceImpl.class).updateBatchById(list);
}
@Override
public Boolean batchUpdateOrderDbs(
BatchUpdateClientCustomerOrdersRpcRequest batchUpdateOrdersRequest) {
final var list = batchUpdateOrdersRequest.getModificationsList().stream().map(modification -> {
var orderDb = new OrderDb();
orderDb.setId(modification.getId());
orderDb.setEnterpriseId(batchUpdateOrdersRequest.getEnterpriseId());
orderDb.setUpdatedBy(batchUpdateOrdersRequest.getUpdatedBy());
orderDb.setUpdateSource(batchUpdateOrdersRequest.getUpdateSourceValue());
if (modification.getShouldUpdateOrderCode()) {
orderDb.setOrderCode(modification.getOrderCode());
}
if (modification.getShouldUpdateClientId()) {
orderDb.setClientId(modification.getClientId());
}
if (modification.getShouldUpdateStallId()) {
orderDb.setStallId(modification.getStallId());
}
if (modification.getShouldUpdateCustomerId()) {
orderDb.setCustomerId(modification.getCustomerId());
}
if (modification.getShouldUpdateOpenId()) {
orderDb.setOpenId(modification.getOpenId());
}
if (modification.getShouldUpdateStatus()) {
orderDb.setStatus(modification.getStatusValue());
}
if (modification.getShouldUpdateMenuId()) {
orderDb.setMenuId(modification.getMenuId());
}
if (modification.getShouldUpdateCloseTimeType()) {
orderDb.setCloseTimeType(modification.getCloseTimeTypeValue());
}
if (modification.getShouldUpdateTotalNum()) {
orderDb.setTotalNum(modification.getTotalNum());
}
if (modification.getShouldUpdatePayPrice()) {
orderDb.setPayPrice(modification.getPayPrice());
}
if (modification.getShouldUpdateOnlinePay()) {
orderDb.setOnlinePay(modification.getOnlinePayValue());
}
if (modification.getShouldUpdatePayTime()) {
orderDb.setPayTime(Instant.ofEpochMilli(modification.getPayTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (modification.getShouldUpdatePayStatus()) {
orderDb.setPayStatus(modification.getPayStatusValue());
}
if (modification.getShouldUpdateErrorMsg()) {
orderDb.setErrorMsg(modification.getErrorMsg());
}
if (modification.getShouldUpdateTransactionId()) {
orderDb.setTransactionId(modification.getTransactionId());
}
if (modification.getShouldUpdateMealTime()) {
orderDb.setMealTime(Instant.ofEpochMilli(modification.getMealTime())
.atZone(ZoneId.systemDefault())
.toLocalDateTime());
}
if (modification.getShouldUpdateAddress()) {
orderDb.setAddress(modification.getAddress());
}
if (modification.getShouldUpdateRoomNo()) {
orderDb.setRoomNo(modification.getRoomNo());
}
if (modification.getShouldUpdateTableCode()) {
orderDb.setTableCode(modification.getTableCode());
}
if (modification.getShouldUpdatePickupCode()) {
orderDb.setPickupCode(modification.getPickupCode());
}
if (modification.getShouldUpdateOrderType()) {
orderDb.setOrderType(modification.getOrderTypeValue());
}
if (modification.getShouldUpdateRemark()) {
orderDb.setRemark(modification.getRemark());
}
ObjectMapper objectMapper = new ObjectMapper();
if (modification.getShouldUpdateCustomerNoticeJson()) {
orderDb.setCustomerNoticeJson(objectMapper.valueToTree(CustomerNoticeDto.builder()
.avoids(modification.getCustomerNoticeJson().getAvoidsList())
.doctors(modification.getCustomerNoticeJson().getDoctorsList())
.build()));
}
if (modification.getShouldUpdateIsRead()) {
orderDb.setIsRead(modification.getIsRead());
}
if (modification.getShouldUpdateIsConfirm()) {
orderDb.setIsConfirm(modification.getIsConfirm());
}
if (modification.getShouldUpdateIsAllocation()) {
orderDb.setIsAllocation(modification.getIsAllocation());
}
return orderDb;
}).collect(Collectors.toList());
return SpringUtil.getBean(OrderDbServiceImpl.class).updateBatchById(list);
}
@Override
public List<OrderDb> getOrdersByOpenId(Integer openId) {
QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
wrapper.eq("openId", openId)
.orderByDesc("createdAt");
return orderDbMapper.selectList(wrapper);
}
@Override
public List<OrderDb> getOrdersByOpenId(Integer openId) {
QueryWrapper<OrderDb> wrapper = new QueryWrapper<>();
wrapper.eq("openId", openId)
.orderByDesc("createdAt");
return orderDbMapper.selectList(wrapper);
}
// @Override
// public List<OrderDb> batchCreateOrdersAndDetails(
......
......@@ -2,10 +2,10 @@ package com.tianting.infoloop.utils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.protobuf.GeneratedMessageV3;
import com.infoloop.tianting.clientcustomerorderservice.CloseTimeType;
import com.infoloop.tianting.clientcustomerorderservice.CustomerNotice;
import com.infoloop.tianting.clientcustomerorderservice.MealDetail;
import com.infoloop.tianting.clientcustomerorderservice.OnlinePayEnum;
import com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum;
import com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum;
import com.infoloop.tianting.clientcustomerorderservice.OrderTypeEnum;
......@@ -15,7 +15,7 @@ import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrde
import com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse;
import com.tianting.infoloop.model.db.OrderDb;
import com.tianting.infoloop.model.db.OrderDetailDb;
import java.lang.reflect.Constructor;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
......@@ -56,7 +56,7 @@ public class DbToProtoUtil {
}
if (orderDb.getOnlinePay()!= null) {
protoBuilder.setOnlinePay(orderDb.getOnlinePay());
protoBuilder.setOnlinePay(OnlinePayEnum.forNumber(orderDb.getOnlinePay()));
}
if (orderDb.getPayStatus()!= null) {
......
......@@ -81,6 +81,15 @@ enum CloseTimeType {
RESERVATION = 1;
}
enum OnlinePayEnum {
UNKNOWN = 0;
ONLINE = 1; //在线
OFFLINE = 2; //线下
LEAVE_HOSPITAL = 3;//出院
EMPLOYEE_CARD = 4; //员工卡
PAPER_VERIFICATION = 5; //纸质核销
}
enum ServeStatusEnum {
UNKNOWN_SERVE_STATUS = 0;
SERVE_NOT_START = 1;
......@@ -106,7 +115,7 @@ message SingleClientCustomerOrderRpcResponse {
CloseTimeType closeTimeType = 10;
int32 totalNum = 11;
int32 payPrice = 12;
bool onlinePay = 13;
OnlinePayEnum onlinePay = 13;
int64 payTime = 14;
PayStatusEnum payStatus = 15;
string errorMsg = 16;
......@@ -205,7 +214,7 @@ message QueryClientCustomerOrdersByConditionRpcRequest {
bool shouldFilterCloseTimeType = 16;
CloseTimeType closeTimeType = 17;
bool shouldFilterOnlinePay = 18;
bool onlinePay = 19;
OnlinePayEnum onlinePay = 19;
bool shouldFilterPayTimeStart = 20;
int64 payTimeStart = 21;
bool shouldFilterPayTimeEnd = 22;
......@@ -254,7 +263,7 @@ message ClientCustomerOrderCreation{
bool shouldCreatePayPrice = 12;
int32 payPrice = 13;
bool shouldCreateOnlinePay = 14;
bool onlinePay = 15;
OnlinePayEnum onlinePay = 15;
bool shouldCreatePayTime = 16;
int64 payTime = 17;
bool shouldCreatePayStatus = 18;
......@@ -330,7 +339,7 @@ message ClientCustomerOrderModification {
bool shouldUpdatePayPrice = 20;
int32 payPrice = 21;
bool shouldUpdateOnlinePay = 22;
bool onlinePay = 23;
OnlinePayEnum onlinePay = 23;
bool shouldUpdatePayTime = 24;
int64 payTime = 25;
bool shouldUpdatePayStatus = 26;
......