コード例 #1
0
        public async Task <IActionResult> ModifyPassword([FromBody] HospitalModifyPasswordRequestDto requestDto)
        {
            if (string.IsNullOrEmpty(UserID))
            {
                return(Failed(ErrorCode.Empty, "账号不存在或已禁用"));
            }

            var hospitalBiz = new HospitalBiz();

            var model = await hospitalBiz.GetAsync(UserID);

            if (model is null)
            {
                return(Failed(ErrorCode.Empty, "账号不存在或已禁用"));
            }

            var addSaltPwd = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.Password);

            if (!model.Password.Equals(addSaltPwd, StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.Empty, "账号或密码错误"));
            }

            model.LastUpdatedBy   = model.HospitalGuid;
            model.LastUpdatedDate = DateTime.Now;
            model.Password        = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.NewPassword);

            var result = await hospitalBiz.UpdateAsync(model);

            return(result ? Success() : Failed(ErrorCode.Empty, "密码更新失败!"));
        }
コード例 #2
0
        public async Task <IActionResult> GetHospitalAsync([FromQuery] string hospitalGuid)
        {
            if (string.IsNullOrEmpty(hospitalGuid))
            {
                return(Failed(ErrorCode.Empty, "医院不存在,参数不正确"));
            }

            var hospitalBiz = new HospitalBiz();

            var hospital = await hospitalBiz.GetAsync(hospitalGuid);

            return(Success(hospital));
        }
コード例 #3
0
        public async Task <IActionResult> EnterpriseWeChatLogin(string code)
        {
            HospitalLoginResponseDto response = null;
            var result = await GetEnterpriseWeChatUserInfo(code);

            if (result == null)
            {
                return(Failed(ErrorCode.Empty, "未找到对应用户信息"));
            }
            //根据用户部门Id查找对应医院数据
            var enterprise = new EnterpriseWeChat();

            PlatformSettings.Mappings.Bind(enterprise);
            List <Mapping> mapList = enterprise?.Mapping.ToList();

            if (mapList == null)
            {
                return(Failed(ErrorCode.Empty, "配置信息错误"));
            }
            int[] departmentList = result.department;
            if (departmentList == null || departmentList.Count() == 0)
            {
                return(Failed(ErrorCode.Empty, "所属部门为空"));
            }
            var hospitalBiz = new HospitalBiz();

            foreach (var item in departmentList)
            {
                var mappingModel = mapList.FirstOrDefault(s => s.DepartmentId == item);
                if (mappingModel != null)
                {
                    var model = await hospitalBiz.GetAsync(mappingModel.HosId);

                    if (model == null)
                    {
                        return(Failed(ErrorCode.Empty, "未找到对应医院"));
                    }
                    //找到对应医院账号进行登录
                    response = new HospitalLoginResponseDto
                    {
                        HospitalGuid = model.HospitalGuid,
                        HospitalName = model.HosName,
                        Token        = CreateToken(model.HospitalGuid, Common.EnumDefine.UserType.Doctor, 30),
                    };
                    return(Success(response));
                }
            }
            return(Failed(ErrorCode.Empty, "未找到对应用户所在医院"));
        }
コード例 #4
0
        public async Task <IActionResult> DisableEnableHospitalAsync([FromBody] DisableEnableHospitalRequestDto request)
        {
            var hospitalBiz = new HospitalBiz();
            var entity      = await hospitalBiz.GetAsync(request.Guid);

            if (entity == null)
            {
                return(Failed(ErrorCode.UserData, "找不到数据"));
            }
            entity.LastUpdatedBy   = UserID;
            entity.LastUpdatedDate = DateTime.Now;
            entity.Enable          = request.Enable;
            var result = await hospitalBiz.UpdateAsync(entity);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "修改失败"));
            }
            return(Success());
        }
コード例 #5
0
        public async Task <IActionResult> ResetPasswordAsync([FromBody] ResetPasswordResponseDto request)
        {
            HospitalBiz hospitalBiz = new HospitalBiz();
            var         entity      = await hospitalBiz.GetAsync(request.Guid);

            if (entity == null)
            {
                return(Failed(ErrorCode.DataBaseError));
            }
            if (string.IsNullOrWhiteSpace(entity.Account))
            {
                return(Failed(ErrorCode.DataBaseError, "请先设置账号"));
            }
            var password = "******";//默认密码

            entity.Password        = CryptoHelper.AddSalt(entity.HospitalGuid, GD.Common.Helper.CryptoHelper.Md5(password));
            entity.LastUpdatedBy   = UserID;
            entity.LastUpdatedDate = DateTime.Now;
            await hospitalBiz.UpdateAsync(entity);

            return(Success());
        }
