Ejemplo n.º 1
0
        public async Task <bool> CreateConsumerHealthInfo(UserModel user, ConsumerModel consumerModel,
                                                          List <ConsumerHealthInfoModel> infosModel)
        {
            return(await MySqlHelper.TransactionAsync(async (conn, trans) =>
            {
                var userResult = await conn.InsertAsync <string, UserModel>(user);

                if (string.IsNullOrEmpty(userResult))
                {
                    return false;
                }

                var consumerResult = await conn.InsertAsync <string, ConsumerModel>(consumerModel);

                if (string.IsNullOrEmpty(consumerResult))
                {
                    return false;
                }

                var infoResult = infosModel.InsertBatch(conn);
                if (infoResult <= 0)
                {
                    return false;
                }

                return true;
            }));
        }
Ejemplo n.º 2
0
 public void ConstructorLosiParametri1(string name, double consumption)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         ConsumerModel battery = new ConsumerModel(name, consumption);
     });
 }
Ejemplo n.º 3
0
 public static Consumer FromModel(this ConsumerModel model)
 {
     return(new Consumer
     {
         Amount = model.Amount,
         ParticipantId = model.ParticipantId
     });
 }
Ejemplo n.º 4
0
        public void ConstructorPrazan()
        {
            ConsumerModel cons = new ConsumerModel();

            Assert.AreEqual("", cons.Name);
            Assert.AreEqual(0, cons.Consumption);
            Assert.AreEqual(SmartHomeEnergySystem.Enums.ConsumerEnum.OFF, cons.State);
        }
Ejemplo n.º 5
0
        public void ConstructorParams(string n, double consumption)
        {
            ConsumerModel cons = new ConsumerModel(n, consumption);

            Assert.AreEqual(n, cons.Name);
            Assert.AreEqual(consumption, cons.Consumption);
            Assert.AreEqual(SmartHomeEnergySystem.Enums.ConsumerEnum.OFF, cons.State);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 异步修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> UpdateAsync(ConsumerModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var count = await conn.UpdateAsync(model);

                return(count == 1);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 异步新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> AddAsync(ConsumerModel model)
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var result = await conn.InsertAsync <string, ConsumerModel>(model);

                return(!string.IsNullOrWhiteSpace(result));
            }
        }
        public void Update(ConsumerModel consumer)
        {
            if (consumer == null)
            {
                return;
            }

            consumers[consumer.Key] = consumer;
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> CancelAppointmentAsync(string appointGuid)
        {
            if (string.IsNullOrWhiteSpace(appointGuid))
            {
                return(Failed(ErrorCode.DataBaseError, "参数不能为空"));
            }
            var biz   = new DoctorAppointmentBiz();
            var model = await biz.GetAsync(appointGuid);

            if (model == null || model.UserGuid != UserID)
            {
                return(Failed(ErrorCode.UserData, "未找到记录"));
            }
            if (model.Status != AppointmentStatusEnum.Waiting.ToString())
            {
                return(Failed(ErrorCode.UserData, "只有待诊状态才可以取消"));
            }
            //检查累计是否超过二次连续取消或者爽约
            var           checkList     = await new DoctorAppointmentBiz().GetDoctorAppointmentListAsync(UserID);
            ConsumerModel consumerModel = null;

            if (checkList != null)
            {
                int missCount = 0;
                foreach (var item in checkList)
                {
                    if (item.Status == AppointmentStatusEnum.Cancel.ToString() || item.Status == AppointmentStatusEnum.Miss.ToString() || (item.Status == AppointmentStatusEnum.Waiting.ToString() && DateTime.Now.Date > item.AppointmentTime.Date))
                    {
                        missCount += 1;
                    }
                    else
                    {
                        missCount = 0;
                    }
                    if (missCount >= 2)
                    {
                        consumerModel = await new ConsumerBiz().GetModelAsync(UserID);
                        if (consumerModel != null)
                        {
                            consumerModel.LastUpdatedBy   = UserID;
                            consumerModel.LastUpdatedDate = DateTime.Now;
                            //三个月之后才可以预约
                            consumerModel.NoAppointmentDate = DateTime.Now.Date.AddMonths(3);
                        }
                        break;
                    }
                }
            }
            model.LastUpdatedBy   = UserID;
            model.LastUpdatedDate = DateTime.Now;
            model.Status          = AppointmentStatusEnum.Cancel.ToString();
            var result = await biz.CancelAppointmentAsync(model, consumerModel);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "取消挂号失败"));
        }
