mirror of https://github.com/elunez/eladmin
发货单
parent
52ab50449d
commit
bc9e4fecf5
|
@ -0,0 +1,75 @@
|
|||
package me.zhengjie.modules.wms.invoice.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="s_invoice")
|
||||
public class Invoice implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "create_time")
|
||||
private Timestamp createTime;
|
||||
|
||||
@Column(name = "update_time")
|
||||
private Timestamp updateTime;
|
||||
|
||||
// 客户订单编号
|
||||
@Column(name = "customer_order_code")
|
||||
private String customerOrderCode;
|
||||
|
||||
// 收货地址
|
||||
@Column(name = "delivery_address")
|
||||
private String deliveryAddress;
|
||||
|
||||
// 收货人
|
||||
@Column(name = "consignee")
|
||||
private String consignee;
|
||||
|
||||
// 联系方式
|
||||
@Column(name = "contact_way")
|
||||
private String contactWay;
|
||||
|
||||
// 发票号
|
||||
@Column(name = "invoice_number")
|
||||
private String invoiceNumber;
|
||||
|
||||
// 物流公司
|
||||
@Column(name = "logistics_company")
|
||||
private String logisticsCompany;
|
||||
|
||||
// 销售发货单号
|
||||
@Column(name = "sale_invoice_code")
|
||||
private String saleInvoiceCode;
|
||||
|
||||
// 状态
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
// 备注
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "customer_id")
|
||||
private Long customerId;
|
||||
|
||||
@Column(name = "customer_name")
|
||||
private String customerName;
|
||||
|
||||
public void copy(Invoice source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package me.zhengjie.modules.wms.invoice.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="s_invoice_product")
|
||||
public class InvoiceProduct implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
// 创建时间
|
||||
@Column(name = "create_status")
|
||||
private Timestamp createStatus;
|
||||
|
||||
// 更新时间
|
||||
@Column(name = "update_status")
|
||||
private Timestamp updateStatus;
|
||||
|
||||
// 状态
|
||||
@Column(name = "status")
|
||||
private Integer status;
|
||||
|
||||
// 产品主键
|
||||
@Column(name = "product_id",nullable = false)
|
||||
private Long productId;
|
||||
|
||||
// 产品名称
|
||||
@Column(name = "product_name",nullable = false)
|
||||
private String productName;
|
||||
|
||||
// 产品编号
|
||||
@Column(name = "product_code",nullable = false)
|
||||
private String productCode;
|
||||
|
||||
// 规格
|
||||
@Column(name = "specifications")
|
||||
private String specifications;
|
||||
|
||||
// 订单数量
|
||||
@Column(name = "customer_order_number",nullable = false)
|
||||
private Long customerOrderNumber;
|
||||
|
||||
// 实际发货单数量
|
||||
@Column(name = "acutal_invoice_number",nullable = false)
|
||||
private Long acutalInvoiceNumber;
|
||||
|
||||
// 瘦瘦金额
|
||||
@Column(name = "sale_price")
|
||||
private Long salePrice;
|
||||
|
||||
// 备注
|
||||
@Column(name = "remark")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "invoice_id")
|
||||
private Long invoiceId;
|
||||
|
||||
public void copy(InvoiceProduct source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.zhengjie.modules.wms.invoice.repository;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
public interface InvoiceProductRepository extends JpaRepository<InvoiceProduct, Long>, JpaSpecificationExecutor {
|
||||
|
||||
List<InvoiceProduct> findByInvoiceIdAndStatusTrue(Long invoiceId);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package me.zhengjie.modules.wms.invoice.repository;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
public interface InvoiceRepository extends JpaRepository<Invoice, Long>, JpaSpecificationExecutor {
|
||||
|
||||
Invoice findBySaleInvoiceCode(String saleInvoiceCode);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
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 java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黄星星
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class CreateInvoiceRequest implements Serializable {
|
||||
|
||||
// 客户订单编号
|
||||
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<InvoiceProduct> invoiceProductList;
|
||||
|
||||
public void copy(Invoice source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package me.zhengjie.modules.wms.invoice.rest;
|
||||
|
||||
import me.zhengjie.aop.log.Log;
|
||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
||||
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 = "SInvoice管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class InvoiceController {
|
||||
|
||||
@Autowired
|
||||
private InvoiceService invoiceService;
|
||||
|
||||
@Log("分页查询销售发货单")
|
||||
@ApiOperation(value = "分页查询销售发货单")
|
||||
@GetMapping(value = "/querySaleInvoicePage")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_SELECT')")
|
||||
public ResponseEntity querySaleInvoicePage(InvoiceQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(invoiceService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Log("查询销售发货单列表")
|
||||
@ApiOperation(value = "查询销售发货单列表")
|
||||
@GetMapping(value = "/querySaleInvoiceList")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_SELECT')")
|
||||
public ResponseEntity querySaleInvoiceList(InvoiceQueryCriteria criteria){
|
||||
return new ResponseEntity(invoiceService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增销售发货单")
|
||||
@ApiOperation(value = "新增销售发货单")
|
||||
@PostMapping(value = "/invoice")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_CREATE')")
|
||||
public ResponseEntity create(@RequestBody CreateInvoiceRequest createInvoiceRequest){
|
||||
return new ResponseEntity(invoiceService.create(createInvoiceRequest),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Log("修改销售发货单")
|
||||
@ApiOperation(value = "修改销售发货单")
|
||||
@PutMapping(value = "/invoice")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody Invoice resources){
|
||||
invoiceService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除销售发货单")
|
||||
@ApiOperation(value = "删除销售发货单")
|
||||
@DeleteMapping(value = "/sInvoice/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','SINVOICE_ALL','SINVOICE_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Long id){
|
||||
invoiceService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package me.zhengjie.modules.wms.invoice.service;
|
||||
|
||||
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.InvoiceProductQueryCriteria;
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
//@CacheConfig(cacheNames = "sInvoiceProduct")
|
||||
public interface InvoiceProductService {
|
||||
|
||||
/**
|
||||
* queryAll 分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
Object queryAll(InvoiceProductQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* queryAll 不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
public Object queryAll(InvoiceProductQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* findById
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
InvoiceProductDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* create
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
InvoiceProductDTO create(InvoiceProduct resources);
|
||||
|
||||
/**
|
||||
* update
|
||||
* @param resources
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void update(InvoiceProduct resources);
|
||||
|
||||
/**
|
||||
* delete
|
||||
* @param id
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Long id);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package me.zhengjie.modules.wms.invoice.service;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||
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.InvoiceQueryCriteria;
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
//@CacheConfig(cacheNames = "sInvoice")
|
||||
public interface InvoiceService {
|
||||
|
||||
/**
|
||||
* queryAll 分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
Object queryAll(InvoiceQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* queryAll 不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(keyGenerator = "keyGenerator")
|
||||
public Object queryAll(InvoiceQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* findById
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
InvoiceDetailDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* create
|
||||
* @param createInvoiceRequest
|
||||
* @return
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
InvoiceDetailDTO create(CreateInvoiceRequest createInvoiceRequest);
|
||||
|
||||
/**
|
||||
* update
|
||||
* @param resources
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void update(Invoice resources);
|
||||
|
||||
/**
|
||||
* delete
|
||||
* @param id
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Long id);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class InvoiceDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Timestamp createTime;
|
||||
|
||||
private Timestamp updateTime;
|
||||
|
||||
private String customerOrderCode;
|
||||
|
||||
// 收货地址
|
||||
private String deliveryAddress;
|
||||
|
||||
// 收货人
|
||||
private String consignee;
|
||||
|
||||
// 联系方式
|
||||
private String contactWay;
|
||||
|
||||
// 发票号
|
||||
private String invoiceNumber;
|
||||
|
||||
// 物流公司
|
||||
private String logisticsCompany;
|
||||
|
||||
// 销售发货单号
|
||||
private String saleInvoiceCode;
|
||||
|
||||
// 状态
|
||||
private Integer status;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 黄星星
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class InvoiceDetailDTO extends InvoiceDTO implements Serializable {
|
||||
|
||||
private List<InvoiceProductDTO> invoiceProductDTOList;
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class InvoiceProductDTO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
// 创建时间
|
||||
private Timestamp createStatus;
|
||||
|
||||
// 更新时间
|
||||
private Timestamp updateStatus;
|
||||
|
||||
// 状态
|
||||
private Integer status;
|
||||
|
||||
// 产品主键
|
||||
private Long productId;
|
||||
|
||||
// 产品名称
|
||||
private String productName;
|
||||
|
||||
// 产品编号
|
||||
private String productCode;
|
||||
|
||||
// 规格
|
||||
private String specifications;
|
||||
|
||||
// 订单数量
|
||||
private Long customerOrderNumber;
|
||||
|
||||
// 实际发货单数量
|
||||
private Long acutalInvoiceNumber;
|
||||
|
||||
// 瘦瘦金额
|
||||
private Long salePrice;
|
||||
|
||||
// 备注
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class InvoiceProductQueryCriteria {
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Data
|
||||
public class InvoiceQueryCriteria {
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.impl;
|
||||
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.modules.wms.invoice.repository.InvoiceProductRepository;
|
||||
import me.zhengjie.modules.wms.invoice.service.InvoiceProductService;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductQueryCriteria;
|
||||
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceProductMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class InvoiceProductServiceImpl implements InvoiceProductService {
|
||||
|
||||
@Autowired
|
||||
private InvoiceProductRepository invoiceProductRepository;
|
||||
|
||||
@Autowired
|
||||
private InvoiceProductMapper invoiceProductMapper;
|
||||
|
||||
@Override
|
||||
public Object queryAll(InvoiceProductQueryCriteria criteria, Pageable pageable){
|
||||
Page<InvoiceProduct> page = invoiceProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(invoiceProductMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(InvoiceProductQueryCriteria criteria){
|
||||
return invoiceProductMapper.toDto(invoiceProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvoiceProductDTO findById(Long id) {
|
||||
Optional<InvoiceProduct> sInvoiceProduct = invoiceProductRepository.findById(id);
|
||||
ValidationUtil.isNull(sInvoiceProduct,"SInvoiceProduct","id",id);
|
||||
return invoiceProductMapper.toDto(sInvoiceProduct.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public InvoiceProductDTO create(InvoiceProduct resources) {
|
||||
return invoiceProductMapper.toDto(invoiceProductRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(InvoiceProduct resources) {
|
||||
Optional<InvoiceProduct> optionalSInvoiceProduct = invoiceProductRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalSInvoiceProduct,"SInvoiceProduct","id",resources.getId());
|
||||
InvoiceProduct invoiceProduct = optionalSInvoiceProduct.get();
|
||||
invoiceProduct.copy(resources);
|
||||
invoiceProductRepository.save(invoiceProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
invoiceProductRepository.deleteById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.impl;
|
||||
|
||||
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.invoice.domain.Invoice;
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import me.zhengjie.modules.wms.invoice.repository.InvoiceProductRepository;
|
||||
import me.zhengjie.modules.wms.invoice.request.CreateInvoiceRequest;
|
||||
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.mapper.InvoiceProductMapper;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.modules.wms.invoice.repository.InvoiceRepository;
|
||||
import me.zhengjie.modules.wms.invoice.service.InvoiceService;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceQueryCriteria;
|
||||
import me.zhengjie.modules.wms.invoice.service.mapper.InvoiceMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class InvoiceServiceImpl implements InvoiceService {
|
||||
|
||||
@Autowired
|
||||
private InvoiceRepository invoiceRepository;
|
||||
|
||||
@Autowired
|
||||
private InvoiceMapper invoiceMapper;
|
||||
|
||||
@Autowired
|
||||
private CustomerInfoRepository customerInfoRepository;
|
||||
|
||||
@Autowired
|
||||
private InvoiceProductMapper invoiceProductMapper;
|
||||
|
||||
@Autowired
|
||||
private InvoiceProductRepository invoiceProductRepository;
|
||||
|
||||
@Override
|
||||
public Object queryAll(InvoiceQueryCriteria criteria, Pageable pageable){
|
||||
Page<Invoice> page = invoiceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(invoiceMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(InvoiceQueryCriteria criteria){
|
||||
return invoiceMapper.toDto(invoiceRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public InvoiceDetailDTO findById(Long id) {
|
||||
Optional<Invoice> invoiceOptional = invoiceRepository.findById(id);
|
||||
ValidationUtil.isNull(invoiceOptional,"SInvoice","id",id);
|
||||
Invoice invoice = invoiceOptional.get();
|
||||
InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice);
|
||||
|
||||
InvoiceDetailDTO invoiceDetailDTO = new InvoiceDetailDTO();
|
||||
BeanUtils.copyProperties(invoiceDTO, invoiceDetailDTO);
|
||||
|
||||
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(id);
|
||||
if(!CollectionUtils.isEmpty(invoiceProductList)){
|
||||
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
||||
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
||||
}
|
||||
return invoiceDetailDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public InvoiceDetailDTO create(CreateInvoiceRequest createInvoiceRequest) {
|
||||
Invoice invoice = new Invoice();
|
||||
// 客户订单编号
|
||||
String customerOrderCode = createInvoiceRequest.getCustomerOrderCode();
|
||||
if(StringUtils.isEmpty(customerOrderCode)){
|
||||
throw new BadRequestException("客户订单编号不能为空!");
|
||||
}
|
||||
|
||||
// 客户ID
|
||||
Long customerId = createInvoiceRequest.getCustomerId();
|
||||
if(null == customerId){
|
||||
throw new BadRequestException("客户ID不能为空!");
|
||||
}
|
||||
|
||||
Optional<CustomerInfo> customerInfoOptional = customerInfoRepository.findById(customerId);
|
||||
if(null == customerInfoOptional){
|
||||
throw new BadRequestException("客户不存在!");
|
||||
}
|
||||
CustomerInfo customerInfo = customerInfoOptional.get();
|
||||
if(null == customerInfo){
|
||||
throw new BadRequestException("客户不存在!");
|
||||
}
|
||||
|
||||
// 销售发货单号
|
||||
String saleInvoiceCode = createInvoiceRequest.getSaleInvoiceCode();
|
||||
if(StringUtils.isEmpty(saleInvoiceCode)){
|
||||
throw new BadRequestException("销售发货单单据编号不能为空!");
|
||||
}
|
||||
|
||||
List<InvoiceProduct> invoiceProductRequestList = createInvoiceRequest.getInvoiceProductList();
|
||||
if(CollectionUtils.isEmpty(invoiceProductRequestList)){
|
||||
throw new BadRequestException("发货单产品信息不能为空!");
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(createInvoiceRequest, invoice);
|
||||
invoiceRepository.save(invoice);
|
||||
invoice = invoiceRepository.findBySaleInvoiceCode(saleInvoiceCode);
|
||||
InvoiceDTO invoiceDTO = invoiceMapper.toDto(invoice);
|
||||
|
||||
|
||||
for(InvoiceProduct invoiceProduct : invoiceProductRequestList){
|
||||
invoiceProduct.setInvoiceId(invoice.getId());
|
||||
invoiceProductRepository.save(invoiceProduct);
|
||||
}
|
||||
|
||||
List<InvoiceProduct> invoiceProductList = invoiceProductRepository.findByInvoiceIdAndStatusTrue(invoice.getId());
|
||||
List<InvoiceProductDTO> invoiceProductDTOList = invoiceProductMapper.toDto(invoiceProductList);
|
||||
|
||||
InvoiceDetailDTO invoiceDetailDTO = new InvoiceDetailDTO();
|
||||
BeanUtils.copyProperties(invoiceDTO, invoiceDetailDTO);
|
||||
invoiceDetailDTO.setInvoiceProductDTOList(invoiceProductDTOList);
|
||||
return invoiceDetailDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Invoice resources) {
|
||||
Optional<Invoice> optionalSInvoice = invoiceRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalSInvoice,"SInvoice","id",resources.getId());
|
||||
Invoice invoice = optionalSInvoice.get();
|
||||
invoice.copy(resources);
|
||||
invoiceRepository.save(invoice);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
invoiceRepository.deleteById(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.mapper;
|
||||
|
||||
import me.zhengjie.mapper.EntityMapper;
|
||||
import me.zhengjie.modules.wms.invoice.domain.Invoice;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface InvoiceMapper extends EntityMapper<InvoiceDTO, Invoice> {
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.zhengjie.modules.wms.invoice.service.mapper;
|
||||
|
||||
import me.zhengjie.mapper.EntityMapper;
|
||||
import me.zhengjie.modules.wms.invoice.domain.InvoiceProduct;
|
||||
import me.zhengjie.modules.wms.invoice.service.dto.InvoiceProductDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author jie
|
||||
* @date 2019-08-27
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface InvoiceProductMapper extends EntityMapper<InvoiceProductDTO, InvoiceProduct> {
|
||||
|
||||
}
|
|
@ -4,9 +4,10 @@ spring:
|
|||
druid:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://localhost:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||
username: root
|
||||
password: 123456
|
||||
url: jdbc:log4jdbc:mysql://rm-2ze4a3l502a15dg50qo.mysql.rds.aliyuncs.com:3306/eladmin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||
username: tenjeu
|
||||
password: starrysky622209Qwe!
|
||||
|
||||
|
||||
# 初始化配置
|
||||
initial-size: 3
|
||||
|
|
|
@ -3,7 +3,7 @@ server:
|
|||
|
||||
spring:
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
|
Loading…
Reference in New Issue