コード例 #6
0
        public async Task <IActionResult> ModifyDoctorInfoAsync([FromBody] ModifyDoctorInfoRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkDoctor     = await doctorBiz.GetAsync(doctorModelGuid);

            if (checkDoctor == null)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!"));
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;

            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            doctorModel = checkDoctor;

            //医生数据
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor      = doctorDto.Honor;
            doctorModel.Background = doctorDto.Background;
            doctorModel.TitleGuid  = doctorDto.DocTitle;
            doctorModel.AdeptTags  = doctorDto.Adepts;
            doctorModel.Status     = StatusEnum.Submit.ToString();
            //doctorModel.SignatureGuid = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, false);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
        }
コード例 #7
0
        public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorRequestDto doctorDto)
        {
            var doctorModelGuid = UserID;
            var doctorBiz       = new DoctorBiz();
            var checkModel      = await doctorBiz.GetAsync(doctorModelGuid, true, true);

            bool isAdd       = checkModel == null;;//当前为更新操作还是新增操作
            var  statusCheck = string.Equals(checkModel?.Status, StatusEnum.Submit.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(checkModel?.Status, StatusEnum.Approved.ToString(), StringComparison.OrdinalIgnoreCase);

            if (checkModel != null && statusCheck && checkModel.Enable)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户已注册过医生!"));
            }

            var doctorCertificates = await new DictionaryBiz().GetListByParentGuidAsync(DictionaryType.DoctorDicConfig);

            foreach (var item in doctorCertificates)
            {
                if (doctorDto.Certificates.FirstOrDefault(a => a.DicGuid == item.DicGuid) == null)
                {
                    var eMsg = $"[{item.ConfigName}]没有上传";
                    return(Failed(ErrorCode.UserData, $"上传的医生证书项和系统配置的项不符,请核对,详情:{eMsg}"));
                }
            }

            var userModel = await new UserBiz().GetModelAsync(UserID);

            userModel.UserName       = doctorDto.UserName;
            userModel.IdentityNumber = doctorDto.IdentityNumber;
            userModel.Birthday       = doctorDto.Birthday;
            userModel.Gender         = doctorDto.Gender;
            var hospitalBiz  = new HospitalBiz();
            var officeBiz    = new OfficeBiz();
            var accessoryBiz = new AccessoryBiz();
            var doctorModel  = new DoctorModel();

            if (!isAdd)
            {
                doctorModel = checkModel;
            }
            //医生数据
            doctorModel.DoctorGuid         = doctorModelGuid;
            doctorModel.HospitalGuid       = doctorDto.HospitalGuid;
            doctorModel.OfficeGuid         = doctorDto.DocOffice;
            doctorModel.WorkCity           = doctorDto.City;
            doctorModel.PractisingHospital = doctorDto.PractisingHospital;
            doctorModel.Honor           = doctorDto.Honor;
            doctorModel.Background      = doctorDto.Background;
            doctorModel.TitleGuid       = doctorDto.DocTitle;
            doctorModel.AdeptTags       = Newtonsoft.Json.JsonConvert.SerializeObject(doctorDto.Adepts);
            doctorModel.Status          = StatusEnum.Submit.ToString();
            doctorModel.SignatureGuid   = doctorDto.SignatureGuid;
            doctorModel.CreatedBy       = UserID;
            doctorModel.OrgGuid         = "";
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.PortraitGuid    = doctorDto.PortraitGuid;
            doctorModel.LastUpdatedDate = DateTime.Now;
            doctorModel.Enable          = true;

            //医院名称
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;

            //医生证书配置项 & 附件
            var lstCertificate = new List <CertificateModel>();
            var lstAccessory   = new List <AccessoryModel>();

            if (doctorDto.Certificates.Any())
            {
                foreach (var certificate in doctorDto.Certificates)
                {
                    var certificateModel = new CertificateModel
                    {
                        CertificateGuid = Guid.NewGuid().ToString("N"),
                        PictureGuid     = certificate.AccessoryGuid,
                        OwnerGuid       = doctorModel.DoctorGuid,
                        DicGuid         = certificate.DicGuid,
                        CreatedBy       = UserID,
                        OrgGuid         = "",
                        LastUpdatedBy   = UserID
                    };
                    lstCertificate.Add(certificateModel);
                    var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid);

                    if (accModel != null)
                    {
                        accModel.OwnerGuid       = certificateModel.CertificateGuid;
                        accModel.LastUpdatedDate = DateTime.Now;
                        lstAccessory.Add(accModel);
                    }
                }
            }
            var doctorCompositeBiz = new DoctorCompositeBiz();
            var result             = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, isAdd);

            if (result)
            {
                new DoctorActionBiz().RegisterDoctor(this.UserID);
            }
            return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生注册数据插入不成功!"));
        }
