package com.by4cloud.platformx.business.service.impl; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjUtil; 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.entity.BusinessCustomer; import com.by4cloud.platformx.business.mapper.BipBanklViewMapper; import com.by4cloud.platformx.business.mapper.BipViewMapper; import com.by4cloud.platformx.business.mapper.BusinessCustomerMapper; import com.by4cloud.platformx.business.service.BusinessCustomerService; import com.by4cloud.platformx.business.vo.BankNameVo; import com.by4cloud.platformx.business.vo.CustBankVo; import com.by4cloud.platformx.business.vo.CustInfoVo; import com.by4cloud.platformx.common.core.util.R; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; /** * 客商信息 * * @author platformx * @date 2026-05-07 10:13:22 */ @Slf4j @RequiredArgsConstructor @Service public class BusinessCustomerServiceImpl extends ServiceImpl implements BusinessCustomerService { private final BipViewMapper bipViewMapper; private final BipBanklViewMapper bipBanklViewMapper; @Override public R syncMainBusCus() { List bcList = baseMapper.selectList(Wrappers.lambdaQuery().isNull(BusinessCustomer::getCreditCode) .or().isNull(BusinessCustomer::getLegalPerson).or().isNull(BusinessCustomer::getLegalPerson) .or().isNull(BusinessCustomer::getBankName).or().isNull(BusinessCustomer::getBankAccount) .or().isNull(BusinessCustomer::getRegisterName)); if (ArrayUtil.isNotEmpty(bcList.toArray())){ for (BusinessCustomer bc:bcList ) { log.info("开始同步{}信息",bc.getCompanyName()); CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(bc.getCompanyName()); if (ObjUtil.isNotNull(custInfo)){ bc.setCreditCode(custInfo.getCertificateId()); bc.setRegisterName(custInfo.getCustName()); bc.setLegalPerson(custInfo.getLegalGerson()); bc.setAddress(custInfo.getRegistrationAddress()); baseMapper.updateById(bc); log.info("{}同步名称、法人、地址、信用码信息成功",bc.getCompanyName()); } CustBankVo bankVo = bipViewMapper.selectBankByCustName(bc.getCompanyName()); if (ObjUtil.isNotNull(bankVo)){ if (StrUtil.isEmpty(bc.getBankAccount())){ bc.setBankAccount(bankVo.getBankAccount()); baseMapper.updateById(bc); log.info("{}同步银行卡号信息成功",bc.getCompanyName()); } BankNameVo bankNameVo = bipBanklViewMapper.selectBankByCode(bankVo.getBankName()); if (ObjUtil.isNotNull(bankVo)){ bc.setBankName(bankNameVo.getBankNameName()); baseMapper.updateById(bc); log.info("{}同步银行名称信息成功",bc.getCompanyName()); } } } } return R.ok(); } }