|
@@ -0,0 +1,127 @@
|
|
|
+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.common.utils.AuthorityUtils;
|
|
|
+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.InvoiceTaxDeductionDto;
|
|
|
+import com.fjhx.oa.entity.invoice.dto.InvoiceTaxDeductionSelectDto;
|
|
|
+import com.fjhx.oa.entity.invoice.po.InvoiceTaxDeduction;
|
|
|
+import com.fjhx.oa.entity.invoice.po.InvoiceTaxDeductionDetails;
|
|
|
+import com.fjhx.oa.entity.invoice.vo.InvoiceTaxDeductionDetailsVo;
|
|
|
+import com.fjhx.oa.entity.invoice.vo.InvoiceTaxDeductionVo;
|
|
|
+import com.fjhx.oa.mapper.invoice.InvoiceTaxDeductionMapper;
|
|
|
+import com.fjhx.oa.service.invoice.InvoiceTaxDeductionDetailsService;
|
|
|
+import com.fjhx.oa.service.invoice.InvoiceTaxDeductionService;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+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-11
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class InvoiceTaxDeductionServiceImpl extends ServiceImpl<InvoiceTaxDeductionMapper, InvoiceTaxDeduction> implements InvoiceTaxDeductionService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FlowExampleService flowExampleService;
|
|
|
+ @Autowired
|
|
|
+ private InvoiceTaxDeductionDetailsService invoiceTaxDeductionDetailsService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<InvoiceTaxDeductionVo> getPage(InvoiceTaxDeductionSelectDto dto) {
|
|
|
+ IWrapper<InvoiceTaxDeduction> wrapper = getWrapper();
|
|
|
+
|
|
|
+
|
|
|
+ AuthorityUtils.cofAuthority("itd", InvoiceTaxDeduction::getCompanyId, wrapper);
|
|
|
+
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("itd", InvoiceTaxDeduction::getCode),
|
|
|
+ new SqlField("itd", InvoiceTaxDeduction::getAmount)
|
|
|
+ );
|
|
|
+ wrapper.eq("itd", InvoiceTaxDeduction::getStatus, dto.getStatus());
|
|
|
+
|
|
|
+ wrapper.orderByDesc("itd", InvoiceTaxDeduction::getId);
|
|
|
+ Page<InvoiceTaxDeductionVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<InvoiceTaxDeductionVo> records = page.getRecords();
|
|
|
+ setInfo(records);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InvoiceTaxDeductionVo detail(Long id) {
|
|
|
+ InvoiceTaxDeduction InvoiceTaxDeduction = this.getById(id);
|
|
|
+ InvoiceTaxDeductionVo result = BeanUtil.toBean(InvoiceTaxDeduction, InvoiceTaxDeductionVo.class);
|
|
|
+ setInfo(Arrays.asList(result));
|
|
|
+ List<InvoiceTaxDeductionDetailsVo> list = invoiceTaxDeductionDetailsService.getList(IWrapper.getWrapper().eq("itdd", InvoiceTaxDeductionDetails::getInvoiceTaxDeductionId, result.getId()));
|
|
|
+ result.setInvoiceTaxDeductionDetailsList(list);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setInfo(List<InvoiceTaxDeductionVo> records) {
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UserUtil.assignmentNickName(records, InvoiceTaxDeductionVo::getCreateUser, InvoiceTaxDeductionVo::setCreateUserName);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void addOrEdit(InvoiceTaxDeductionDto dto) {
|
|
|
+ dto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+ this.saveOrUpdate(dto);
|
|
|
+ List<InvoiceTaxDeductionDetails> detailsList = dto.getInvoiceTaxDeductionDetailsList();
|
|
|
+ detailsList.stream().forEach(item -> item.setInvoiceTaxDeductionId(dto.getId()));
|
|
|
+ invoiceTaxDeductionDetailsService.editLinked(detailsList, InvoiceTaxDeductionDetails::getInvoiceTaxDeductionId, dto.getId());
|
|
|
+ for (InvoiceTaxDeductionDetails details : detailsList) {
|
|
|
+ ObsFileUtil.editFile(details.getFileList(), dto.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancellation(Long businessId) {
|
|
|
+ InvoiceTaxDeduction byId = getById(businessId);
|
|
|
+ this.update(q -> q
|
|
|
+ .eq(InvoiceTaxDeduction::getId, businessId)
|
|
|
+ .set(InvoiceTaxDeduction::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())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|