コード例 #8
0
        public async Task <IActionResult> UpdateHospitalAsync([FromBody] UpdateHospitalRequestDto request)
        {
            var hospitalBiz   = new HospitalBiz();
            var hospitalModel = await hospitalBiz.GetAsync(request.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "数据错误"));
            }
            if (request.Account != hospitalModel.Account && await hospitalBiz.AnyAccountAsync(request.Account))
            {
                return(Failed(ErrorCode.UserData, "已经存在相同的账号!"));
            }
            var contentBiz = new RichtextBiz();

            request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content;
            request.HosTag  = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag;
            var richtextModel = await contentBiz.GetAsync(hospitalModel.HosDetailGuid);

            var richtextIsAdd = false;

            if (richtextModel != null)
            {
                richtextModel.Content         = request.Content;
                richtextModel.LastUpdatedBy   = UserID;
                richtextModel.LastUpdatedDate = DateTime.Now;
                richtextModel.OrgGuid         = string.Empty;
                richtextModel.OwnerGuid       = request.HospitalGuid;
            }
            else
            {
                var textGuid = Guid.NewGuid().ToString("N");
                richtextModel = new RichtextModel
                {
                    Content         = request.Content,
                    CreatedBy       = UserID,
                    CreationDate    = DateTime.Now,
                    Enable          = true,
                    LastUpdatedBy   = UserID,
                    LastUpdatedDate = DateTime.Now,
                    OrgGuid         = string.Empty,
                    OwnerGuid       = hospitalModel.HospitalGuid,
                    TextGuid        = textGuid,
                };
                hospitalModel.HosDetailGuid = textGuid;
                richtextIsAdd = true;
            }

            hospitalModel.HosAbstract     = request.HosAbstract;
            hospitalModel.HosLevel        = request.HosLevel;
            hospitalModel.HosName         = request.HosName;
            hospitalModel.HosTag          = request.HosTag;
            hospitalModel.Location        = request.Location;
            hospitalModel.LogoGuid        = request.LogoGuid;
            hospitalModel.RegisteredDate  = request.RegisteredDate;
            hospitalModel.Visibility      = request.Visibility;
            hospitalModel.LastUpdatedBy   = UserID;
            hospitalModel.LastUpdatedDate = DateTime.Now;
            hospitalModel.Enable          = request.Enable;
            hospitalModel.ContactNumber   = request.ContactNumber;
            hospitalModel.Sort            = request.Sort;
            hospitalModel.GuidanceUrl     = request.GuidanceUrl ?? string.Empty;
            hospitalModel.ExternalLink    = request.ExternalLink ?? string.Empty;
            hospitalModel.Account         = request.Account;
            hospitalModel.IsHospital      = request.IsHospital;
            hospitalModel.Longitude       = request.Longitude;
            hospitalModel.Latitude        = request.Latitude;
            if (null != request.Password)
            {
                hospitalModel.Password = CryptoHelper.AddSalt(hospitalModel.HospitalGuid, request.Password);
            }

            var response = await hospitalBiz.UpdateAsync(hospitalModel, richtextModel, richtextIsAdd);

            if (!response)
            {
                return(Failed(ErrorCode.DataBaseError, "修改失败"));
            }
            return(Success(response));
        }
