|
|
@@ -1,14 +1,13 @@
|
|
|
package com.fs.company.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.QRutils;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
|
import com.fs.common.constant.UserConstants;
|
|
|
-import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
@@ -20,36 +19,35 @@ import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.*;
|
|
|
-import com.fs.company.param.CompanyUserAreaParam;
|
|
|
-import com.fs.company.param.CompanyUserCodeParam;
|
|
|
-import com.fs.company.param.CompanyUserQwParam;
|
|
|
+import com.fs.company.param.*;
|
|
|
import com.fs.company.service.*;
|
|
|
import com.fs.company.vo.*;
|
|
|
import com.fs.course.service.IFsUserCompanyUserService;
|
|
|
+import com.fs.his.config.StoreConfig;
|
|
|
+import com.fs.his.domain.FsPatient;
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
+import com.fs.his.domain.FsUserAddress;
|
|
|
+import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
|
+import com.fs.his.mapper.FsPatientMapper;
|
|
|
+import com.fs.his.mapper.FsUserAddressMapper;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
+import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
|
import com.fs.his.service.IFsCityService;
|
|
|
+import com.fs.his.utils.IdCardUtil;
|
|
|
+import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.CitysAreaVO;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
-import com.fs.hisStore.domain.FsStoreProductAttrScrm;
|
|
|
-import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
|
|
|
-import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
-import com.fs.hisStore.dto.ProductArrtDTO;
|
|
|
-import com.fs.hisStore.vo.FsStoreProductExportVO;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.dto.UserProjectDTO;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
-import com.fs.qw.service.IQwExternalContactService;
|
|
|
import com.fs.qw.service.IQwUserService;
|
|
|
import com.fs.qw.vo.CompanyUserQwVO;
|
|
|
import com.fs.qw.vo.QwOptionsVO;
|
|
|
import com.fs.qw.vo.QwUserVO;
|
|
|
-import com.fs.system.domain.SysConfig;
|
|
|
-import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.oss.CloudStorageService;
|
|
|
import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.system.service.ISysRoleService;
|
|
|
-import com.fs.system.service.ISysUserService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
import com.fs.wxUser.domain.CompanyWxUser;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
@@ -62,9 +60,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -128,6 +129,13 @@ public class CompanyUserServiceImpl implements ICompanyUserService
|
|
|
// @Autowired
|
|
|
// private ICompanyUserRoleService userRoleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private FsPatientMapper fsPatientMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsUserAddressMapper fsUserAddressMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询物业公司管理员信息
|
|
|
@@ -1071,4 +1079,192 @@ public class CompanyUserServiceImpl implements ICompanyUserService
|
|
|
public String selectMpOpenIdByCompanyUserId(Long companyUserId) {
|
|
|
return companyUserMapper.selectMpOpenIdByCompanyUserId(companyUserId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 销售帮填用户就诊人和地址
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> addHelpPatientAndAddress(Long companyUserId, Long userId, HelpAddPatientParam patientParam, HelpAddUserAddressParam addressParam) {
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserById(userId);
|
|
|
+ if (fsUser == null) {
|
|
|
+ throw new CustomException("帮填用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存帮填就诊人
|
|
|
+ FsPatient patient = addHelpPatient(companyUserId, userId, patientParam);
|
|
|
+
|
|
|
+ // 保存帮填地址
|
|
|
+ FsUserAddress userAddress = addHelpAddress(companyUserId, userId, addressParam);
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("patient", patient);
|
|
|
+ result.put("userAddress", userAddress);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 帮填地址
|
|
|
+ */
|
|
|
+ private FsUserAddress addHelpAddress(Long companyUserId, Long userId, HelpAddUserAddressParam address) {
|
|
|
+ //处理地址数量 最大20个
|
|
|
+ Integer count = fsUserAddressMapper.selectFsUserAddressCountsByUserId(userId);
|
|
|
+ if(count > 10){
|
|
|
+ throw new CustomException("最多可创建10个地址");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(address.getIsDefault() == 1){
|
|
|
+ //处理默认地址
|
|
|
+ fsUserAddressMapper.clearIsDefalut(userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ FsUserAddress userAddress = fsUserAddressMapper.selectFsUserAddressByCompanyUserId(companyUserId, userId);
|
|
|
+ if (userAddress == null) {
|
|
|
+ userAddress = new FsUserAddress();
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(address, userAddress, "addressId");
|
|
|
+ address.setPhone(address.getPhone().trim());
|
|
|
+ userAddress.setUserId(userId);
|
|
|
+ userAddress.setDetail(userAddress.getDetail().trim());
|
|
|
+ userAddress.setCreateTime(DateUtils.getNowDate());
|
|
|
+ userAddress.setIsConfirm(0);
|
|
|
+ userAddress.setHelpCompanyUserId(companyUserId);
|
|
|
+ if (userAddress.getAddressId() == null) {
|
|
|
+ fsUserAddressMapper.insertFsUserAddress(userAddress);
|
|
|
+ } else {
|
|
|
+ fsUserAddressMapper.updateFsUserAddress(userAddress);
|
|
|
+ }
|
|
|
+
|
|
|
+ return userAddress;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 帮填就诊人
|
|
|
+ */
|
|
|
+ private FsPatient addHelpPatient(Long companyUserId, Long userId, HelpAddPatientParam param) {
|
|
|
+ String json = configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
+ Integer isIdVerification = storeConfig.getIsIdVerification();
|
|
|
+
|
|
|
+ String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
+ String mobile = param.getMobile();
|
|
|
+ if (idCardNumber == null || idCardNumber.trim().isEmpty()) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+// //大陆身份证是18位
|
|
|
+// if (isIdVerification != 1) {
|
|
|
+// return R.error("身份证号码不合法");
|
|
|
+// } else {
|
|
|
+// //非大陆身份校验需要手机号 手机号只支持大陆的办理的手机号
|
|
|
+// if (StringUtils.isBlank(mobile)){
|
|
|
+// R.error("手机号不能为空");
|
|
|
+// }
|
|
|
+// }
|
|
|
+ //暂时仅支持大陆身份证
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ } else {
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
+ throw new CustomException("就诊人名称不合法");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (idCardNumber != null) {
|
|
|
+ String birthDateString = idCardNumber.substring(6, 14);
|
|
|
+ LocalDate birthDate = LocalDate.parse(birthDateString, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ int age = currentDate.getYear() - birthDate.getYear();
|
|
|
+ if (currentDate.getMonthValue() < birthDate.getMonthValue()
|
|
|
+ || (currentDate.getMonthValue() == birthDate.getMonthValue()
|
|
|
+ && currentDate.getDayOfMonth() < birthDate.getDayOfMonth())) {
|
|
|
+ age--;
|
|
|
+ }
|
|
|
+ if (age < 18) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+
|
|
|
+ }
|
|
|
+ Date birthday = param.getBirthday();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
+ String formattedBirthday = sdf.format(birthday);
|
|
|
+ LocalDate da = LocalDate.parse(formattedBirthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
+ LocalDate currentDate2 = LocalDate.now();
|
|
|
+ int age2 = currentDate2.getYear() - da.getYear();
|
|
|
+ if (currentDate2.getMonthValue() < da.getMonthValue()
|
|
|
+ || (currentDate2.getMonthValue() == da.getMonthValue()
|
|
|
+ && currentDate2.getDayOfMonth() < da.getDayOfMonth())) {
|
|
|
+ age2--;
|
|
|
+ }
|
|
|
+ if (age2 < 18) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age2 > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new CustomException("身份证校验错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ //三方校验
|
|
|
+ if (isIdVerification!=null&&isIdVerification == 1){
|
|
|
+ boolean match = true;
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ match = IdCardUtil.isMatchByMobile(storeConfig,param.getPatientName(), mobile);
|
|
|
+ } else {
|
|
|
+ match = IdCardUtil.isMatchById(storeConfig,param.getPatientName(), param.getIdCard());
|
|
|
+ }
|
|
|
+ if (!match){
|
|
|
+ throw new CustomException("身份证校验错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ FsPatient patient = fsPatientMapper.selectFsPatientByCompanyUserId(companyUserId, userId);
|
|
|
+ if (patient == null) {
|
|
|
+ patient = new FsPatient();
|
|
|
+ }
|
|
|
+
|
|
|
+ BeanUtil.copyProperties(param, patient, "patientId");
|
|
|
+ patient.setUserId(userId);
|
|
|
+ patient.setHelpCompanyUserId(companyUserId);
|
|
|
+ patient.setIsDel(0);
|
|
|
+ patient.setStatus(1);
|
|
|
+ patient.setIsConfirm(0);
|
|
|
+ patient.setCreateTime(DateUtils.getNowDate());
|
|
|
+ if (StringUtils.isNotBlank(mobile)){
|
|
|
+ patient.setMobile(PhoneUtil.encryptPhone(mobile));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (patient.getPatientId() == null) {
|
|
|
+ fsPatientMapper.insertFsPatient(patient);
|
|
|
+ } else {
|
|
|
+ fsPatientMapper.updateFsPatient(patient);
|
|
|
+ }
|
|
|
+
|
|
|
+ return patient;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取销售帮填用户就诊人和地址
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getHelpPatientAndAddress(Long companyUserId, Long userId) {
|
|
|
+ FsPatient fsPatient = fsPatientMapper.selectFsPatientByCompanyUserId(companyUserId, userId);
|
|
|
+ if (fsPatient != null && StringUtils.isNotNull(fsPatient.getMobile())) {
|
|
|
+ fsPatient.setMobile(PhoneUtil.decryptPhone(fsPatient.getMobile()));
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("patient", fsPatient);
|
|
|
+ result.put("userAddress", fsUserAddressMapper.selectFsUserAddressByCompanyUserId(companyUserId, userId));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|