| | |
| | | import cn.iocoder.yudao.module.mes.enums.wm.MesWmQualityStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.wm.MesWmReturnSalesStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.wm.MesWmTransactionTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.aftersales.api.AfterSaleTicketApi; |
| | | import cn.iocoder.yudao.module.mes.service.mdm.MesMdmItemService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.transaction.MesWmTransactionService; |
| | | import cn.iocoder.yudao.module.mes.service.wm.transaction.dto.MesWmTransactionSaveReqDTO; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.beans.factory.ObjectProvider; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | import java.util.Map; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * MES 销售退货单 Service 实现类 |
| | | * |
| | | * @author 芋道源码 |
| | | * @author 超级管理员 |
| | | */ |
| | | @Service |
| | | @Validated |
| | |
| | | @Resource |
| | | private MesWmReturnSalesDetailService returnSalesDetailService; |
| | | @Resource |
| | | private MesMdClientService clientService; |
| | | private CrmCustomerApi customerApi; |
| | | @Resource |
| | | private MesMdmItemService mdmItemService; |
| | | @Resource |
| | | private MesWmTransactionService wmTransactionService; |
| | | @Resource |
| | | private ObjectProvider<AfterSaleTicketApi> afterSaleTicketApiProvider; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | @Override |
| | | public PageResult<MesWmReturnSalesDO> getReturnSalesPage(MesWmReturnSalesPageReqVO pageReqVO) { |
| | | return returnSalesMapper.selectPage(pageReqVO); |
| | | return returnSalesMapper.selectPage(pageReqVO, (List<Long>) null); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // 3. 更新退货单状态 |
| | | returnSalesMapper.updateById(new MesWmReturnSalesDO() |
| | | .setId(id).setStatus(MesWmReturnSalesStatusEnum.FINISHED.getStatus())); |
| | | if (returnSales.getAfterSaleReturnId() != null) { |
| | | AfterSaleTicketApi api = afterSaleTicketApiProvider.getIfAvailable(); |
| | | if (api == null) throw invalidParamException("售后服务不可用,无法同步退货入库状态"); |
| | | var response = api.onReturnInboundFinished(returnSales.getAfterSaleReturnId()); |
| | | if (response == null || !Boolean.TRUE.equals(response.getCheckedData())) |
| | | throw invalidParamException("售后退货入库状态同步失败"); |
| | | } |
| | | } |
| | | |
| | | private void createTransactionList(MesWmReturnSalesDO returnSales) { |
| | |
| | | */ |
| | | private void validateSaveData(MesWmReturnSalesSaveReqVO reqVO) { |
| | | validateCodeUnique(reqVO.getId(), reqVO.getCode()); |
| | | clientService.validateClientExistsAndEnable(reqVO.getClientId()); |
| | | customerApi.validateCustomer(reqVO.getClientId()); |
| | | } |
| | | |
| | | } |