客户订单录入

pull/451/head
starrysky 2019-08-17 12:14:21 +08:00
parent de3d669892
commit 898ac8f71b
15 changed files with 300 additions and 35 deletions

View File

@ -13,4 +13,6 @@ public class CustomerInfoQueryCriteria {
private String customerName; private String customerName;
private String customerCode;
} }

View File

@ -10,4 +10,10 @@ import me.zhengjie.annotation.Query;
*/ */
@Data @Data
public class OutSourceCompanyInfoQueryCriteria { public class OutSourceCompanyInfoQueryCriteria {
// 委外公司名称
private String outSourceCompanyName;
// 委外公司编号
private String outSourceCompanyCode;
} }

View File

@ -56,7 +56,7 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
//客户名称 //客户名称
String customerName = criteria.getCustomerName(); String customerName = criteria.getCustomerName();
if (!StringUtils.isEmpty(customerName)) { if (!StringUtils.isEmpty(customerName)) {
Predicate namePredicate = criteriaBuilder.like(root.get("name"), "%" + customerName + "%"); Predicate namePredicate = criteriaBuilder.like(root.get("customerName"), "%" + customerName + "%");
targetPredicateList.add(namePredicate); targetPredicateList.add(namePredicate);
} }
@ -64,6 +64,12 @@ public class CustomerInfoServiceImpl implements CustomerInfoService {
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1); Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate); targetPredicateList.add(statusPredicate);
String customerCode = criteria.getCustomerCode();
if(!StringUtils.isEmpty(customerCode)){
Predicate customerCodePredicate = criteriaBuilder.like(root.get("customerCode"), "%" + customerName + "%");
targetPredicateList.add(customerCodePredicate);
}
if(CollectionUtils.isEmpty(targetPredicateList)){ if(CollectionUtils.isEmpty(targetPredicateList)){
return null; return null;
}else{ }else{

View File

@ -23,6 +23,7 @@ import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
@ -54,6 +55,20 @@ public class OutSourceCompanyInfoServiceImpl implements OutSourceCompanyInfoServ
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1); Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate); targetPredicateList.add(statusPredicate);
//委外公司名称
String outSourceCompanyName = criteria.getOutSourceCompanyName();
if (!StringUtils.isEmpty(outSourceCompanyName)) {
Predicate outSourceCompanyNamePredicate = criteriaBuilder.like(root.get("outSourceCompanyName"), "%" + outSourceCompanyName + "%");
targetPredicateList.add(outSourceCompanyNamePredicate);
}
//委外公司名称
String outSourceCompanyCode = criteria.getOutSourceCompanyCode();
if (!StringUtils.isEmpty(outSourceCompanyName)) {
Predicate outSourceCompanyCodePredicate = criteriaBuilder.like(root.get("outSourceCompanyCode"), "%" + outSourceCompanyCode + "%");
targetPredicateList.add(outSourceCompanyCodePredicate);
}
if(CollectionUtils.isEmpty(targetPredicateList)){ if(CollectionUtils.isEmpty(targetPredicateList)){
return null; return null;
}else{ }else{
@ -76,6 +91,20 @@ public class OutSourceCompanyInfoServiceImpl implements OutSourceCompanyInfoServ
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1); Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate); targetPredicateList.add(statusPredicate);
//委外公司名称
String outSourceCompanyName = criteria.getOutSourceCompanyName();
if (!StringUtils.isEmpty(outSourceCompanyName)) {
Predicate outSourceCompanyNamePredicate = criteriaBuilder.like(root.get("outSourceCompanyName"), "%" + outSourceCompanyName + "%");
targetPredicateList.add(outSourceCompanyNamePredicate);
}
//委外公司名称
String outSourceCompanyCode = criteria.getOutSourceCompanyCode();
if (!StringUtils.isEmpty(outSourceCompanyName)) {
Predicate outSourceCompanyCodePredicate = criteriaBuilder.like(root.get("outSourceCompanyCode"), "%" + outSourceCompanyCode + "%");
targetPredicateList.add(outSourceCompanyCodePredicate);
}
if(CollectionUtils.isEmpty(targetPredicateList)){ if(CollectionUtils.isEmpty(targetPredicateList)){
return null; return null;
}else{ }else{

View File

@ -60,6 +60,13 @@ public class CustomerOrderProduct implements Serializable {
@Column(name = "update_time") @Column(name = "update_time")
private Timestamp updateTime; private Timestamp updateTime;
// 状态
private Boolean status;
// 产品编号
@Column(name = "product_code")
private String productCode;
public void copy(CustomerOrderProduct source){ public void copy(CustomerOrderProduct source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -4,9 +4,13 @@ import me.zhengjie.modules.wms.order.domain.CustomerOrderProduct;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/** /**
* @author jie * @author jie
* @date 2019-08-03 * @date 2019-08-03
*/ */
public interface CustomerOrderProductRepository extends JpaRepository<CustomerOrderProduct, Long>, JpaSpecificationExecutor { public interface CustomerOrderProductRepository extends JpaRepository<CustomerOrderProduct, Long>, JpaSpecificationExecutor {
List<CustomerOrderProduct> findByCustomerOrderIdAndStatusTrue(Long customerId);
} }

View File

@ -14,9 +14,19 @@ public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Lo
/** /**
* () * ()
*
* @param id * @param id
*/ */
@Modifying @Modifying
@Query(value = "update s_customer_order set status = 0 where id = ?1",nativeQuery = true) @Query(value = "update s_customer_order set status = 0 where id = ?1", nativeQuery = true)
void deleteCustomerOrder(long id); void deleteCustomerOrder(long id);
}
/**
*
*
* @param customerOrderCode
* @return
*/
@Query(value = "select * from s_customer_order where customerOrderCode = ?1 and status = 1", nativeQuery = true)
CustomerOrder findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
}

View File

@ -0,0 +1,82 @@
package me.zhengjie.modules.wms.order.request;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import me.zhengjie.modules.wms.order.domain.CustomerOrder;
import java.sql.Timestamp;
import java.util.List;
/**
* @author
* @date 2019-08-17
*/
@Data
public class CreateCustomerOrderRequest {
// 所属客户主键
private Long customerId;
// 客户名称
private String customerName;
// 订单日期
private Timestamp orderDate;
// 交货日期
private Timestamp deliveryDate;
// 客户订单编号
private String customerOrderCode;
// 制单人主键
private Long customerOrderMakerId;
// 制单人姓名
private String customerOrderMakerName;
// 交货方式code
private String deliveryWayCode;
// 交货方式名称
private String deliveryWayName;
// 付款方式
private String payWayCode;
// 付款方式名称
private String payWayName;
// 收货地址
private String deliveryAddress;
// 收货人
private String deliveryUser;
// 收货人联系方式
private String deliveryUserContact;
// 备注
private String remark;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
// 总额
private Long totalMoney;
// 总数量
private Long totalNumber;
private List<CustomerOrderProductRequest> customerOrderProductList;
public void copy(CustomerOrder source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@ -0,0 +1,47 @@
package me.zhengjie.modules.wms.order.request;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author
* @date 2019-08-17
*/
@Data
public class CustomerOrderProductRequest implements Serializable {
// 产品主键
private Long productId;
// 产品名称
private Long productName;
// 规格
private String specifications;
// 产品单价
private Long unitPrice;
// 产品总价
private Long totalPrice;
// 产品数量
private Long productNumber;
// 备注
private String remark;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
// 状态
private Boolean status;
// 产品编号
private String productCode;
}

View File

@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.order.rest;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.wms.order.domain.CustomerOrder; import me.zhengjie.modules.wms.order.domain.CustomerOrder;
import me.zhengjie.modules.wms.order.request.CreateCustomerOrderRequest;
import me.zhengjie.modules.wms.order.service.CustomerOrderService; import me.zhengjie.modules.wms.order.service.CustomerOrderService;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,11 +14,14 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/** /**
* @author jie * @author jie
* @date 2019-08-03 * @date 2019-08-03
*/ */
@Api(tags = "SCustomerOrder管理") @Api(tags = "客户订单管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("api")
public class CustomerOrderController { public class CustomerOrderController {
@ -27,9 +31,9 @@ public class CustomerOrderController {
@Log("分页查询客户订单列表") @Log("分页查询客户订单列表")
@ApiOperation(value = "分页查询客户订单列表") @ApiOperation(value = "分页查询客户订单列表")
@GetMapping(value = "/customerOrders") @GetMapping(value = "/queryCustomerOrderPage")
@PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_SELECT')")
public ResponseEntity getCustomerOrders(CustomerOrderQueryCriteria criteria, Pageable pageable){ public ResponseEntity queryCustomerOrderPage(CustomerOrderQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(customerOrderService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity(customerOrderService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@ -37,11 +41,11 @@ public class CustomerOrderController {
@ApiOperation(value = "新增客户订单") @ApiOperation(value = "新增客户订单")
@PostMapping(value = "/customerOrder") @PostMapping(value = "/customerOrder")
@PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_CREATE')")
public ResponseEntity create(@RequestBody CustomerOrder resources){ public ResponseEntity create(@RequestBody CreateCustomerOrderRequest createCustomerOrderRequest){
return new ResponseEntity(customerOrderService.create(resources),HttpStatus.CREATED); return new ResponseEntity(customerOrderService.create(createCustomerOrderRequest),HttpStatus.CREATED);
} }
@Log("修改SCustomerOrder") @Log("修改客户订单")
@ApiOperation(value = "修改SCustomerOrder") @ApiOperation(value = "修改SCustomerOrder")
@PutMapping(value = "/customerOrder") @PutMapping(value = "/customerOrder")
@PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_EDIT')")
@ -50,7 +54,7 @@ public class CustomerOrderController {
return new ResponseEntity(HttpStatus.NO_CONTENT); return new ResponseEntity(HttpStatus.NO_CONTENT);
} }
@Log("删除SCustomerOrder") @Log("删除客户订单")
@ApiOperation(value = "删除SCustomerOrder") @ApiOperation(value = "删除SCustomerOrder")
@DeleteMapping(value = "/customerOrder/{id}") @DeleteMapping(value = "/customerOrder/{id}")
@PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_DELETE')")
@ -58,4 +62,12 @@ public class CustomerOrderController {
customerOrderService.delete(id); customerOrderService.delete(id);
return new ResponseEntity(HttpStatus.OK); return new ResponseEntity(HttpStatus.OK);
} }
@Log("初始化客户订单编号")
@GetMapping(value = "/initCustomerOrderCode")
public ResponseEntity initCustomerOrderCode(){
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");//设置日期格式
String supplierCode = "DD"+ LocalDateTime.now().format(fmt);
return new ResponseEntity(supplierCode,HttpStatus.OK);
}
} }

View File

@ -17,7 +17,7 @@ import io.swagger.annotations.*;
* @author jie * @author jie
* @date 2019-08-03 * @date 2019-08-03
*/ */
@Api(tags = "SCustomerOrderProduct管理") @Api(tags = "客户订单管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("api")
public class CustomerOrderProductController { public class CustomerOrderProductController {
@ -25,11 +25,11 @@ public class CustomerOrderProductController {
@Autowired @Autowired
private CustomerOrderProductService customerOrderProductService; private CustomerOrderProductService customerOrderProductService;
@Log("查询SCustomerOrderProduct") @Log("分页查询客户订单产品列表")
@ApiOperation(value = "查询SCustomerOrderProduct") @ApiOperation(value = "分页查询客户订单产品列表")
@GetMapping(value = "/sCustomerOrderProduct") @GetMapping(value = "/queryCustomerOrderProductPage")
@PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDERPRODUCT_ALL','SCUSTOMERORDERPRODUCT_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDERPRODUCT_ALL','SCUSTOMERORDERPRODUCT_SELECT')")
public ResponseEntity getSCustomerOrderProducts(CustomerOrderProductQueryCriteria criteria, Pageable pageable){ public ResponseEntity queryCustomerOrderProductPage(CustomerOrderProductQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(customerOrderProductService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity(customerOrderProductService.queryAll(criteria,pageable),HttpStatus.OK);
} }

View File

@ -4,6 +4,7 @@ package me.zhengjie.modules.wms.order.service;
//import org.springframework.cache.annotation.CacheEvict; //import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable; //import org.springframework.cache.annotation.Cacheable;
import me.zhengjie.modules.wms.order.domain.CustomerOrder; import me.zhengjie.modules.wms.order.domain.CustomerOrder;
import me.zhengjie.modules.wms.order.request.CreateCustomerOrderRequest;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderDTO; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderDTO;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -42,11 +43,11 @@ public interface CustomerOrderService {
/** /**
* create * create
* @param resources * @param createCustomerOrderRequest
* @return * @return
*/ */
//@CacheEvict(allEntries = true) //@CacheEvict(allEntries = true)
CustomerOrderDTO create(CustomerOrder resources); CustomerOrderDTO create(CreateCustomerOrderRequest createCustomerOrderRequest);
/** /**
* update * update

View File

@ -1,9 +1,12 @@
package me.zhengjie.modules.wms.order.service.dto; package me.zhengjie.modules.wms.order.service.dto;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data; import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List;
/** /**
* @author jie * @author jie
@ -70,4 +73,14 @@ public class CustomerOrderDTO implements Serializable {
// 总数量 // 总数量
private Long totalNumber; private Long totalNumber;
// 状态
private Boolean status;
// 订单产品
private List<CustomerOrderProductDTO> customerOrderProductList;
public void copy(CustomerOrderDTO source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
} }

View File

@ -1,21 +1,14 @@
package me.zhengjie.modules.wms.order.service.dto; package me.zhengjie.modules.wms.order.service.dto;
import lombok.Data;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/** /**
* @author jie * @author
* @date 2019-08-03 * @date 2019-08-17
*/ */
@Data public class CustomerOrderProductDTO {
public class CustomerOrderProductDTO implements Serializable {
// 处理精度丢失问题
@JsonSerialize(using= ToStringSerializer.class)
private Long id; private Long id;
// 所属客户订单 // 所属客户订单
@ -47,4 +40,10 @@ public class CustomerOrderProductDTO implements Serializable {
// 更新时间 // 更新时间
private Timestamp updateTime; private Timestamp updateTime;
}
// 状态
private Boolean status;
// 产品编号
private String productCode;
}

View File

@ -1,21 +1,33 @@
package me.zhengjie.modules.wms.order.service.impl; package me.zhengjie.modules.wms.order.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.wms.order.domain.CustomerOrder; import me.zhengjie.modules.wms.order.domain.CustomerOrder;
import me.zhengjie.modules.wms.order.domain.CustomerOrderProduct;
import me.zhengjie.modules.wms.order.repository.CustomerOrderProductRepository;
import me.zhengjie.modules.wms.order.repository.CustomerOrderRepository; import me.zhengjie.modules.wms.order.repository.CustomerOrderRepository;
import me.zhengjie.modules.wms.order.request.CreateCustomerOrderRequest;
import me.zhengjie.modules.wms.order.request.CustomerOrderProductRequest;
import me.zhengjie.modules.wms.order.service.CustomerOrderService; import me.zhengjie.modules.wms.order.service.CustomerOrderService;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderDTO; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderDTO;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderProductDTO;
import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderQueryCriteria;
import me.zhengjie.modules.wms.order.service.mapper.CustomerOrderMapper; import me.zhengjie.modules.wms.order.service.mapper.CustomerOrderMapper;
import me.zhengjie.modules.wms.order.service.mapper.CustomerOrderProductMapper;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp; import me.zhengjie.utils.QueryHelp;
import org.springframework.util.CollectionUtils;
/** /**
* @author jie * @author jie
@ -28,9 +40,15 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
@Autowired @Autowired
private CustomerOrderRepository customerOrderRepository; private CustomerOrderRepository customerOrderRepository;
@Autowired
private CustomerOrderProductRepository customerOrderProductRepository;
@Autowired @Autowired
private CustomerOrderMapper customerOrderMapper; private CustomerOrderMapper customerOrderMapper;
@Autowired
private CustomerOrderProductMapper customerOrderProductMapper;
@Override @Override
public Object queryAll(CustomerOrderQueryCriteria criteria, Pageable pageable){ public Object queryAll(CustomerOrderQueryCriteria criteria, Pageable pageable){
Page<CustomerOrder> page = customerOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Page<CustomerOrder> page = customerOrderRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
@ -51,9 +69,38 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CustomerOrderDTO create(CustomerOrder resources) { public CustomerOrderDTO create(CreateCustomerOrderRequest createCustomerOrderRequest) {
resources.setStatus(true); CustomerOrder customerOrder = new CustomerOrder();
return customerOrderMapper.toDto(customerOrderRepository.save(resources)); BeanUtils.copyProperties(createCustomerOrderRequest, customerOrder);
customerOrder.setStatus(true);
//插入客户订单
customerOrderRepository.save(customerOrder);
customerOrder= customerOrderRepository.findByCustomerOrderCodeAndStatusTrue(createCustomerOrderRequest.getCustomerOrderCode());
//插入客户订单对应的产品信息
List<CustomerOrderProductRequest> customerOrderProductRequestList = createCustomerOrderRequest.getCustomerOrderProductList();
if(CollectionUtils.isEmpty(customerOrderProductRequestList)){
throw new BadRequestException("订单产品不能为空!");
}
List<CustomerOrderProduct> customerOrderProductList = new ArrayList<>();
for(CustomerOrderProductRequest customerOrderProductRequest : customerOrderProductRequestList){
CustomerOrderProduct customerOrderProduct = new CustomerOrderProduct();
BeanUtils.copyProperties(customerOrderProductRequest, customerOrderProduct);
customerOrderProduct.setCustomerOrderId(customerOrder.getId());
customerOrderProduct.setStatus(true);
}
customerOrderProductRepository.saveAll(customerOrderProductList);
CustomerOrderDTO customerOrderDTO = customerOrderMapper.toDto(customerOrder);
List<CustomerOrderProduct> byCustomerOrderIdAndStatusTrue = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrder.getId());
List<CustomerOrderProductDTO> customerOrderProductDTOList = customerOrderProductMapper.toDto(byCustomerOrderIdAndStatusTrue);
customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList);
return customerOrderDTO;
} }
@Override @Override