Ejemplo n.º 10
0
 public static Consumer ToDomain(this ConsumerModel model)
 {
     return(new Consumer()
     {
         Name = model.Name,
         ApiKey = model.ApiKey,
         CanEdit = model.CanEdit,
         IsAdmin = model.IsAdmin,
         Jobs = model.JobsCsv.ToCsvArray()
     });
 }
Ejemplo n.º 11
0
        public ActionResult Edit(int?id)
        {
            var consumer = this.provider.Find(id);

            var model = new ConsumerModel
            {
                ConsumerID  = consumer.ID,
                Description = consumer.Description,
                IsActive    = consumer.IsActive,
                Name        = consumer.Name
            };

            return(View(model));
        }
Ejemplo n.º 12
0
 private void loadConsumers()
 {
     consumers = new ObservableCollection <ConsumerModel>();
     using (dbSHESEntities entity = new dbSHESEntities())
     {
         List <ConsumerTable> cons = entity.ConsumerTables.ToList <ConsumerTable>();
         foreach (var c in cons)
         {
             ConsumerModel consumer = new ConsumerModel(c.Name, (double)c.Consumption);
             consumer.State = (ConsumerEnum)Enum.Parse(typeof(ConsumerEnum), c.State);
             consumers.Add(consumer);
         }
     };
 }
