Exemple #1
0
        /// <summary>
        /// 取消关注
        /// </summary>
        /// <param name="requestDoc"></param>
        /// <returns></returns>
        public async Task <ObjectResultModule> UnFocusOn(XDocument requestDoc)
        {
            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                //取消关注
                var openid = JsonHelper.GetXmlValue(requestDoc, "FromUserName");
                if (openid == null)
                {
                    return(new ObjectResultModule("", 401, ""));
                }
                // SystemToken systemToken = new SystemToken();
                // systemToken.TokenType = "Wechar";
                var    Tokens       = _systemTokenService.SystemTokenList("Wechar").Result;
                string access_token = Tokens.access_token;
                var    UserInfo     = await _yaeherUserService.YaeherUserByExpress(a => a.WecharOpenID == openid && a.IsDelete == false);

                if (UserInfo != null)
                {
                    YaeherUser yaeherUser = UserInfo;
                    yaeherUser.IsLabel         = false;
                    yaeherUser.IsPay           = false;
                    yaeherUser.IsUpdate        = false;
                    yaeherUser.IsProfitSharing = false;
                    UserInfo = await _yaeherUserService.UpdateYaeherUser(yaeherUser);
                }
                unitOfWork.Complete();
            }
            return(new ObjectResultModule("", 200, ""));
        }
