客户订单返货单

pull/451/head
starrysky 2019-09-07 11:46:05 +08:00
parent a0106efcb4
commit ada4484489
9 changed files with 105 additions and 4 deletions

View File

@ -64,9 +64,11 @@ public class CustomerOrderDTO implements Serializable {
// 创建时间 // 创建时间
private Timestamp createTime; private Timestamp createTime;
private String createTimeStr;
// 更新时间 // 更新时间
private Timestamp updateTime; private Timestamp updateTime;
private String updateTimeStr;
// 总额 // 总额
private Long totalMoney; private Long totalMoney;

View File

@ -29,6 +29,8 @@ 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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -103,6 +105,8 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
for(CustomerOrderDTO customerOrderDTO : customerOrderDTOList){ for(CustomerOrderDTO customerOrderDTO : customerOrderDTOList){
List<CustomerOrderProduct> customerOrderProductList = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrderDTO.getId()); List<CustomerOrderProduct> customerOrderProductList = customerOrderProductRepository.findByCustomerOrderIdAndStatusTrue(customerOrderDTO.getId());
List<CustomerOrderProductDTO> customerOrderProductDTOList = customerOrderProductMapper.toDto(customerOrderProductList); List<CustomerOrderProductDTO> customerOrderProductDTOList = customerOrderProductMapper.toDto(customerOrderProductList);
Timestamp createTime = customerOrderDTO.getCreateTime();
customerOrderDTO.setCreateTimeStr(new SimpleDateFormat("yyyy-MM-dd").format(createTime));
customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList); customerOrderDTO.setCustomerOrderProductList(customerOrderProductDTOList);
} }
} }

View File