Ejemplo n.º 13
0
        public ActionResult Save(ConsumerModel model, List <Application> selectedApplications, IApplicationProvider applicationProvider)
        {
            var consumer = model.IsNew ? new Consumer() : this.provider.Find(model.ConsumerID);

            consumer.Name        = model.Name;
            consumer.Description = model.Description;
            consumer.IsActive    = model.IsActive;

            consumer.Applications.Clear();
            selectedApplications.ForEach(a => consumer.Applications.Add(a));

            this.provider.Save(consumer);

            return(Json(new { result = true }));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="userModel"></param>
        /// <param name="consumerModel"></param>
        /// <param name="registerModel"></param>
        /// <returns></returns>
        /// <remarks>
        /// 返回空,主键重复
        /// </remarks>
        public bool?Register(UserModel userModel, ConsumerModel consumerModel, RegisterModel registerModel)
        {
            bool?result = false;  // 默认为失败

            MySqlHelper.Transaction((conn, tran) =>
            {
                try
                {
                    result = string.Equals(userModel.Insert(conn), userModel.UserGuid) && string.Equals(consumerModel.Insert(conn), consumerModel.ConsumerGuid);
                    return(result.Value);
                }
                catch (MySql.Data.MySqlClient.MySqlException e) when(e.Message.Contains("Duplicate"))
                {
                    result = null; // 返回空,主键重复
                    return(false);
                }
            });

            return(result);
        }
Ejemplo n.º 15
0
        public ShortMessageModel Post([FromBody] IncomingShortMessageModel incomingMessage)
        {
            if (incomingMessage == null)
            {
                return(new ShortMessageModel());
            }

            ShortMessageModel shortMessageModel = new ShortMessageModel()
            {
                Created = DateTime.Now,
                Text    = incomingMessage.Text
            };

            var consumer = valueRepository.Get(incomingMessage.ConsumerKey);

            //Consumer does not exist
            if (consumer == null)
            {
                consumer        = new ConsumerModel();
                consumer.Key    = incomingMessage.ConsumerKey;
                consumer.Secret = incomingMessage.ConsumerSecret;

                consumer.ShortMessages.Add(shortMessageModel);
                valueRepository.Update(consumer);
            }
            else
            {
                //Consumer already exists, check secret
                if (consumer.Secret == incomingMessage.ConsumerSecret)
                {
                    consumer.ShortMessages.Add(shortMessageModel);
                    valueRepository.Update(consumer);
                }
            }

            return(shortMessageModel);
        }
Ejemplo n.º 16
0
        public async Task <IActionResult> AddAppointmentAsync([FromBody] AddAppointmentRequestDto requestDto)
        {
            var doctorModel = await new DoctorBiz().GetAsync(requestDto.DoctorGuid);

            if (doctorModel == null)
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            if (!doctorModel.Enable || string.Equals(doctorModel.Status, StatusEnum.Draft.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            var scheduleModel = await new DoctorScheduleBiz().GetAsync(requestDto.ScheduleGuid);

            if (scheduleModel == null || !scheduleModel.Enable)
            {
                return(Failed(ErrorCode.UserData, "未查询到此排班信息"));
            }
            if (scheduleModel.ScheduleDate.Date < DateTime.Now.Date || scheduleModel.ScheduleDate.Date > DateTime.Now.AddDays(6))
            {
                return(Failed(ErrorCode.UserData, "此时间段排班目前无法预约"));
            }
            var patientMemberModel = await new PatientMemberBiz().GetAsync(requestDto.PatientGuid);

            if (patientMemberModel == null || !patientMemberModel.Enable || patientMemberModel.UserGuid != UserID)
            {
                return(Failed(ErrorCode.UserData, "未查询到就诊人信息"));
            }
            //判断当前就诊人是否已经预约过
            var checkPatient = await new DoctorAppointmentBiz().GetDoctorAppointmentAsync(requestDto.DoctorGuid, scheduleModel.ScheduleDate, patientMemberModel.PatientGuid);

            if (checkPatient != null)
            {
                return(Failed(ErrorCode.UserData, "就诊人当天已经预约过该医生"));
            }
            //查询当前用户是否允许当天挂号
            ConsumerModel consumerModel = await new ConsumerBiz().GetModelAsync(UserID);

            if (consumerModel != null)
            {
                if (consumerModel.NoAppointmentDate.HasValue && consumerModel.NoAppointmentDate > DateTime.Now.Date)
                {
                    return(Failed(ErrorCode.UserData, "您在一个月内有连续爽约或取消超过3次的记录" + consumerModel.NoAppointmentDate.Value.ToString("yyyy-MM-dd") + "才可再次预约"));
                }
            }
            //检查累计是否超过二次连续取消或者爽约
            var checkList = await new DoctorAppointmentBiz().GetThreeMonthsDoctorAppointmentListAsync(UserID);

            if (checkList != null)
            {
                List <DateTime> resultList = new List <DateTime>();
                var             group      = checkList.GroupBy(s => s.CreationDate.ToString("yyyy-MM"));
                foreach (var items in group)
                {
                    foreach (var item in items)
                    {
                        if (item.Status == AppointmentStatusEnum.Cancel.ToString() || item.Status == AppointmentStatusEnum.Miss.ToString() || (item.Status == AppointmentStatusEnum.Waiting.ToString() && DateTime.Now.Date > item.AppointmentTime.Date))
                        {
                            resultList.Add(item.AppointmentTime.Date);
                        }
                        else
                        {
                            resultList.Clear();
                        }
                        if (resultList.Count >= 3 && DateTime.Now.Date < resultList.LastOrDefault().Date.AddMonths(3))
                        {
                            return(Failed(ErrorCode.UserData, "您在一个月内有连续爽约或取消超过3次的记录" + resultList.LastOrDefault().Date.AddMonths(3).ToString("yyyy-MM-dd") + "才可再次预约"));
                        }
                    }
                }
            }
            var doctorWorkshiftDetailModel = await new DoctorWorkshiftDetailBiz().GetAsync(scheduleModel.WorkshiftDetailGuid);
            var appointmentTime            = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.StartTime.ToString()}");
            var appointmentEndTime         = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.EndTime.ToString()}");

            if (DateTime.Now >= appointmentEndTime)
            {
                return(Failed(ErrorCode.UserData, "当前时间不可大于就诊截止时间,请重新挂号"));
            }
            var model = new DoctorAppointmentModel
            {
                AppointmentGuid     = Guid.NewGuid().ToString("N"),
                HospitalGuid        = doctorModel.HospitalGuid,
                UserGuid            = UserID,
                AppointmentNo       = "",
                ScheduleGuid        = requestDto.ScheduleGuid,
                DoctorGuid          = requestDto.DoctorGuid,
                OfficeGuid          = doctorModel.OfficeGuid,
                AppointmentTime     = appointmentTime,
                AppointmentDeadline = appointmentEndTime,
                PatientGuid         = patientMemberModel.PatientGuid,
                PatientName         = patientMemberModel.Name,
                PatientPhone        = patientMemberModel.Phone,
                PatientGender       = patientMemberModel.Gender,
                PatientBirthday     = patientMemberModel.Birthday,
                PatientCardno       = patientMemberModel.CardNo,
                PatientRelationship = patientMemberModel.Relationship,
                Status        = AppointmentStatusEnum.Waiting.ToString(),
                CreatedBy     = UserID,
                LastUpdatedBy = UserID,
                OrgGuid       = string.Empty
            };

            if (!string.IsNullOrWhiteSpace(requestDto.Phone))
            {
                model.PatientPhone = requestDto.Phone;
            }
            var result = await new DoctorAppointmentBiz().CreateAppointmentAsync(model, doctorWorkshiftDetailModel.AppointmentNoPrefix, false);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "挂号失败"));
            }
            var doctorAppointmentModel = await new DoctorAppointmentBiz().GetAppointmentAsync(model.AppointmentGuid);

            if (doctorAppointmentModel == null)
            {
                return(Failed(ErrorCode.UserData, "挂号失败"));
            }
            return(Success(doctorAppointmentModel));
        }