コード例 #9
0
        public async Task <IActionResult> AddDoctorInfoAsync([FromBody] AddDoctorInfoRequestDto request)
        {
            var doctorBiz    = new DoctorBiz();
            var userIsInsert = false;
            var userModel    = await new UserBiz().GetByPnoneAsync(request.Phone);

            if (userModel != null)
            {
                var doctor = await doctorBiz.GetAsync(userModel.UserGuid);

                if (doctor != null)
                {
                    return(Failed(ErrorCode.DataBaseError, "该用户已注册医生!"));
                }
                userModel.UserName       = request.UserName;
                userModel.IdentityNumber = request.IdentityNumber;
                userModel.Birthday       = request.Birthday;
                userModel.Gender         = request.Gender;
                userModel.Phone          = request.Phone;
            }
            else
            {
                //var password = request.Phone.Substring(request.Phone.Length - 6);
                var password = "******";//默认密码
                var userid   = Guid.NewGuid().ToString("N");
                userModel = new UserModel
                {
                    Birthday       = request.Birthday,
                    CreatedBy      = userid,
                    Enable         = true,
                    Gender         = request.Gender,
                    LastUpdatedBy  = userid,
                    NickName       = request.UserName,
                    OrgGuid        = string.Empty,
                    Password       = Common.Helper.CryptoHelper.AddSalt(userid, GD.Common.Helper.CryptoHelper.Md5(password)),
                    Phone          = request.Phone,
                    UserGuid       = userid,
                    UserName       = request.UserName,
                    IdentityNumber = request.IdentityNumber
                };
                userIsInsert = true;
            }

            var existNumber = await doctorBiz.ExistJobNumber(request.JobNumber);

            if (existNumber)
            {
                return(Failed(ErrorCode.DataBaseError, $"工号【{request.JobNumber}】已存在"));
            }

            //医生数据
            var doctorModel = new DoctorModel
            {
                DoctorGuid         = userModel.UserGuid,
                HospitalGuid       = request.HospitalGuid,
                OfficeGuid         = request.OfficeGuid,
                WorkCity           = string.Join('-', request.WorkCity),
                PractisingHospital = request.PractisingHospital,
                Honor         = request.Honor,
                Background    = request.Background,
                TitleGuid     = request.TitleGuid,
                AdeptTags     = Newtonsoft.Json.JsonConvert.SerializeObject(request.AdeptTags),
                Status        = DoctorModel.StatusEnum.Approved.ToString(),
                SignatureGuid = string.Empty,
                CreatedBy     = userModel.UserGuid,
                OrgGuid       = string.Empty,
                LastUpdatedBy = userModel.UserGuid,
                PortraitGuid  = request.PortraitGuid,
                //HospitalName = string.Empty,
                //OfficeName = string.Empty,
                CreationDate  = DateTime.Now,
                IsRecommend   = request.IsRecommend,
                RecommendSort = request.RecommendSort,
                Enable        = request.Enable,
                WorkAge       = request.WorkAge,
                JobNumber     = request.JobNumber
            };
            //医院名称
            var hospitalBiz   = new HospitalBiz();
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;
            //商户配置项证书信息 & 配置项证书附件信息
            var lstCertificate = request.Certificates.Select(item => new CertificateModel
            {
                CertificateGuid = Guid.NewGuid().ToString("N"),
                PictureGuid     = item.AccessoryGuid,
                OwnerGuid       = doctorModel.DoctorGuid,
                DicGuid         = item.DicGuid,
                CreatedBy       = UserID,
                OrgGuid         = string.Empty,
                LastUpdatedBy   = UserID
            });
            var result = await doctorBiz.AddDoctorAsync(doctorModel, userModel, userIsInsert, lstCertificate);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
            }
            return(Success());
        }
