Пример #1
0
        public BaseGetResponse <List <DBPoint> > GetPointList(string session)
        {
            BaseGetResponse <List <DBPoint> > res = new BaseGetResponse <List <DBPoint> >()
            {
                Code = -1, Msg = "未知错误"
            };

            var user = UserRepository.FindUser(session);

            if (user != null)
            {
                if (!user.IsManager)
                {
                    res.Code = 2;
                    res.Msg  = "只有管理员才能发起支部活动";
                    return(res);
                }
            }
            else
            {
                res.Code = 1;
                res.Msg  = "用户登录超时";
                return(res);
            }

            res.Code = 0;
            res.Msg  = "获取打卡点成功";
            res.Data = PointRepository.GetPointList();
            return(res);
        }
Пример #2
0
        public BaseGetResponse <List <CheckResult> > UnSignBA_Data(string sessionkey)
        {
            var res = new BaseGetResponse <List <CheckResult> >()
            {
                Code = -1, Msg = "未知错误", Data = null
            };

            //1.检查是否有这个用户
            var user = UserRepository.FindUser(sessionkey);

            if (user == null)
            {
                res.Msg  = "会话已过期,需要重新登录";
                res.Code = 1;
                return(res);
            }


            var BA_list = BranchActionRepository.GetUnsiginBA_DataByUserID(user.OpenID);

            if (BA_list == null || BA_list.Count == 0)
            {
                res.Code = 2;
                res.Msg  = "本月无未打卡支部活动";
                return(res);
            }
            List <CheckResult> list = new List <CheckResult>();

            foreach (var item in BA_list)
            {
                list.Add(new CheckResult()
                {
                    CheckPoint = item.Title, CheckTime = item.BeginTime
                });
            }
            //List<CheckResult> list = BA_list.Select(x => x.Title).ToList();
            res.Code = 0;
            res.Msg  = "找到以下未打卡支部活动";
            res.Data = list;
            return(res);
        }
Пример #3
0
        public BaseGetResponse <List <CheckResult> > GetThisMounthSignData(string sessionkey)
        {
            var res = new BaseGetResponse <List <CheckResult> >()
            {
                Code = -1, Msg = "未知错误", Data = null
            };

            if (string.IsNullOrEmpty(sessionkey))
            {
                res.Msg  = "会话已过期,需要重新登录";
                res.Code = 1;
                return(res);
            }
            //TODO:
            //1.检查是否有这个用户
            var user = UserRepository.FindUser(sessionkey);

            if (user == null)
            {
                res.Msg  = "会话已过期,需要重新登录";
                res.Code = 1;
                return(res);
            }

            var datalist = ScoreRepository.GetThisMounthSignData(user.OpenID);

            if (datalist == null || datalist.Count == 0)
            {
                res.Msg  = "本月无打卡记录";
                res.Code = 2;
                return(res);
            }
            res.Msg  = "OK";
            res.Code = 0;
            res.Data = datalist;
            return(res);
        }
Пример #4
0
        public BaseGetResponse <CheckResult> CheckByScanQrcode([FromUri] string code, [FromUri] string sessionkey)
        {
            var res = new BaseGetResponse <CheckResult>()
            {
                Code = -1, Msg = "没有这个打卡点", Data = null
            };

            //TODO:
            //1.检查是否有这个用户
            var user = UserRepository.FindUser(sessionkey);

            if (user == null)
            {
                res.Msg  = "会话已过期,需要重新登录";
                res.Code = 1;
                return(res);
            }
            //2.检查是否有这个二维码对应的打卡点
            DBCommon.Model.DBPoint point = null;
            point = PointRepository.FindPoint(code);
            if (point == null)
            {
                return(res);
            }

            //找出该打卡点当前时间正在进行的支部活动
            var BA_list = PointRepository.FindBranchActionByPointID(point.ID);

            BA_list = BA_list.Where(a => a.BranchID.Equals(user.BranchID)).ToList();
            bool isBranchAction = false;

            if (BA_list.Count > 0)
            {
                isBranchAction = true;
            }


            //3.打卡是否重复,不重复则写入数据库,重复则返回打卡失败
#warning 需要完善步骤
            if (isBranchAction)
            {
                string title = "";
                int    num   = 0;
                foreach (var action in BA_list)
                {
                    var dataresult = ScoreRepository.BA_Signin(action.ID, user.OpenID);
                    if (dataresult != null)
                    {
                        num++;
                        title += string.Format("[{0}.{1}]", num, dataresult.CheckPoint);
                    }
                    else
                    {
                        res.Msg  = "打卡失败,没有找到未打卡的支部活动";
                        res.Code = 4;
                    }
                }
                if (num > 0)
                {
                    res.Msg  = "打卡成功";
                    res.Code = 0;
                    res.Data = new CheckResult()
                    {
                        CheckPoint = string.Format("{0}共{1}个活动打卡", title, num),
                        CheckTime  = DateTime.Now
                    };
                }
                else
                {
                    return(res);
                }
            }
            else
            {
                string dataid = ScoreRepository.IsSignined(point.ID, user.OpenID);
                if (dataid != null)
                {
                    res.Msg  = "今天已打卡,请勿重复打卡";
                    res.Code = 2;
                    return(res);
                }
                var dataresult = ScoreRepository.Signin(point.ID, user.OpenID);
                if (dataresult != null)
                {
                    res.Msg  = "打卡成功";
                    res.Code = 0;
                    res.Data = dataresult;
                }
                else
                {
                    res.Msg  = "打卡失败,未知错误";
                    res.Code = 4;
                }
            }
            //var resultModel = PointRepository.CheckByScanQrcode(code, sessionkey);

            return(res);
        }
Пример #5
0
        public BaseGetResponse <string> LanchAction(dynamic data)
        {
            var res = new BaseGetResponse <string>()
            {
                Code = -1, Msg = "没有这个打卡点", Data = null
            };

            DBCommon.Model.DBBranchAction action = new DBCommon.Model.DBBranchAction();
            string session = data.Session;
            var    user    = UserRepository.FindUser(session);

            if (user != null)
            {
                if (user.IsManager)
                {
                    action.BranchID = user.BranchID;
                }
                else
                {
                    res.Code = 2;
                    res.Msg  = "只有管理员才能发起支部活动";
                    return(res);
                }
            }
            else
            {
                res.Code = 1;
                res.Msg  = "用户登录超时";
                return(res);
            }

            action.BeginTime = data.BeginTime;
            action.EndTime   = data.EndTime;
            action.Title     = data.Title;
            action.PointID   = data.PointID;


            var point = PointRepository.FindPointById(action.PointID);

            if (point == null)
            {
                res.Code = 3;
                res.Msg  = "没有这个打卡点";
                return(res);
            }

            string id = BranchActionRepository.LanuchAction(action);

            if (string.IsNullOrEmpty(id))
            {
                res.Code = 2;
                res.Msg  = "数据库错误,发起活动失败";
                return(res);
            }

            res.Code = 0;
            res.Msg  = "发起活动成功";
            res.Data = id;

            return(res);
        }