diff --git a/oms_web/oms_vue/src/api/finance/payment.js b/oms_web/oms_vue/src/api/finance/payment.js index afb563a2..d2b84816 100644 --- a/oms_web/oms_vue/src/api/finance/payment.js +++ b/oms_web/oms_vue/src/api/finance/payment.js @@ -150,3 +150,23 @@ export function listPaymentApproved(query) { }) } +// 查询付款单列表 (核销专用) +export function listPaymentForWriteOff(query) { + return request({ + url: '/finance/payment/write-off/list', + method: 'post', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: tansParams(query) + }) +} + +// 手工匹配核销 +export function manualWriteOff(data) { + return request({ + url: '/finance/writeoff', + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/oms_web/oms_vue/src/views/finance/writeoff/index.vue b/oms_web/oms_vue/src/views/finance/writeoff/index.vue deleted file mode 100644 index d2730718..00000000 --- a/oms_web/oms_vue/src/views/finance/writeoff/index.vue +++ /dev/null @@ -1,395 +0,0 @@ - - - - - diff --git a/oms_web/oms_vue/src/views/finance/writeoff/payment/index.vue b/oms_web/oms_vue/src/views/finance/writeoff/payment/index.vue new file mode 100644 index 00000000..d6654e42 --- /dev/null +++ b/oms_web/oms_vue/src/views/finance/writeoff/payment/index.vue @@ -0,0 +1,567 @@ + + + + + diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPayableWriteOffController.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPayableWriteOffController.java index 236b1aeb..47db7013 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPayableWriteOffController.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPayableWriteOffController.java @@ -1,29 +1,21 @@ package com.ruoyi.sip.controller; -import java.util.List; -import javax.servlet.http.HttpServletResponse; - -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.sip.domain.OmsPayableWriteOff; -import com.ruoyi.sip.dto.WriteOffRequestDto; -import com.ruoyi.sip.dto.WriteOffQueryDto; import com.ruoyi.sip.dto.WriteOffDetailResultDto; +import com.ruoyi.sip.dto.WriteOffRequestDto; import com.ruoyi.sip.service.IOmsPayableWriteOffService; -import com.ruoyi.common.core.page.TableDataInfo; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * 采购应付核销单Controller @@ -32,7 +24,7 @@ import com.ruoyi.common.core.page.TableDataInfo; * @date 2025-12-16 */ @RestController -@RequestMapping("/sip/writeOff") +@RequestMapping("/finance/writeoff") public class OmsPayableWriteOffController extends BaseController { @Autowired @@ -43,7 +35,7 @@ public class OmsPayableWriteOffController extends BaseController */ @RequiresPermissions("sip:writeOff:list") @GetMapping("/list") - public TableDataInfo list(WriteOffQueryDto writeOffQueryDto) + public TableDataInfo list(OmsPayableWriteOff writeOffQueryDto) { startPage(); List list = omsPayableWriteOffService.selectOmsPayableWriteOffList(writeOffQueryDto); @@ -56,7 +48,7 @@ public class OmsPayableWriteOffController extends BaseController @RequiresPermissions("sip:writeOff:export") @Log(title = "采购应付核销单", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, WriteOffQueryDto writeOffQueryDto) + public void export(HttpServletResponse response, OmsPayableWriteOff writeOffQueryDto) { List list = omsPayableWriteOffService.selectOmsPayableWriteOffList(writeOffQueryDto); ExcelUtil util = new ExcelUtil(OmsPayableWriteOff.class); diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java index 497d1e4f..538f1b00 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/controller/OmsPaymentBillController.java @@ -68,6 +68,14 @@ public class OmsPaymentBillController extends BaseController , OmsPaymentBill::getPaymentBillCode, (a, b) -> a.setApproveNode(b.get(a.getPaymentBillCode()))); return getDataTable(list); } + @PostMapping("/write-off/list") + @ResponseBody + public TableDataInfo listWriteOff(OmsPaymentBill omsPaymentBill) + { + startPage(); + List list = omsPaymentBillService.listWriteOff(omsPaymentBill); + return getDataTable(list); + } @RequiresPermissions("finance:payment:approve") diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayablePaymentDetail.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayablePaymentDetail.java index 0fbc4153..668ee6d6 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayablePaymentDetail.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayablePaymentDetail.java @@ -20,9 +20,12 @@ public class OmsPayablePaymentDetail extends BaseEntity { private Date paymentTime; private BigDecimal paymentAmount; + private BigDecimal paymentAmountWithoutTax; + private BigDecimal paymentAmountTax; private BigDecimal paymentRate; private String paymentBillCode; private Long paymentBillId; + private Long writeOffId; private Date actualPaymentTime; private String paymentStatus; @@ -36,6 +39,7 @@ public class OmsPayablePaymentDetail extends BaseEntity { /** 已确认 */ PREPAY_WRITE_OFF("2", "预付核销"), REFUND("3", "退款"), + REFUND_WRITE_OFF("4", "反核销"), ; diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayableWriteOff.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayableWriteOff.java index 7bec5e80..4e2369c3 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayableWriteOff.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPayableWriteOff.java @@ -2,11 +2,14 @@ package com.ruoyi.sip.domain; import java.math.BigDecimal; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.Getter; /** * 采购应付核销单对象 oms_payable_write_off @@ -34,10 +37,12 @@ public class OmsPayableWriteOff extends BaseEntity /** 付款单编号 */ @Excel(name = "付款单编号") private String paymentBillCode; + private List paymentBillCodeList; /** 供应商编码 */ @Excel(name = "供应商编码") private String vendorCode; + private String vendorName; /** 本次核销总金额 */ @Excel(name = "本次核销总金额") @@ -62,6 +67,7 @@ public class OmsPayableWriteOff extends BaseEntity /** 创建人 */ private String createBy; + private String createByName; /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @@ -73,4 +79,20 @@ public class OmsPayableWriteOff extends BaseEntity /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; + + @Getter + public enum WriteOffTypeEnum { + + AUTO("AUTO", "自动核销"), + USER("USER", "手动核销"), + + ; + private final String code; + private final String desc; + WriteOffTypeEnum(String code, String desc) { + this.code = code; + this.desc = desc; + } + } + } \ No newline at end of file diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java index 4114f5fe..5856446d 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/OmsPaymentBill.java @@ -135,6 +135,10 @@ public class OmsPaymentBill extends BaseEntity private String taskId; + private BigDecimal writeOffAmount; + private BigDecimal writeOffAmountWithoutTax; + private BigDecimal writeOffTaxAmount; + @Getter public enum PaymentBillTypeEnum { diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffItemDto.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffItemDto.java index 91f0a8eb..8a58d13a 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffItemDto.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffItemDto.java @@ -47,6 +47,7 @@ public class WriteOffItemDto * 本次核销税额 */ private BigDecimal writeOffTaxAmount; + private BigDecimal paymentRate; /** * 备注 diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffQueryDto.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffQueryDto.java deleted file mode 100644 index cbbf2a39..00000000 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffQueryDto.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ruoyi.sip.dto; - -import com.ruoyi.common.core.domain.BaseEntity; -import java.util.Date; - -/** - * 采购应付核销单记录查询DTO - * - * @author zghz - * @date 2025-12-16 - */ -public class WriteOffQueryDto extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 核销单号 */ - private String writeOffCode; - - /** 供货商代码 */ - private String vendorCode; - - // Getters and Setters - public String getWriteOffCode() { - return writeOffCode; - } - - public void setWriteOffCode(String writeOffCode) { - this.writeOffCode = writeOffCode; - } - - public String getVendorCode() { - return vendorCode; - } - - public void setVendorCode(String vendorCode) { - this.vendorCode = vendorCode; - } -} \ No newline at end of file diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffRequestDto.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffRequestDto.java index 791ad9c4..cd5e3ea5 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffRequestDto.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/dto/WriteOffRequestDto.java @@ -1,5 +1,6 @@ package com.ruoyi.sip.dto; +import com.ruoyi.sip.domain.OmsPayablePaymentDetail; import lombok.Data; import java.util.List; @@ -24,7 +25,7 @@ public class WriteOffRequestDto /** * 核销项列表 */ - private List writeOffItems; + private List detailList; /** * 供应商代码 diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayableWriteOffDetailMapper.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayableWriteOffDetailMapper.java deleted file mode 100644 index 9337a50f..00000000 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/mapper/OmsPayableWriteOffDetailMapper.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.ruoyi.sip.mapper; - -import java.util.List; -import com.ruoyi.sip.domain.OmsPayableWriteOffDetail; - -/** - * 应付单付款计划核销明细Mapper接口 - * - * @author zghz - * @date 2025-12-16 - */ -public interface OmsPayableWriteOffDetailMapper -{ - /** - * 查询应付单付款计划核销明细 - * - * @param id 应付单付款计划核销明细ID - * @return 应付单付款计划核销明细 - */ - public OmsPayableWriteOffDetail selectOmsPayableWriteOffDetailById(Long id); - - /** - * 查询应付单付款计划核销明细列表 - * - * @param omsPayableWriteOffDetail 应付单付款计划核销明细 - * @return 应付单付款计划核销明细集合 - */ - public List selectOmsPayableWriteOffDetailList(OmsPayableWriteOffDetail omsPayableWriteOffDetail); - - /** - * 新增应付单付款计划核销明细 - * - * @param omsPayableWriteOffDetail 应付单付款计划核销明细 - * @return 结果 - */ - public int insertOmsPayableWriteOffDetail(OmsPayableWriteOffDetail omsPayableWriteOffDetail); - - /** - * 修改应付单付款计划核销明细 - * - * @param omsPayableWriteOffDetail 应付单付款计划核销明细 - * @return 结果 - */ - public int updateOmsPayableWriteOffDetail(OmsPayableWriteOffDetail omsPayableWriteOffDetail); - - /** - * 删除应付单付款计划核销明细 - * - * @param id 应付单付款计划核销明细ID - * @return 结果 - */ - public int deleteOmsPayableWriteOffDetailById(Long id); - - /** - * 批量删除应付单付款计划核销明细 - * - * @param ids 需要删除的数据ID - * @return 结果 - */ - public int deleteOmsPayableWriteOffDetailByIds(Long[] ids); - - /** - * 根据核销单ID删除应付单付款计划核销明细 - * - * @param writeOffId 核销单ID - * @return 结果 - */ - public int deleteOmsPayableWriteOffDetailByWriteOffId(Long writeOffId); - - /** - * 批量删除应付单付款计划核销明细 - * - * @param writeOffIds 核销单ID数组 - * @return 结果 - */ - public int deleteOmsPayableWriteOffDetailByWriteOffIds(Long[] writeOffIds); - - /** - * 根据核销单ID查询核销明细 - * - * @param writeOffId 核销单ID - * @return 核销明细集合 - */ - public List selectOmsPayableWriteOffDetailByWriteOffId(Long writeOffId); -} \ No newline at end of file diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayablePaymentDetailService.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayablePaymentDetailService.java index fcb1b1db..ebb0529e 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayablePaymentDetailService.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayablePaymentDetailService.java @@ -1,6 +1,7 @@ package com.ruoyi.sip.service; import com.ruoyi.sip.domain.OmsPayablePaymentDetail; +import com.ruoyi.sip.domain.OmsPayableWriteOffDetail; import com.ruoyi.sip.domain.dto.PaymentBillPayableDetailDTO; import java.util.List; @@ -17,4 +18,8 @@ public interface IOmsPayablePaymentDetailService { List selectByPaymentPlanIds(List paymentPlanIds); List listBypaymentCode(String paymentBillCode); + + void insertBatch(List detailList); + +// List listWriteOffByPaymentCode(List ); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayableWriteOffService.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayableWriteOffService.java index 760df520..ecb8b834 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayableWriteOffService.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPayableWriteOffService.java @@ -1,10 +1,10 @@ package com.ruoyi.sip.service; -import java.util.List; import com.ruoyi.sip.domain.OmsPayableWriteOff; -import com.ruoyi.sip.dto.WriteOffRequestDto; -import com.ruoyi.sip.dto.WriteOffQueryDto; import com.ruoyi.sip.dto.WriteOffDetailResultDto; +import com.ruoyi.sip.dto.WriteOffRequestDto; + +import java.util.List; /** * 采购应付核销单Service接口 @@ -28,7 +28,7 @@ public interface IOmsPayableWriteOffService * @param writeOffQueryDto 核销查询条件 * @return 采购应付核销单集合 */ - public List selectOmsPayableWriteOffList(WriteOffQueryDto writeOffQueryDto); + public List selectOmsPayableWriteOffList(OmsPayableWriteOff writeOffQueryDto); /** * 新增采购应付核销单 @@ -69,4 +69,6 @@ public interface IOmsPayableWriteOffService * @return 核销详情列表 */ public List selectWriteOffDetailsByWriteOffId(Long writeOffId); + + List listByPaymentBillCodeList(List collect); } \ No newline at end of file diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPaymentBillService.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPaymentBillService.java index 78015c18..266f9ebf 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPaymentBillService.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/IOmsPaymentBillService.java @@ -103,4 +103,6 @@ public interface IOmsPaymentBillService AjaxResult revoke(OmsPaymentBill paymentBill); AjaxResult applyRefundApprove(OmsPaymentBill paymentBill); + + List listWriteOff(OmsPaymentBill omsPaymentBill); } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayablePaymentDetailServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayablePaymentDetailServiceImpl.java index 140a6e73..edf935a6 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayablePaymentDetailServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayablePaymentDetailServiceImpl.java @@ -112,4 +112,9 @@ public class OmsPayablePaymentDetailServiceImpl implements IOmsPayablePaymentDet omsPayablePaymentDetail.setPaymentBillCode(paymentBillCode); return omsPayablePaymentDetailMapper.list(omsPayablePaymentDetail); } + + @Override + public void insertBatch(List detailList) { + omsPayablePaymentDetailMapper.insertBatch(detailList); + } } diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/OmsPayableWriteOffServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayableWriteOffServiceImpl.java similarity index 65% rename from ruoyi-sip/src/main/java/com/ruoyi/sip/service/OmsPayableWriteOffServiceImpl.java rename to ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayableWriteOffServiceImpl.java index ce05cdf5..32df57de 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/OmsPayableWriteOffServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPayableWriteOffServiceImpl.java @@ -1,27 +1,29 @@ -package com.ruoyi.sip.service; +package com.ruoyi.sip.service.impl; + +import cn.hutool.core.collection.CollUtil; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.sip.domain.OmsPayablePaymentDetail; +import com.ruoyi.sip.domain.OmsPayableWriteOff; +import com.ruoyi.sip.domain.OmsPayableWriteOffDetail; +import com.ruoyi.sip.domain.OmsPaymentBill; +import com.ruoyi.sip.dto.WriteOffDetailResultDto; +import com.ruoyi.sip.dto.WriteOffRequestDto; +import com.ruoyi.sip.mapper.OmsPayableWriteOffMapper; +import com.ruoyi.sip.mapper.OmsPaymentBillMapper; +import com.ruoyi.sip.service.IOmsPayableBillService; +import com.ruoyi.sip.service.IOmsPayablePaymentDetailService; +import com.ruoyi.sip.service.IOmsPayableWriteOffService; +import com.ruoyi.sip.utils.WriteOffCodeGenerator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.stream.Collectors; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.sip.domain.OmsPayableWriteOff; -import com.ruoyi.sip.domain.OmsPayableWriteOffDetail; -import com.ruoyi.sip.domain.OmsPayableBill; -import com.ruoyi.sip.domain.OmsPaymentBill; -import com.ruoyi.sip.domain.OmsPayablePaymentPlan; -import com.ruoyi.sip.mapper.OmsPayableWriteOffMapper; -import com.ruoyi.sip.mapper.OmsPayableWriteOffDetailMapper; -import com.ruoyi.sip.mapper.OmsPayableBillMapper; -import com.ruoyi.sip.mapper.OmsPaymentBillMapper; -import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper; -import com.ruoyi.sip.dto.WriteOffRequestDto; -import com.ruoyi.sip.dto.WriteOffItemDto; -import com.ruoyi.sip.dto.WriteOffQueryDto; -import com.ruoyi.sip.dto.WriteOffDetailResultDto; -import com.ruoyi.sip.utils.WriteOffCodeGenerator; /** * 采购应付核销单Service业务层处理 @@ -35,14 +37,14 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService @Autowired private OmsPayableWriteOffMapper omsPayableWriteOffMapper; - @Autowired - private OmsPayableWriteOffDetailMapper omsPayableWriteOffDetailMapper; - @Autowired - private OmsPayableBillMapper omsPayableBillMapper; @Autowired private OmsPaymentBillMapper omsPaymentBillMapper; + @Autowired + private IOmsPayablePaymentDetailService omsPayablePaymentDetailService; + @Autowired + private IOmsPayableBillService payableBillService; /** @@ -64,12 +66,8 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService * @return 采购应付核销单集合 */ @Override - public List selectOmsPayableWriteOffList(WriteOffQueryDto writeOffQueryDto) + public List selectOmsPayableWriteOffList(OmsPayableWriteOff omsPayableWriteOff) { - OmsPayableWriteOff omsPayableWriteOff = new OmsPayableWriteOff(); - omsPayableWriteOff.setWriteOffCode(writeOffQueryDto.getWriteOffCode()); - omsPayableWriteOff.setVendorCode(writeOffQueryDto.getVendorCode()); - return omsPayableWriteOffMapper.selectOmsPayableWriteOffList(omsPayableWriteOff); } @@ -83,17 +81,20 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService @Transactional public Long insertOmsPayableWriteOff(WriteOffRequestDto writeOffRequestDto) { + if (CollUtil.isEmpty(writeOffRequestDto.getDetailList())){ + throw new ServiceException("请选择核销明细"); + } // 获取付款单信息 OmsPaymentBill paymentBill = omsPaymentBillMapper.selectOmsPaymentBillById(writeOffRequestDto.getPaymentBillId()); if (paymentBill == null) { - throw new RuntimeException("付款单不存在"); + throw new ServiceException("付款单不存在"); } // 创建核销主记录 OmsPayableWriteOff writeOff = new OmsPayableWriteOff(); writeOff.setWriteOffCode(WriteOffCodeGenerator.generateWriteOffCode()); // 默认为用户手动核销 - writeOff.setWriteOffType("USER"); + writeOff.setWriteOffType(OmsPayableWriteOff.WriteOffTypeEnum.USER.getCode()); writeOff.setPaymentBillCode(paymentBill.getPaymentBillCode()); writeOff.setVendorCode(writeOffRequestDto.getVendorCode()); writeOff.setWriteOffTime(new Date()); @@ -104,51 +105,40 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService BigDecimal totalAmountWithoutTax = BigDecimal.ZERO; BigDecimal totalTaxAmount = BigDecimal.ZERO; - for (WriteOffItemDto item : writeOffRequestDto.getWriteOffItems()) { - totalAmount = totalAmount.add(item.getWriteOffAmount()); - totalAmountWithoutTax = totalAmountWithoutTax.add(item.getWriteOffAmountWithoutTax()); - totalTaxAmount = totalTaxAmount.add(item.getWriteOffTaxAmount()); + for (OmsPayablePaymentDetail item : writeOffRequestDto.getDetailList()) { + totalAmount = totalAmount.add(item.getPaymentAmount()); + totalAmountWithoutTax = totalAmountWithoutTax.add(item.getPaymentAmountWithoutTax()); + totalTaxAmount = totalTaxAmount.add(item.getPaymentAmountTax()); } writeOff.setWriteOffAmount(totalAmount); writeOff.setWriteOffAmountWithoutTax(totalAmountWithoutTax); writeOff.setWriteOffTaxAmount(totalTaxAmount); + //预付额度减少 + OmsPaymentBill updateBill = new OmsPaymentBill(); + BigDecimal decimal = paymentBill.getPreResidueAmount().subtract(totalAmount); + if (decimal.compareTo(BigDecimal.ZERO) < 0) { + throw new RuntimeException("核销金额不能大于预付剩余额度"); + } + updateBill.setPreResidueAmount(decimal); + updateBill.setId(paymentBill.getId()); + omsPaymentBillMapper.updateOmsPaymentBill(updateBill); // 设置创建时间 writeOff.setCreateTime(new Date()); + writeOff.setCreateBy(ShiroUtils.getUserId().toString()); writeOff.setUpdateTime(new Date()); - // 保存核销主记录 omsPayableWriteOffMapper.insertOmsPayableWriteOff(writeOff); - // 保存核销明细 - for (WriteOffItemDto item : writeOffRequestDto.getWriteOffItems()) - { - OmsPayableWriteOffDetail detail = new OmsPayableWriteOffDetail(); - detail.setWriteOffId(writeOff.getId()); - detail.setPayableBillId(item.getPayableBillId()); - detail.setPaymentPlanId(item.getPaymentPlanId()); - detail.setPaymentBillId(item.getPaymentBillId()); - detail.setWriteOffAmount(item.getWriteOffAmount()); - detail.setWriteOffAmountWithoutTax(item.getWriteOffAmountWithoutTax()); - detail.setWriteOffTaxAmount(item.getWriteOffTaxAmount()); - detail.setRemark(item.getRemark()); - detail.setCreateTime(new Date()); - detail.setUpdateTime(new Date()); - - // 获取应付单编号 - OmsPayableBill payableBill = omsPayableBillMapper.selectOmsPayableBillById(item.getPayableBillId()); - if (payableBill != null) { - detail.setPayableBillCode(payableBill.getPayableBillCode()); - } - - // 设置付款单编号 - detail.setPaymentBillCode(paymentBill.getPaymentBillCode()); - - // 保存核销明细记录 - omsPayableWriteOffDetailMapper.insertOmsPayableWriteOffDetail(detail); + for (OmsPayablePaymentDetail omsPayablePaymentDetail : writeOffRequestDto.getDetailList()) { + omsPayablePaymentDetail.setPayableDetailType(OmsPayablePaymentDetail.PayableDetailTypeEnum.PREPAY_WRITE_OFF.getCode()); + omsPayablePaymentDetail.setPaymentTime(DateUtils.getNowDate()); + omsPayablePaymentDetail.setCreateBy(ShiroUtils.getUserId().toString()); + omsPayablePaymentDetail.setWriteOffId(writeOff.getId()); } - + omsPayablePaymentDetailService.insertBatch( writeOffRequestDto.getDetailList()); + payableBillService.updatePaymentAmount(writeOffRequestDto.getDetailList().stream().map(OmsPayablePaymentDetail::getPayableBillId).collect(Collectors.toList())); return writeOff.getId(); } @@ -174,8 +164,11 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService @Transactional public int deleteOmsPayableWriteOffByIds(Long[] ids) { + //反核销逻辑 todo + + // 先删除明细记录 - omsPayableWriteOffDetailMapper.deleteOmsPayableWriteOffDetailByWriteOffIds(ids); +// omsPayablePaymentDetailService.deleteOmsPayableWriteOffDetailByWriteOffIds(ids); // 再删除主记录 return omsPayableWriteOffMapper.deleteOmsPayableWriteOffByIds(ids); } @@ -190,10 +183,8 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService @Transactional public int deleteOmsPayableWriteOffById(Long id) { - // 先删除明细记录 - omsPayableWriteOffDetailMapper.deleteOmsPayableWriteOffDetailByWriteOffId(id); // 再删除主记录 - return omsPayableWriteOffMapper.deleteOmsPayableWriteOffById(id); + return deleteOmsPayableWriteOffByIds(new Long[]{id}); } /** @@ -205,8 +196,16 @@ public class OmsPayableWriteOffServiceImpl implements IOmsPayableWriteOffService @Override public List selectWriteOffDetailsByWriteOffId(Long writeOffId) { - List details = omsPayableWriteOffDetailMapper.selectOmsPayableWriteOffDetailByWriteOffId(writeOffId); - return details.stream().map(this::convertToWriteOffDetailResultDto).collect(Collectors.toList()); +// List details = omsPayableWriteOffDetailMapper.selectOmsPayableWriteOffDetailByWriteOffId(writeOffId); +// return details.stream().map(this::convertToWriteOffDetailResultDto).collect(Collectors.toList()); + return null; + } + + @Override + public List listByPaymentBillCodeList(List collect) { + OmsPayableWriteOff omsPayableWriteOff = new OmsPayableWriteOff(); + omsPayableWriteOff.setPaymentBillCodeList(collect); + return omsPayableWriteOffMapper.selectOmsPayableWriteOffList(omsPayableWriteOff); } /** diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPaymentBillServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPaymentBillServiceImpl.java index 5feb740c..032e35bf 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPaymentBillServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/OmsPaymentBillServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.sip.service.impl; +import java.math.BigDecimal; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -63,6 +64,8 @@ public class OmsPaymentBillServiceImpl implements IOmsPaymentBillService , TodoC private ProcessConfig processConfig; @Autowired protected ManagementService managementService; + @Autowired + private IOmsPayableWriteOffService writeOffService; /** * 查询采购付款单 * @@ -462,4 +465,34 @@ public class OmsPaymentBillServiceImpl implements IOmsPaymentBillService , TodoC return AjaxResult.success("申请退款成功"); } + + @Override + public List listWriteOff(OmsPaymentBill omsPaymentBill) { + omsPaymentBill.setPreResidueAmount(new BigDecimal("-1")); + List omsPaymentBills = omsPaymentBillMapper.selectOmsPaymentBillList(omsPaymentBill); + if (CollUtil.isEmpty(omsPaymentBills)) { + return omsPaymentBills; + } + //实时计算已核销金额 查询核销数据 + List omsPayableWriteOffs = writeOffService.listByPaymentBillCodeList(omsPaymentBills.stream().map(OmsPaymentBill::getPaymentBillCode).collect(Collectors.toList())); + Map> writeOffListMap = omsPayableWriteOffs.stream().collect(Collectors.groupingBy(OmsPayableWriteOff::getPaymentBillCode)); + for (OmsPaymentBill paymentBill : omsPaymentBills) { + List writeOffList = writeOffListMap.get(paymentBill.getPaymentBillCode()); + BigDecimal writeOffAmount = BigDecimal.ZERO; + BigDecimal writeOffAmountWithoutTax = BigDecimal.ZERO; + BigDecimal writeOffTaxAmount = BigDecimal.ZERO; + if (CollUtil.isNotEmpty(writeOffList)) { + for (OmsPayableWriteOff omsPayableWriteOff : writeOffList) { + writeOffAmount = writeOffAmount.add(omsPayableWriteOff.getWriteOffAmount()); + writeOffAmountWithoutTax = writeOffAmountWithoutTax.add(omsPayableWriteOff.getWriteOffAmountWithoutTax()); + writeOffTaxAmount = writeOffTaxAmount.add(omsPayableWriteOff.getWriteOffTaxAmount()); + } + } + paymentBill.setWriteOffAmount(writeOffAmount); + paymentBill.setWriteOffAmountWithoutTax(writeOffAmountWithoutTax); + paymentBill.setWriteOffTaxAmount(writeOffTaxAmount); + } + + return omsPaymentBills; + } } diff --git a/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffDetailMapper.xml b/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffDetailMapper.xml deleted file mode 100644 index e2b238df..00000000 --- a/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffDetailMapper.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - select id, write_off_id, payable_bill_id, payable_bill_code, payment_plan_id, payment_bill_id, payment_bill_code, - write_off_amount, write_off_amount_without_tax, write_off_tax_amount, - remark, create_by, create_time, update_by, update_time - from oms_payable_write_off_detail - - - - - - - - - - insert into oms_payable_write_off_detail - - write_off_id, - payable_bill_id, - payable_bill_code, - payment_plan_id, - payment_bill_id, - payment_bill_code, - write_off_amount, - write_off_amount_without_tax, - write_off_tax_amount, - remark, - create_by, - create_time, - update_by, - update_time, - - - #{writeOffId}, - #{payableBillId}, - #{payableBillCode}, - #{paymentPlanId}, - #{paymentBillId}, - #{paymentBillCode}, - #{writeOffAmount}, - #{writeOffAmountWithoutTax}, - #{writeOffTaxAmount}, - #{remark}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - - - - - update oms_payable_write_off_detail - - write_off_id = #{writeOffId}, - payable_bill_id = #{payableBillId}, - payable_bill_code = #{payableBillCode}, - payment_plan_id = #{paymentPlanId}, - payment_bill_id = #{paymentBillId}, - payment_bill_code = #{paymentBillCode}, - write_off_amount = #{writeOffAmount}, - write_off_amount_without_tax = #{writeOffAmountWithoutTax}, - write_off_tax_amount = #{writeOffTaxAmount}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = #{updateTime}, - - where id = #{id} - - - - delete from oms_payable_write_off_detail where id = #{id} - - - - delete from oms_payable_write_off_detail where write_off_id = #{writeOffId} - - - - delete from oms_payable_write_off_detail where write_off_id in - - #{writeOffId} - - - - - delete from oms_payable_write_off_detail where id in - - #{id} - - - \ No newline at end of file diff --git a/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffMapper.xml b/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffMapper.xml index 486d6b60..940e80bd 100644 --- a/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffMapper.xml @@ -22,10 +22,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, write_off_code, write_off_type, payment_bill_code, vendor_code, - write_off_amount, write_off_amount_without_tax, write_off_tax_amount, write_off_time, - remark, create_by, create_time, update_by, update_time - from oms_payable_write_off + select t1.id, t1.write_off_code, t1.write_off_type, t1.payment_bill_code, t1.vendor_code, + t1.write_off_amount, t1.write_off_amount_without_tax, t1.write_off_tax_amount, t1.write_off_time, + t1.remark, t1.create_by, t1.create_time, t1.update_by, t1.update_time, + t2.vendor_name,t3.user_name as create_by_name + from oms_payable_write_off t1 + left join oms_vendor_info t2 on t1.vendor_code=t2.vendor_code + left join sys_user t3 on t1.create_by=t3.user_id diff --git a/ruoyi-sip/src/main/resources/mapper/finance/OmsPayableBillMapper.xml b/ruoyi-sip/src/main/resources/mapper/finance/OmsPayableBillMapper.xml index 23c9e8e6..ce67ec4e 100644 --- a/ruoyi-sip/src/main/resources/mapper/finance/OmsPayableBillMapper.xml +++ b/ruoyi-sip/src/main/resources/mapper/finance/OmsPayableBillMapper.xml @@ -96,30 +96,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and pb.payment_bill_code like concat('%', #{paymentBillCode}, '%') - and pb.payment_bill_type = #{paymentBillType} - and date_format(pb.payment_time,'%Y-%m-%d') = date_format(#{paymentTime},'%Y-%m-%d') - and pb.vendor_code like concat('%', #{vendorCode}, '%') - and pb.order_code like concat('%', #{orderCode}, '%') - and pb.total_price_with_tax = #{totalPriceWithTax} - and pb.total_price_without_tax = #{totalPriceWithoutTax} - and pb.tax_amount = #{taxAmount} - and pb.project_code like concat('%', #{projectCode}, '%') - and pb.project_name like concat('%', #{projectName}, '%') - and pb.payment_status = #{paymentStatus} - and pb.approve_status = #{approveStatus} - and pb.approve_node = #{approveNode} - and date_format(pb.approve_time,'%Y-%m-%d') = date_format(#{approveTime},'%Y-%m-%d') - and date_format(pb.actual_payment_time,'%Y-%m-%d') = date_format(#{actualPaymentTime},'%Y-%m-%d') - and pb.payment_method = #{paymentMethod} - and apb.payable_bill_code like concat('%', #{payableBillCode}, '%') + and pb.payment_bill_code like concat('%', + #{paymentBillCode}, '%') + + and pb.payment_bill_type = + #{paymentBillType} + + and date_format(pb.payment_time,'%Y-%m-%d') = + date_format(#{paymentTime},'%Y-%m-%d') + + and pb.vendor_code like concat('%', #{vendorCode}, + '%') + + and pb.order_code like concat('%', #{orderCode}, '%') + and pb.total_price_with_tax = #{totalPriceWithTax} + and pb.total_price_without_tax = #{totalPriceWithoutTax} + and pb.tax_amount = #{taxAmount} + and pb.project_code like concat('%', #{projectCode}, + '%') + + and pb.project_name like concat('%', #{projectName}, + '%') + + and pb.payment_status = #{paymentStatus} + and pb.approve_status = #{approveStatus} + and pb.approve_node = #{approveNode} + and date_format(pb.approve_time,'%Y-%m-%d') = + date_format(#{approveTime},'%Y-%m-%d') + + and date_format(pb.actual_payment_time,'%Y-%m-%d') = + date_format(#{actualPaymentTime},'%Y-%m-%d') + + and pb.payment_method = #{paymentMethod} + and apb.payable_bill_code like concat('%', + #{payableBillCode}, '%') + + + + + and pb.pre_residue_amount != 0 + + + and pb.pre_residue_amount = #{preResidueAmount} + + + + and pb.del_flag = '0' - group by pb.id order by pb.create_time desc -