diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/request/UpdateCustomerOrderRequest.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/request/UpdateCustomerOrderRequest.java new file mode 100644 index 00000000..cb1ef71b --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/request/UpdateCustomerOrderRequest.java @@ -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 customerOrderProductList; + + public void copy(UpdateCustomerOrderRequest source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/rest/CustomerOrderController.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/rest/CustomerOrderController.java index 0e05afa6..eee5d5b0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/rest/CustomerOrderController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/rest/CustomerOrderController.java @@ -3,6 +3,7 @@ package me.zhengjie.modules.wms.order.rest; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.wms.order.domain.CustomerOrder; 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.dto.CustomerOrderQueryCriteria; import org.springframework.beans.factory.annotation.Autowired; @@ -49,8 +50,8 @@ public class CustomerOrderController { @ApiOperation(value = "修改SCustomerOrder") @PutMapping(value = "/customerOrder") @PreAuthorize("hasAnyRole('ADMIN','SCUSTOMERORDER_ALL','SCUSTOMERORDER_EDIT')") - public ResponseEntity update(@RequestBody CustomerOrder resources){ - customerOrderService.update(resources); + public ResponseEntity update(@RequestBody UpdateCustomerOrderRequest updateCustomerOrderRequest){ + customerOrderService.update(updateCustomerOrderRequest); return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/CustomerOrderService.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/CustomerOrderService.java index 66f599bc..699e6203 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/CustomerOrderService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/CustomerOrderService.java @@ -5,6 +5,7 @@ package me.zhengjie.modules.wms.order.service; //import org.springframework.cache.annotation.Cacheable; import me.zhengjie.modules.wms.order.domain.CustomerOrder; 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.CustomerOrderQueryCriteria; import org.springframework.data.domain.Pageable; @@ -51,10 +52,10 @@ public interface CustomerOrderService { /** * update - * @param resources + * @param updateCustomerOrderRequest */ //@CacheEvict(allEntries = true) - void update(CustomerOrder resources); + void update(UpdateCustomerOrderRequest updateCustomerOrderRequest); /** * delete diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/impl/CustomerOrderServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/impl/CustomerOrderServiceImpl.java index 973cd611..5cbc2f0c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/impl/CustomerOrderServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/wms/order/service/impl/CustomerOrderServiceImpl.java @@ -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.request.CreateCustomerOrderRequest; 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.dto.CustomerOrderDTO; import me.zhengjie.modules.wms.order.service.dto.CustomerOrderProductDTO; @@ -105,12 +106,25 @@ public class CustomerOrderServiceImpl implements CustomerOrderService { @Override @Transactional(rollbackFor = Exception.class) - public void update(CustomerOrder resources) { - Optional optionalSCustomerOrder = customerOrderRepository.findById(resources.getId()); - ValidationUtil.isNull( optionalSCustomerOrder,"SCustomerOrder","id",resources.getId()); - CustomerOrder customerOrder = optionalSCustomerOrder.get(); - customerOrder.copy(resources); + public void update(UpdateCustomerOrderRequest updateCustomerOrderRequest) { + + CustomerOrder customerOrder = new CustomerOrder(); + BeanUtils.copyProperties(updateCustomerOrderRequest, customerOrder); customerOrderRepository.save(customerOrder); + + List customerOrderProductRequestList = updateCustomerOrderRequest.getCustomerOrderProductList(); + if(CollectionUtils.isEmpty(customerOrderProductRequestList)){ + throw new BadRequestException("订单产品不能为空!"); + } + + List 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