| | |
| | | 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.entity.Contract; |
| | | 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.mapper.ContractMapper; |
| | | import com.by4cloud.platformx.business.service.BusinessCustomerService; |
| | | import com.by4cloud.platformx.business.vo.*; |
| | | import com.by4cloud.platformx.common.core.util.R; |
| | |
| | | import com.by4cloud.platformx.common.security.util.SecurityUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.BindingResult; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | @Service |
| | | public class BusinessCustomerServiceImpl extends ServiceImpl<BusinessCustomerMapper, BusinessCustomer> implements BusinessCustomerService { |
| | | |
| | | @Value("${dept.smj}") |
| | | private String smj; |
| | | |
| | | @Value("${dept.smjhw}") |
| | | private String smjhw; |
| | | |
| | | private final BipViewMapper bipViewMapper; |
| | | private final BipBanklViewMapper bipBanklViewMapper; |
| | | private final ContractMapper contractMapper; |
| | | |
| | | @Override |
| | | public R syncMainBusCus(String compId) { |
| | |
| | | if (StrUtil.isBlank(addDTO.getCompanyName())||StrUtil.isBlank(addDTO.getCreditCode())){ |
| | | return R.failed("客商名称或社会信用代码不能为空"); |
| | | } |
| | | BusinessCustomer bc = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery().eq(BusinessCustomer::getCompanyName,addDTO.getCompanyName()) |
| | | BusinessCustomer bc = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode,addDTO.getCreditCode()) |
| | | .eq(BusinessCustomer::getCompId, SecurityUtils.getUser().getCompId()) |
| | | .last("limit 1")); |
| | |
| | | } |
| | | } |
| | | customer.setRegisterName(custInfo.getCustName()); |
| | | customer.setBipCode(custInfo.getCertificateId()); |
| | | baseMapper.insert(customer); |
| | | return R.ok(); |
| | | } |
| | |
| | | errorMessageList.add(new ErrorMessage(line++, errorMsg)); |
| | | continue; |
| | | } |
| | | BusinessCustomer customer = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode, excelVO.getCreditCode()) |
| | | .last("limit 1")); |
| | | BusinessCustomer customer = null; |
| | | if (StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smj) || StrUtil.equals(SecurityUtils.getUser().getCompId() + "", smjhw)) { |
| | | List<String> smjList = new ArrayList<>(); |
| | | smjList.add(smj); |
| | | smjList.add(smjhw); |
| | | customer = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode, excelVO.getCreditCode()) |
| | | .in(BusinessCustomer::getCompId, smjList) |
| | | .last("limit 1")); |
| | | }else { |
| | | customer = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(BusinessCustomer::getCreditCode, excelVO.getCreditCode()) |
| | | .last("limit 1")); |
| | | } |
| | | if (ObjUtil.isNull(customer)) { |
| | | customer = BeanUtil.copyProperties(excelVO, BusinessCustomer.class); |
| | | CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCustName(excelVO.getCompanyName()); |
| | | CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCertId(excelVO.getCreditCode()); |
| | | if (ObjUtil.isNotNull(custInfo)) { |
| | | customer.setCreditCode(custInfo.getCertificateId()); |
| | | customer.setRegisterName(custInfo.getCustName()); |
| | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public R syncCustomer(Long id) { |
| | | BusinessCustomer customer = baseMapper.selectById(id); |
| | | if (ObjUtil.isNull(customer)||StrUtil.isBlank(customer.getCreditCode())){ |
| | | return R.failed("客户信息异常"); |
| | | } |
| | | CustInfoVo custInfo = bipViewMapper.selectBaseInfoByCertId(customer.getCreditCode()); |
| | | if (ObjUtil.isNull(custInfo)) { |
| | | return R.failed("主数据无该客户信息,无法更新"); |
| | | } |
| | | customer.setCreditCode(custInfo.getCertificateId()); |
| | | baseMapper.updateById(customer); |
| | | List<Contract> contractList = contractMapper.selectList(Wrappers.<Contract>lambdaQuery() |
| | | .eq(Contract::getPartyAId,id) |
| | | .eq(Contract::getContractStatus,2)); |
| | | if (CollUtil.isNotEmpty(contractList)){ |
| | | contractList.stream().forEach(contract -> { |
| | | contract.setPartyA(customer.getCompanyName()); |
| | | contractMapper.updateById(contract); |
| | | }); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |