mirror of https://github.com/elunez/eladmin
修改客户订单
parent
898ac8f71b
commit
f809070e53
|
@ -0,0 +1,87 @@
|
||||||
|
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.service.dto.CustomerOrderProductDTO;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jie
|
||||||
|
* @date 2019-08-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UpdateCustomerOrderRequest implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
// 所属客户主键
|
||||||
|
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 Boolean status;
|
||||||
|
|
||||||
|
// 订单产品
|
||||||
|
private List<CustomerOrderProductDTO> customerOrderProductList;
|
||||||
|
|
||||||
|
public void copy(UpdateCustomerOrderRequest source){
|
||||||
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,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.request.CreateCustomerOrderRequest;
|
||||||
|
import me.zhengjie.modules.wms.order.request.UpdateCustomerOrderRequest;
|
||||||
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;
|
||||||
|
@ -49,8 +50,8 @@ public class CustomerOrderController {
|
||||||
@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')")
|
||||||
public ResponseEntity update(@RequestBody CustomerOrder resources){
|
public ResponseEntity update(@RequestBody UpdateCustomerOrderRequest updateCustomerOrderRequest){
|
||||||
customerOrderService.update(resources);
|
customerOrderService.update(updateCustomerOrderRequest);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ package me.zhengjie.modules.wms.order.service;
|
||||||
//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.request.CreateCustomerOrderRequest;
|
||||||
|
import me.zhengjie.modules.wms.order.request.UpdateCustomerOrderRequest;
|
||||||
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;
|
||||||
|
@ -51,10 +52,10 @@ public interface CustomerOrderService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
* @param resources
|
* @param updateCustomerOrderRequest
|
||||||
*/
|
*/
|
||||||
//@CacheEvict(allEntries = true)
|
//@CacheEvict(allEntries = true)
|
||||||
void update(CustomerOrder resources);
|
void update(UpdateCustomerOrderRequest updateCustomerOrderRequest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete
|
* delete
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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.CreateCustomerOrderRequest;
|
||||||
import me.zhengjie.modules.wms.order.request.CustomerOrderProductRequest;
|
import me.zhengjie.modules.wms.order.request.CustomerOrderProductRequest;
|
||||||
|
import me.zhengjie.modules.wms.order.request.UpdateCustomerOrderRequest;
|
||||||
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.CustomerOrderProductDTO;
|
||||||
|
@ -105,12 +106,25 @@ public class CustomerOrderServiceImpl implements CustomerOrderService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(CustomerOrder resources) {
|
public void update(UpdateCustomerOrderRequest updateCustomerOrderRequest) {
|
||||||
Optional<CustomerOrder> optionalSCustomerOrder = customerOrderRepository.findById(resources.getId());
|
|
||||||
ValidationUtil.isNull( optionalSCustomerOrder,"SCustomerOrder","id",resources.getId());
|
CustomerOrder customerOrder = new CustomerOrder();
|
||||||
CustomerOrder customerOrder = optionalSCustomerOrder.get();
|
BeanUtils.copyProperties(updateCustomerOrderRequest, customerOrder);
|
||||||
customerOrder.copy(resources);
|
|
||||||
customerOrderRepository.save(customerOrder);
|
customerOrderRepository.save(customerOrder);
|
||||||
|
|
||||||
|
List<CustomerOrderProductDTO> customerOrderProductRequestList = updateCustomerOrderRequest.getCustomerOrderProductList();
|
||||||
|
if(CollectionUtils.isEmpty(customerOrderProductRequestList)){
|
||||||
|
throw new BadRequestException("订单产品不能为空!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CustomerOrderProduct> customerOrderProductList = new ArrayList<>();
|
||||||
|
for(CustomerOrderProductDTO customerOrderProductDTO : customerOrderProductRequestList){
|
||||||
|
CustomerOrderProduct customerOrderProduct = new CustomerOrderProduct();
|
||||||
|
BeanUtils.copyProperties(customerOrderProductDTO, customerOrderProduct);
|
||||||
|
customerOrderProduct.setCustomerOrderId(customerOrder.getId());
|
||||||
|
customerOrderProduct.setStatus(true);
|
||||||
|
}
|
||||||
|
customerOrderProductRepository.saveAll(customerOrderProductList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue