From 6bbed1ea6b36af4eb0b234bec9d6e42d56f0cd00 Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期三, 30 九月 2026 16:12:49 +0800
Subject: [PATCH] feat:合同新增关联单位  开票可根据甲方或关联单位选择开票单位  收款去掉强制确认 收款只关联合同甲方或关联单位

---
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
index 3be2168..fe543dc 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
@@ -6,6 +6,7 @@
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.by4cloud.platformx.business.dto.BusinessCustomerAddDTO;
 import com.by4cloud.platformx.business.entity.BusinessCustomer;
 import com.by4cloud.platformx.business.mapper.BipBanklViewMapper;
 import com.by4cloud.platformx.business.mapper.BipViewMapper;
@@ -114,4 +115,55 @@
 		}
 		return bc;
 	}
+
+	@Override
+	public R saveCustomerSgb(BusinessCustomerAddDTO addDTO) {
+		if (StrUtil.isBlank(addDTO.getCompanyName())||StrUtil.isBlank(addDTO.getCreditCode())){
+			return R.failed("瀹㈠晢鍚嶇О鎴栫ぞ浼氫俊鐢ㄤ唬鐮佷笉鑳戒负绌�");
+		}
+		BusinessCustomer bc = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery().eq(BusinessCustomer::getCompanyName,addDTO.getCompanyName())
+				.eq(BusinessCustomer::getCreditCode,addDTO.getCreditCode()).last("limit 1"));
+		if (ObjUtil.isNotNull(bc)){
+			return R.failed("瀹㈠晢宸插瓨鍦�");
+		}
+		BusinessCustomer customer = new BusinessCustomer();
+		log.info("涓绘暟鎹煡璇}淇℃伅",addDTO.getCompanyName());
+		CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(addDTO.getCompanyName());
+		if (ObjUtil.isNotNull(custInfo)){
+			if (!addDTO.getCreditCode().equals(custInfo.getCertificateId())){
+				return R.failed("涓绘暟鎹ぞ浼氫俊鐢ㄤ唬鐮佷笌鏂板鐨勪笉涓�鑷�");
+			}
+			customer.setCompanyName(addDTO.getCompanyName());
+			customer.setCreditCode(custInfo.getCertificateId());
+			customer.setRegisterName(custInfo.getCustName());
+			customer.setLegalPerson(custInfo.getLegalPerson());
+			customer.setAddress(custInfo.getRegistrationAddress());
+			customer.setProvince(customer.getCreditCode().substring(2,4));
+			if (StrUtil.isNotEmpty(addDTO.getSalesModel())&& addDTO.getSalesModel().matches("[0-9]+")){
+				customer.setSalesModel(Long.valueOf(addDTO.getSalesModel()));
+			}
+			if (StrUtil.isNotEmpty(addDTO.getExportServiceAttr())&& addDTO.getExportServiceAttr().matches("[0-9]+")){
+				customer.setExportServiceAttr(Long.valueOf(addDTO.getExportServiceAttr()));
+			}
+			if (StrUtil.isNotEmpty(addDTO.getClassId())&& addDTO.getClassId().matches("[0-9]+")){
+				customer.setClassId(Long.valueOf(addDTO.getClassId()));
+			}
+			customer.setInvoiceType("01");
+			log.info("{}涓绘暟鎹煡璇㈠悕绉般�佹硶浜恒�佸湴鍧�銆佷俊鐢ㄧ爜淇℃伅鎴愬姛",addDTO.getCompanyName());
+			List<CustBankVo> bankVoList = bipViewMapper.selectBankByCustName(addDTO.getCompanyName());
+			if (CollUtil.isNotEmpty(bankVoList)){
+				customer.setBankAccount(bankVoList.get(0).getBankAccount());
+				log.info("{}涓绘暟鎹煡璇㈤摱琛屽崱鍙蜂俊鎭垚鍔�",addDTO.getCompanyName());
+				List<BankNameVo> bankNameVoList = bipBanklViewMapper.selectBankByCode(bankVoList.get(0).getBankName());
+				if (CollUtil.isNotEmpty(bankNameVoList)){
+					customer.setBankName(bankNameVoList.get(0).getBankNameName());
+					log.info("{}涓绘暟鎹煡璇㈤摱琛屽悕绉颁俊鎭垚鍔�",addDTO.getCompanyName());
+				}
+			}
+			customer.setRegisterName(custInfo.getCustName());
+			baseMapper.insert(customer);
+			return R.ok();
+		}
+		return R.failed("涓绘暟鎹鍟嗕俊鎭笉瀛樺湪");
+	}
 }
\ No newline at end of file

--
Gitblit v1.9.1