mirror of https://github.com/elunez/eladmin
发货单
parent
bc9e4fecf5
commit
3b78ebb4c5
|
@ -30,7 +30,7 @@ public class CustomerOrderProduct implements Serializable {
|
||||||
|
|
||||||
// 产品名称
|
// 产品名称
|
||||||
@Column(name = "product_name")
|
@Column(name = "product_name")
|
||||||
private Long productName;
|
private String productName;
|
||||||
|
|
||||||
// 规格
|
// 规格
|
||||||
@Column(name = "specifications")
|
@Column(name = "specifications")
|
||||||
|
|
|
@ -27,6 +27,6 @@ public interface CustomerOrderRepository extends JpaRepository<CustomerOrder, Lo
|
||||||
* @param customerOrderCode
|
* @param customerOrderCode
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Query(value = "select * from s_customer_order where customerOrderCode = ?1 and status = 1", nativeQuery = true)
|
@Query(value = "select * from s_customer_order where customer_order_code = ?1 and status = 1", nativeQuery = true)
|
||||||
CustomerOrder findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
CustomerOrder findByCustomerOrderCodeAndStatusTrue(String customerOrderCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class CustomerOrderProductRequest implements Serializable {
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
// 产品名称
|
// 产品名称
|
||||||
private Long productName;
|
private String productName;
|
||||||
|
|
||||||
// 规格
|
// 规格
|
||||||
private String specifications;
|
private String specifications;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class CustomerOrderProductDTO {
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
||||||
// 产品名称
|
// 产品名称
|
||||||
private Long productName;
|
private String productName;
|
||||||
|
|
||||||
// 规格
|
// 规格
|
||||||
private String specifications;
|
private String specifications;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package me.zhengjie.modules.wms.customerOrder.service.impl;
|
package me.zhengjie.modules.wms.customerOrder.service.impl;
|
||||||
|
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
|
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
||||||
|
import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
||||||
|
import me.zhengjie.modules.wms.bd.service.mapper.CustomerInfoMapper;
|
||||||
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||||
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderRepository;
|
import me.zhengjie.modules.wms.customerOrder.repository.CustomerOrderRepository;
|
||||||
import me.zhengjie.modules.wms.customerOrder.request.UpdateCustomerOrderRequest;
|
import me.zhengjie.modules.wms.customerOrder.request.UpdateCustomerOrderRequest;
|
||||||
|
@ -54,6 +57,12 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerOrderProductMapper customerOrderProductMapper;
|
private CustomerOrderProductMapper customerOrderProductMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerInfoMapper customerInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerInfoRepository customerInfoRepository;
|
||||||
|
|
||||||
@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);
|
||||||
|
@ -84,19 +93,34 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CustomerOrderDTO create(CreateCustomerOrderRequest createCustomerOrderRequest) {
|
public CustomerOrderDTO create(CreateCustomerOrderRequest createCustomerOrderRequest) {
|
||||||
CustomerOrder customerOrder = new CustomerOrder();
|
|
||||||
BeanUtils.copyProperties(createCustomerOrderRequest, customerOrder);
|
|
||||||
customerOrder.setStatus(true);
|
|
||||||
//插入客户订单
|
|
||||||
customerOrderRepository.save(customerOrder);
|
|
||||||
customerOrder= customerOrderRepository.findByCustomerOrderCodeAndStatusTrue(createCustomerOrderRequest.getCustomerOrderCode());
|
|
||||||
|
|
||||||
//插入客户订单对应的产品信息
|
//插入客户订单对应的产品信息
|
||||||
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();
|
||||||
|
BeanUtils.copyProperties(createCustomerOrderRequest, customerOrder);
|
||||||
|
customerOrder.setStatus(true);
|
||||||
|
|
||||||
|
|
||||||
|
Long customerId = createCustomerOrderRequest.getCustomerId();
|
||||||
|
if(null == customerId){
|
||||||
|
throw new BadRequestException("客户不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<CustomerInfo> customerInfoOptional = customerInfoRepository.findById(customerId);
|
||||||
|
if(null == customerInfoOptional || null == customerInfoOptional.get()){
|
||||||
|
throw new BadRequestException("客户不存在!");
|
||||||
|
}
|
||||||
|
CustomerInfo customerInfo = customerInfoOptional.get();
|
||||||
|
|
||||||
|
customerOrder.setCustomerName(customerInfo.getCustomerName());
|
||||||
|
|
||||||
|
//插入客户订单
|
||||||
|
customerOrderRepository.save(customerOrder);
|
||||||
|
customerOrder= customerOrderRepository.findByCustomerOrderCodeAndStatusTrue(createCustomerOrderRequest.getCustomerOrderCode());
|
||||||
|
|
||||||
List<CustomerOrderProduct> customerOrderProductList = new ArrayList<>();
|
List<CustomerOrderProduct> customerOrderProductList = new ArrayList<>();
|
||||||
for(CustomerOrderProductRequest customerOrderProductRequest : customerOrderProductRequestList){
|
for(CustomerOrderProductRequest customerOrderProductRequest : customerOrderProductRequestList){
|
||||||
CustomerOrderProduct customerOrderProduct = new CustomerOrderProduct();
|
CustomerOrderProduct customerOrderProduct = new CustomerOrderProduct();
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Invoice implements Serializable {
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 备注
|
// 备注
|
||||||
@Column(name = "remark")
|
@Column(name = "remark")
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class InvoiceProduct implements Serializable {
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 产品主键
|
// 产品主键
|
||||||
@Column(name = "product_id",nullable = false)
|
@Column(name = "product_id",nullable = false)
|
||||||
|
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.invoice.repository;
|
||||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||||
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 org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -13,4 +15,18 @@ import java.util.List;
|
||||||
public interface InvoiceProductRepository extends JpaRepository<InvoiceProduct, Long>, JpaSpecificationExecutor {
|
public interface InvoiceProductRepository extends JpaRepository<InvoiceProduct, Long>, JpaSpecificationExecutor {
|
||||||
|
|
||||||
List<InvoiceProduct> findByInvoiceIdAndStatusTrue(Long invoiceId);
|
List<InvoiceProduct> findByInvoiceIdAndStatusTrue(Long invoiceId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "update s_invoice_product set status = 0 where invoice_id = ?1", nativeQuery = true)
|
||||||
|
void deleteInvoiceProduct(long invoiceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据产品code以及客户订单id删除发货单中对应的产品信息
|
||||||
|
* @param productCode
|
||||||
|
* @param invoiceId
|
||||||
|
*/
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "delete s_invoice_product where product_code = ?1 and invoice_id = ?2", nativeQuery = true)
|
||||||
|
void deleteByProductCodeAndInvoiceId(String productCode, Long invoiceId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,6 +3,8 @@ package me.zhengjie.modules.wms.invoice.repository;
|
||||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||||
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 org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author jie
|
||||||
|
@ -11,4 +13,8 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
public interface InvoiceRepository extends JpaRepository<Invoice, Long>, JpaSpecificationExecutor {
|
public interface InvoiceRepository extends JpaRepository<Invoice, Long>, JpaSpecificationExecutor {
|
||||||
|
|
||||||
Invoice findBySaleInvoiceCode(String saleInvoiceCode);
|
Invoice findBySaleInvoiceCode(String saleInvoiceCode);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "update s_invoice set status = 0 where id = ?1", nativeQuery = true)
|
||||||
|
void deleteInvoice(long invoiceId);
|
||||||
}
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package me.zhengjie.modules.wms.invoice.request;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import lombok.Data;
|
||||||
|
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||||
|
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||||
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 黄星星
|
||||||
|
* @date 2019-08-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateInvoiceRequest implements Serializable {
|
||||||
|
// 主键
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
// 客户订单编号
|
||||||
|
private String customerOrderCode;
|
||||||
|
|
||||||
|
// 收货地址
|
||||||
|
private String deliveryAddress;
|
||||||
|
|
||||||
|
// 收货人
|
||||||
|
private String consignee;
|
||||||
|
|
||||||
|
// 联系方式
|
||||||
|
private String contactWay;
|
||||||
|
|
||||||
|
// 发票号
|
||||||
|
private String invoiceNumber;
|
||||||
|
|
||||||
|
// 物流公司
|
||||||
|
private String logisticsCompany;
|
||||||
|
|
||||||
|
// 销售发货单号
|
||||||
|
private String saleInvoiceCode;
|
||||||
|
|
||||||
|
// 备注
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
// 客户ID
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
private List<InvoiceProductDTO> invoiceProductList;
|
||||||
|
|
||||||
|
public void copy(Invoice source){
|
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package me.zhengjie.modules.wms.invoice.rest;
|
||||||
import me.zhengjie.aop.log.Log;
|
import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||||
|
import me.zhengjie.modules.wms.invoice.request.UpdateInvoiceRequest;
|
||||||
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -14,6 +15,9 @@ 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-27
|
* @date 2019-08-27
|
||||||
|
@ -55,8 +59,8 @@ public class InvoiceController {
|
||||||
@ApiOperation(value = "修改销售发货单")
|
@ApiOperation(value = "修改销售发货单")
|
||||||
@PutMapping(value = "/invoice")
|
@PutMapping(value = "/invoice")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_EDIT')")
|
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_EDIT')")
|
||||||
public ResponseEntity update(@Validated @RequestBody Invoice resources){
|
public ResponseEntity update(@RequestBody UpdateInvoiceRequest updateInvoiceRequest){
|
||||||
invoiceService.update(resources);
|
invoiceService.update(updateInvoiceRequest);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,4 +72,12 @@ public class InvoiceController {
|
||||||
invoiceService.delete(id);
|
invoiceService.delete(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("初始化发货单编号")
|
||||||
|
@GetMapping(value = "/initInvoiceCode")
|
||||||
|
public ResponseEntity initInvoiceCode(){
|
||||||
|
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");//设置日期格式
|
||||||
|
String supplierCode = "INVOICE"+ LocalDateTime.now().format(fmt);
|
||||||
|
return new ResponseEntity(supplierCode,HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
package me.zhengjie.modules.wms.invoice.rest;
|
|
||||||
|
|
||||||
import me.zhengjie.aop.log.Log;
|
|
||||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
|
||||||
import me.zhengjie.modules.wms.invoice.service.InvoiceProductService;
|
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductQueryCriteria;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import io.swagger.annotations.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author jie
|
|
||||||
* @date 2019-08-27
|
|
||||||
*/
|
|
||||||
@Api(tags = "SInvoiceProduct管理")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("api")
|
|
||||||
public class InvoiceProductController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private InvoiceProductService invoiceProductService;
|
|
||||||
|
|
||||||
@Log("查询SInvoiceProduct")
|
|
||||||
@ApiOperation(value = "查询SInvoiceProduct")
|
|
||||||
@GetMapping(value = "/sInvoiceProduct")
|
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICEPRODUCT_ALL','SINVOICEPRODUCT_SELECT')")
|
|
||||||
public ResponseEntity getSInvoiceProducts(InvoiceProductQueryCriteria criteria, Pageable pageable){
|
|
||||||
return new ResponseEntity(invoiceProductService.queryAll(criteria,pageable),HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log("新增SInvoiceProduct")
|
|
||||||
@ApiOperation(value = "新增SInvoiceProduct")
|
|
||||||
@PostMapping(value = "/sInvoiceProduct")
|
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICEPRODUCT_ALL','SINVOICEPRODUCT_CREATE')")
|
|
||||||
public ResponseEntity create(@Validated @RequestBody InvoiceProduct resources){
|
|
||||||
return new ResponseEntity(invoiceProductService.create(resources),HttpStatus.CREATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log("修改SInvoiceProduct")
|
|
||||||
@ApiOperation(value = "修改SInvoiceProduct")
|
|
||||||
@PutMapping(value = "/sInvoiceProduct")
|
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICEPRODUCT_ALL','SINVOICEPRODUCT_EDIT')")
|
|
||||||
public ResponseEntity update(@Validated @RequestBody InvoiceProduct resources){
|
|
||||||
invoiceProductService.update(resources);
|
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log("删除SInvoiceProduct")
|
|
||||||
@ApiOperation(value = "删除SInvoiceProduct")
|
|
||||||
@DeleteMapping(value = "/sInvoiceProduct/{id}")
|
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICEPRODUCT_ALL','SINVOICEPRODUCT_DELETE')")
|
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
|
||||||
invoiceProductService.delete(id);
|
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.invoice.service;
|
||||||
|
|
||||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||||
|
import me.zhengjie.modules.wms.invoice.request.UpdateInvoiceRequest;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
||||||
|
@ -52,10 +53,10 @@ public interface InvoiceService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
* @param resources
|
* @param updateInvoiceRequest
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void update(Invoice resources);
|
void update(UpdateInvoiceRequest updateInvoiceRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete
|
* delete
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class InvoiceDTO implements Serializable {
|
||||||
private String saleInvoiceCode;
|
private String saleInvoiceCode;
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 备注
|
// 备注
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class InvoiceProductDTO implements Serializable {
|
||||||
private Timestamp updateStatus;
|
private Timestamp updateStatus;
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
private Integer status;
|
private Boolean status;
|
||||||
|
|
||||||
// 产品主键
|
// 产品主键
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
|
|
@ -3,10 +3,14 @@ package me.zhengjie.modules.wms.invoice.service.impl;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
import me.zhengjie.modules.wms.bd.domain.CustomerInfo;
|
||||||
import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
import me.zhengjie.modules.wms.bd.repository.CustomerInfoRepository;
|
||||||
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrder;
|
||||||
|
import me.zhengjie.modules.wms.customerOrder.domain.CustomerOrderProduct;
|
||||||
|
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;
|
||||||
import me.zhengjie.modules.wms.invoice.repository.InvoiceProductRepository;
|
import me.zhengjie.modules.wms.invoice.repository.InvoiceProductRepository;
|
||||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||||
|
import me.zhengjie.modules.wms.invoice.request.UpdateInvoiceRequest;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDetailDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
||||||
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceProductMapper;
|
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceProductMapper;
|
||||||
|
@ -22,8 +26,13 @@ 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.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -141,17 +150,63 @@ public class InvoiceServiceImpl implements InvoiceService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Invoice resources) {
|
public void update(UpdateInvoiceRequest updateInvoiceRequest) {
|
||||||
Optional<Invoice> optionalSInvoice = invoiceRepository.findById(resources.getId());
|
Invoice invoice = new Invoice();
|
||||||
ValidationUtil.isNull( optionalSInvoice,"SInvoice","id",resources.getId());
|
BeanUtils.copyProperties(updateInvoiceRequest, invoice);
|
||||||
Invoice invoice = optionalSInvoice.get();
|
// 修改发货单概要信息
|
||||||
invoice.copy(resources);
|
|
||||||
invoiceRepository.save(invoice);
|
invoiceRepository.save(invoice);
|
||||||
|
|
||||||
|
// 修改产品信息之前,查询该订单中原来的产品信息,key为产品code
|
||||||
|
List<InvoiceProduct> invoiceProductListBeforeUpdate = invoiceProductRepository.findByInvoiceIdAndStatusTrue(invoice.getId());
|
||||||
|
Map<String, InvoiceProduct> invoiceProductMapBefore = invoiceProductListBeforeUpdate.stream().collect(Collectors.toMap(InvoiceProduct::getProductCode, Function.identity()));
|
||||||
|
|
||||||
|
List<InvoiceProductDTO> invoiceProductRequestList = updateInvoiceRequest.getInvoiceProductList();
|
||||||
|
if(CollectionUtils.isEmpty(invoiceProductRequestList)){
|
||||||
|
throw new BadRequestException("发货单产品不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, InvoiceProductDTO> invoiceProductMapAfter = invoiceProductRequestList.stream().collect(Collectors.toMap(InvoiceProductDTO::getProductCode, Function.identity()));
|
||||||
|
|
||||||
|
//需要将订单中原来订单对应的产品删除了的数据
|
||||||
|
List<String> deleteTargetList = new ArrayList<>();
|
||||||
|
//比较量个map中,key不一样的数据
|
||||||
|
for(Map.Entry<String, InvoiceProduct> entry:invoiceProductMapBefore.entrySet()){
|
||||||
|
String productCode = entry.getKey();
|
||||||
|
//修改后的map记录对应的key在原来中是否存在
|
||||||
|
InvoiceProductDTO invoiceProductDTOTemp = invoiceProductMapAfter.get(productCode);
|
||||||
|
if(null == invoiceProductDTOTemp){
|
||||||
|
deleteTargetList.add(entry.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<InvoiceProduct> invoiceProductList = new ArrayList<>();
|
||||||
|
for(InvoiceProductDTO invoiceProductDTO : invoiceProductRequestList){
|
||||||
|
InvoiceProduct invoiceProduct = new InvoiceProduct();
|
||||||
|
BeanUtils.copyProperties(invoiceProductDTO, invoiceProduct);
|
||||||
|
invoiceProduct.setInvoiceId(invoice.getId());
|
||||||
|
invoiceProduct.setStatus(true);
|
||||||
|
}
|
||||||
|
invoiceProductRepository.saveAll(invoiceProductList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场景描述:
|
||||||
|
* 1.刚开始新增了 a b c三种产品
|
||||||
|
* 2.修改的时候删除了 a c两种产品
|
||||||
|
* 3.所以需要查修改前数据库中有的产品,再比较修改传过来的产品数据,如果修改后的在原来里面没有,需要将原来里面对应的删除
|
||||||
|
*/
|
||||||
|
if(!CollectionUtils.isEmpty(deleteTargetList)){
|
||||||
|
for(String prductCode : deleteTargetList){
|
||||||
|
invoiceProductRepository.deleteByProductCodeAndInvoiceId(prductCode, invoice.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(Long id) {
|
public void delete(Long id) {
|
||||||
invoiceRepository.deleteById(id);
|
invoiceRepository.deleteInvoice(id);
|
||||||
|
invoiceProductRepository.deleteInvoiceProduct(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,8 +4,8 @@ spring:
|
||||||
druid:
|
druid:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
url: jdbc:log4jdbc:mysql://rm-2ze4a3l502a15dg50qo.mysql.rds.aliyuncs.com:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
url: jdbc:log4jdbc:mysql://47.103.159.227:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||||
username: tenjeu
|
username: root
|
||||||
password: starrysky622209Qwe!
|
password: starrysky622209Qwe!
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ spring:
|
||||||
druid:
|
druid:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||||
url: jdbc:log4jdbc:mysql://rm-2ze4a3l502a15dg50qo.mysql.rds.aliyuncs.com:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
url: jdbc:log4jdbc:mysql://47.103.159.227:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||||
username: tenjeu
|
username: root
|
||||||
password: starrysky622209Qwe!
|
password: starrysky622209Qwe!
|
||||||
|
|
||||||
# 初始化配置
|
# 初始化配置
|
||||||
|
|
|
@ -3,7 +3,7 @@ server:
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: prod
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
data:
|
data:
|
||||||
|
|
Loading…
Reference in New Issue