| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderPageReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; |
| | | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; |
| | |
| | | @Resource |
| | | private ErpProductService productService; |
| | | @Resource |
| | | private ErpCustomerService customerService; |
| | | private CrmCustomerApi customerApi; |
| | | @Resource |
| | | private ErpAccountService accountService; |
| | | |
| | |
| | | public Long createSaleOrder(ErpSaleOrderSaveReqVO createReqVO) { |
| | | // 1.1 校验订单项的有效性 |
| | | List<ErpSaleOrderItemDO> saleOrderItems = validateSaleOrderItems(createReqVO.getItems()); |
| | | // 1.2 校验客户 |
| | | customerService.validateCustomer(createReqVO.getCustomerId()); |
| | | // 1.2 校验客户(使用 CRM 客户 API) |
| | | customerApi.validateCustomer(createReqVO.getCustomerId()); |
| | | // 1.3 校验结算账户 |
| | | if (createReqVO.getAccountId() != null) { |
| | | accountService.validateAccount(createReqVO.getAccountId()); |
| | |
| | | if (ErpAuditStatus.APPROVE.getStatus().equals(saleOrder.getStatus())) { |
| | | throw exception(SALE_ORDER_UPDATE_FAIL_APPROVE, saleOrder.getNo()); |
| | | } |
| | | // 1.2 校验客户 |
| | | customerService.validateCustomer(updateReqVO.getCustomerId()); |
| | | // 1.2 校验客户(使用 CRM 客户 API) |
| | | customerApi.validateCustomer(updateReqVO.getCustomerId()); |
| | | // 1.3 校验结算账户 |
| | | if (updateReqVO.getAccountId() != null) { |
| | | accountService.validateAccount(updateReqVO.getAccountId()); |