发货单

pull/451/head
starrysky 2020-01-04 18:51:57 +08:00
parent e5bd305c22
commit 7e2daa57d1
4 changed files with 68 additions and 6 deletions

View File

@ -153,13 +153,17 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
throw new BadRequestException("产品" + repeatProductCodeStr + "请合并为一条记录"); throw new BadRequestException("产品" + repeatProductCodeStr + "请合并为一条记录");
} }
Long totalMoney = 0L; Long totalMoney = 0L;
//插入客户订单对应的产品信息 //插入客户订单对应的产品信息
List<CustomerOrderProductRequest> customerOrderProductRequestList = createCustomerOrderRequest.getCustomerOrderProductList(); List<CustomerOrderProductRequest> customerOrderProductRequestList = createCustomerOrderRequest.getCustomerOrderProductList();
if(CollectionUtils.isEmpty(customerOrderProductRequestList)){ if(CollectionUtils.isEmpty(customerOrderProductRequestList)){
throw new BadRequestException("订单产品不能为空!"); throw new BadRequestException("订单产品不能为空!");
} }
CustomerOrder customerOrder = new CustomerOrder(); CustomerOrder customerOrder = new CustomerOrder();
BeanUtils.copyProperties(createCustomerOrderRequest, customerOrder); BeanUtils.copyProperties(createCustomerOrderRequest, customerOrder);
customerOrder.setStatus(true); customerOrder.setStatus(true);

View File

@ -6,8 +6,14 @@ import lombok.Data;
import me.zhengjie.modules.wms.invoice.domain.Invoice; import me.zhengjie.modules.wms.invoice.domain.Invoice;
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct; import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO; import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
/** /**
@ -16,9 +22,12 @@ import java.util.List;
*/ */
@Data @Data
public class UpdateInvoiceRequest implements Serializable { public class UpdateInvoiceRequest implements Serializable {
// 主键
private Long id; private Long id;
private Timestamp createTime;
private Timestamp updateTime;
// 客户订单编号 // 客户订单编号
private String customerOrderCode; private String customerOrderCode;
@ -37,15 +46,22 @@ public class UpdateInvoiceRequest implements Serializable {
// 物流公司 // 物流公司
private String logisticsCompany; private String logisticsCompany;
// 物流单号
private String logisticsCode;
// 销售发货单号 // 销售发货单号
private String saleInvoiceCode; private String saleInvoiceCode;
// 状态
private Boolean status;
// 备注 // 备注
private String remark; private String remark;
// 客户ID
private Long customerId; private Long customerId;
private String customerName;
private List<InvoiceProductDTO> invoiceProductList; private List<InvoiceProductDTO> invoiceProductList;
public void copy(Invoice source){ public void copy(Invoice source){

View File

@ -44,6 +44,8 @@ public class InvoiceProductDTO implements Serializable {
// 瘦瘦金额 // 瘦瘦金额
private Long salePrice; private Long salePrice;
private Long unitPrice;
// 备注 // 备注
private String remark; private String remark;
} }

View File

@ -7,6 +7,7 @@ import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository; import me.zhengjie.modules.wms.bd.repository.ProductInfoRepository;
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder; import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct; import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
import me.zhengjie.modules.wms.customerOrder.request.CustomerOrderProductRequest;
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderDTO; import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderDTO;
import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderProductDTO; import me.zhengjie.modules.wms.customerOrder.service.dto.CustomerOrderProductDTO;
import me.zhengjie.modules.wms.invoice.domain.Invoice; import me.zhengjie.modules.wms.invoice.domain.Invoice;
@ -32,10 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -203,6 +201,39 @@ public class InvoiceServiceImpl implements InvoiceService {
throw new BadRequestException("发货单产品信息不能为空!"); throw new BadRequestException("发货单产品信息不能为空!");
} }
// 校验
for(InvoiceProduct invoiceProduct : invoiceProductRequestList){
String productCode = invoiceProduct.getProductCode();
if(StringUtils.isEmpty(productCode)){
throw new BadRequestException("产品编号不能为空!");
}
String productName = invoiceProduct.getProductName();
if(StringUtils.isEmpty(productName)){
throw new BadRequestException("产品编号" + productCode+"对应的产品名称不能为空!");
}
String specifications = invoiceProduct.getSpecifications();
if(StringUtils.isEmpty(specifications)){
throw new BadRequestException("产品编号" + productCode+"对应的产品规格不能为空!");
}
Long unitPrice = invoiceProduct.getUnitPrice();
if(null == unitPrice){
throw new BadRequestException("产品编号" + productCode+"对应的产品单价不能为空!");
}
Long customerOrderNumber = invoiceProduct.getCustomerOrderNumber();
if(null == customerOrderNumber){
throw new BadRequestException("产品编号" + productCode+"对应的订单数量不能为空!");
}
Long actualInvoiceNumber = invoiceProduct.getActualInvoiceNumber();
if(null == actualInvoiceNumber){
throw new BadRequestException("产品编号" + productCode+"对应的实发数量不能为空!");
}
Long salePrice = invoiceProduct.getSalePrice();
if(null == salePrice){
throw new BadRequestException("产品编号" + productCode+"对应的销售金额不能为空!");
}
}
BeanUtils.copyProperties(createInvoiceRequest, invoice); BeanUtils.copyProperties(createInvoiceRequest, invoice);
invoice.setStatus(true); invoice.setStatus(true);
invoiceRepository.save(invoice); invoiceRepository.save(invoice);
@ -249,9 +280,18 @@ public class InvoiceServiceImpl implements InvoiceService {
throw new BadRequestException("产品" + repeatProductCodeStr + "请合并为一条记录"); throw new BadRequestException("产品" + repeatProductCodeStr + "请合并为一条记录");
} }
Optional<Invoice> invoiceOptional = invoiceRepository.findById(updateInvoiceRequest.getId());
ValidationUtil.isNull(invoiceOptional,"SInvoice","id",updateInvoiceRequest.getId());
Invoice invoiceOrigin = invoiceOptional.get();
Invoice invoice = new Invoice(); Invoice invoice = new Invoice();
BeanUtils.copyProperties(updateInvoiceRequest, invoice); BeanUtils.copyProperties(updateInvoiceRequest, invoice);
// 修改发货单概要信息 // 修改发货单概要信息
invoice.setCreateTime(invoiceOrigin.getCreateTime());
Timestamp updateTime = new Timestamp(System.currentTimeMillis());
invoice.setUpdateTime(updateTime);
invoice.setStatus(true);
invoiceRepository.save(invoice); invoiceRepository.save(invoice);
// 修改产品信息之前查询该订单中原来的产品信息key为产品code // 修改产品信息之前查询该订单中原来的产品信息key为产品code