forked from kidgrow-microservices-platform

zxh
2020-08-28 2e72649b5ced02a26db7f4cda9959e26ad4343fa
kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-biz/src/main/java/com/kidgrow/usercenter/service/impl/SysUserServiceImpl.java
@@ -272,7 +272,7 @@
        String oldTel = MapUtils.getString(params, "oldTel");
        String newTel = AesUtils.desEncrypt(MapUtils.getString(params, "newTel")).trim();
        String authCode = AesUtils.desEncrypt(MapUtils.getString(params, "authCode")).trim();
        String userPassword = AesUtils.desEncrypt(MapUtils.getString(params, "userPassword")).trim();
        String userPassword =MapUtils.getString(params, "userPassword");
        if (id > 0 && StringUtils.isNotBlank(oldTel) && StringUtils.isNotBlank(newTel) && StringUtils.isNotBlank(authCode) && StringUtils.isNotBlank(userPassword)) {
            //检查验证码
@@ -298,8 +298,8 @@
                        com.kidgrow.usercenter.model.SysDoctor newsysDoctorModel = new com.kidgrow.usercenter.model.SysDoctor();
                        if (sysDoctorModel != null) {
                            //理论上只有一个,如果有多个 只取第一个
                            newsysDoctorModel.setId(sysDoctorModel.getId());
                            newsysDoctorModel.setDoctorTel(newTel);
                            sysDoctorModel.setId(sysDoctorModel.getId());
                            sysDoctorModel.setDoctorTel(newTel);
                            sysDoctorMapper.updateById(newsysDoctorModel);
                        }
                        if (baseMapper.updateById(user) > 0) {
@@ -467,7 +467,7 @@
    @Override
    public ResultBody findCountByMap(Map<String, Object> map) {
        map.put("enable", 1);
        map.put("is_del", 0);
        map.put("isDel", 0);
        Integer integer = baseMapper.selectCountByMap(map);
        return ResultBody.ok().data(integer);
    }
@@ -672,6 +672,10 @@
        Long createUserId = CommonConstant.CREATE_USER_ID;
        //创建人名称
        String createUserName = CommonConstant.CREATE_USER_NAME;
        //销售服务人员
        SysUser sysUserSale = baseMapper.selectById(CommonConstant.SALE_USER_ID);
        //运营服务人员
        SysUser sysUserOpration = baseMapper.selectById(CommonConstant.OPRATION_USER_ID);
        //是否注册用户
        Boolean isReg = false;
        //业务成功
@@ -679,8 +683,8 @@
        //业务失败提示信息
        String expMsg = "";
        //系统内置的注册医院和科室的组织数据
        Long organizationHos = CommonConstant.HOSPITAL_ORG_ID;
        Long organizationDep = CommonConstant.DEPARTMENT_ORG_ID;
        Long organizationHos = 0L;
        Long organizationDep = 0L;
        //检查判断是注册 还是添加用户,注册用户先走基本数据建设 医院/科室
        SysUserOrg sysUserOrgH = new SysUserOrg();
        SysUserOrg sysUserOrgD = new SysUserOrg();
@@ -690,44 +694,72 @@
            isReg = true;
            if (CheckVerificationCode(ConstantSMS.REGISTER_SMS, userRegVo.getMobile(), userRegVo.getVerification())) {
                userRegVo.setDoctorState(true);
                //写医院数据
                SysHospital sysHospital = new SysHospital();
                sysHospital.setHospitalName(userRegVo.getHospitalName());
                sysHospital.setOrgId(organizationHos);
                //注册的用户所在医院默认是试用状态
                sysHospital.setHospitalState(0);
                sysHospital.setCreateUserId(createUserId);
                sysHospital.setCreateUserName(createUserName);
                boolean h = hospitalService.save(sysHospital);
                if (h) {
                    userRegVo.setHospitalId(sysHospital.getId());
                    //保存科室数据
                    SysDepartment sysDepartment = new SysDepartment();
                    sysDepartment.setOrgId(organizationDep);
                    sysDepartment.setDepartmentName(userRegVo.getDepartmentName());
                    sysDepartment.setSaleUserId(createUserId);
                    sysDepartment.setAccountsCount(1);
                    sysDepartment.setSaleUserName(createUserName);
                    sysDepartment.setSaleUserTel("0");
                    sysDepartment.setServerUserId(createUserId);
                    sysDepartment.setServerUserTel("0");
                    sysDepartment.setServerUserName(createUserName);
                    boolean d = departmentService.save(sysDepartment);
                    if (d) {
                        userRegVo.setDepartmentId(sysDepartment.getId());
                        //自动充入系统指定的试用套餐
                        if (!saveProductDetail(sysHospital.getId(), sysDepartment.getId(), sysHospital.getHospitalName(), sysDepartment.getDepartmentName())) {
                //写医院组织数据
                SysOrganization sysOrganizationH = new SysOrganization();
                sysOrganizationH.setOrgLevel(1);
                sysOrganizationH.setOrgAttr(1);
                sysOrganizationH.setOrgParentId(CommonConstant.ORG_PARENT_ID);
                sysOrganizationH.setOrgName(userRegVo.getHospitalName());
                sysOrganizationH.setCreateUserId(createUserId);
                sysOrganizationH.setCreateUserName(createUserName);
                if (organizationService.save(sysOrganizationH)) {
                    //写科室组织数据
                    SysOrganization sysOrganizationD = new SysOrganization();
                    sysOrganizationD.setOrgLevel(2);
                    sysOrganizationD.setOrgAttr(2);
                    sysOrganizationD.setOrgParentId(sysOrganizationH.getId());
                    sysOrganizationD.setOrgName(userRegVo.getDepartmentName());
                    sysOrganizationD.setCreateUserId(createUserId);
                    sysOrganizationD.setCreateUserName(createUserName);
                    if (organizationService.save(sysOrganizationD)) {
                        //写医院组织数据
                        SysHospital sysHospital = new SysHospital();
                        sysHospital.setHospitalName(userRegVo.getHospitalName());
                        sysHospital.setOrgId(sysOrganizationH.getId());
                        //注册的用户所在医院默认是试用状态
                        sysHospital.setHospitalState(0);
                        sysHospital.setCreateUserId(createUserId);
                        sysHospital.setCreateUserName(createUserName);
                        if (hospitalService.save(sysHospital)) {
                            userRegVo.setHospitalId(sysHospital.getId());
                            //保存科室数据
                            SysDepartment sysDepartment = new SysDepartment();
                            sysDepartment.setOrgId(sysOrganizationD.getId());
                            sysDepartment.setDepartmentName(userRegVo.getDepartmentName());
                            sysDepartment.setSaleUserId(sysUserSale.getId());
                            sysDepartment.setAccountsCount(1);
                            sysDepartment.setSaleUserName(sysUserSale.getNickname());
                            sysDepartment.setSaleUserTel(sysUserSale.getMobile());
                            sysDepartment.setServerUserId(sysUserOpration.getId());
                            sysDepartment.setServerUserTel(sysUserOpration.getMobile());
                            sysDepartment.setServerUserName(sysUserOpration.getNickname());
                            sysDepartment.setCreateUserId(createUserId);
                            sysDepartment.setCreateUserName(createUserName);
                            if (departmentService.save(sysDepartment)) {
                                userRegVo.setDepartmentId(sysDepartment.getId());
                                //自动充入系统指定的试用套餐
                                if (!saveProductDetail(sysHospital.getId(),
                                        sysDepartment.getId(),
                                        sysHospital.getHospitalName(),
                                        sysDepartment.getDepartmentName())) {
                                    isSuccess = false;
                                    expMsg = "试用套餐充值失败";
                                }
                            } else {
                                isSuccess = false;
                                expMsg = "科室数据写入失败";
                            }
                        } else {
                            isSuccess = false;
                            expMsg = "套餐充值失败";
                            expMsg = "医院数据写入失败";
                        }
                    } else {
                        isSuccess = false;
                        expMsg = "科室数据写入失败";
                        expMsg = "科室组织数据写入失败";
                    }
                } else {
                    isSuccess = false;
                    expMsg = "医院数据写入失败";
                    expMsg = "医院组织数据写入失败";
                }
            } else {
                return ResultBody.failed("无效的验证码");
@@ -787,18 +819,19 @@
                    if (StringUtils.isNotBlank(userRegVo.getDoctorRank())) {
                        //检查医生职务是否存在
                        Map<String, Object> selectMap = new HashMap<>();
                        selectMap.put("dictionariesName", userRegVo.getDoctorRank());
                        selectMap.put("dictionariesNameAll", userRegVo.getDoctorRank().trim());
                        List<SysDictionaries> dictionariesList = sysDictionariesService.findAll(selectMap);
                        boolean dicBool = false;
                        if (dictionariesList.size() > 0) {
                            for (int i = dictionariesList.size() - 1; i >= 0; i--) {
                                if (dictionariesList.get(i).getDictionariesName().equals(userRegVo.getDoctorRank())) {
                                if (dictionariesList.get(i).getDictionariesName().trim().equals(userRegVo.getDoctorRank().trim())) {
                                    userRegVo.setDoctorRankId(dictionariesList.get(i).getId());
                                    dicBool = true;
                                    break;
                                }
                            }
                        } else {
                        }
                        else {
                            //创建字典数据
                            sysDictionaries.setDictionariesClassId(DictionariesConstants.DOCTOR_RANK);
                            //将名称汉字转为拼音
@@ -846,8 +879,8 @@
                                sysDoctor.setDoctorState(!isReg);
                                sysDoctor.setDoctorTel(userRegVo.getMobile());
                                sysDoctor.setDoctorName(userRegVo.getNickname());
                                sysDoctor.setServerUserId(isReg ? createUserId : sysUserd.getId());
                                sysDoctor.setServerUserName(isReg ? createUserName : sysUserd.getUsername());
                                sysDoctor.setServerUserId(isReg ? sysUserSale.getId() : sysUserd.getId());
                                sysDoctor.setServerUserName(isReg ? sysUserSale.getNickname() : sysUserd.getUsername());
                                sysDoctor.setIsAdminUser(false);
                                sysDoctor.setDoctorCcie(userRegVo.getDoctorCcie());
                                sysDoctor.setEnabled(true);
@@ -930,6 +963,9 @@
            } else {
                listVoList = baseMapper.hospitalDoctorList(hospitalId, departmentId, CommonConstant.HOSPITAL_DOCTOR_ID, CommonConstant.HOSPITAL_ADMIN_ID);
            }
            listVoList.sort((e1,e2)->
                e2.getUserId().compareTo(e1.getUserId())
            );
            return ResultBody.ok().data(listVoList);
        } else {
            return ResultBody.failed("医院数据有误");