From 10b88a7ff17caf92f3d4e8a550c1085a70c2517a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 28 五月 2026 17:43:26 +0800
Subject: [PATCH] Merge dev_New_pro into dev_山西_晋和园_pro
---
src/main/java/com/ruoyi/account/service/impl/purchase/AccountPaymentApplicationServiceImpl.java | 96 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 96 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPaymentApplicationServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPaymentApplicationServiceImpl.java
new file mode 100644
index 0000000..9eecc49
--- /dev/null
+++ b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPaymentApplicationServiceImpl.java
@@ -0,0 +1,96 @@
+package com.ruoyi.account.service.impl.purchase;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.bean.dto.purchase.AccountPaymentApplicationDto;
+import com.ruoyi.account.bean.vo.purchase.AccountPaymentApplicationVo;
+import com.ruoyi.account.bean.vo.purchase.PurchaseInboundVo;
+import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper;
+import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper;
+import com.ruoyi.account.pojo.purchase.AccountPaymentApplication;
+import com.ruoyi.account.pojo.purchase.AccountPurchasePayment;
+import com.ruoyi.account.service.purchase.AccountPaymentApplicationService;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * <p>
+ * 璐㈠姟绠$悊--浠樻鐢宠 鏈嶅姟瀹炵幇绫�
+ * </p>
+ *
+ * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
+ * @since 2026-05-19 03:44:22
+ */
+@Service
+@RequiredArgsConstructor
+public class AccountPaymentApplicationServiceImpl extends ServiceImpl<AccountPaymentApplicationMapper, AccountPaymentApplication> implements AccountPaymentApplicationService {
+
+ private final AccountPaymentApplicationMapper accountPaymentApplicationMapper;
+ private final AccountPurchasePaymentMapper accountPurchasePaymentMapper;
+ private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");
+
+ @Override
+ public IPage<AccountPaymentApplicationVo> listPageAccountPaymentApplication(Page page, AccountPaymentApplicationDto accountPaymentApplicationDto) {
+ return accountPaymentApplicationMapper.listPageAccountPaymentApplication(page, accountPaymentApplicationDto);
+ }
+
+ @Override
+ public List<PurchaseInboundVo> getInboundBatchesBySupplier(Integer supplierId) {
+ return accountPaymentApplicationMapper.getInboundBatchesBySupplier(supplierId);
+ }
+
+ @Override
+ public boolean addAccountPaymentApplication(AccountPaymentApplication accountPaymentApplication) {
+ if (StringUtils.isEmpty(accountPaymentApplication.getInvoiceApplicationNo())) {
+ accountPaymentApplication.setInvoiceApplicationNo(genPaymentApplicationNo());
+ }
+ String stockInRecordIds= accountPaymentApplication.getStockInRecordIds();
+ if (stockInRecordIds != null && !stockInRecordIds.isEmpty()) {
+ List<Long> ids = Arrays.stream(stockInRecordIds.split(","))
+ .map(Long::valueOf)
+ .toList();
+ if (accountPaymentApplicationMapper.existsByStockInRecordId(ids)){
+ throw new ServiceException("瀛樺湪閲嶅鐨勫叆搴撳崟");
+ }
+ }
+ return save(accountPaymentApplication);
+ }
+
+ @Override
+ public boolean deleteAccountPaymentApplication(List<Long> ids) {
+ if (ids == null || ids.isEmpty()) {
+ throw new ServiceException("鍒犻櫎澶辫触锛岃閫夋嫨瑕佸垹闄ょ殑鏁版嵁");
+ }
+ //鍒ゆ柇鏄惁宸茬粡鏈夊搴旂殑浠樻鍗�,濡傛灉鏈夊垯鏃犳硶鍒犻櫎
+ List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery().in(AccountPurchasePayment::getAccountPaymentApplicationId, ids));
+ if (CollectionUtils.isNotEmpty(accountPurchasePayments)){
+ throw new ServiceException("鍒犻櫎澶辫触锛屽凡缁忔湁鍏宠仈鐨勪粯娆惧崟");
+ }
+ //鍒犻櫎寮�绁ㄧ敵璇�
+ return removeBatchByIds(ids);
+ }
+
+ @Override
+ public void exportAccountPaymentApplication(HttpServletResponse response, AccountPaymentApplicationDto accountPaymentApplicationDto) {
+ List<AccountPaymentApplicationVo> list = accountPaymentApplicationMapper.listPageAccountPaymentApplication(new Page(1,-1),accountPaymentApplicationDto).getRecords();
+ ExcelUtil<AccountPaymentApplicationVo> util = new ExcelUtil<>(AccountPaymentApplicationVo.class);
+ util.exportExcel(response, list , "浠樻鐢宠");
+ }
+
+ private String genPaymentApplicationNo() {
+ return "FK" + LocalDateTime.now().format(CODE_TIME_FORMATTER) + new Random().nextInt(10);
+ }
+}
--
Gitblit v1.9.3