コード例 #10
0
        public async Task <IActionResult> UpdateDoctorInfoAsync([FromBody] UpdateDoctorInfoRequestDto request)
        {
            var doctorBiz   = new DoctorBiz();
            var doctorModel = await doctorBiz.GetAsync(request.DoctorGuid);

            if (doctorModel == null)
            {
                return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!"));
            }
            var userModel = await new UserBiz().GetAsync(request.DoctorGuid);

            if (userModel.Phone != request.Phone)
            {
                UserModel userPhoneModel = await new UserBiz().GetByPnoneAsync(request.Phone);
                if (userPhoneModel != null)
                {
                    return(Failed(ErrorCode.UserData, "用户手机已注册!"));
                }
            }

            var existNumber = await doctorBiz.ExistJobNumber(request.JobNumber, doctorModel.DoctorGuid);

            if (existNumber)
            {
                return(Failed(ErrorCode.DataBaseError, $"工号【{request.JobNumber}】已存在"));
            }

            userModel.UserName        = request.UserName;
            userModel.IdentityNumber  = request.IdentityNumber;
            userModel.Birthday        = request.Birthday;
            userModel.Gender          = request.Gender;
            userModel.Phone           = request.Phone;
            userModel.LastUpdatedBy   = UserID;
            userModel.LastUpdatedDate = DateTime.Now;

            //医生数据
            doctorModel.HospitalGuid       = request.HospitalGuid;
            doctorModel.OfficeGuid         = request.OfficeGuid;
            doctorModel.WorkCity           = string.Join('-', request.WorkCity);
            doctorModel.JobNumber          = request.JobNumber;
            doctorModel.PractisingHospital = request.PractisingHospital;
            doctorModel.Honor           = request.Honor;
            doctorModel.Background      = request.Background;
            doctorModel.TitleGuid       = request.TitleGuid;
            doctorModel.AdeptTags       = Newtonsoft.Json.JsonConvert.SerializeObject(request.AdeptTags);
            doctorModel.IsRecommend     = request.IsRecommend;
            doctorModel.RecommendSort   = request.RecommendSort;
            doctorModel.LastUpdatedBy   = UserID;
            doctorModel.LastUpdatedDate = DateTime.Now;
            doctorModel.PortraitGuid    = request.PortraitGuid;

            //医院名称
            var hospitalBiz   = new HospitalBiz();
            var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid);

            if (hospitalModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到医院数据"));
            }
            doctorModel.HospitalName = hospitalModel?.HosName;
            //科室名称
            var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid);

            if (officeModel == null)
            {
                return(Failed(ErrorCode.Empty, "未查到科室数据"));
            }
            doctorModel.OfficeName = officeModel?.OfficeName;
            //商户配置项证书信息 & 配置项证书附件信息
            var            clientDicGuids = request.Certificates.Select(b => b.DicGuid);
            CertificateBiz certificateBiz = new CertificateBiz();
            var            dbCertificate  = await certificateBiz.GetListAsync(doctorModel.DoctorGuid);

            var dbDicGuids = dbCertificate.Select(b => b.DicGuid);

            var updateCertificate = dbCertificate.Where(a => clientDicGuids.Contains(a.DicGuid)).Select(a =>
            {
                var cc            = request.Certificates.FirstOrDefault(c => c.DicGuid == a.DicGuid);
                a.PictureGuid     = cc.AccessoryGuid;
                a.LastUpdatedBy   = UserID;
                a.LastUpdatedDate = DateTime.Now;
                return(a);
            });
            var addCertificate = request.Certificates.Where(a => !dbDicGuids.Contains(a.DicGuid)).Select(item => new CertificateModel
            {
                CertificateGuid = Guid.NewGuid().ToString("N"),
                PictureGuid     = item.AccessoryGuid,
                OwnerGuid       = doctorModel.DoctorGuid,
                DicGuid         = item.DicGuid,
                CreatedBy       = UserID,
                OrgGuid         = string.Empty,
                LastUpdatedBy   = UserID
            });
            var delCertificate = dbCertificate.Where(a => !clientDicGuids.Contains(a.DicGuid));
            var result         = await doctorBiz.UpdateDoctorAsync(doctorModel, userModel, addCertificate, delCertificate, updateCertificate);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "医生数据修改失败!"));
            }
            return(Success());
        }