Ejemplo n.º 17
0
        public IList <RegisterdConsumersModel> GetPageList2(DbConn conn, string partitionid, string consumerclientid, string mqpathid, int pageIndex, int pageSize, ref int count)
        {
            int tempCount = 0;
            IList <RegisterdConsumersModel> list = new List <RegisterdConsumersModel>();
            ConsumerModel cm     = new ConsumerModel();
            var           result = SqlHelper.Visit((ps) =>
            {
                StringBuilder where = new StringBuilder(" WHERE 1=1 ");
                if (!string.IsNullOrEmpty(consumerclientid))
                {
                    if (!consumerclientid.isint())
                    {
                        where.AppendFormat(" AND  (c.client LIKE '%{0}%')", consumerclientid);
                    }
                    else
                    {
                        where.AppendFormat(" AND  (c.id = '{0}')", consumerclientid);
                    }
                }
                if (!string.IsNullOrEmpty(partitionid))
                {
                    where.AppendFormat(" AND  (p.partitionid='{0}')", partitionid);
                }
                if (!string.IsNullOrEmpty(mqpathid))
                {
                    if (!mqpathid.isint())
                    {
                        where.AppendFormat(" AND  (m.mqpath like '%{0}%')", mqpathid);
                    }
                    else
                    {
                        where.AppendFormat(" AND  (m.id='{0}')", mqpathid);
                    }
                }
                string sql      = @"SELECT ROW_NUMBER() OVER(ORDER BY p.consumerclientid DESC,p.partitionindex desc) AS rownum, s.id as tb_consumer_id,tempid as tb_consumer_tempid,s.consumerclientid as tb_consumer_consumerclientid,s.partitionindexs as tb_consumer_partitionindexs
,s.clientname as tb_consumer_clientname,s.lastheartbeat as tb_consumer_lastheartbeat,s.lastupdatetime as tb_consumer_lastupdatetime,s.createtime as tb_consumer_createtime, 
c.id as tb_consumer_client_id, c.client as tb_consumer_client_client,c.createtime as tb_consumer_client_createtime, p.id as tb_consumer_partition_id,p.consumerclientid as tb_consumer_partition_consumerclientid
,p.partitionindex as tb_consumer_partition_partitionindex,p.partitionid as tb_consumer_partition_partitionid,p.lastconsumertempid as tb_consumer_partition_lastconsumertempid,p.lastmqid as tb_consumer_partition_lastmqid
,p.lastupdatetime as tb_consumer_partition_lastupdatetime,p.createtime as tb_consumer_partition_createtime,m.mqpath as tb_mqpath_mqpath,m.id as tb_mqpath_id
from tb_consumer_partition p WITH(NOLOCK) left join tb_consumer s WITH(NOLOCK) on s.tempid=p.lastconsumertempid left join tb_consumer_client c WITH(NOLOCK) on p.consumerclientid=c.id  left join tb_mqpath_partition mp with (nolock) on mp.partitionid=p.partitionid left join tb_mqpath m with (nolock) on m.id=mp.mqpathid ";
                string countSql = "SELECT COUNT(p.id) from tb_consumer_partition p WITH(NOLOCK) left join tb_consumer s WITH(NOLOCK) on s.tempid=p.lastconsumertempid left join tb_consumer_client c WITH(NOLOCK) on p.consumerclientid=c.id   left join tb_mqpath_partition mp with (nolock) on mp.partitionid=p.partitionid left join tb_mqpath m with (nolock) on m.id=mp.mqpathid " + where.ToString();
                object obj      = conn.ExecuteScalar(countSql, null);
                if (obj != DBNull.Value && obj != null)
                {
                    tempCount = LibConvert.ObjToInt(obj);
                }
                string sqlPage = string.Concat("SELECT * FROM (", sql.ToString(), where.ToString(), ") A WHERE rownum BETWEEN ", ((pageIndex - 1) * pageSize + 1), " AND ", pageSize * pageIndex);
                DataTable dt   = conn.SqlToDataTable(sqlPage, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        RegisterdConsumersModel model = new RegisterdConsumersModel(dr);
                        model.msgCount    = reportDal.GetMsgCount(conn, model.consumerpartitionmodel.lastmqid);
                        model.nonMsgCount = reportDal.GetNonMsgCount(conn, model.consumerpartitionmodel.lastmqid);
                        model.mqpath      = dr["tb_mqpath_mqpath"].Tostring();
                        model.mqpathid    = dr["tb_mqpath_id"].Toint();
                        list.Add(model);
                    }
                }
                return(list);
            });

            count = tempCount;
            return(result);
        }
