From e8c9efca8e9bdd253fe5e48dcb4fbf5ef6afbe08 Mon Sep 17 00:00:00 2001 From: river <1376754470@qq.com> Date: Fri, 29 Jan 2021 14:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=E8=AE=A4=E8=AF=81(=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BD=95=E5=85=A5)=E4=BC=98=E5=8C=96=E4=B8=8E?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerAppletController.java | 21 +-- .../financial/crms/dao/CustomerAppletDao.java | 2 + .../model/request/CompanyAppletRequest.java | 92 +++++++++++ ...equest.java => PersonalAppletRequest.java} | 107 +++--------- .../crms/service/CustomerAppletService.java | 16 +- .../impl/CustomerAppletServiceImpl.java | 153 ++++++++++++++---- .../src/main/resources/bootstrap.properties | 84 +++++----- .../mapper/crms/CustomerAppletDao.xml | 7 + .../resources/mapper/crms/CustomerDao.xml | 2 +- .../domain/crms/response/CrmsCode.java | 3 +- 10 files changed, 306 insertions(+), 181 deletions(-) create mode 100644 dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/CompanyAppletRequest.java rename dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/{PersonalCustomerRequest.java => PersonalAppletRequest.java} (65%) diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerAppletController.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerAppletController.java index deab5eea..ddb899c9 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerAppletController.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerAppletController.java @@ -1,7 +1,8 @@ package com.daqing.financial.crms.controller; +import com.daqing.financial.crms.model.request.CompanyAppletRequest; import com.daqing.financial.crms.model.request.CompanyCustomerRequest; -import com.daqing.financial.crms.model.request.PersonalCustomerRequest; +import com.daqing.financial.crms.model.request.PersonalAppletRequest; import com.daqing.financial.crms.service.CustomerAppletService; import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI; import com.daqing.framework.model.response.ResponseResult; @@ -31,9 +32,9 @@ public class CustomerAppletController { */ @PostMapping("/save/personal") @ApiOperation(value = "个人类型客户数据录入(认证)") - public ResponseResult savePersonal(@RequestBody @Valid CustomerPersonalTOI customerPersonalTOI) { + public ResponseResult savePersonal(@RequestBody @Valid PersonalAppletRequest personalAppletRequest) { - Boolean result = customerAppletService.savePersonal(customerPersonalTOI); + Boolean result = customerAppletService.savePersonal(personalAppletRequest); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); } @@ -43,9 +44,9 @@ public class CustomerAppletController { */ @PostMapping("/save/company") @ApiOperation(value = "企业类型客户数据录入(认证)") - public ResponseResult saveCompany(@RequestBody @Valid CompanyCustomerRequest companyCustomerRequest) { + public ResponseResult saveCompany(@RequestBody @Valid CompanyAppletRequest companyAppletRequest) { - Boolean result = customerAppletService.saveCompany(companyCustomerRequest); + Boolean result = customerAppletService.saveCompany(companyAppletRequest); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); } @@ -67,7 +68,7 @@ public class CustomerAppletController { @ApiOperation(value = "获取已认证的客户信息") public ResponseResult getCustomer(@RequestParam("type") Integer type) { - return customerAppletService.getCustomer(type); + return ResponseResult.SUCCESS(customerAppletService.getCustomer(type)); } /** @@ -75,9 +76,9 @@ public class CustomerAppletController { */ @ApiOperation(value = "更新个人类型的客户信息") @PostMapping("/update/personal") - public ResponseResult updatePersonal(@RequestBody @Valid PersonalCustomerRequest personalCustomerRequest) { + public ResponseResult updatePersonal(@RequestBody @Valid PersonalAppletRequest personalAppletRequest) { - Boolean result = customerAppletService.updatePersonal(personalCustomerRequest); + Boolean result = customerAppletService.updatePersonal(personalAppletRequest); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); } @@ -87,9 +88,9 @@ public class CustomerAppletController { */ @PostMapping("/update/company") @ApiOperation(value = "更新企业类型的客户信息") - public ResponseResult updateCompany(@RequestBody @Valid CompanyCustomerRequest companyCustomerRequest) { + public ResponseResult updateCompany(@RequestBody @Valid CompanyAppletRequest companyAppletRequest) { - Boolean result = customerAppletService.updateCompany(companyCustomerRequest); + Boolean result = customerAppletService.updateCompany(companyAppletRequest); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java index b33df54c..5870d53a 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java @@ -21,4 +21,6 @@ public interface CustomerAppletDao extends BaseMapper { Integer getCustomerId(@Param("userId") Integer userId, @Param("type") Integer type); + Boolean updateCustomer(@Param("customer") CustomerEntity customerEntity); + } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/CompanyAppletRequest.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/CompanyAppletRequest.java new file mode 100644 index 00000000..ebf11dd2 --- /dev/null +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/CompanyAppletRequest.java @@ -0,0 +1,92 @@ +package com.daqing.financial.crms.model.request; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 小程序客户模块企业类型数据录入(认证) + * + * @auther River + * @date 2021/1/29 11:16 + */ +@Data +@ToString +public class CompanyAppletRequest implements Serializable { + + @NotNull(message = "客户名称不能为空") + @ApiModelProperty(value = "客户名称") + private String name; + + @NotNull(message = "社会统一代码不能为空") + @ApiModelProperty(value = "社会统一代码") + private String socialUnifiedCode; + + @NotNull(message = "联系电话不能为空") + @Pattern(regexp = "^[0-9]*$",message = "联系电话格式错误") + @ApiModelProperty(value = "联系电话") + private String phone; + + @ApiModelProperty(value = "注册时间") + private Date registerTime; + + @Pattern(regexp = "^[0-9]+\\.{0,1}[0-9]{0,2}$",message = "注册资金格式有误") + @NotNull(message = "注册资金不能为空") + @ApiModelProperty(value = "注册资金") + private String registeredCapital; + + @Pattern(regexp = "^[0-9]*$",message = "员工人数格式错误") + @NotNull(message = "员工人数不能为空") + @ApiModelProperty(value = "员工人数") + private String empNum; + + @ApiModelProperty(value = "注册地址") + private String registerAddr; + + @NotNull(message = "联系人不能为空") + @ApiModelProperty(value = "联系人") + private String linkman; + + @ApiModelProperty(value = "联系人电话") + private String linkPhone; + + @ApiModelProperty(value = "经营地址") + private String businessAddr; + + @NotNull(message = "业务来源不能为空") + @ApiModelProperty(value = "业务来源") + private String businessSource; + + @ApiModelProperty(value = "经营范围") + private String businessScope; + + @ApiModelProperty(value = "法人-姓名") + private String legalName; + + @ApiModelProperty(value = "法人-性别 1、男,0、女") + private Integer legalGender; + + @ApiModelProperty(value = "法人-身份证号") + private String legalIdNumber; + + @ApiModelProperty(value = "法人-户口所在地") + private String legalHukouAddr; + + @ApiModelProperty(value = "法人-联系电话") + private String legalPhone; + + @ApiModelProperty(value = "法人-家庭住址") + private String legalHomeAddr; + + @ApiModelProperty(value = "是否存在关联人 0->否;1->是") + private Integer isExistRelated; + + @ApiModelProperty(value = "关联人id") + private List relatedId; +} diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalCustomerRequest.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalAppletRequest.java similarity index 65% rename from dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalCustomerRequest.java rename to dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalAppletRequest.java index 76fc4c25..56a8fd71 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalCustomerRequest.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/model/request/PersonalAppletRequest.java @@ -1,7 +1,5 @@ package com.daqing.financial.crms.model.request; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; @@ -16,146 +14,87 @@ import java.io.Serializable; * 小程序客户模块个人类型数据录入(认证) * * @auther River - * @date 2021/1/28 11:44 + * @date 2021/1/29 11:04 */ @Data @ToString -public class PersonalCustomerRequest implements Serializable { - - /** - * 主键 - */ - @ApiModelProperty(value = "id") - @TableId(value = "id", type = IdType.INPUT) - private Long id; - /** - * 客户编号 - */ - @NotNull(message = "客户编号不能为空") - @ApiModelProperty(value = "客户编号") - private String code; - /** - * 客户类型:1、企业类型,0:个人类型 - */ - @ApiModelProperty(value = "客户类型") - private Integer type; - /** - * 客户的经理人id - */ - @ApiModelProperty(value = "客户经理人id") - private Long manager; - /** - * 客户名称 - */ +public class PersonalAppletRequest implements Serializable { + @NotNull(message = "客户名称不能为空") @ApiModelProperty(value = "客户名称") private String name; - /** - * 联系地址 - */ + @NotNull(message = "联系地址不能为空") @ApiModelProperty(value = "联系地址") private String addr; - /** - * 联系电话 - */ + @Pattern(regexp = "^[0-9]*$",message = "联系电话格式错误") @NotNull(message = "联系电话不能为空") @ApiModelProperty(value = "联系电话") private String phone; - /** - * 身份证号 - */ + @NotNull(message = "身份证号不能为空") @ApiModelProperty(value = "身份证号") private String idCard; - /** - * 年龄 - */ + @NotNull(message = "年龄不能为空") @ApiModelProperty(value = "年龄") private Integer age; - /** - * 性别:1、男,0、女 - */ + @Min(value = 0,message = "性别格式有误") @Max(value = 1,message = "性别格式有误") @NotNull(message = "性别不能为空") - @ApiModelProperty(value = "性别") + @ApiModelProperty(value = "性别,1、男,0、女") private Integer gender; - /** - * 婚姻状况,0:未婚,1:已婚,2:离异,3:再婚 - */ + @Min(value = 0,message = "婚姻状况格式有误") @Max(value = 3,message = "婚姻状况格式有误") @NotNull(message = "婚姻状况不能为空") - @ApiModelProperty(value = "婚姻状况") + @ApiModelProperty(value = "婚姻状况,0:未婚,1:已婚,2:离异,3:再婚") private Integer maritalStatus; - /** - * 学历,0:本科,1:大专,2:高职,3:中专,4:其他 - */ + @Min(value = 0,message = "学历格式有误") @Max(value = 4,message = "学历格式有误") @NotNull(message = "学历不能为空") - @ApiModelProperty(value = "学历") + @ApiModelProperty(value = "学历,0:本科,1:大专,2:高职,3:中专,4:其他") private Integer education; - /** - * 工作单位 - */ + @NotNull(message = "工作单位不能为空") @ApiModelProperty(value = "工作单位") private String employer; - /** - * 职务 - */ + @NotNull(message = "职务不能为空") @ApiModelProperty(value = "职务") private String position; - /** - * 工作年限 - */ + @NotNull(message = "工作年限不能为空") @ApiModelProperty(value = "工作年限") private Integer workingYears; - /** - * 社保账号 - */ + @NotNull(message = "社保账号不能为空") @ApiModelProperty(value = "社保账号") private String socialSecurityNum; - /** - * 居住情况 - */ + @NotNull(message = "居住情况不能为空") @ApiModelProperty(value = "居住情况") private String livingSituation; - /** - * 户籍地址 - */ + @NotNull(message = "户籍地址不能为空") @ApiModelProperty(value = "户籍地址") private String residenceAddr; - /** - * 业务来源 - */ + @NotNull(message = "业务来源不能为空") @ApiModelProperty(value = "业务来源") private String businessSource; - /** - * 紧急联系人 - */ + @NotNull(message = "紧急联系人不能为空") @ApiModelProperty(value = "紧急联系人") private String emergencyLinkman; - /** - * 紧急联系人关系 - */ + @NotNull(message = "紧急联系人关系不能为空") @ApiModelProperty(value = "紧急联系人关系") private String emergencyLinkmanRelationship; - /** - * 紧急联系人电话 - */ + @Pattern(regexp = "^[0-9]*$",message = "紧急联系人电话格式错误") @NotNull(message = "紧急联系人电话不能为空") @ApiModelProperty(value = "紧急联系人电话") diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerAppletService.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerAppletService.java index 64808af2..530eed5b 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerAppletService.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/CustomerAppletService.java @@ -1,11 +1,9 @@ package com.daqing.financial.crms.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.daqing.financial.crms.model.request.CompanyCustomerRequest; -import com.daqing.financial.crms.model.request.PersonalCustomerRequest; +import com.daqing.financial.crms.model.request.CompanyAppletRequest; +import com.daqing.financial.crms.model.request.PersonalAppletRequest; import com.daqing.framework.domain.crms.CustomerEntity; -import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI; -import com.daqing.framework.model.response.ResponseResult; import java.util.Map; @@ -17,15 +15,15 @@ import java.util.Map; */ public interface CustomerAppletService extends IService { - Boolean savePersonal(CustomerPersonalTOI customerPersonalTOI); + Boolean savePersonal(PersonalAppletRequest personalAppletRequest); - Boolean saveCompany(CompanyCustomerRequest companyCustomerRequest); + Boolean saveCompany(CompanyAppletRequest companyAppletRequest); Map getCustomerStatus(); - ResponseResult getCustomer(Integer type); + Object getCustomer(Integer type); - Boolean updatePersonal(PersonalCustomerRequest personalCustomerRequest); + Boolean updatePersonal(PersonalAppletRequest personalAppletRequest); - Boolean updateCompany(CompanyCustomerRequest companyCustomerRequest); + Boolean updateCompany(CompanyAppletRequest companyAppletRequest); } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java index e0f84b51..7fc9c931 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java @@ -1,12 +1,15 @@ package com.daqing.financial.crms.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.daqing.financial.crms.dao.CompanyCustomerDao; import com.daqing.financial.crms.dao.CustomerAppletDao; import com.daqing.financial.crms.dao.CustomerDao; import com.daqing.financial.crms.dao.PersonalCustomerDao; +import com.daqing.financial.crms.mapper.CrmsCustomerRelatedMapper; +import com.daqing.financial.crms.model.request.CompanyAppletRequest; import com.daqing.financial.crms.model.request.CompanyCustomerRequest; -import com.daqing.financial.crms.model.request.PersonalCustomerRequest; +import com.daqing.financial.crms.model.request.PersonalAppletRequest; import com.daqing.financial.crms.service.CustomerAppletService; import com.daqing.financial.crms.service.CustomerService; import com.daqing.financial.crms.service.ICrmsCustomerRelatedService; @@ -15,7 +18,6 @@ import com.daqing.framework.domain.crms.CrmsCustomerRelated; import com.daqing.framework.domain.crms.CustomerEntity; import com.daqing.framework.domain.crms.PersonalCustomerEntity; import com.daqing.framework.domain.crms.ext.CrmsConstant; -import com.daqing.framework.domain.crms.ext.CustomerPersonalTOI; import com.daqing.framework.domain.crms.ext.CustomerPersonalTOU; import com.daqing.framework.domain.crms.response.CrmsCode; import com.daqing.framework.exception.ExceptionCast; @@ -30,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.*; @@ -49,34 +52,37 @@ public class CustomerAppletServiceImpl extends ServiceImpl 0) { + ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_EXIST); + } + if (personalAppletRequest.getName() != null && personalAppletRequest.getName().length() != 0) { // 客户姓名判重 List names = customerDao.listCustomerName(0); // 个人类型客户名称 for (String name : names) { - if (customerPersonalTOI.getName().equals(name)) { + if (personalAppletRequest.getName().equals(name)) { ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); } } } CustomerEntity customerEntity = new CustomerEntity(); PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); - BeanUtils.copyProperties(customerPersonalTOI, customerEntity); - BeanUtils.copyProperties(customerPersonalTOI, personalCustomerEntity); + BeanUtils.copyProperties(personalAppletRequest, customerEntity); + BeanUtils.copyProperties(personalAppletRequest, personalCustomerEntity); // 设置客户编号 String code = customerDao.getCodeByType(CrmsConstant.CustomerType.PERSONAL_CUSTOMER.getType()); if (code == null || code.length() == 0) { @@ -88,9 +94,8 @@ public class CustomerAppletServiceImpl extends ServiceImpl 0) { + ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_EXIST); + } // 客户名称判重 - if (companyCustomerReq.getName() != null && companyCustomerReq.getName().length() != 0) { + if (companyAppletRequest.getName() != null && companyAppletRequest.getName().length() != 0) { List names = customerDao.listCustomerName(1); // 企业类型客户名称 for (String name : names) { - if (companyCustomerReq.getName().equals(name)) { + if (companyAppletRequest.getName().equals(name)) { ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); } } } CustomerEntity customerEntity = new CustomerEntity(); CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); - BeanUtils.copyProperties(companyCustomerReq, customerEntity); - BeanUtils.copyProperties(companyCustomerReq, companyCustomerEntity); + BeanUtils.copyProperties(companyAppletRequest, customerEntity); + BeanUtils.copyProperties(companyAppletRequest, companyCustomerEntity); // 设置客户编号 String code = customerDao.getCodeByType(CrmsConstant.CustomerType.COMPANY_CUSTOMER.getType()); if (code == null || code.length() == 0) { @@ -124,17 +132,16 @@ public class CustomerAppletServiceImpl extends ServiceImpl relatedList = new ArrayList<>(); - List intList = companyCustomerReq.getRelatedId(); + List intList = companyAppletRequest.getRelatedId(); for (int i = 0; i < intList.size(); i++) { CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); @@ -179,43 +186,120 @@ public class CustomerAppletServiceImpl extends ServiceImpl() + .eq("customer_id", (long) customerId)); + BeanUtils.copyProperties(customer, companyAppletRequest); + BeanUtils.copyProperties(companyCustomerEntity, companyAppletRequest); + return companyAppletRequest; + } + return null; } /** * 修改个人类型的认证信息 */ @Override - public Boolean updatePersonal(PersonalCustomerRequest personalCustomerRequest) { + public Boolean updatePersonal(PersonalAppletRequest personalAppletRequest) { Integer customerId = this.getBaseMapper().getCustomerId(Integer.parseInt(this.getUserId()), 0); if (customerId == null) { ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_IS_NULL); } - personalCustomerRequest.setId((long) customerId); - personalCustomerRequest.setType(0); - CustomerPersonalTOU customerPersonalTOU = new CustomerPersonalTOU(); - BeanUtils.copyProperties(personalCustomerRequest, customerPersonalTOU); - return customerService.updateCustomerPersonal(customerPersonalTOU); + // 客户名称判重,注意判断是否与原来相同 + if (personalAppletRequest.getName() != null && personalAppletRequest.getName().length() != 0) { + String customerName = customerDao.getNameByCustomerId((long) customerId); + if (!personalAppletRequest.getName().equals(customerName)) { + List names = customerDao.listCustomerName(0); + for (String name : names) { + if (personalAppletRequest.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } + } + CustomerEntity customerEntity = new CustomerEntity(); + PersonalCustomerEntity personalCustomerEntity = new PersonalCustomerEntity(); + BeanUtils.copyProperties(personalAppletRequest, customerEntity); + BeanUtils.copyProperties(personalAppletRequest, personalCustomerEntity); + customerEntity.setId((long) customerId); + customerEntity.setMotifyTime(new Date()); + boolean customer = this.getBaseMapper().updateCustomer(customerEntity); + personalCustomerEntity.setCustomerId(customerEntity.getId()); + boolean personal = personalCustomerDao.updatePersonalCustomer(personalCustomerEntity); + return customer && personal; } /** * 修改企业类型的认证信息 */ @Override - public Boolean updateCompany(CompanyCustomerRequest companyCustomerRequest) { + public Boolean updateCompany(CompanyAppletRequest companyAppletRequest) { Integer customerId = this.getBaseMapper().getCustomerId(Integer.parseInt(this.getUserId()), 1); if (customerId == null) { ExceptionCast.cast(CrmsCode.CUSTOMER_APPLET_IS_NULL); } - companyCustomerRequest.setId((long) customerId); - companyCustomerRequest.setType(1); + // 客户名称判重,注意判断是否与原来相同 + if (companyAppletRequest.getName() != null && companyAppletRequest.getName().length() != 0) { + String customerName = customerDao.getNameByCustomerId((long) customerId); + if (!companyAppletRequest.getName().equals(customerName)) { + List names = customerDao.listCustomerName(1); + for (String name : names) { + if (companyAppletRequest.getName().equals(name)) { + ExceptionCast.cast(CrmsCode.CUSTOMER_NAME_REPETITION); + } + } + } + } + CustomerEntity customerEntity = new CustomerEntity(); + CompanyCustomerEntity companyCustomerEntity = new CompanyCustomerEntity(); + BeanUtils.copyProperties(companyAppletRequest, customerEntity); + BeanUtils.copyProperties(companyAppletRequest, companyCustomerEntity); + customerEntity.setId((long) customerId); + customerEntity.setMotifyTime(new Date()); + boolean customer = this.getBaseMapper().updateCustomer(customerEntity); + companyCustomerEntity.setCustomerId(customerEntity.getId()); + int company = companyCustomerDao.update(companyCustomerEntity, new QueryWrapper() + .eq("customer_id", companyCustomerEntity.getCustomerId())); + + //根据企业id删除关联关系 + crmsCustomerRelatedMapper.delete(new QueryWrapper().eq("customer_id", companyCustomerEntity.getId())); + + //绑定关联关系 + List relatedList = new ArrayList<>(); + List intList = companyAppletRequest.getRelatedId(); + + for (int i = 0; i < intList.size(); i++) { + CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); + Integer integer = intList.get(i); + crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id + crmsCustomerRelated.setRelatedId(integer);//关联人/企业id + relatedList.add(crmsCustomerRelated); + } + if (relatedList.size() > 0) { + crmsCustomerRelatedService.insertCustomerRelated(relatedList); + } - return customerService.updateCompanyNew(companyCustomerRequest); + if (customer && company > 0) { + return true; + } + return false; } @@ -229,6 +313,7 @@ public class CustomerAppletServiceImpl extends ServiceImpl + + + UPDATE crms_customer + SET name=#{customer.name},addr=#{customer.addr},phone=#{customer.phone},motify_time=#{customer.motifyTime} + WHERE id = #{customer.id} + + \ No newline at end of file diff --git a/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml b/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml index 8f147d8f..9e7a3810 100644 --- a/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml +++ b/dq-financial-crms/src/main/resources/mapper/crms/CustomerDao.xml @@ -42,7 +42,7 @@ - SELECT id,code,type,manager,name,addr,phone FROM crms_customer WHERE del_or_not = 0 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java index 77d98f79..fa9adece 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/crms/response/CrmsCode.java @@ -21,7 +21,8 @@ public enum CrmsCode implements ResultCode { NOT_NULL(false,20004,"上传的文件不能为空"), CUSTOMER_IS_NULL(false,20005,"导入数据失败,当前员工不存在!"), CUSTOMER_NAME_REPETITION(false, 20006, "当前客户名称已存在!"), - CUSTOMER_APPLET_IS_NULL(false, 20007,"未查询到你的信息,请先录入(认证)你的信息!"); + CUSTOMER_APPLET_IS_NULL(false, 20007,"未查询到你的信息,请先录入(认证)你的信息!"), + CUSTOMER_APPLET_EXIST(false, 20008,"你已认证自己的信息,无需再次认证!"); /** * 操作是否成功