コード例 #11
0
        public async Task <IActionResult> EvaluvationAsync([FromBody] CreateHospitalEvaluvationRequestDto request)
        {
            if (request.Tags.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "评价标签必填"));
            }

            var tag = string.Join("", request.Tags);

            if (tag.Length > 500)
            {
                return(Failed(ErrorCode.Empty, "评价标签超过最大长度限制"));
            }

            if (request.Score <= 0 || request.Score > 5)
            {
                return(Failed(ErrorCode.Empty, "满意度参数不正确"));
            }

            var hospitalBiz = new HospitalBiz();
            var hospital    = await hospitalBiz.GetAsync(request.HospitalGuid);

            if (hospital is null)
            {
                return(Failed(ErrorCode.Empty, "医院不存在,请检查提交参数"));
            }

            if (!hospital.Enable)
            {
                return(Failed(ErrorCode.Empty, $"医院“{hospital.HosName}”已被禁用,无法提交"));
            }

            var officeBiz = new OfficeBiz();
            var office    = await officeBiz.GetAsync(request.OfficeGuid);

            if (office is null)
            {
                return(Failed(ErrorCode.Empty, "科室不存在,请检查提交参数"));
            }

            if (!office.Enable)
            {
                return(Failed(ErrorCode.Empty, $"科室“{office.OfficeName}”已被禁用,无法提交"));
            }

            if (!office.HospitalGuid.Equals(hospital.HospitalGuid))
            {
                return(Failed(ErrorCode.Empty, $"科室“{office.OfficeName}”不属于医院“{hospital.HosName}”,无法提交"));
            }

            var evaluationBiz = new HospitalEvaluationBiz();
            var evaluvation   = await evaluationBiz.GetAsync(request.EvaluationGuid);

            if (evaluvation is null)
            {
                return(Failed(ErrorCode.Empty, "预评论参数不正确,请检查"));
            }

            if (!string.IsNullOrEmpty(evaluvation.UserGuid))
            {
                return(Failed(ErrorCode.Empty, "已提交,请勿重复提交"));
            }

            evaluvation.UserGuid        = UserID;
            evaluvation.HospitalGuid    = hospital.HospitalGuid;
            evaluvation.OfficeGuid      = office.OfficeGuid;
            evaluvation.EvaluationTag   = JsonConvert.SerializeObject(request.Tags);
            evaluvation.Score           = request.Score;
            evaluvation.ConditionDetail = request.ConditionDetail;
            evaluvation.Anonymous       = request.Anonymous;
            evaluvation.CreatedBy       = UserID;
            evaluvation.LastUpdatedBy   = UserID;

            var result = await evaluationBiz.UpdateAsync(evaluvation);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "提交评论失败,请稍后重试"));
            }
            return(Success());
        }
コード例 #12
0
        public async Task <IActionResult> GetUserWeChatQRCodeAsync(string hospiltalGuid)
        {
            if (string.IsNullOrEmpty(hospiltalGuid))
            {
                return(Failed(ErrorCode.Empty, "参数不正确"));
            }

            var hosiptalBiz = new HospitalBiz();
            var hospital    = await hosiptalBiz.GetAsync(hospiltalGuid);

            if (hospital is null)
            {
                return(Failed(ErrorCode.Empty, "对应医院不存在,请检查参数"));
            }

            if (!hospital.Enable)
            {
                return(Failed(ErrorCode.Empty, $"医院“{hospital.HosName}”已被禁用"));
            }

            var tokenResult = await WeChartApi.GetAccessToken(PlatformSettings.CDClientAppId, PlatformSettings.CDClientAppSecret);

            if (tokenResult.Errcode != 0)
            {
                Logger.Error($"GD.API.Controllers.System.{nameof(UserController)}.{nameof(GetUserWeChatQRCodeAsync)}({hospiltalGuid})-- 获取云医用户端token失败  {Environment.NewLine} {tokenResult.Errmsg}");
                return(Failed(ErrorCode.SystemException, "获取云医用户端token失败"));
            }

            var qrcodeResult = (CreateQRCodeResponseDto)null;

            var sceneBiz = new WechatSceneBiz();

            var scene = await sceneBiz.GetAsync(hospiltalGuid);

            if (scene is null)
            {
                var param = new CreateTemporaryQRCodeRequestDto
                {
                    ActionName = ActionNameEnum.QR_LIMIT_STR_SCENE.ToString(),
                    ActionInfo = new QRCodeActionInfo
                    {
                        Scene = new QRCodeActionInfoStringScene
                        {
                            SceneStr = hospiltalGuid
                        }
                    }
                };

                qrcodeResult = await WeChartApi.CreateQRCodeAsync(param, tokenResult.AccessToken);

                scene = new WechatSceneModel()
                {
                    SceneId   = hospiltalGuid,
                    Action    = WeChatSceneActionEnum.pay.ToString(),
                    SceneName = "扫码缴费",
                    Extension = JsonConvert.SerializeObject(new
                    {
                        value = hospiltalGuid,
                        url   = qrcodeResult.Url,
                        name  = HttpUtility.UrlEncode(hospital.HosName)
                    }),
                    CreatedBy     = UserID,
                    LastUpdatedBy = UserID
                };

                var result = await sceneBiz.InsertAsync(scene);

                if (!result)
                {
                    return(Failed(ErrorCode.Empty, "生成二维码场景参数失败,请稍后重试"));
                }
            }
            else
            {
                dynamic extension = JObject.Parse(scene.Extension);
                qrcodeResult = new CreateQRCodeResponseDto()
                {
                    Errcode = 0,
                    Url     = (string)extension.url
                };
            }

            return(Success(qrcodeResult));
        }