| | |
| | | import com.ruoyi.approve.vo.ApproveProcessVO; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.uuid.UUID; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Override |
| | | public boolean add(SalesQuotationDto salesQuotationDto) { |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SalesQuotation salesQuotation = new SalesQuotation(); |
| | | BeanUtils.copyProperties(salesQuotationDto, salesQuotation); |
| | | String quotationNo = OrderUtils.countTodayByCreateTime(salesQuotationMapper, "QT"); |
| | |
| | | }).collect(Collectors.toList()); |
| | | salesQuotationProductService.saveBatch(products); |
| | | // 报价审批 |
| | | ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | approveProcessVO.setApproveType(6); |
| | | approveProcessVO.setApproveDeptId(loginUser.getTenantId()); |
| | | approveProcessVO.setApproveReason(quotationNo); |
| | | approveProcessVO.setApproveUserIds(salesQuotationDto.getApproveUserIds()); |
| | | approveProcessVO.setApproveUser(loginUser.getUserId()); |
| | | approveProcessVO.setApproveTime(LocalDate.now().toString()); |
| | | approveProcessVO.setPrice(salesQuotationDto.getTotalAmount()); |
| | | try { |
| | | approveProcessService.addApprove(approveProcessVO); |
| | | }catch (Exception e){ |
| | | log.error("SalesQuotationServiceImpl error:{}", e); |
| | | throw new RuntimeException("审批失败"); |
| | | } |
| | | // ApproveProcessVO approveProcessVO = new ApproveProcessVO(); |
| | | // approveProcessVO.setApproveType(6); |
| | | // approveProcessVO.setApproveDeptId(loginUser.getTenantId()); |
| | | // approveProcessVO.setApproveReason(quotationNo); |
| | | // approveProcessVO.setApproveUserIds(salesQuotationDto.getApproveUserIds()); |
| | | // approveProcessVO.setApproveUser(loginUser.getUserId()); |
| | | // approveProcessVO.setApproveTime(LocalDate.now().toString()); |
| | | // approveProcessVO.setPrice(salesQuotationDto.getTotalAmount()); |
| | | // try { |
| | | // approveProcessService.addApprove(approveProcessVO); |
| | | // }catch (Exception e){ |
| | | // log.error("SalesQuotationServiceImpl error:{}", e); |
| | | // throw new RuntimeException("审批失败"); |
| | | // } |
| | | return true; |
| | | } |
| | | @Override |
| | |
| | | }).collect(Collectors.toList()); |
| | | |
| | | salesQuotationProductService.saveBatch(products); |
| | | // 修改报价审批 |
| | | vo.setApproveUserIds(salesQuotationDto.getApproveUserIds()); |
| | | vo.setApproveType(6); |
| | | vo.setApproveReason(salesQuotationDto.getQuotationNo()); |
| | | approveProcessService.updateApproveUser(vo); |
| | | // // 修改报价审批 |
| | | // vo.setApproveUserIds(salesQuotationDto.getApproveUserIds()); |
| | | // vo.setApproveType(6); |
| | | // vo.setApproveReason(salesQuotationDto.getQuotationNo()); |
| | | // approveProcessService.updateApproveUser(vo); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal detail(String type, String productName, String specification) { |
| | | if(StringUtils.isEmpty(type)) return null; |
| | | SalesQuotationProduct salesQuotationProduct = salesQuotationProductMapper.selectOne(new LambdaQueryWrapper<SalesQuotationProduct>() |
| | | .eq(SalesQuotationProduct::getProduct, productName) |
| | | .eq(SalesQuotationProduct::getSpecification, specification) |
| | | .last("limit 1")); |
| | | if(salesQuotationProduct==null) return null; |
| | | switch (type){ |
| | | case "一批商": |
| | | return salesQuotationProduct.getUnitPrice(); |
| | | case "终端商": |
| | | return salesQuotationProduct.getUnitPriceTwo(); |
| | | default: |
| | | return salesQuotationProduct.getUnitPriceThree(); |
| | | } |
| | | } |
| | | @Override |
| | | public boolean delete(Long id) { |
| | | salesQuotationMapper.deleteById(id); |