Beispiel #1
0
        public bool Insert(ApplyInfoEntity entity)
        {
            var sql = @"INSERT INTO dbo.ApplyInfo
                                  (ApplyId
                                  ,MomentId
                                  ,MomentUId
                                  ,UId
                                  ,ApplyState
                                  ,Source
                                  ,CreateTime
                                  ,UpdateTime)
                            VALUES
                                  (@ApplyId
                                  ,@MomentId
                                  ,@MomentUId
                                  ,@UId
                                  ,@ApplyState
                                  ,@Source
                                  ,@CreateTime
                                  ,@UpdateTime)";

            using var Db = GetDbConnection();
            return(Db.Execute(sql, entity) > 0);
        }
Beispiel #2
0
        public Response Ask(RequestContext <AskActivityRequest> request)
        {
            MomentEntity moment = momentDao.GetMomentByMomentId(request.Data.MomentId);

            if (moment == null)
            {
                return(new Response(ErrCodeEnum.DataIsnotExist, "活动不存在"));
            }

            var appLyList = applyInfoDao.GetListByMomentId(request.Data.MomentId);

            if (appLyList.NotEmpty())
            {
                var myApply = appLyList.FirstOrDefault(a => a.UId == request.Head.UId);
                if (myApply != null)
                {
                    return(new Response(ErrCodeEnum.Failure, "你已申请过,不能重复申请"));
                }
                var usableList = appLyList.Where(a => a.ApplyState == ApplyStateEnum.申请通过).ToList();
                if (usableList.NotEmpty() && usableList.Count >= moment.NeedCount)
                {
                    return(new Response(ErrCodeEnum.Failure, "人数已满,无法申请"));
                }
            }

            if (moment.IsDelete || moment.State != MomentStateEnum.正常发布中 || MomentContentBuilder.IsOverTime(moment.StopTime))
            {
                return(new Response(ErrCodeEnum.IsOverTime, "活动已失效"));
            }

            var dto = new ApplyInfoEntity()
            {
                ApplyId    = Guid.NewGuid(),
                MomentId   = moment.MomentId,
                MomentUId  = moment.UId,
                ApplyState = ApplyStateEnum.申请中,
                Source     = request.Data.Source,
                UId        = request.Head.UId,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            applyInfoDao.Insert(dto);

            string remark = "申请加入该活动";

            if (!string.IsNullOrEmpty(request.Data.Remark))
            {
                remark = request.Data.Remark;
            }

            InsertDetail(moment.MomentId, dto.ApplyId, request.Head.UId, remark);

            var momentUser = uerInfoBiz.GetUserInfoByUid(moment.UId);

            if (momentUser != null)
            {
                //发送通知
                AppFactory.Factory(momentUser.Platform).Send_Moment_Join_MsgAsync(moment, request.Head.UId, momentUser.OpenId);
            }
            return(new Response(ErrCodeEnum.Success, "申请提交成功"));
        }