Ejemplo n.º 18
0
        public IList <ConsumerModel> GetPageList(DbConn conn, string name, int pageIndex, int pageSize, ref int count)
        {
            int tempCount = 0;
            IList <ConsumerModel> list = new List <ConsumerModel>();
            ConsumerModel         cm   = new ConsumerModel();
            var result = SqlHelper.Visit((ps) =>
            {
                StringBuilder where = new StringBuilder(" WHERE 1=1 ");
                if (!string.IsNullOrEmpty(name))
                {
                    where.AppendFormat(" AND  clientname LIKE '%{0}%'", name);
                }
                string sql      = "SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) AS rownum,* FROM tb_consumer WITH(NOLOCK)";
                string countSql = "SELECT COUNT(1) FROM tb_consumer WITH(NOLOCK) " + where.ToString();
                object obj      = conn.ExecuteScalar(countSql, null);
                if (obj != DBNull.Value && obj != null)
                {
                    tempCount = LibConvert.ObjToInt(obj);
                }
                string sqlPage = string.Concat("SELECT * FROM (", sql.ToString(), where.ToString(), ") A WHERE rownum BETWEEN ", ((pageIndex - 1) * pageSize + 1), " AND ", pageSize * pageIndex);
                DataTable dt   = conn.SqlToDataTable(sqlPage, null);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        ConsumerModel model = cm.CreateModel(dr);

                        IList <tb_consumer_partition_model> consumerList = partitionDal.GetPartitionByConsumerId(conn, model.consumerclientid);
                        if (consumerList != null && consumerList.Count > 0)
                        {
                            IList <ConsumerPartition> partitionList = new List <ConsumerPartition>();

                            foreach (var item in consumerList)
                            {
                                ConsumerPartition m = new ConsumerPartition();
                                m.PartitionId       = item.partitionid;

                                PartitionIDInfo partitionInfo = PartitionRuleHelper.GetPartitionIDInfo(item.partitionid);
                                string node = string.Empty;
                                if (partitionInfo.DataNodePartition < 10)
                                {
                                    node = "0" + partitionInfo.DataNodePartition.Tostring();
                                }
                                else
                                {
                                    node = partitionInfo.DataNodePartition.Tostring();
                                }

                                using (DbConn nodeConn = DbConfig.CreateConn(DataConfig.DataNodeParConn(node)))
                                {
                                    nodeConn.Open();
                                    tb_partition_model partitionModel = new tb_partition_dal().Get(conn, item.partitionid);
                                    if (partitionModel != null)
                                    {
                                        m.IsOnline = partitionModel.isused;
                                    }
                                    string table = msgDal.GetMaxMqTable(nodeConn, node);
                                    m.Msg        = msgDal.GetMsgCount(nodeConn, table, 0);
                                    m.NonMsg     = msgDal.GetMsgCount(nodeConn, table, 1);
                                    partitionList.Add(m);
                                }
                            }
                            model.PartitionList = partitionList;
                        }
                        list.Add(model);
                    }
                }
                return(list);
            });

            count = tempCount;
            return(result);
        }
        public IActionResult Register([FromBody] PhonePasswordCodeRequestDto request)
        {
            var accountBiz = new AccountBiz();

            if (!accountBiz.VerifyCode(request.Phone, request.Code))
            {
                return(Failed(ErrorCode.VerificationCode, "手机验证码错误"));
            }

            var userID       = Guid.NewGuid().ToString("N");
            var saltPassword = CryptoHelper.AddSalt(userID, request.Password);

            if (string.IsNullOrEmpty(saltPassword))
            {
                return(Failed(ErrorCode.SystemException, "密码加盐失败"));
            }

            var biz  = new AccountBiz();
            var list = biz.GetUserByPhone(request.Phone);

            if (list.Any())
            {
                return(Failed(ErrorCode.DuplicatePhone, "该手机号已经注册"));
            }
            #region 获取用户是否有推荐关注公众号记录,若有,则将推荐人设为平台账户推荐人
            var recommendUser = TryGetSubscriptionRecommendUser(request.OpenId);
            if (!string.IsNullOrWhiteSpace(recommendUser))
            {
                request.Referrer = recommendUser;
            }
            #endregion
            var userModel = new UserModel
            {
                UserGuid      = userID,
                WechatOpenid  = request.OpenId,
                NickName      = userID.Substring(0, 6),
                UserName      = userID.Substring(0, 6),
                Phone         = request.Phone,
                Password      = saltPassword,
                Birthday      = new DateTime(2000, 1, 1),
                RecommendGuid = request.Referrer,
                CreatedBy     = userID,
                LastUpdatedBy = userID,
                OrgGuid       = "guodan"
            };

            var consumerModel = new ConsumerModel
            {
                ConsumerGuid  = userID,
                CreatedBy     = userID,
                LastUpdatedBy = userID
            };

            var registerModel = new RegisterModel
            {
                PlatformType = request.PlatformType,
                Parameters   = request.Parameters
            };

            var result = biz.Register(userModel, consumerModel, registerModel);

            if (result == null)
            {
                return(Failed(ErrorCode.DuplicatePhone));
            }

            if (result.Value)
            {
                var message = string.Empty;
                if (enableXmpp && !RegisterIM(userModel)) // 启用XMPP的情况下,才执行注册
                {
                    message = $"register im account failed. user id: {userID}, user phone: {request.Phone}";
                    Logger.Error(message);
                }

                var scoreBiz = new ScoreRulesBiz();
                scoreBiz.AddScoreByRules(userID, ActionEnum.Registered, UserType.Consumer);

                if (!string.IsNullOrEmpty(request.Referrer))
                {
                    scoreBiz.AddScoreByRules(request.Referrer, ActionEnum.RecommendRegistered, UserType.Doctor);
                    scoreBiz.AddScoreByRules(request.Referrer, ActionEnum.RecommendRegistered, UserType.Consumer);
                }

                return(Success(userID, message));
            }
            else
            {
                return(Failed(ErrorCode.DataBaseError));
            }
        }