Exemple #2
0
        private ClaimsIdentity GenerateUserIdentity(YaeherUser user, SystemConfig.UserManager userManager, string authenticationType)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            string     userdata   = "";
            UserMemory userMemory = new UserMemory();

            userMemory.WecharOpenID   = user.WecharOpenID;
            userMemory.MobileRoleName = user.RoleName;
            if (userManager != null)
            {
                userMemory.IsAdmin           = userManager.IsAdmin;
                userMemory.IsCustomerService = userManager.IsCustomerService;
                userMemory.IsDoctor          = userManager.IsDoctor;
                userMemory.IsQC     = userManager.IsQC;
                userMemory.DoctorID = userManager.YaeherUserInfo.RoleName == "doctor" ? userManager.YaeherDoctorInfo.Id : 0;
            }
            userdata = JsonHelper.ToJson(userMemory);
            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
                new Claim(ClaimsIdentity.DefaultNameClaimType, string.IsNullOrEmpty(user.LoginName)?"":user.LoginName),
                new Claim(ClaimTypes.Role, string.IsNullOrEmpty(user.RoleName)?"":user.RoleName),
                new Claim(ClaimTypes.UserData, userdata),
            };
            var identity = new ClaimsIdentity(claims, authenticationType, ClaimsIdentity.DefaultNameClaimType,
                                              ClaimsIdentity.DefaultRoleClaimType);

            return(identity);
        }
        public virtual ClaimsIdentity Create(YaeherUser user, string authenticationType)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            var claims = new[]
            {
                new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
                new Claim(ClaimsIdentity.DefaultNameClaimType, user.LoginName),
                new Claim(ClaimTypes.Email, user.Email),
                new Claim(ClaimTypes.Name, user.LoginName),
            };
            var identity = new ClaimsIdentity(claims, authenticationType, ClaimsIdentity.DefaultNameClaimType,
                                              ClaimsIdentity.DefaultRoleClaimType);

            return(identity);
        }
 //public YaeherDoctorUser(YaeherDoctor doctor, YaeherUser user, List<SystemParameter> paramlist)
 //{
 //    DoctorName = doctor.DoctorName;
 //    UserID = doctor.UserID;
 //    Address = doctor.Address;
 //    HospitalName = doctor.HospitalName;
 //    Department = doctor.Department;
 //    WorkYear = doctor.WorkYear;
 //    Title = doctor.Title;
 //    GraduateSchool = doctor.GraduateSchool;
 //    IsBelieveTCM = doctor.IsBelieveTCM;
 //    IsServiceConscious = doctor.IsServiceConscious;
 //    WechatNum = doctor.WechatNum;
 //    PhoneNumber = doctor.PhoneNumber;
 //    Recommender = doctor.Recommender;
 //    CheckRes = doctor.CheckRes;
 //    Checker = doctor.Checker;
 //    AuthType = string.IsNullOrEmpty(doctor.AuthType) ? "" : paramlist.Find(t => t.Code == doctor.AuthType).Name;
 //    CheckRemark = doctor.CheckRemark;
 //    CheckTime = doctor.CheckTime;
 //    TsetTime = doctor.TsetTime;
 //    TestID = doctor.TestID;
 //    BaseTestRes = doctor.BaseTestRes;
 //    SimTestRes = doctor.SimTestRes;
 //    AuthCheckRes = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : paramlist.Find(t => t.Code == doctor.AuthCheckRes).Name;
 //    AuthCheckResCode = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : doctor.AuthCheckRes;
 //    AuthChecker = doctor.AuthChecker;
 //    AuthCheckRemark = doctor.AuthCheckRemark;
 //    AuthCheckTime = doctor.AuthCheckTime;
 //    CreatedOn = doctor.CreatedOn;
 //    UserImage = user.UserImage;
 //    CreatedOnUtc = doctor.CreatedOn.ToString("yyyy-MM-ddTHH:mm:ss");
 //    Id = doctor.Id;
 //    Resume = doctor.Resume;
 //    Sex = user.Sex;
 //    AuthType = doctor.AuthType;
 //    UserImageFile = doctor.UserImageFile;
 //}
 public YaeherDoctorUser(YaeherDoctor doctor, YaeherUser user, List <SystemParameter> paramlist, IList <DoctorFileApply> file, List <SystemParameter> paramlist1)
 {
     AuthType           = string.IsNullOrEmpty(doctor.AuthType) ? "" : paramlist1.Find(t => t.Code == doctor.AuthType).Name;
     File               = file;
     DoctorName         = doctor.DoctorName;
     UserID             = doctor.UserID;
     Address            = doctor.Address;
     HospitalName       = doctor.HospitalName;
     Department         = doctor.Department;
     WorkYear           = doctor.WorkYear;
     Title              = doctor.Title;
     GraduateSchool     = doctor.GraduateSchool;
     IsBelieveTCM       = doctor.IsBelieveTCM;
     IsServiceConscious = doctor.IsServiceConscious;
     WechatNum          = doctor.WechatNum;
     PhoneNumber        = doctor.PhoneNumber;
     Recommender        = doctor.Recommender;
     CheckRes           = doctor.CheckRes;
     Checker            = doctor.Checker;
     CheckRemark        = doctor.CheckRemark;
     CheckTime          = doctor.CheckTime;
     TsetTime           = doctor.TsetTime;
     TestID             = doctor.TestID;
     BaseTestRes        = doctor.BaseTestRes;
     SimTestRes         = doctor.SimTestRes;
     AuthCheckRes       = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : paramlist.Find(t => t.Code == doctor.AuthCheckRes).Name;
     AuthCheckResCode   = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : doctor.AuthCheckRes;
     AuthChecker        = doctor.AuthChecker;
     AuthCheckRemark    = doctor.AuthCheckRemark;
     AuthCheckTime      = doctor.AuthCheckTime;
     CreatedOn          = doctor.CreatedOn;
     UserImage          = user.UserImage;
     IDCard             = doctor.IDCard;
     CreatedOn          = doctor.CreatedOn;
     Id            = doctor.Id;
     Resume        = doctor.Resume;
     Sex           = user.Sex;
     UserImageFile = doctor.UserImageFile;
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 public YaeherDoctorUser(YaeherDoctor doctor, YaeherUser user, List <SystemParameter> paramlist, QualityCommittee quality)
 {
     DoctorName         = doctor.DoctorName;
     UserID             = doctor.UserID;
     Address            = doctor.Address;
     HospitalName       = doctor.HospitalName;
     Department         = doctor.Department;
     WorkYear           = doctor.WorkYear;
     Title              = doctor.Title;
     GraduateSchool     = doctor.GraduateSchool;
     IsBelieveTCM       = doctor.IsBelieveTCM;
     IsServiceConscious = doctor.IsServiceConscious;
     WechatNum          = doctor.WechatNum;
     PhoneNumber        = doctor.PhoneNumber;
     Recommender        = doctor.Recommender;
     CheckRes           = doctor.CheckRes;
     Checker            = doctor.Checker;
     CheckRemark        = doctor.CheckRemark;
     CheckTime          = doctor.CheckTime;
     TsetTime           = doctor.TsetTime;
     TestID             = doctor.TestID;
     BaseTestRes        = doctor.BaseTestRes;
     SimTestRes         = doctor.SimTestRes;
     AuthCheckRes       = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : paramlist.Find(t => t.Code == doctor.AuthCheckRes).Name;
     AuthCheckResCode   = string.IsNullOrEmpty(doctor.AuthCheckRes) ? "unupload" : doctor.AuthCheckRes;
     AuthChecker        = doctor.AuthChecker;
     AuthCheckRemark    = doctor.AuthCheckRemark;
     AuthCheckTime      = doctor.AuthCheckTime;
     CreatedOn          = doctor.CreatedOn;
     UserImage          = user.UserImage;
     CreatedOn          = doctor.CreatedOn;
     Id            = doctor.Id;
     Resume        = doctor.Resume;
     Sex           = user.Sex;
     AuthType      = doctor.AuthType;
     UserImageFile = doctor.UserImageFile;
     IsQuality     = (quality == null || quality.QualityState == "close") ? false : true;
 }
Exemple #6
0
        /// <summary>
        /// 接受消息
        /// </summary>
        /// <param name="requestDoc"></param>
        /// <returns></returns>
        public async Task <ObjectResultModule> AcceptWechar(XDocument requestDoc)
        {
            using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                // 将接收到的消息存储
                AcceptTencentWechar acceptTencentWechar = new AcceptTencentWechar();
                acceptTencentWechar.ToUserName   = JsonHelper.GetXmlValue(requestDoc, "ToUserName");
                acceptTencentWechar.FromUserName = JsonHelper.GetXmlValue(requestDoc, "FromUserName");
                acceptTencentWechar.CreateTime   = JsonHelper.GetXmlValue(requestDoc, "CreateTime");
                acceptTencentWechar.MsgType      = JsonHelper.GetXmlValue(requestDoc, "MsgType");
                acceptTencentWechar.Content      = JsonHelper.GetXmlValue(requestDoc, "Content");
                acceptTencentWechar.PicUrl       = JsonHelper.GetXmlValue(requestDoc, "PicUrl");
                acceptTencentWechar.MediaId      = JsonHelper.GetXmlValue(requestDoc, "MediaId");
                acceptTencentWechar.ThumbMediaId = JsonHelper.GetXmlValue(requestDoc, "ThumbMediaId");
                acceptTencentWechar.Format       = JsonHelper.GetXmlValue(requestDoc, "Format");
                acceptTencentWechar.Recognition  = JsonHelper.GetXmlValue(requestDoc, "Recognition");
                acceptTencentWechar.Title        = JsonHelper.GetXmlValue(requestDoc, "Title");
                acceptTencentWechar.Description  = JsonHelper.GetXmlValue(requestDoc, "Description");
                acceptTencentWechar.Url          = JsonHelper.GetXmlValue(requestDoc, "Url");
                acceptTencentWechar.Location_X   = JsonHelper.GetXmlValue(requestDoc, "Location_X");
                acceptTencentWechar.Location_Y   = JsonHelper.GetXmlValue(requestDoc, "Location_Y");
                acceptTencentWechar.Scale        = JsonHelper.GetXmlValue(requestDoc, "Scale");
                acceptTencentWechar.Label        = JsonHelper.GetXmlValue(requestDoc, "Label");
                acceptTencentWechar.MsgId        = JsonHelper.GetXmlValue(requestDoc, "MsgId");
                acceptTencentWechar.MessageFrom  = "Consultant";
                if (acceptTencentWechar.FromUserName == null)
                {
                    return(new ObjectResultModule("", 401, ""));
                }
                // SystemToken systemToken = new SystemToken();
                //  systemToken.TokenType = "Wechar";
                var    Tokens       = _systemTokenService.SystemTokenList("Wechar").Result;
                string access_token = Tokens.access_token;
                // 检测用户信息
                YaeherUser YaerherUser = new YaeherUser();
                try
                {
                    TencentUserManage usermanage = new TencentUserManage();
                    var usermsg = usermanage.WeiXinUserInfoUtils(acceptTencentWechar.FromUserName, Tokens.access_token).Result;
                    if (usermsg.subscribe != 0)
                    {
                        string OperType = "用户咨询客服";
                        YaerherUser = await _yaeherUserService.YaeherUserInfo(usermsg, access_token, OperType);

                        #region 检测发送消息状态
                        acceptTencentWechar.FullName  = YaerherUser.FullName;  // 用户全称
                        acceptTencentWechar.CreatedBy = YaerherUser.Id;        // 用户ID
                        acceptTencentWechar.UserImage = YaerherUser.UserImage; // 增加用户图像
                        acceptTencentWechar.NickName  = YaerherUser.NickName;  // 增加用户昵称
                        //检测是否客服跟进
                        AcceptWecharStateIn acceptWecharStateIn = new AcceptWecharStateIn();
                        acceptWecharStateIn.AndAlso(a => a.ConsultantOpenID == acceptTencentWechar.FromUserName);
                        var StateList = await _acceptWecharStateService.WecharStateList(acceptWecharStateIn);

                        AcceptWecharState acceptWecharState = StateList.FirstOrDefault();
                        bool   OverTime    = false;
                        string AcceptState = string.Empty;
                        if (acceptWecharState != null)
                        {
                            OverTime    = acceptWecharState.AcceptTime.AddHours(2) < DateTime.Now;
                            AcceptState = acceptWecharState.AcceptState;
                            if (OverTime == true || acceptWecharState.AcceptState == "3")
                            {
                                // 需要根据当前客服排班记录查询
                                acceptWecharState.CustomerServiceID   = 0;
                                acceptWecharState.CustomerServiceName = "客服";
                                acceptWecharState.CustomerServiceJson = "客服";
                            }
                            acceptWecharState.AcceptState    = "2";
                            acceptWecharState.UserImage      = YaerherUser.UserImage; // 增加用户图像
                            acceptWecharState.NickName       = YaerherUser.NickName;  // 增加用户昵称
                            acceptWecharState.ConsultantID   = YaerherUser.Id;
                            acceptWecharState.ConsultantName = YaerherUser.FullName;
                            acceptWecharState.ConsultantJSON = JsonHelper.ToJson(YaerherUser);
                            acceptWecharState.IsReady        = false;
                            acceptWecharState.AcceptTime     = DateTime.Now;
                            var UpdateState = await _acceptWecharStateService.UpdateAcceptWecharState(acceptWecharState);
                        }
                        else
                        {
                            AcceptWecharState WecharState = new AcceptWecharState();
                            // 需要根据当前客服排班记录查询
                            WecharState.CustomerServiceID   = 0;
                            WecharState.CustomerServiceName = "客服";
                            WecharState.CustomerServiceJson = "客服";
                            WecharState.UserImage           = YaerherUser.UserImage; // 增加用户图像
                            WecharState.NickName            = YaerherUser.NickName;  // 增加用户昵称
                            WecharState.ConsultantID        = YaerherUser.Id;
                            WecharState.ConsultantName      = YaerherUser.FullName;
                            WecharState.ConsultantJSON      = JsonHelper.ToJson(YaerherUser);
                            WecharState.ConsultantOpenID    = acceptTencentWechar.FromUserName;
                            WecharState.AcceptState         = "2";
                            WecharState.IsReady             = false;
                            WecharState.AcceptTime          = DateTime.Now;
                            //插入回复状态
                            var CreateState = await _acceptWecharStateService.CreateAcceptWecharState(WecharState);
                        }
                        #endregion
                        // 插入接受消息
                        var Result = await _acceptTencentWecharService.CreateAcceptTencent(acceptTencentWechar);

                        #region 关键字检索
                        string Content = string.Empty;
                        // 将特殊符过滤掉
                        string KeyWord = new StringHepler().FilterString(acceptTencentWechar.Content).Trim();
                        if (string.IsNullOrEmpty(KeyWord))
                        {
                            Content = null;
                        }
                        else
                        {
                            Content = _acceptTencentWecharService.SendWecharMesaage(KeyWord).Result;
                        }
                        if (string.IsNullOrEmpty(Content))
                        {
                            Content = null;
                        }
                        #endregion
                        // 当没客服跟进时先发送一条短信
                        if (acceptWecharState == null || AcceptState == "3" || OverTime || Content != null)
                        {
                            StringBuilder Contentsb = new StringBuilder();
                            Contentsb.Append("<a href=\"https://mp.weixin.qq.com/s/20iAOwP8Gzrq3zCdwMASng\">客服常见问题</a>\n");
                            Contentsb.Append("\n");
                            Contentsb.Append("客服工作时间: \n");
                            Contentsb.Append("周一到周五 9:00-17:30 \n");
                            Contentsb.Append("收到消息后我们会尽快反馈。\n");
                            Contentsb.Append("非工作时间请留言。\n");
                            // 增加问医生
                            Contentsb.Append("\n");
                            Contentsb.Append("<a href=\"" + Commons.WecharWeb + "?link=index-patient\">查看所有医生</a>    ");
                            if (Content != null)
                            {
                                StringBuilder stringBuilder = new StringBuilder();
                                stringBuilder.Append(Content);
                                // 增加问医生
                                stringBuilder.Append("\n");
                                stringBuilder.Append("<a href=\"" + Commons.WecharWeb + "?link=index-patient\">查看所有医生</a>    ");

                                Content = stringBuilder.ToString();
                            }

                            // 回复消息
                            var textSingleMessage = new TextSingleMessage()
                            {
                                ToUser      = acceptTencentWechar.FromUserName,
                                TextContent = Content == null?Contentsb.ToString() : Content
                            };
                            textSingleMessage.Send(Tokens.access_token).ToString();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Info("我是一个发送消息的错误:" + ex.ToString() + "DateTime:" + DateTime.Now);
                }
                unitOfWork.Complete();
            }
            return(new ObjectResultModule("", 200, ""));
        }
Exemple #7
0
        /// <summary>
        /// 患者微信支付下订单
        /// </summary>
        /// <returns></returns>
        public async Task <TencentJSPayRequestModel> UnifiedorderAsync(bool sharing, string spbillCreateIp, YaeherConsultation consul, YaeherUser user, ServiceMoneyList product, SystemConfigs tencentparam)
        {
            TencentJSPayRequestModel jspay = new TencentJSPayRequestModel();

            try
            {
                TenPayV3Info tenPayV3Info = new TenPayV3Info(tencentparam.AppID, tencentparam.AppSecret, tencentparam.TenPayMchId, tencentparam.TenPayKey, tencentparam.TenPayNotify, tencentparam.TenPayWxOpenNotify);

                //生成订单10位序列号,此处用时间和随机数生成,商户根据自己调整,保证唯一
                //  var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
                // var sjs =;//随机数
                var sjs       = consul.ConsultNumber.Substring(3, consul.ConsultNumber.Length - 3) + TenPayV3Util.BuildRandomStr(6);
                var sp_billno = sjs;
                //   var sp_billno = string.Format("{0}{1}", sjs, user.Id);
                var shortbillno = sp_billno;

                TenPayInfo tenPayInfo = new TenPayInfo();
                //   var body = product == null ? "怡芽问诊" : product.DoctorName+"医生" + product.ServiceType;
                var body      = "怡禾健康咨询";
                var price     = product == null ? 100 : (int)(product.ServiceExpense * 100);//单位:分
                var timeStamp = TenPayV3Util.GetTimestamp();
                var nonceStr  = TenPayV3Util.GetNoncestr();

                var xmlDataInfo = new TenPayV3UnifiedorderRequestData(tenPayV3Info.AppId, tenPayV3Info.MchId, body, sp_billno, price, spbillCreateIp, tenPayV3Info.TenPayV3Notify, TenPayV3Type.JSAPI, user.WecharOpenID, tenPayV3Info.Key, nonceStr);
                //CreateWrite("C:\\回调.txt", "订单参数:" + JsonHelper.ToJson(xmlDataInfo));
                var result = await UnifiedorderAsync(xmlDataInfo, sharing? "Y" : "N"); //调用统一订单接口

                //JsSdkUiPackage jsPackage = new JsSdkUiPackage(TenPayV3Info.AppId, timeStamp, nonceStr,);

                if (result.IsResultCodeSuccess())
                {
                    var package = string.Format("prepay_id={0}", result.prepay_id);
                    var paysign = TenPayV3.GetJsPaySign(tenPayV3Info.AppId, timeStamp, nonceStr, package, tenPayV3Info.Key);

                    jspay.product   = product;
                    jspay.timeStamp = timeStamp;
                    jspay.nonceStr  = nonceStr;
                    jspay.package   = package;
                    jspay.paySign   = paysign;
                    jspay.appid     = tenPayV3Info.AppId;
                    jspay.sp_billno = shortbillno;
                    jspay.code      = result.result_code;
                    jspay.msg       = result.return_msg;
                }
                else
                {
                    jspay.code = result.result_code;
                    jspay.msg  = result.return_msg;
                }
            }
            catch (Exception ex)
            {
                jspay.code = "FAIL";
                jspay.msg  = ex.Message.ToString();
            }
            return(jspay);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <param name="doctor"></param>
 /// <param name="user"></param>
 ///  <param name="typelist1"></param>
 ///  <param name="doctorFileApplies"></param>
 public DoctorClinicApplyOutDetail(DoctorClinicApply item, YaeherDoctor doctor, YaeherUser user, List <SystemParameter> typelist1, List <DoctorFileApply> doctorFileApplies)
 {
     UserImage                = user.UserImage;
     DoctorName               = item.DoctorName;
     DoctorID                 = item.DoctorID;
     ApplyType                = item.ApplyType;
     ClinicID                 = item.ClinicID;
     ClinicName               = item.ClinicName;
     ApplyRemark              = item.ApplyRemark;
     CheckTime                = item.CheckTime;
     CheckRemark              = item.CheckRemark;
     Id                       = item.Id;
     CreatedOn                = item.CreatedOn;
     CheckResCode             = item.CheckRes;
     CheckRes                 = typelist1.Find(t => t.Code == item.CheckRes).Name;
     Certificateofpractice    = doctorFileApplies.Count > 0? doctorFileApplies.Find(t => t.TypeDetail == "Certificateofpractice").Address:"";
     Qualificationcertificate = doctorFileApplies.Count > 0 ? doctorFileApplies.Find(t => t.TypeDetail == "Qualificationcertificate").Address : "";
 }
Exemple #9
0
        /// <summary>
        /// 输出模型
        /// </summary>
        /// <param name="quality"></param>
        /// <param name="item"></param>
        /// <param name="hasCollect"></param>
        /// <param name="consultationfile"></param>
        /// <param name="reply"></param>
        /// <param name="doctor"></param>
        /// <param name="eva"></param>
        /// <param name="serverid"></param>
        /// <param name="IIIness"></param>
        ///  <param name="paramlist"></param>
        public QualityControlManageOutDetail(QualityControlManage quality, YaeherConsultation item, bool hasCollect, IList <ReplyDetail> consultationfile, IList <ReplyDetail> reply, YaeherUser doctor, IList <ConsultationEvaluation> eva, int serverid, int IIIness, List <SystemParameter> paramlist)
        {
            Id                      = quality.Id;
            Sex                     = JsonHelper.FromJson <YaeherPatientLeaguerInfo>(item.PatientJSON).Sex;
            QualityLevel            = quality.QualityLevel;
            RepayIllnessDescription = quality.RepayIllnessDescription;
            ReplyState              = quality.ReplyState;
            IsReturnVisit           = item.IsReturnVisit;
            HasCollect              = hasCollect;
            CreatedBy               = item.CreatedBy;
            CreatedOn               = item.CreatedOn;
            UserImage               = doctor.UserImage;
            ConsultNumber           = item.ConsultNumber;
            ConsultantID            = item.ConsultantID;
            ConsultantName          = item.ConsultantName;
            ConsultantJSON          = item.ConsultantJSON;
            DoctorName              = item.DoctorName;
            DoctorID                = item.DoctorID;
            DoctorJSON              = item.DoctorJSON;
            PatientID               = item.PatientID;
            PatientName             = item.PatientName;
            PatientJSON             = item.PatientJSON;
            ConsultType             = item.ConsultType;
            IIInessType             = item.IIInessType;
            IIInessId               = IIIness;
            IIInessJSON             = item.IIInessJSON;
            PhoneNumber             = item.PhoneNumber;
            PatientCity             = item.PatientCity;
            IIInessDescription      = item.IIInessDescription;
            InquiryTimes            = item.InquiryTimes;
            ConsultState            = item.ConsultState;
            OvertimeRemindTimes     = item.OvertimeRemindTimes;
            Overtime                = item.Overtime;
            RefundBy                = item.RefundBy;
            RefundTime              = item.RefundTime;
            RefundType              = item.RefundType;
            RefundNumber            = item.RefundNumber;
            RefundState             = item.RefundState;
            RefundReason            = item.RefundReason;
            RefundRemarks           = item.RefundRemarks;
            RecommendDoctorName     = item.RecommendDoctorName;
            RecommendDoctorID       = item.RecommendDoctorID;
            QualityDoctor           = quality.DoctorName;
            Age                     = item.Age;
            Replys                  = reply.OrderBy(t => t.CreatedOn).ToList();
            Consultationfile        = consultationfile.ToList();
            TimeSpan ts = DateTime.UtcNow.Subtract(item.CreatedOn);

            if (ts.TotalMinutes >= 3 || Replys.Count > 0)
            {
                Canhargeback = false;
            }
            else
            {
                Canhargeback = true;
            }
            var replycount = reply.Where(t => t.Message != "" && t.Message != null && t.ReplyType == "inquiries").ToList();

            ReplysCount           = 2 - replycount.Count > 0 ? 2 - replycount.Count : 0;
            ConsulationStatusCode = item.ConsultState;
            ConsultState          = paramlist.Find(t => t.Code == item.ConsultState).Name;
            if (item.ConsultState == "consulting")
            {
                CanReplys = true;
            }
            else
            {
                CanReplys = false;
            }
            if (item.ConsultState == "success" && !HasEvaluation)
            {
                CanEvaluation = true;
            }
            else
            {
                CanEvaluation = false;
            }
            if (item.ConsultState == "success" || item.ConsultState == "return")
            {
                CanDelete = true;
            }
            else
            {
                CanDelete = false;
            }
            if (ReplysCount < 1)
            {
                CanReplys = false;
            }
            HasEvaluation      = item.IsEvaluate;
            ReturnVisit        = item.ReturnVisit;
            EvaluationId       = eva.Count > 0 ? eva[0].Id : 0;
            ServiceMoneyListID = serverid;
            HasAllergic        = JsonHelper.FromJson <YaeherPatientLeaguerInfo>(item.PatientJSON).HasAllergic;
            AllergicHistory    = JsonHelper.FromJson <YaeherPatientLeaguerInfo>(item.PatientJSON).AllergicHistory;
        }
Exemple #10
0
        public async Task <ObjectResultModule> Authenticate([FromBody] AuthenticateModel model)
        {
            try
            {
                ///配置文件判断来源
                ///1.当来源于Patient 患者端,开启http请求到Admin管理端查询用户名密码进行匹配.
                ///2.当来源于Admin管理端或者Doctor医生端则直接查询数据库进行匹配
                if (!Commons.CheckSecret(model.Secret))
                {
                    return(new ObjectResultModule("", 422, "自签名错误!"));
                }
                YaeherUser        user       = null;
                TencentUserManage usermanage = new TencentUserManage();
                // 获取微信WecharToken
                // SystemToken systemToken = new SystemToken();
                //  systemToken.TokenType = "Wechar";

                string openid = "";
                if (!string.IsNullOrEmpty(model.WXCode))//微信code登陆
                {
                    var Tokens = await _systemTokenService.SystemTokenList("Wechar");

                    //Logger.Info("modelWXCode:"+JsonHelper.ToJson(model));
                    ///调用微信接口获取openid
                    ///查找数据库
                    TencentWeCharEntity tencentWeCharEntity = new TencentWeCharEntity();
                    SystemConfigsIn     systemConfigsIn     = new SystemConfigsIn();
                    systemConfigsIn.AndAlso(t => !t.IsDelete && t.SystemType == "TencentWechar");
                    var configs = await _systemConfigsService.SystemConfigsList(systemConfigsIn);

                    var tencentparam = configs.FirstOrDefault();
                    tencentWeCharEntity.grant_type = "authorization_code";
                    tencentWeCharEntity.appid      = tencentparam.AppID;
                    tencentWeCharEntity.secret     = tencentparam.AppSecret;
                    var usertoken = usermanage.WeiXinUserToken(model.WXCode, tencentWeCharEntity).Result;
                    if (usertoken == null || string.IsNullOrEmpty(usertoken.openid))
                    {
                        return(new ObjectResultModule("", 400, "获取用户信息失败!"));
                    }
                    openid = usertoken.openid;
                }
                else if (!string.IsNullOrEmpty(model.WecharOpenID))//微信openid登陆
                {
                    openid = model.WecharOpenID;
                }
                else
                {
                    if (_appConfiguration["Authentication:AUTHTO"] == "YaeherPatientAPI")//swagger登陆
                    {
                        var Content = "{\"LoginName\":\"" + model.UserNameOrEmailAddress + "\",\"LoginPwd\":\"" + model.Password + "\",\"Secret\":\"" + model.Secret + "\"}";
                        user = await UserAsync(_appConfiguration["Authentication:AUTHURL"], Content);
                    }
                    else//用户名密码登陆登陆
                    {
                        user = await _yaeherUserService.YaeherUserByExpress(t => (t.Email == model.UserNameOrEmailAddress || t.LoginName == model.UserNameOrEmailAddress || t.PhoneNumber == model.UserNameOrEmailAddress) &&
                                                                            t.LoginPwd == model.Password &&
                                                                            !t.IsDelete);
                    }
                    if (user == null || user.Id < 0)
                    {
                        return(new ObjectResultModule("Login failed", 400, "用户名或者密码错误!"));
                    }
                    if (!user.Enabled)
                    {
                        return(new ObjectResultModule("Login failed", 400, "用户账号没激活,请联系管理员!"));
                    }
                }
                SystemConfig.UserManager userManager = null;
                if (model.Platform == "PC")
                {
                    if (_appConfiguration["Authentication:AUTHTO"] != "YaeherPatientAPI")
                    {
                        userManager = _userManagerService.UserManager(user.Id);
                    }
                }
                else
                {
                    // 利用OPenID登陆
                    if (!string.IsNullOrEmpty(openid))
                    {
                        var Tokens = await _systemTokenService.SystemTokenList("Wechar");

                        try
                        {
                            var usermsg = usermanage.WeiXinUserInfoUtils(openid, Tokens.access_token).Result;
                            // 未关注不可进入系统
                            if (usermsg.subscribe != 0)
                            {
                                #region  步提交
                                //using (var unitOfWork = _unitOfWorkManager.Begin())
                                //{
                                //    TencentWXPay tencentWXPay = new TencentWXPay();
                                //    user = _yaeherUserService.YaeherUserInfo(openid, Tokens.access_token);
                                //    if (user.Id > 0)
                                //    {
                                //        user = await usermanage.YaeherUserLable(usermsg, user, Tokens.access_token);
                                //        if (!user.IsPay)
                                //        {
                                //            var payment = await _yaeherUserPaymentService.YaeherUserPaymentByUserID(user.Id);
                                //            if (payment == null || payment.Id < 1)
                                //            {
                                //                //http请求微信信息,获取账户的信息 新增用户payment
                                //                var CreateUserPayment = new YaeherUserPayment()
                                //                {
                                //                    UserID = user.Id,
                                //                    FullName = user.FullName,
                                //                    PayMethod = "wxpay",
                                //                    PayMethodName = "微信支付",
                                //                    PaymentAccout = user.WecharName,
                                //                    BankName = "wx",
                                //                    Subbranch = "wx",
                                //                    BandAdd = "wx",
                                //                    BankNo = "wx",
                                //                    CreatedOn = DateTime.Now,
                                //                    IsDefault = true,
                                //                };
                                //                CreateUserPayment = await _yaeherUserPaymentService.CreateYaeherUserPayment(CreateUserPayment);
                                //            }
                                //            user.IsPay = true;
                                //        }
                                //        if (!user.IsUpdate)
                                //        {
                                //            var DoctorInfo = await _yaeherDoctorService.YaeherDoctorByUserID(user.Id);
                                //            if (DoctorInfo != null && DoctorInfo.IsSharing && user.IsProfitSharing == false)   //医生角色切没有生成分账账号
                                //            {
                                //                //查询分账配置
                                //                SystemConfigsIn systemConfigsIn = new SystemConfigsIn();
                                //                systemConfigsIn.AndAlso(a => a.IsDelete == false);
                                //                systemConfigsIn.AndAlso(a => a.SystemType == "TencentWechar");
                                //                var configs = await _systemConfigsService.SystemConfigsList(systemConfigsIn);
                                //                // 查询医生信息
                                //                var tencentparam = configs.ToList().FirstOrDefault();
                                //                var receiver = new receiver();
                                //                receiver.name = DoctorInfo.DoctorName;
                                //                receiver.type = "PERSONAL_OPENID";
                                //                receiver.account = openid;
                                //                var addresult = tencentWXPay.ProfitSharingAddReceiver(receiver, tencentparam).Result;
                                //                if (addresult.result_code == "SUCCESS")  //插入成功后更新状态
                                //                {
                                //                    user.IsProfitSharing = true;
                                //                }
                                //            }
                                //        }
                                //        user = await _yaeherUserService.UpdateYaeherUser(user);
                                //    }
                                //    unitOfWork.Complete();
                                //}
                                #endregion
                                string OperType = "用户登陆";
                                user = await _yaeherUserService.YaeherUserInfo(usermsg, Tokens.access_token, OperType);
                            }
                            else
                            {
                                return(new ObjectResultModule("", 402, "用户未关注,请重新关注公众号!"));
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Info("我是一个通过页面进来的错误" + ex.ToString() + "DateTime:" + DateTime.Now);
                        }
                        if (user == null)
                        {
                            return(new ObjectResultModule("Login failed", 400, "openid错误,请刷新页面!"));
                        }
                        if (!user.Enabled)
                        {
                            return(new ObjectResultModule("Login failed", 400, "用户账号没激活,请联系管理员!"));
                        }
                    }
                    else
                    {
                        return(new ObjectResultModule("", 402, "用户未关注,请重新关注公众号!"));
                    }
                }
                // 登陆判断用户是否存在
                if (user != null)
                {
                    var Identity    = GenerateUserIdentity(user, userManager, ClaimTypes.NameIdentifier);
                    var accessToken = CreateAccessToken(CreateJwtClaims(Identity));
                    this.ObjectResultModule.Object = new AuthenticateResultModel
                    {
                        AccessToken          = accessToken,
                        EncryptedAccessToken = GetEncrpyedAccessToken(accessToken),
                        ExpireInSeconds      = (int)_configuration.Expiration.TotalSeconds,
                        UserId         = user.Id,
                        MobileRoleName = user.RoleName,
                        WecharOpenID   = user.WecharOpenID,
                        userManager    = userManager
                    };
                    this.ObjectResultModule.StatusCode = 200;
                    this.ObjectResultModule.Message    = "sucess";
                    return(this.ObjectResultModule);
                }
                else
                {
                    this.ObjectResultModule.StatusCode = 400;
                    this.ObjectResultModule.Message    = "获取用户信息失败";
                    return(this.ObjectResultModule);
                }
            }
            catch (Exception ex)
            {
                this.ObjectResultModule.Message    = "error";
                this.ObjectResultModule.StatusCode = 500;
                this.ObjectResultModule.Object     = ex.Message;
                return(this.ObjectResultModule);
            }
        }
Exemple #11
0
        //public async Task<PostResultModel> Profitsharingaddreceiver(CreateReceiver model)
        //{
        //    try
        //    {
        //        StringBuilder stringBuilder = new StringBuilder();
        //        string url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver/";
        //        var Content =JsonHelper.ToJson(model);
        //        var AccessToken = await httpHelper.PostResponseAsync(url, Content);
        //        return JsonHelper.FromJson<PostResultModel>(AccessToken);
        //    }
        //    catch (Exception ex)
        //    {
        //        return new PostResultModel();
        //    }
        //}
        #endregion
        #region 检测用户标签
        /// <summary>
        /// 检测用户标签
        /// </summary>
        /// <param name="tencentFocusUser"></param>
        /// <param name="yaeherUser"></param>
        /// <param name="access_token"></param>
        /// <returns></returns>
        public async Task <YaeherUser> YaeherUserLable(TencentFocusUser tencentFocusUser, YaeherUser yaeherUser, string access_token)
        {
            TencentUserManage usermanage = new TencentUserManage();

            // 检查用户标签功能
            if (tencentFocusUser.tagid_list != null && tencentFocusUser.tagid_list.Count > 0)
            {
                bool IsExis = false;
                if (tencentFocusUser.tagid_list.Exists(a => a == yaeherUser.WecharLableId))
                {
                    IsExis = true;
                    // 剔除已存在的标签
                    tencentFocusUser.tagid_list.Remove(yaeherUser.WecharLableId);
                }
                //  将不是系统存在的标签删除
                if (tencentFocusUser.tagid_list.Count > 0)
                {
                    foreach (var item in tencentFocusUser.tagid_list)
                    {
                        BatchtaggingTag batchtagging1 = new BatchtaggingTag();
                        batchtagging1.openid_list = new List <string>();
                        batchtagging1.openid_list.Add(yaeherUser.WecharOpenID);
                        batchtagging1.tagid = item;
                        var responsemsg1 = await usermanage.DeleteWeiXinUserTag(batchtagging1, access_token);
                    }
                }
                if (!IsExis)
                {
                    BatchtaggingTag batchtagging = new BatchtaggingTag();
                    batchtagging.openid_list = new List <string>();
                    batchtagging.openid_list.Add(yaeherUser.WecharOpenID);
                    batchtagging.tagid = yaeherUser.WecharLableId;
                    var responsemsg = await usermanage.WeiXinUserbatchtaggingTag(batchtagging, access_token);
                }
            }
            else  // 当没标签时将数据回复
            {
                BatchtaggingTag batchtagging = new BatchtaggingTag();
                batchtagging.openid_list = new List <string>();
                batchtagging.openid_list.Add(yaeherUser.WecharOpenID);
                batchtagging.tagid = yaeherUser.WecharLableId;
                var responsemsg = await usermanage.WeiXinUserbatchtaggingTag(batchtagging, access_token);
            }
            return(yaeherUser);
        }