| | |
| | | import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus; |
| | | import java.util.Objects; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; |
| | | |
| | | /** |
| | | * ERP 销售订单 API 实现类 |
| | |
| | | @Override |
| | | public CommonResult<ErpSaleOrderRespDTO> getSaleOrder(Long id) { |
| | | ErpSaleOrderDO order = saleOrderService.getSaleOrder(id); |
| | | return success(BeanUtils.toBean(order, ErpSaleOrderRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.MANDATORY) |
| | | public CommonResult<ErpSaleOrderRespDTO> lockSaleOrderForNotice(Long id, String orderNo) { |
| | | if (id == null && (orderNo == null || orderNo.isBlank())) return success(null); |
| | | ErpSaleOrderDO order = id != null ? saleOrderMapper.selectByIdForUpdate(id) : saleOrderMapper.selectByNoForUpdate(orderNo); |
| | | if (order == null || (orderNo != null && !orderNo.isBlank() && !Objects.equals(orderNo, order.getNo()))) |
| | | throw invalidParamException("关联销售订单不存在或订单编号不匹配"); |
| | | if (!Objects.equals(order.getStatus(), ErpAuditStatus.APPROVE.getStatus())) |
| | | throw invalidParamException("销售订单未审核或已作废,不能生成发货通知"); |
| | | return success(BeanUtils.toBean(order, ErpSaleOrderRespDTO.class)); |
| | | } |
| | | |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| | | } |