Ejemplo n.º 20
0
 public DeleteConsumerCommand(ConsumerModel consumerToDelete)
 {
     this.consumerToDelete = consumerToDelete;
 }
Ejemplo n.º 21
0
        public async Task <IActionResult> CreateConsumerHealthInfo([FromBody] CreateConsumerRequestDto request)
        {
            if (request.Informations.Count <= 0)
            {
                return(Failed(ErrorCode.Empty, "基础信息未提交"));
            }

            if (request.Informations.Any(d => string.IsNullOrEmpty(d.InformationGuid)))
            {
                return(Failed(ErrorCode.Empty, "基础信息未提交"));
            }

            var userBiz = new UserBiz();

            var user = await userBiz.GetByPnoneAsync(request.Phone);

            if (user != null)
            {
                return(Failed(ErrorCode.Empty, $"该手机号【{request.Phone}】已注册,请直接在会员列表搜索"));
            }

            var userGuid = Guid.NewGuid().ToString("N");

            var pwd = request.Phone.Substring(request.Phone.Length - 6);

            var userModel = new UserModel()
            {
                Phone          = request.Phone,
                UserGuid       = userGuid,
                UserName       = string.IsNullOrWhiteSpace(request.UserName) ? userGuid.Substring(0, 6) : request.UserName,//userGuid.Substring(0, 6),
                Password       = CryptoHelper.AddSalt(userGuid, CryptoHelper.Md5(pwd)),
                NickName       = userGuid.Substring(0, 6),
                Gender         = string.IsNullOrWhiteSpace(request.Gender) ? "M" : request.Gender,
                Birthday       = request.Birthday,
                IdentityNumber = request.IdentityNumber,
                CreatedBy      = UserID,
                LastUpdatedBy  = UserID,
                OrgGuid        = ""
            };

            var consumerModel = new ConsumerModel()
            {
                ConsumerGuid  = userGuid,
                CreatedBy     = UserID,
                LastUpdatedBy = UserID,
                OrgGuid       = ""
            };

            var infos = request.Informations.Select(d => new ConsumerHealthInfoModel()
            {
                InfoRecordGuid  = Guid.NewGuid().ToString("N"),
                UserGuid        = userGuid,
                InformationGuid = d.InformationGuid,
                InformationType = d.InformationType?.ToString(),
                OptionGuids     = JsonConvert.SerializeObject(d.OptionGuids),
                ResultValue     = d.ResultValue,
                CreatedBy       = UserID,
                LastUpdatedBy   = UserID,
                OrgGuid         = ""
            }).ToList();

            var consumerBiz = new ConsumerBiz();

            var result = await consumerBiz.CreateConsumerHealthInfo(userModel, consumerModel, infos);

            if (!result)
            {
                return(Failed(ErrorCode.Empty, "注册失败,请稍后重试"));
            }

            return(Success());
        }
Ejemplo n.º 22
0
 public TurnOnCommand(ConsumerModel consumer)
 {
     consumerOn = consumer;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 修改取消预约
        /// </summary>
        /// <param name="doctorAppointmentModel"></param>
        /// <param name="consumerModel"></param>
        /// <returns></returns>
        public async Task <bool> CancelAppointmentAsync(DoctorAppointmentModel doctorAppointmentModel, ConsumerModel consumerModel)
        {
            return(await MySqlHelper.TransactionAsync(async (conn, trans) =>
            {
                await conn.UpdateAsync(doctorAppointmentModel);
                //更新医生排班表记录已预约数量-1
                var sql = $@"UPDATE t_doctor_schedule 
                            SET appointment_quantity = appointment_quantity - 1 
                            WHERE
	                            schedule_guid = @ScheduleGuid "    ;
                await conn.ExecuteAsync(sql, new { doctorAppointmentModel.ScheduleGuid });
                //修改截止日期
                if (consumerModel != null)
                {
                    await conn.UpdateAsync(consumerModel);
                }
                return true;
            }));
        }
Ejemplo n.º 24
0
 public TurnOffCommand(ConsumerModel consumer)
 {
     consumerOff = consumer;
 }