|
|
@@ -74,5 +74,89 @@ public class LawFirmServiceImpl extends ServiceImpl<LawFirmMapper, LawFirm> impl
|
|
|
}
|
|
|
return R.fail("删除失败");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<LawFirm> register(LawFirm lawFirm) {
|
|
|
+ log.info("LawFirmServiceImpl.register?lawFirm={}", lawFirm);
|
|
|
+
|
|
|
+ // 校验必填字段
|
|
|
+ if (!StringUtils.hasText(lawFirm.getFirmName())) {
|
|
|
+ return R.fail("律所名称不能为空");
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(lawFirm.getCreditCode())) {
|
|
|
+ return R.fail("统一社会信用代码不能为空");
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(lawFirm.getPhone())) {
|
|
|
+ return R.fail("联系电话不能为空");
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(lawFirm.getDirectorName())) {
|
|
|
+ return R.fail("负责人姓名不能为空");
|
|
|
+ }
|
|
|
+ if (!StringUtils.hasText(lawFirm.getDirectorPhone())) {
|
|
|
+ return R.fail("负责人电话不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验统一社会信用代码是否已存在
|
|
|
+ LambdaQueryWrapper<LawFirm> creditCodeWrapper = new LambdaQueryWrapper<>();
|
|
|
+ creditCodeWrapper.eq(LawFirm::getCreditCode, lawFirm.getCreditCode());
|
|
|
+ creditCodeWrapper.eq(LawFirm::getDeleteFlag, 0);
|
|
|
+ long creditCodeCount = this.count(creditCodeWrapper);
|
|
|
+ if (creditCodeCount > 0) {
|
|
|
+ return R.fail("该统一社会信用代码已注册,请勿重复注册");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验联系电话是否已存在
|
|
|
+ if (StringUtils.hasText(lawFirm.getPhone())) {
|
|
|
+ LambdaQueryWrapper<LawFirm> phoneWrapper = new LambdaQueryWrapper<>();
|
|
|
+ phoneWrapper.eq(LawFirm::getPhone, lawFirm.getPhone());
|
|
|
+ phoneWrapper.eq(LawFirm::getDeleteFlag, 0);
|
|
|
+ long phoneCount = this.count(phoneWrapper);
|
|
|
+ if (phoneCount > 0) {
|
|
|
+ return R.fail("该联系电话已被使用,请更换其他号码");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验负责人电话是否已存在
|
|
|
+ if (StringUtils.hasText(lawFirm.getDirectorPhone())) {
|
|
|
+ LambdaQueryWrapper<LawFirm> directorPhoneWrapper = new LambdaQueryWrapper<>();
|
|
|
+ directorPhoneWrapper.eq(LawFirm::getDirectorPhone, lawFirm.getDirectorPhone());
|
|
|
+ directorPhoneWrapper.eq(LawFirm::getDeleteFlag, 0);
|
|
|
+ long directorPhoneCount = this.count(directorPhoneWrapper);
|
|
|
+ if (directorPhoneCount > 0) {
|
|
|
+ return R.fail("该负责人电话已被使用,请更换其他号码");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验邮箱是否已存在
|
|
|
+ if (StringUtils.hasText(lawFirm.getEmail())) {
|
|
|
+ LambdaQueryWrapper<LawFirm> emailWrapper = new LambdaQueryWrapper<>();
|
|
|
+ emailWrapper.eq(LawFirm::getEmail, lawFirm.getEmail());
|
|
|
+ emailWrapper.eq(LawFirm::getDeleteFlag, 0);
|
|
|
+ long emailCount = this.count(emailWrapper);
|
|
|
+ if (emailCount > 0) {
|
|
|
+ return R.fail("该邮箱已被使用,请更换其他邮箱");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置注册时的初始状态
|
|
|
+ lawFirm.setStatus(1); // 启用状态
|
|
|
+ lawFirm.setCertificationStatus(0); // 未认证状态
|
|
|
+ lawFirm.setDeleteFlag(0); // 未删除
|
|
|
+ lawFirm.setIsRecommended(0); // 默认不推荐
|
|
|
+ if (lawFirm.getLawyerCount() == null) {
|
|
|
+ lawFirm.setLawyerCount(0);
|
|
|
+ }
|
|
|
+ if (lawFirm.getPartnerCount() == null) {
|
|
|
+ lawFirm.setPartnerCount(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存律所信息
|
|
|
+ boolean result = this.save(lawFirm);
|
|
|
+ if (result) {
|
|
|
+ return R.data(lawFirm, "注册成功,请等待审核");
|
|
|
+ }
|
|
|
+ return R.fail("注册失败,请稍后重试");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|