|
@@ -0,0 +1,138 @@
|
|
|
+package com.fjhx.oa.service.invoice.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.enums.FlowStatusEnum1;
|
|
|
+import com.fjhx.file.utils.ObsFileUtil;
|
|
|
+import com.fjhx.flow.entity.flow.po.FlowExample;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
+import com.fjhx.flow.service.flow.FlowExampleService;
|
|
|
+import com.fjhx.oa.entity.invoice.dto.InvoiceApplyDto;
|
|
|
+import com.fjhx.oa.entity.invoice.dto.InvoiceApplySelectDto;
|
|
|
+import com.fjhx.oa.entity.invoice.po.InvoiceApply;
|
|
|
+import com.fjhx.oa.entity.invoice.po.InvoiceApplyContractDetail;
|
|
|
+import com.fjhx.oa.entity.invoice.po.InvoiceApplyDetail;
|
|
|
+import com.fjhx.oa.entity.invoice.vo.InvoiceApplyContractDetailVo;
|
|
|
+import com.fjhx.oa.entity.invoice.vo.InvoiceApplyDetailVo;
|
|
|
+import com.fjhx.oa.entity.invoice.vo.InvoiceApplyVo;
|
|
|
+import com.fjhx.oa.mapper.invoice.InvoiceApplyMapper;
|
|
|
+import com.fjhx.oa.service.invoice.InvoiceApplyContractDetailService;
|
|
|
+import com.fjhx.oa.service.invoice.InvoiceApplyDetailService;
|
|
|
+import com.fjhx.oa.service.invoice.InvoiceApplyService;
|
|
|
+import com.fjhx.tenant.utils.DeptUstil;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 开票申请 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-04-13
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class InvoiceApplyServiceImpl extends ServiceImpl<InvoiceApplyMapper, InvoiceApply> implements InvoiceApplyService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FlowExampleService flowExampleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InvoiceApplyContractDetailService invoiceApplyContractDetailService;
|
|
|
+ @Autowired
|
|
|
+ private InvoiceApplyDetailService invoiceApplyDetailService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<InvoiceApplyVo> getPage(InvoiceApplySelectDto dto) {
|
|
|
+ IWrapper<InvoiceApply> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("ia", InvoiceApply::getId);
|
|
|
+ Page<InvoiceApplyVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ setInfo(page.getRecords());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InvoiceApplyVo detail(Long id) {
|
|
|
+ InvoiceApply InvoiceApply = this.getById(id);
|
|
|
+ InvoiceApplyVo result = BeanUtil.toBean(InvoiceApply, InvoiceApplyVo.class);
|
|
|
+
|
|
|
+ setInfo(Arrays.asList(result));
|
|
|
+
|
|
|
+ List<InvoiceApplyContractDetailVo> iacd = invoiceApplyContractDetailService.getList(IWrapper.getWrapper().eq("iacd", InvoiceApplyContractDetail::getInvoiceApplyId, id));
|
|
|
+ result.setInvoiceApplyContractDetailList(iacd);
|
|
|
+
|
|
|
+ List<InvoiceApplyDetailVo> iad = invoiceApplyDetailService.getList(IWrapper.getWrapper().eq("iad", InvoiceApplyDetail::getInvoiceApplyId, id));
|
|
|
+ result.setInvoiceApplyDetailList(iad);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ void setInfo(List<InvoiceApplyVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UserUtil.assignmentNickName(records, InvoiceApply::getCreateUser, InvoiceApplyVo::setCreateUserName);
|
|
|
+ DeptUstil.assignmentNickName(records, InvoiceApply::getDeptId, InvoiceApplyVo::setDeptName);
|
|
|
+ DeptUstil.assignmentNickName(records, InvoiceApply::getCompanyId, InvoiceApplyVo::setCompanyName);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void addOrEdit(InvoiceApplyDto dto) {
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ //相关审批附件
|
|
|
+ ObsFileUtil.editFile(dto.getFileList(), dto.getId(), 10);
|
|
|
+ //聚水潭订单界面金额截图(需有订单号和金额)
|
|
|
+ ObsFileUtil.editFile(dto.getJstOrderFileList(), dto.getId(), 20);
|
|
|
+ //店铺交易截图(含店铺名称、订单编号)
|
|
|
+ ObsFileUtil.editFile(dto.getShopTradeFileList(), dto.getId(), 30);
|
|
|
+ //开票员上传发票附件
|
|
|
+ ObsFileUtil.editFile(dto.getInvoicerFileList(), dto.getId(), 40);
|
|
|
+
|
|
|
+ List<InvoiceApplyContractDetail> invoiceApplyContractDetailList = dto.getInvoiceApplyContractDetailList();
|
|
|
+ invoiceApplyContractDetailList.forEach(item -> item.setInvoiceApplyId(dto.getId()));
|
|
|
+ invoiceApplyContractDetailService.editLinked(invoiceApplyContractDetailList, InvoiceApplyContractDetail::getInvoiceApplyId, dto.getId());
|
|
|
+
|
|
|
+ List<InvoiceApplyDetail> invoiceApplyDetailList = dto.getInvoiceApplyDetailList();
|
|
|
+ invoiceApplyDetailList.forEach(item -> item.setInvoiceApplyId(dto.getId()));
|
|
|
+ invoiceApplyDetailService.editLinked(invoiceApplyDetailList, InvoiceApplyDetail::getInvoiceApplyId, dto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancellation(Long businessId) {
|
|
|
+ InvoiceApply byId = getById(businessId);
|
|
|
+ this.update(q -> q
|
|
|
+ .eq(InvoiceApply::getId, businessId)
|
|
|
+ .set(InvoiceApply::getStatus, FlowStatusEnum1.CANCELLATION.getKey())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ //销毁审批中的流程
|
|
|
+ flowExampleService.update(q -> q
|
|
|
+ .eq(FlowExample::getId, byId.getFlowId())
|
|
|
+ .in(FlowExample::getStatus, FlowStatusEnum.READY_START.getKey(), FlowStatusEnum.IN_PROGRESS.getKey())
|
|
|
+ .set(FlowExample::getStatus, FlowStatusEnum.CANCELLATION.getKey())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|