@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.invoice.domain;
import lombok.Data; import lombok.Data;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.io.Serializable; import java.io.Serializable;
@ -22,9 +24,11 @@ public class Invoice implements Serializable {
private Long id; private Long id;
@Column(name = "create_time") @Column(name = "create_time")
@CreationTimestamp
private Timestamp createTime; private Timestamp createTime;
@Column(name = "update_time") @Column(name = "update_time")
@CreationTimestamp
private Timestamp updateTime; private Timestamp updateTime;
// 客户订单编号 // 客户订单编号
@ -51,6 +55,10 @@ public class Invoice implements Serializable {
@Column(name = "logistics_company") @Column(name = "logistics_company")
private String logisticsCompany; private String logisticsCompany;
// 物流单号
@Column(name = "logistics_code")
private String logisticsCode;
// 销售发货单号 // 销售发货单号
@Column(name = "sale_invoice_code") @Column(name = "sale_invoice_code")
private String saleInvoiceCode; private String saleInvoiceCode;

View File

@ -34,6 +34,9 @@ public class CreateInvoiceRequest implements Serializable {
// 物流公司 // 物流公司
private String logisticsCompany; private String logisticsCompany;
// 物流编号
private String logisticsCode;
// 销售发货单号 // 销售发货单号
private String saleInvoiceCode; private String saleInvoiceCode;

View File

@ -66,7 +66,7 @@ public class InvoiceController {
@Log("删除销售发货单") @Log("删除销售发货单")
@ApiOperation(value = "删除销售发货单") @ApiOperation(value = "删除销售发货单")
@DeleteMapping(value = "/sInvoice/{id}") @DeleteMapping(value = "/invoice/{id}")
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
invoiceService.delete(id); invoiceService.delete(id);

View File

@ -1,6 +1,12 @@
package me.zhengjie.modules.wms.invoice.service.dto; package me.zhengjie.modules.wms.invoice.service.dto;
import lombok.Data; import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.io.Serializable; import java.io.Serializable;
@ -16,8 +22,13 @@ public class InvoiceDTO implements Serializable {
private Timestamp createTime; private Timestamp createTime;
private String createTimeStr;
private Timestamp updateTime; private Timestamp updateTime;
private String updateTimeStr;
// 客户订单编号
private String customerOrderCode; private String customerOrderCode;
// 收货地址 // 收货地址
@ -35,6 +46,9 @@ public class InvoiceDTO implements Serializable {
// 物流公司 // 物流公司
private String logisticsCompany; private String logisticsCompany;
// 物流单号
private String logisticsCode;
// 销售发货单号 // 销售发货单号
private String saleInvoiceCode; private String saleInvoiceCode;
@ -43,4 +57,8 @@ public class InvoiceDTO implements Serializable {
// 备注 // 备注
private String remark; private String remark;
private Long customerId;
private String customerName;
} }

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.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;
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct; import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
@ -24,10 +25,13 @@ import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceMapper; import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceMapper;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -42,6 +46,11 @@ import me.zhengjie.utils.QueryHelp;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
/** /**
* @author jie * @author jie
* @date 2019-08-27 * @date 2019-08-27
@ -70,13 +79,59 @@ public class InvoiceServiceImpl implements InvoiceService {
@Override @Override
public Object queryAll(InvoiceQueryCriteria criteria, Pageable pageable){ public Object queryAll(InvoiceQueryCriteria criteria, Pageable pageable){
Page<Invoice> page = invoiceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Specification<Invoice> specification = new Specification<Invoice>() {
return PageUtil.toPage(page.map(invoiceMapper::toDto)); @Override
public Predicate toPredicate(Root<Invoice> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
Page<Invoice> page = invoiceRepository.findAll(specification,pageable);
Page<InvoiceDTO> invoiceDTOPage = page.map(invoiceMapper::toDto);
if(null != invoiceDTOPage){
List<InvoiceDTO> invoiceDTOList = invoiceDTOPage.getContent();
if(!CollectionUtils.isEmpty(invoiceDTOList)){
for(InvoiceDTO invoiceDTO : invoiceDTOList){
Timestamp createTime = invoiceDTO.getCreateTime();
invoiceDTO.setCreateTimeStr(new SimpleDateFormat("yyyy-MM-dd").format(createTime));
}
}
}
return PageUtil.toPage(invoiceDTOPage);
} }
@Override @Override
public Object queryAll(InvoiceQueryCriteria criteria){ public Object queryAll(InvoiceQueryCriteria criteria){
return invoiceMapper.toDto(invoiceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
Specification<Invoice> specification = new Specification<Invoice>() {
@Override
public Predicate toPredicate(Root<Invoice> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
List invoiceLIst = invoiceRepository.findAll(specification);
List<InvoiceDTO> invoiceDtoList = invoiceMapper.toDto(invoiceLIst);
return invoiceDtoList;
} }
@Override @Override
@ -122,6 +177,8 @@ public class InvoiceServiceImpl implements InvoiceService {
throw new BadRequestException("客户不存在!"); throw new BadRequestException("客户不存在!");
} }
invoice.setCustomerName(customerInfo.getCustomerName());
// 销售发货单号 // 销售发货单号
String saleInvoiceCode = createInvoiceRequest.getSaleInvoiceCode(); String saleInvoiceCode = createInvoiceRequest.getSaleInvoiceCode();
if(StringUtils.isEmpty(saleInvoiceCode)){ if(StringUtils.isEmpty(saleInvoiceCode)){
@ -134,6 +191,7 @@ public class InvoiceServiceImpl implements InvoiceService {
} }
BeanUtils.copyProperties(createInvoiceRequest, invoice); BeanUtils.copyProperties(createInvoiceRequest, invoice);
invoice.setStatus(true);
invoiceRepository.save(invoice); invoiceRepository.save(invoice);
invoice = invoiceRepository.findBySaleInvoiceCode(saleInvoiceCode); invoice = invoiceRepository.findBySaleInvoiceCode(saleInvoiceCode);
InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice); InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice);

View File

@ -9,4 +9,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @date 2019-08-29 * @date 2019-08-29
*/ */
public interface ProductCountRepository extends JpaRepository<ProductCount, Long>, JpaSpecificationExecutor { public interface ProductCountRepository extends JpaRepository<ProductCount, Long>, JpaSpecificationExecutor {
ProductCount findByProductId(Long productId);
} }

View File

@ -75,6 +75,12 @@ public class ProductCountServiceImpl implements ProductCountService {
throw new BadRequestException("产品不存在 !"); throw new BadRequestException("产品不存在 !");
} }
resources.setProductName(productInfo.getName()); resources.setProductName(productInfo.getName());
//验证产品库存统计是否存在
ProductCount productCountTemp = productCountRepository.findByProductId(productId);
if(null != productCountTemp){
throw new BadRequestException("该产品统计记录已经存在 !");
}
return productCountMapper.toDto(productCountRepository.save(resources)); return productCountMapper.toDto(productCountRepository.save(resources));
} }