Commit 7e9e6bc8 by jianan

客户信息优化2

parent e7243cf5
...@@ -2,6 +2,8 @@ package com.yd.csf.api.controller; ...@@ -2,6 +2,8 @@ package com.yd.csf.api.controller;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yd.base.feign.client.relobjectcertificate.ApiRelObjectCertificateFeignClient;
import com.yd.base.feign.request.relobjectcertificate.ApiRelObjectCertificateListAddRequest;
import com.yd.common.enums.CommonEnum; import com.yd.common.enums.CommonEnum;
import com.yd.common.enums.ResultCode; import com.yd.common.enums.ResultCode;
import com.yd.common.exception.BusinessException; import com.yd.common.exception.BusinessException;
...@@ -15,7 +17,6 @@ import com.yd.csf.service.dto.CustomerQueryRequest; ...@@ -15,7 +17,6 @@ import com.yd.csf.service.dto.CustomerQueryRequest;
import com.yd.csf.service.dto.CustomerUpdateRequest; import com.yd.csf.service.dto.CustomerUpdateRequest;
import com.yd.csf.service.model.Customer; import com.yd.csf.service.model.Customer;
import com.yd.csf.service.service.CustomerService; import com.yd.csf.service.service.CustomerService;
import com.yd.csf.service.service.ITaxationService;
import com.yd.csf.service.vo.CustomerVO; import com.yd.csf.service.vo.CustomerVO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -45,6 +46,8 @@ public class ApiCustomerController { ...@@ -45,6 +46,8 @@ public class ApiCustomerController {
private CustomerService customerService; private CustomerService customerService;
@Resource @Resource
private ApiTaxationService apiTaxationService; private ApiTaxationService apiTaxationService;
@Resource
private ApiRelObjectCertificateFeignClient apiRelObjectCertificateFeignClient;
/** /**
* 创建客户 * 创建客户
...@@ -55,10 +58,12 @@ public class ApiCustomerController { ...@@ -55,10 +58,12 @@ public class ApiCustomerController {
*/ */
@Operation(summary = "创建客户") @Operation(summary = "创建客户")
@PostMapping("/add") @PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
public Result<Map<String, Object>> addCustomer(@RequestBody CustomerAddRequest customerAddRequest, HttpServletRequest request) { public Result<Map<String, Object>> addCustomer(@RequestBody CustomerAddRequest customerAddRequest, HttpServletRequest request) {
if (customerAddRequest == null) { if (customerAddRequest == null) {
return Result.fail(ErrorCode.PARAMS_ERROR.getCode(), ErrorCode.PARAMS_ERROR.getMessage()); return Result.fail(ResultCode.PARAMS_ERROR.getCode(), ResultCode.PARAMS_ERROR.getMessage());
}
if (ObjectUtils.isEmpty(customerAddRequest.getFnaBizId())) {
return Result.fail(ResultCode.PARAMS_ERROR.getCode(), "fnaBizId不能为空");
} }
Map<String, Object> resultMap = customerService.addCustomer(customerAddRequest); Map<String, Object> resultMap = customerService.addCustomer(customerAddRequest);
...@@ -80,6 +85,17 @@ public class ApiCustomerController { ...@@ -80,6 +85,17 @@ public class ApiCustomerController {
.apiTaxationDtoList(apiTaxationDtoList) .apiTaxationDtoList(apiTaxationDtoList)
.build()); .build());
} }
// 添加客户证件列表信息
if (CollUtil.isNotEmpty(customerAddRequest.getApiCertificateDtoList())) {
apiRelObjectCertificateFeignClient.addRelObjectCertificateList(ApiRelObjectCertificateListAddRequest.builder()
.objectBizId(customerBizId)
.objectName(CommonEnum.UID_TYPE_CUSTOMER.getName())
.objectTableName(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.objectType(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.apiCertificateDtoList(customerAddRequest.getApiCertificateDtoList())
.build());
}
return Result.success(resultMap); return Result.success(resultMap);
} }
...@@ -118,11 +134,13 @@ public class ApiCustomerController { ...@@ -118,11 +134,13 @@ public class ApiCustomerController {
*/ */
@PostMapping("/update") @PostMapping("/update")
@Operation(summary = "更新客户信息") @Operation(summary = "更新客户信息")
@Transactional(rollbackFor = Exception.class)
public Result<Boolean> updateCustomer(@RequestBody CustomerUpdateRequest customerUpdateRequest) { public Result<Boolean> updateCustomer(@RequestBody CustomerUpdateRequest customerUpdateRequest) {
String customerBizId = customerUpdateRequest.getCustomerBizId(); String customerBizId = customerUpdateRequest.getCustomerBizId();
if (ObjectUtils.isEmpty(customerBizId)) { if (ObjectUtils.isEmpty(customerBizId)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), ErrorCode.PARAMS_ERROR.getMessage()); throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "customerBizId不能为空");
}
if (ObjectUtils.isEmpty(customerUpdateRequest.getFnaBizId())) {
throw new BusinessException(ResultCode.PARAMS_ERROR.getCode(), "fnaBizId不能为空");
} }
boolean result = customerService.updateCustomer(customerUpdateRequest); boolean result = customerService.updateCustomer(customerUpdateRequest);
...@@ -144,6 +162,17 @@ public class ApiCustomerController { ...@@ -144,6 +162,17 @@ public class ApiCustomerController {
.build()); .build());
} }
// 添加客户证件列表信息
if (CollUtil.isNotEmpty(customerUpdateRequest.getApiCertificateDtoList())) {
apiRelObjectCertificateFeignClient.addRelObjectCertificateList(ApiRelObjectCertificateListAddRequest.builder()
.objectBizId(customerBizId)
.objectName(CommonEnum.UID_TYPE_CUSTOMER.getName())
.objectTableName(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.objectType(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.apiCertificateDtoList(customerUpdateRequest.getApiCertificateDtoList())
.build());
}
return Result.success(result); return Result.success(result);
} }
......
package com.yd.csf.api.controller;
import com.yd.common.enums.ResultCode;
import com.yd.common.result.Result;
import com.yd.csf.api.service.ApiTaxationService;
import com.yd.csf.service.model.FnaCustomer;
import com.yd.csf.service.service.CustomerService;
import com.yd.csf.service.service.FnaCustomerService;
import com.yd.csf.service.vo.CustomerVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* fna_customer接口
*
* @author jianan
* @since 2025-07-31
*/
@RestController
@RequestMapping("/fna_customer")
@Tag(name = "fna_customer接口")
public class ApiFnaCustomerController {
@Resource
private FnaCustomerService fnaCustomerService;
@Resource
private CustomerService customerService;
@Resource
private ApiTaxationService apiTaxationService;
/**
* 删除fna
*
* @param deleteRequest
* @param request
* @return
*/
// @PostMapping("/delete")
// public Result<Boolean> deleteFna(@RequestBody DeleteRequest deleteRequest, HttpServletRequest request) {
// if (deleteRequest == null || deleteRequest.getId() <= 0) {
// throw new BusinessException(ErrorCode.PARAMS_ERROR);
// }
// User user = userService.getLoginUser(request);
// long id = deleteRequest.getId();
// // 判断是否存在
// Customer oldFna = customerService.getById(id);
// ThrowUtils.throwIf(oldFna == null, ErrorCode.NOT_FOUND_ERROR);
// // 仅本人或管理员可删除
// if (!oldFna.getUserId().equals(user.getId()) && !userService.isAdmin(request)) {
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR);
// }
// // 操作数据库
// boolean result = customerService.removeById(id);
// ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR);
// return Result.success(true);
// }
/**
* 根据 fnaBizId 获取客户(封装类)
*
* @param fnaBizId
* @return
*/
@GetMapping("/get/vo")
@Operation(summary = "根据 fnaBizId 获取客户详情")
public Result<CustomerVO> getCustomerVOByCustomerBizId(@RequestParam("fnaBizId") String fnaBizId, HttpServletRequest request) {
if (fnaBizId == null) {
return Result.fail(ResultCode.PARAMS_ERROR.getCode(), "fnaBizId 不能为空");
}
// 查询数据库
FnaCustomer fnaCustomer = fnaCustomerService.lambdaQuery()
.eq(FnaCustomer::getFnaBizId, fnaBizId)
.one();
if (fnaCustomer == null) {
return Result.fail(ResultCode.NULL_ERROR.getCode(), ResultCode.NULL_ERROR.getMessage());
}
// 获取客户封装类
return Result.success(fnaCustomerService.getCustomerVO(fnaCustomer));
}
/**
* 分页获取客户列表(仅管理员可用)
*
* @param fnaQueryRequest
* @return
*/
// @PostMapping("/list/page")
// public Result<Page<Customer>> listFnaByPage(@RequestBody FnaQueryRequest fnaQueryRequest) {
// long current = fnaQueryRequest.getPageNo();
// long size = fnaQueryRequest.getPageSize();
// // 查询数据库
// Page<Customer> fnaPage = customerService.page(new Page<>(current, size),
// customerService.getQueryWrapper(fnaQueryRequest));
// return Result.success(fnaPage);
// }
}
package com.yd.csf.api.controller; package com.yd.csf.api.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yd.auth.core.dto.AuthUserDto; import com.yd.auth.core.dto.AuthUserDto;
import com.yd.auth.core.utils.SecurityUtil; import com.yd.auth.core.utils.SecurityUtil;
import com.yd.common.enums.CommonEnum; import com.yd.common.enums.CommonEnum;
......
package com.yd.csf.service.dao;
import com.yd.csf.service.model.FnaCustomer;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Zhang Jianan
* @description 针对表【fna_customer(客户信息表)】的数据库操作Mapper
* @createDate 2026-03-09 10:45:37
* @Entity com.yd.csf.service.model.FnaCustomer
*/
public interface FnaCustomerMapper extends BaseMapper<FnaCustomer> {
}
...@@ -16,6 +16,12 @@ import java.util.List; ...@@ -16,6 +16,12 @@ import java.util.List;
@Data @Data
public class CustomerAddRequest implements Serializable { public class CustomerAddRequest implements Serializable {
/** /**
* fna业务id
*/
@Schema(description = "fna业务id")
private String fnaBizId;
/**
* 姓名-中文 * 姓名-中文
*/ */
@Schema(description = "姓名-中文") @Schema(description = "姓名-中文")
......
...@@ -15,6 +15,13 @@ import java.util.List; ...@@ -15,6 +15,13 @@ import java.util.List;
*/ */
@Data @Data
public class CustomerUpdateRequest implements Serializable { public class CustomerUpdateRequest implements Serializable {
/**
* fna业务id
*/
@Schema(description = "fna业务id", requiredMode = Schema.RequiredMode.REQUIRED)
private String fnaBizId;
/** /**
* 客户主表业务唯一id * 客户主表业务唯一id
*/ */
......
package com.yd.csf.service.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 客户信息表
*
* @TableName fna_customer
*/
@TableName(value = "fna_customer")
@Data
public class FnaCustomer implements Serializable {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* fna客户唯一业务ID
*/
private String fnaCustomerBizId;
/**
* customer唯一业务ID
*/
private String customerBizId;
/**
* fna唯一业务ID
*/
private String fnaBizId;
/**
* 姓名-中文
*/
private String nameCn;
/**
* 姓名-(拼音/英文,通过中文自动加载全部大写的拼音)
*/
private String namePyEn;
/**
* 证件类型(字典,下拉选择)
*/
private String documentType;
/**
* 证件号码
*/
private String idNumber;
/**
* 性别(字典,如果是身份证,自动获取性别和生日)
*/
private String gender;
/**
* 出生日期(生日,如果是身份证,自动获取性别和生日)
*/
private Date birthday;
/**
* 年龄(通过生日自动获取年龄)
*/
private String age;
/**
* 国籍(下拉选择)
*/
private String nationality;
/**
* 出生地
*/
private String birthplace;
/**
* 是否拥有其他国家公民身份(如美国、日本等): 0-否, 1-是(字典)
*/
private String isOtherCountry;
/**
* 税务国家
*/
private Object taxList;
/**
* 吸烟情况(字典)
*/
private String smokingStatus;
/**
* 婚姻情况(字典)
*/
private String maritalStatus;
/**
* 教育程度(字典)
*/
private String educationLevel;
/**
* 是否退休(字典)
*/
private String isRetirement;
/**
* 退休年龄(如已退休,再显示)
*/
private String retirementAge;
/**
* 身高(CM)
*/
private String height;
/**
* 体重(KG)
*/
private String weight;
/**
* BMI指数(根据身高和体重自动计算)
*/
private String bmi;
/**
* 风险偏好(字典,下拉选择)
*/
private String riskAppetite;
/**
* 受供养人数目(通过FNA带入)
*/
private Integer dependentsNum;
/**
* 移动电话区号
*/
private String mobileCode;
/**
* 移动电话
*/
private String mobile;
/**
* 住宅电话区号
*/
private String residenceMobileCode;
/**
* 住宅电话
*/
private String residenceMobile;
/**
* 固定电话区号
*/
private String landlineCode;
/**
* 固定电话
*/
private String landline;
/**
* 邮箱
*/
private String email;
/**
* 证件地址
*/
private String certificateAddress;
/**
* 通讯地址
*/
private String mailingAddress;
/**
* 居住地址(住宅地址)
*/
private String residentialAddress;
/**
* 通讯地址邮政编号
*/
private String mailingAddressCode;
/**
* 就业情况(字典,下拉选择)
*/
private String employmentStatus;
/**
* 公司/学校名称
*/
private String csName;
/**
* 行业
*/
private String industry;
/**
* 现时每月收入(HKD)
*/
private BigDecimal currentMonthlyIncome;
/**
* 总工作年期
*/
private BigDecimal totalWorkingYears;
/**
* 受雇于现职年期
*/
private BigDecimal currentTenure;
/**
* 职位
*/
private String position;
/**
* 公司地址
*/
private String companyAddress;
/**
* 公司电话区号
*/
private String companyMobileCode;
/**
* 公司电话
*/
private String companyMobile;
/**
* 公司地址邮政编号
*/
private String companyAddressCode;
/**
* 平均每月收入(HKD)
*/
private BigDecimal monthIncome;
/**
* 平均每月支出(HKD)
*/
private BigDecimal monthExpenditure;
/**
* 总流动资产(HKD)
*/
private BigDecimal totalCurrentAssets;
/**
* 总负债额(HKD)
*/
private BigDecimal totalDebt;
/**
* 旅行(字典)
*/
private String travel;
/**
* 运动(字典,下拉选择)
*/
private String exercise;
/**
* 游戏(字典,下拉选择)
*/
private String game;
/**
* 电影/戏剧(字典,下拉选择)
*/
private String movieDrama;
/**
* 美食(输入)
*/
private String delicacy;
/**
* 地址列表(json串)
*/
private String addressList;
/**
*
*/
private Object certificateList;
/**
* 通用备注
*/
private String remark;
/**
* 删除标识: 0-正常, 1-删除
*/
private Integer isDeleted;
/**
* 创建人ID
*/
private String creatorId;
/**
* 更新人ID
*/
private String updaterId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package com.yd.csf.service.service;
import com.yd.csf.service.model.FnaCustomer;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yd.csf.service.vo.CustomerVO;
/**
* @author Zhang Jianan
* @description 针对表【fna_customer(客户信息表)】的数据库操作Service
* @createDate 2026-03-09 10:45:37
*/
public interface FnaCustomerService extends IService<FnaCustomer> {
void validCustomer(FnaCustomer fnaCustomer);
int queryDependentsNum(String fnaBizId);
CustomerVO getCustomerVO(FnaCustomer fnaCustomer);
}
...@@ -8,8 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -8,8 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.yd.base.feign.client.relobjectcertificate.ApiRelObjectCertificateFeignClient; import com.yd.base.feign.dto.ApiCertificateDto;
import com.yd.base.feign.request.relobjectcertificate.ApiRelObjectCertificateListAddRequest;
import com.yd.common.enums.CommonEnum; import com.yd.common.enums.CommonEnum;
import com.yd.common.exception.BusinessException; import com.yd.common.exception.BusinessException;
import com.yd.common.utils.RandomStringGenerator; import com.yd.common.utils.RandomStringGenerator;
...@@ -17,17 +16,21 @@ import com.yd.csf.service.common.ErrorCode; ...@@ -17,17 +16,21 @@ import com.yd.csf.service.common.ErrorCode;
import com.yd.csf.service.dao.CustomerMapper; import com.yd.csf.service.dao.CustomerMapper;
import com.yd.csf.service.dto.*; import com.yd.csf.service.dto.*;
import com.yd.csf.service.model.Customer; import com.yd.csf.service.model.Customer;
import com.yd.csf.service.model.FnaCustomer;
import com.yd.csf.service.model.FnaForm; import com.yd.csf.service.model.FnaForm;
import com.yd.csf.service.service.CustomerService; import com.yd.csf.service.service.CustomerService;
import com.yd.csf.service.service.FnaCustomerService;
import com.yd.csf.service.service.FnaFormService; import com.yd.csf.service.service.FnaFormService;
import com.yd.csf.service.service.FnaService; import com.yd.csf.service.service.FnaService;
import com.yd.csf.service.utils.GSONUtil; import com.yd.csf.service.utils.GSONUtil;
import com.yd.csf.service.utils.ValidateUtil; import com.yd.csf.service.utils.ValidateUtil;
import com.yd.csf.service.vo.CustomerVO; import com.yd.csf.service.vo.CustomerVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
...@@ -46,15 +49,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -46,15 +49,13 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
@Resource @Resource
private CustomerService customerService; private CustomerService customerService;
@Resource @Resource
private FnaService fnaService; private FnaService fnaService;
@Resource @Resource
private FnaFormService fnaFormService; private FnaFormService fnaFormService;
@Resource @Resource
private ApiRelObjectCertificateFeignClient apiRelObjectCertificateFeignClient; private FnaCustomerService fnaCustomerService;
@Override @Override
public CustomerVO getCustomerVO(Customer customer) { public CustomerVO getCustomerVO(Customer customer) {
...@@ -97,14 +98,21 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -97,14 +98,21 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> addCustomer(CustomerAddRequest customerAddRequest) { public Map<String, Object> addCustomer(CustomerAddRequest customerAddRequest) {
// 校验 请求 对象中,参数是否全部为空 // 校验 请求 对象中,参数是否全部为空
if (ValidateUtil.isAllFieldsNull(customerAddRequest)) { if (ValidateUtil.isAllFieldsNull(customerAddRequest)) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), ErrorCode.PARAMS_ERROR.getMessage()); throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), ErrorCode.PARAMS_ERROR.getMessage());
} }
// 检查字段 certificate_list,根据证件类型、证件号码查询客户是否存在
Customer customer = queryByCertificate(customerAddRequest.getApiCertificateDtoList());
if (customer == null) {
customer = new Customer();
}
// 客户主表信息 // 客户主表信息
Customer customer = new Customer(); BeanUtils.copyProperties(customerAddRequest, customer, "addressList", "apiTaxationDtoList", "apiCertificateDtoList");
BeanUtils.copyProperties(customerAddRequest, customer, "addressList", "apiCertificateDtoList");
// 地址列表 // 地址列表
if (CollUtil.isNotEmpty(customerAddRequest.getAddressList())) { if (CollUtil.isNotEmpty(customerAddRequest.getAddressList())) {
customer.setAddressList(GSON.toJson(customerAddRequest.getAddressList())); customer.setAddressList(GSON.toJson(customerAddRequest.getAddressList()));
...@@ -122,20 +130,19 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -122,20 +130,19 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
// 客户主表业务唯一id // 客户主表业务唯一id
customer.setCustomerBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_CUSTOMER.getCode())); customer.setCustomerBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_CUSTOMER.getCode()));
boolean result = customerService.save(customer); boolean result = customerService.saveOrUpdate(customer);
if (!result) { if (!result) {
throw new BusinessException(ErrorCode.OPERATION_ERROR.getCode(), ErrorCode.OPERATION_ERROR.getMessage()); throw new BusinessException(ErrorCode.OPERATION_ERROR.getCode(), ErrorCode.OPERATION_ERROR.getMessage());
} }
// 添加客户证件列表信息 // 保存 fna_customer
if (CollUtil.isNotEmpty(customerAddRequest.getApiCertificateDtoList())) { FnaCustomer fnaCustomer = new FnaCustomer();
apiRelObjectCertificateFeignClient.addRelObjectCertificateList(ApiRelObjectCertificateListAddRequest.builder() BeanUtils.copyProperties(customer, fnaCustomer);
.objectBizId(customer.getCustomerBizId()) fnaCustomer.setFnaBizId(customerAddRequest.getFnaBizId());
.objectName(CommonEnum.UID_TYPE_CUSTOMER.getName()) fnaCustomer.setFnaCustomerBizId(RandomStringGenerator.generateBizId16("fna_customer"));
.objectTableName(CommonEnum.UID_TYPE_CUSTOMER.getCode()) result = fnaCustomerService.saveOrUpdate(fnaCustomer);
.objectType(CommonEnum.UID_TYPE_CUSTOMER.getCode()) if (!result) {
.apiCertificateDtoList(customerAddRequest.getApiCertificateDtoList()) throw new BusinessException(ErrorCode.OPERATION_ERROR.getCode(), ErrorCode.OPERATION_ERROR.getMessage());
.build());
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -143,6 +150,50 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -143,6 +150,50 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
return map; return map;
} }
private Customer queryByCertificate(List<ApiCertificateDto> certificateList) {
if (CollUtil.isNotEmpty(certificateList)) {
for (ApiCertificateDto certificate : certificateList) {
if (StringUtils.isNotBlank(certificate.getDocumentType()) && StringUtils.isNotBlank(certificate.getIdNumber())) {
// 查询所有有 certificateList 的客户
List<Customer> existingCustomers = customerService.lambdaQuery()
.isNotNull(Customer::getCertificateList)
.ne(Customer::getCertificateList, "")
.list();
if (CollUtil.isNotEmpty(existingCustomers)) {
for (Customer existingCustomer : existingCustomers) {
if (ObjectUtils.isNotEmpty(existingCustomer.getCertificateList())) {
try {
// 解析 JSON 中的证件列表
List<ApiCertificateDto> certList = GSON.fromJson(
(String) existingCustomer.getCertificateList(),
new TypeToken<List<ApiCertificateDto>>() {}.getType()
);
if (CollUtil.isNotEmpty(certList)) {
for (ApiCertificateDto cert : certList) {
String docType = cert.getDocumentType();
String idNum = cert.getIdNumber();
// 比对证件类型和证件号码
if (certificate.getDocumentType().equals(docType)
&& certificate.getIdNumber().equals(idNum)) {
return existingCustomer;
}
}
}
} catch (Exception e) {
// JSON 解析失败,跳过该客户
}
}
}
}
}
}
}
return null;
}
@Override @Override
public void validCustomer(Customer customer) { public void validCustomer(Customer customer) {
if (StringUtils.isBlank(customer.getNamePyEn())) { if (StringUtils.isBlank(customer.getNamePyEn())) {
...@@ -160,6 +211,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -160,6 +211,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateCustomer(CustomerUpdateRequest customerUpdateRequest) { public Boolean updateCustomer(CustomerUpdateRequest customerUpdateRequest) {
// 判断是否存在 // 判断是否存在
String customerBizId = customerUpdateRequest.getCustomerBizId(); String customerBizId = customerUpdateRequest.getCustomerBizId();
...@@ -189,15 +241,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> ...@@ -189,15 +241,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
fnaService.updateCustomerNameByCustomerBizId(customerUpdateRequest.getNamePyEn(), customerBizId); fnaService.updateCustomerNameByCustomerBizId(customerUpdateRequest.getNamePyEn(), customerBizId);
} }
// 添加客户证件列表信息 // 更新 fna_customer 表
if (CollUtil.isNotEmpty(customerUpdateRequest.getApiCertificateDtoList())) { FnaCustomer fnaCustomer = fnaCustomerService.lambdaQuery().eq(FnaCustomer::getFnaBizId, customerBizId).one();
apiRelObjectCertificateFeignClient.addRelObjectCertificateList(ApiRelObjectCertificateListAddRequest.builder() if (fnaCustomer != null) {
.objectBizId(customerBizId) BeanUtils.copyProperties(oldCustomer, fnaCustomer, "id", "fna_customer_biz_id", "fnaBizId", "customerBizId");
.objectName(CommonEnum.UID_TYPE_CUSTOMER.getName()) fnaCustomerService.updateById(fnaCustomer);
.objectTableName(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.objectType(CommonEnum.UID_TYPE_CUSTOMER.getCode())
.apiCertificateDtoList(customerUpdateRequest.getApiCertificateDtoList())
.build());
} }
return true; return true;
......
package com.yd.csf.service.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.gson.reflect.TypeToken;
import com.yd.base.feign.client.relobjectcertificate.ApiRelObjectCertificateFeignClient;
import com.yd.base.feign.dto.ApiCertificateDto;
import com.yd.common.exception.BusinessException;
import com.yd.csf.service.common.ErrorCode;
import com.yd.csf.service.dto.DependantData;
import com.yd.csf.service.dto.TaxCountry;
import com.yd.csf.service.model.Fna;
import com.yd.csf.service.model.FnaCustomer;
import com.yd.csf.service.model.FnaForm;
import com.yd.csf.service.service.CustomerService;
import com.yd.csf.service.service.FnaCustomerService;
import com.yd.csf.service.dao.FnaCustomerMapper;
import com.yd.csf.service.service.FnaFormService;
import com.yd.csf.service.service.FnaService;
import com.yd.csf.service.utils.GSONUtil;
import com.yd.csf.service.vo.AddressVO;
import com.yd.csf.service.vo.CustomerVO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author Zhang Jianan
* @description 针对表【fna_customer(客户信息表)】的数据库操作Service实现
* @createDate 2026-03-09 10:45:37
*/
@Service
public class FnaCustomerServiceImpl extends ServiceImpl<FnaCustomerMapper, FnaCustomer>
implements FnaCustomerService {
@Resource
private FnaCustomerService fnaCustomerService;
@Resource
private CustomerService customerService;
@Resource
private FnaService fnaService;
@Resource
private FnaFormService fnaFormService;
@Resource
private ApiRelObjectCertificateFeignClient apiRelObjectCertificateFeignClient;
@Override
public void validCustomer(FnaCustomer fnaCustomer) {
if (StringUtils.isBlank(fnaCustomer.getNamePyEn())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), "名字-英文不能为空");
}
if (StringUtils.isBlank(fnaCustomer.getMobile())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), "客户手机号不能为空");
}
if (StringUtils.isBlank(fnaCustomer.getAge())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), "年龄不能为空");
}
if (StringUtils.isBlank(fnaCustomer.getNationality())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR.getCode(), "国籍不能为空");
}
}
@Override
public int queryDependentsNum(String fnaBizId) {
Fna fna = fnaService.getByBizId(fnaBizId);
if (fna == null) {
return 0;
}
FnaForm fnaForm = fnaFormService.getByFnaFormBizId(fna.getFnaFormBizId());
if (fnaForm != null) {
if (StringUtils.isNotBlank((CharSequence) fnaForm.getDependantList()) && !"null".equals(fnaForm.getDependantList())) {
List<DependantData> dependantList = GSONUtil.fromJson((String) fnaForm.getDependantList(), new TypeToken<List<DependantData>>() {
}.getType());
return dependantList.size();
}
}
return 0;
}
@Override
public CustomerVO getCustomerVO(FnaCustomer fnaCustomer) {
if (fnaCustomer == null) {
return null;
}
// 查询受供养人数量
int dependentsNum = fnaCustomerService.queryDependentsNum(fnaCustomer.getFnaBizId());
// 获取封装类
CustomerVO customerVO = new CustomerVO();
BeanUtils.copyProperties(fnaCustomer, customerVO);
customerVO.setDependentsNum(dependentsNum);
if (ObjectUtils.isNotEmpty(fnaCustomer.getAddressList())) {
List<AddressVO> addressList = GSONUtil.fromJson(fnaCustomer.getAddressList(), new TypeToken<List<AddressVO>>() {
}.getType());
customerVO.setAddressList(addressList);
}
if (ObjectUtils.isNotEmpty(fnaCustomer.getTaxList())) {
List<TaxCountry> taxList = GSONUtil.fromJson((String) fnaCustomer.getTaxList(), new TypeToken<List<TaxCountry>>() {
}.getType());
customerVO.setApiTaxationDtoList(taxList);
}
if (ObjectUtils.isNotEmpty(fnaCustomer.getCertificateList())) {
List<ApiCertificateDto> certificateList = GSONUtil.fromJson((String) fnaCustomer.getCertificateList(), new TypeToken<List<ApiCertificateDto>>() {
}.getType());
customerVO.setApiCertificateDtoList(certificateList);
}
return customerVO;
}
}
...@@ -28,6 +28,12 @@ public class CustomerVO implements Serializable { ...@@ -28,6 +28,12 @@ public class CustomerVO implements Serializable {
private Long id; private Long id;
/** /**
* fna业务id
*/
@Schema(description = "fna业务id")
private String fnaBizId;
/**
* 客户唯一业务ID * 客户唯一业务ID
*/ */
@Schema(description = "客户业务ID") @Schema(description = "客户业务ID")
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yd.csf.service.dao.FnaCustomerMapper">
<resultMap id="BaseResultMap" type="com.yd.csf.service.model.FnaCustomer">
<id property="id" column="id" />
<result property="fnaCustomerBizId" column="fna_customer_biz_id" />
<result property="customerBizId" column="customer_biz_id" />
<result property="fnaBizId" column="fna_biz_id" />
<result property="nameCn" column="name_cn" />
<result property="namePyEn" column="name_py_en" />
<result property="documentType" column="document_type" />
<result property="idNumber" column="id_number" />
<result property="gender" column="gender" />
<result property="birthday" column="birthday" />
<result property="age" column="age" />
<result property="nationality" column="nationality" />
<result property="birthplace" column="birthplace" />
<result property="isOtherCountry" column="is_other_country" />
<result property="taxList" column="tax_list" />
<result property="smokingStatus" column="smoking_status" />
<result property="maritalStatus" column="marital_status" />
<result property="educationLevel" column="education_level" />
<result property="isRetirement" column="is_retirement" />
<result property="retirementAge" column="retirement_age" />
<result property="height" column="height" />
<result property="weight" column="weight" />
<result property="bmi" column="bmi" />
<result property="riskAppetite" column="risk_appetite" />
<result property="dependentsNum" column="dependents_num" />
<result property="mobileCode" column="mobile_code" />
<result property="mobile" column="mobile" />
<result property="residenceMobileCode" column="residence_mobile_code" />
<result property="residenceMobile" column="residence_mobile" />
<result property="landlineCode" column="landline_code" />
<result property="landline" column="landline" />
<result property="email" column="email" />
<result property="certificateAddress" column="certificate_address" />
<result property="mailingAddress" column="mailing_address" />
<result property="residentialAddress" column="residential_address" />
<result property="mailingAddressCode" column="mailing_address_code" />
<result property="employmentStatus" column="employment_status" />
<result property="csName" column="cs_name" />
<result property="industry" column="industry" />
<result property="currentMonthlyIncome" column="current_monthly_income" />
<result property="totalWorkingYears" column="total_working_years" />
<result property="currentTenure" column="current_tenure" />
<result property="position" column="position" />
<result property="companyAddress" column="company_address" />
<result property="companyMobileCode" column="company_mobile_code" />
<result property="companyMobile" column="company_mobile" />
<result property="companyAddressCode" column="company_address_code" />
<result property="monthIncome" column="month_income" />
<result property="monthExpenditure" column="month_expenditure" />
<result property="totalCurrentAssets" column="total_current_assets" />
<result property="totalDebt" column="total_debt" />
<result property="travel" column="travel" />
<result property="exercise" column="exercise" />
<result property="game" column="game" />
<result property="movieDrama" column="movie_drama" />
<result property="delicacy" column="delicacy" />
<result property="addressList" column="address_list" />
<result property="certificateList" column="certificate_list" />
<result property="remark" column="remark" />
<result property="isDeleted" column="is_deleted" />
<result property="creatorId" column="creator_id" />
<result property="updaterId" column="updater_id" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="Base_Column_List">
id,fna_customer_biz_id,customer_biz_id,fna_biz_id,name_cn,name_py_en,document_type,
id_number,gender,birthday,age,nationality,
birthplace,is_other_country,tax_list,smoking_status,marital_status,
education_level,is_retirement,retirement_age,height,weight,
bmi,risk_appetite,dependents_num,mobile_code,mobile,
residence_mobile_code,residence_mobile,landline_code,landline,email,
certificate_address,mailing_address,residential_address,mailing_address_code,employment_status,
cs_name,industry,current_monthly_income,total_working_years,current_tenure,
position,company_address,company_mobile_code,company_mobile,company_address_code,
month_income,month_expenditure,total_current_assets,total_debt,travel,
exercise,game,movie_drama,delicacy,address_list,
certificate_list,remark,is_deleted,creator_id,updater_id,
create_time,update_time
</sql>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment