Exemple #1
0
        public bool UpdateMoment(MomentEntity entity)
        {
            var sql = @"UPDATE dbo.Moment
                        SET IsOffLine = @IsOffLine,
                            IsHide = @IsHide,
                            HidingNickName = @HidingNickName,
                            NeedCount = @NeedCount,
                            StopTime = @StopTime,
                            Place = @Place,
                            ExpectGender = @ExpectGender,
                            ShareType = @ShareType,
                            Latitude = @Latitude,
                            Longitude = @Longitude,
                            Location=geography :: STGeomFromText ('POINT(@LongitudeValue @LatitudeVaule)',4326),
                            Title = @Title,
                            Content = @Content,
                            State = @State,
                            UpdateTime = @UpdateTime
                        WHERE MomentId=@MomentId";

            sql          = sql.Replace("@LongitudeValue", entity.Longitude.ToString());
            sql          = sql.Replace("@LatitudeVaule", entity.Latitude.ToString());
            using var Db = GetDbConnection();
            return(Db.Execute(sql, entity) > 0);
        }
Exemple #2
0
        public static List <ApplyDetailItem> GetCheckDetails(MomentEntity moment, UserInfoEntity momentUserInfo, RequestHead head)
        {
            var resultList = new List <ApplyDetailItem>()
            {
                new ApplyDetailItem()
                {
                    UserInfo       = UserInfoBuilder.BuildUserInfo(momentUserInfo, head),
                    Content        = "首次提交审核",
                    CreateTimeDesc = DateTimeHelper.GetDateDesc(moment.CreateTime, true),
                }
            };

            var applyDetaiList = applyDetailDao.GetListByMomentId(moment.MomentId);

            if (applyDetaiList.NotEmpty())
            {
                var resultDic = GetUserInfo(applyDetaiList, head);
                foreach (var item in applyDetaiList)
                {
                    resultList.Add(new ApplyDetailItem()
                    {
                        CreateTimeDesc = DateTimeHelper.GetDateDesc(item.CreateTime, true),
                        Content        = item.Content,
                        UserInfo       = resultDic[item.UId]
                    });
                }
            }
            return(resultList);
        }
        public static List <ContentItem> BuilderContent2Contact(MomentEntity moment, UserInfoEntity userInfo, bool displayContact)
        {
            var resultList = new List <ContentItem>();
            int index      = 1;

            AddItem(resultList, index++, "发布时间", DateTimeHelper.GetDateDesc(moment.CreateTime, true), TagTypeEnum.PublishTime);
            if (moment.StopTime.HasValue)
            {
                string stopStr = moment.StopTime.Value.ToString(DateTimeHelper.yMdHm);
                if (IsOverTime(moment.StopTime))
                {
                    stopStr += "(已过期)";
                }
                AddItem(resultList, index++, "截止时间", stopStr);
            }
            AddItem(resultList, index++, "性别要求", GenderMap(moment.ExpectGender));
            AddItem(resultList, index++, "人数限制", string.Format("{0}人", moment.NeedCount));
            AddItem(resultList, index++, "地点", moment.Place);
            if (displayContact)
            {
                if (!string.IsNullOrEmpty(userInfo.Mobile))
                {
                    AddItem(resultList, index++, "手机号", userInfo.Mobile, TagTypeEnum.Contact);
                }
                if (!string.IsNullOrEmpty(userInfo.WeChatNo))
                {
                    AddItem(resultList, index++, "微信号", userInfo.WeChatNo, TagTypeEnum.Contact);
                }
                if (!string.IsNullOrEmpty(userInfo.QQNo))
                {
                    AddItem(resultList, index++, "QQ号", userInfo.QQNo, TagTypeEnum.Contact);
                }
            }
            return(resultList);
        }
        public static List <ContentItem> BuilderContent(MomentEntity moment, bool displayContact = true)
        {
            var resultList = new List <ContentItem>();
            int index      = 1;

            AddItem(resultList, index++, "发布时间", DateTimeHelper.GetDateDesc(moment.CreateTime, true));
            if (moment.StopTime.HasValue)
            {
                string stopStr = moment.StopTime.Value.ToString("yyyy-MM-dd HH:mm");
                if (IsOverTime(moment.StopTime))
                {
                    stopStr += "(已过期)";
                }
                AddItem(resultList, index++, "截止时间", stopStr);
            }
            AddItem(resultList, index++, "性别要求", GenderMap(moment.ExpectGender));
            AddItem(resultList, index++, "人数限制", string.Format("{0}人", moment.NeedCount));
            if (moment.IsOffLine)
            {
                AddItem(resultList, index++, "地点", moment.Place);
            }
            if (displayContact)
            {
                AddItem(resultList, index++, "联系方式", "通过申请后可查看", TagTypeEnum.Contact);
            }
            return(resultList);
        }
Exemple #5
0
        public ResponseContext <bool> AddOrUpdateSimulateMoment(MomentEntity request)
        {
            bool success = true;

            if (request.MomentId == new Guid())
            {
                request.UpdateTime = DateTime.Now;
                request.MomentId   = Guid.NewGuid();
                success            = letterDal.InsertMoment(request);
            }
            else
            {
                var moment = letterDal.GetMoment(request.MomentId);
                if (moment == null)
                {
                    return(new ResponseContext <bool>(false, ErrCodeEnum.InnerError, false, "动态不存在,请联系管理员"));
                }
                if (moment.ReplyCount > 0)
                {
                    return(new ResponseContext <bool>(false, ErrCodeEnum.InnerError, false, "该动态已被订阅,不能修改!"));
                }
                request.UpdateTime = DateTime.Now;
                success            = letterDal.UpdateMoment(request);
            }
            return(new ResponseContext <bool>(success));
        }
Exemple #6
0
        /// <summary>
        /// 获取指定用户的动态
        /// </summary>
        /// <param name="id">用户id</param>
        /// <param name="count">获取数量</param>
        /// <returns></returns>
        public static async Task <MomentEntity> GetMoment(int id, int count = 1)
        {
            var responseString = await client.GetStringAsync(String.Format("https://mini.pocketword.cn/api/acfun/user/moment?pcursor=0&userId={0}&count={1}", id.ToString(), count.ToString()));

            MomentEntity moments = JsonConvert.DeserializeObject <MomentEntity>(responseString);

            return(moments);
        }
Exemple #7
0
        public Response AskAction(RequestContext <AskActionRequest> request)
        {
            var applyInfo = applyInfoDao.GetByApplyId(request.Data.ApplyId);

            if (applyInfo == null)
            {
                return(new Response(ErrCodeEnum.DataIsnotExist, "申请不存在"));
            }
            string remark      = string.Empty;
            bool   sendMsg     = false;
            bool   joinSuccess = true;

            if (string.Equals(request.Data.Action, "cancel"))
            {
                applyInfoDao.UpdateState(ApplyStateEnum.申请已撤销, applyInfo.ApplyId);
                remark = "撤销活动申请";
            }
            if (string.Equals(request.Data.Action, "reask"))
            {
                applyInfoDao.UpdateState(ApplyStateEnum.申请中, applyInfo.ApplyId);
                remark = "重新申请加入活动";
            }
            if (string.Equals(request.Data.Action, "pass"))
            {
                applyInfoDao.UpdateState(ApplyStateEnum.申请通过, applyInfo.ApplyId);
                momentDao.UpdateApplyCount(applyInfo.MomentId);
                remark  = "通过了活动申请";
                sendMsg = true;
            }
            if (string.Equals(request.Data.Action, "black"))
            {
                applyInfoDao.UpdateState(ApplyStateEnum.永久拉黑, applyInfo.ApplyId);
                remark      = "拉黑了活动申请";
                sendMsg     = true;
                joinSuccess = false;
            }
            if (string.Equals(request.Data.Action, "refuse"))
            {
                applyInfoDao.UpdateState(ApplyStateEnum.被拒绝, applyInfo.ApplyId);
                if (!string.IsNullOrEmpty(request.Data.Remark))
                {
                    remark = request.Data.Remark;
                }
                sendMsg     = true;
                joinSuccess = false;
            }
            InsertDetail(applyInfo.MomentId, request.Data.ApplyId, request.Head.UId, remark);

            UserInfoEntity userInfo   = uerInfoBiz.GetUserInfoByUid(applyInfo.UId);
            MomentEntity   momentInfo = momentDao.GetMomentByMomentId(applyInfo.MomentId);

            if (sendMsg && userInfo != null && momentInfo != null)
            {
                //发送通知
                AppFactory.Factory(userInfo.Platform).Send_Activity_Join_MsgAsync(momentInfo, userInfo.UId, joinSuccess, remark);
            }
            return(new Response(ErrCodeEnum.Success, "提交成功"));
        }
Exemple #8
0
        public Response UpdateMoment(UpdateMomentType moment, long uId)
        {
            var  momentInfo = momentDao.GetMomentByMomentId(moment.MomentId);
            bool canEdit    = momentInfo.State != MomentStateEnum.审核中 || momentInfo.State != MomentStateEnum.审核被拒绝;

            if (momentInfo == null || !canEdit)
            {
                return(new Response(ErrCodeEnum.Failure, "你的动态已审核通过,不能修改,可以删除后重发哦~"));
            }
            var entity = new MomentEntity()
            {
                MomentId       = moment.MomentId,
                IsOffLine      = moment.IsOffLine,
                IsHide         = moment.IsHide,
                HidingNickName = moment.HidingNickName,
                NeedCount      = moment.NeedCount,
                StopTime       = DateTime.Parse(moment.StopTime),
                ExpectGender   = moment.ExpectGender,
                ShareType      = moment.ShareType,
                Place          = moment.Place,
                Address        = moment.Address,
                Latitude       = moment.Latitude,
                Longitude      = moment.Longitude,
                Title          = moment.Title,
                Content        = moment.Content,
                State          = MomentStateEnum.审核中,
                CreateTime     = momentInfo.CreateTime,
                UpdateTime     = DateTime.Now
            };
            bool sucess = momentDao.UpdateMoment(entity);

            if (sucess)
            {
                InsertApplyDetail(moment.MomentId, "修改活动内容,重新审核中", uId);
                if (!string.IsNullOrEmpty(moment.Mobile))
                {
                    userInfoDao.UpdateMobile(uId, moment.Mobile);
                }
                if (!string.IsNullOrEmpty(moment.WeChatNo))
                {
                    userInfoDao.UpdateMobile(uId, moment.WeChatNo);
                }
                if (!string.IsNullOrEmpty(moment.QQNo))
                {
                    userInfoDao.UpdateMobile(uId, moment.QQNo);
                }
                return(new Response());
            }
            else
            {
                return(new Response(ErrCodeEnum.Failure, "修改失败"));
            }
        }
Exemple #9
0
        public int Insert(MomentEntity entity)
        {
            var sql = @"INSERT INTO dbo.Moment
                                  (MomentId
                                  ,UId
                                  ,IsDelete
                                  ,IsOffLine
                                  ,IsHide
                                  ,HidingNickName
                                  ,State
                                  ,NeedCount
                                  ,ApplyCount
                                  ,StopTime
                                  ,Place
                                  ,Address
                                  ,Latitude
                                  ,Longitude
                                  ,ExpectGender
                                  ,ShareType
                                  ,Title
                                  ,Content
                                  ,Location
                                  ,CreateTime
                                  ,UpdateTime)
                            VALUES
                                  (@MomentId
                                  ,@UId
                                  ,@IsDelete
                                  ,@IsOffLine
                                  ,@IsHide
                                  ,@HidingNickName
                                  ,@State
                                  ,@NeedCount
                                  ,@ApplyCount
                                  ,@StopTime
                                  ,@Place
                                  ,@Address
                                  ,@Latitude
                                  ,@Longitude
                                  ,@ExpectGender
                                  ,@ShareType
                                  ,@Title
                                  ,@Content
                                  ,geography :: STGeomFromText ('POINT(@LongitudeValue @LatitudeVaule)',4326)
                                  ,@CreateTime
                                  ,@UpdateTime)";

            sql          = sql.Replace("@LongitudeValue", entity.Longitude.ToString());
            sql          = sql.Replace("@LatitudeVaule", entity.Latitude.ToString());
            using var Db = GetDbConnection();
            return(Db.Execute(sql, entity));
        }
Exemple #10
0
        public Response Publish(RequestContext <PublishMomentRequest> request)
        {
            bool msgSec = AppFactory.Factory(request.Head.Platform).MsgSecCheck(request.Data.Content);

            if (!msgSec)
            {
                return(new Response(ErrCodeEnum.MessageCheckError));
            }
            var response = new Response();
            var moment   = new MomentEntity()
            {
                MomentId       = Guid.NewGuid(),
                UId            = request.Head.UId,
                IsDelete       = false,
                IsHide         = request.Data.IsHide,
                IsOffLine      = request.Data.IsOffLine,
                HidingNickName = request.Data.HidingNickName,
                State          = MomentStateEnum.审核中,
                NeedCount      = request.Data.NeedCount,
                Place          = request.Data.Place,
                Address        = request.Data.Address,
                Latitude       = request.Data.Latitude,
                Longitude      = request.Data.Longitude,
                ExpectGender   = request.Data.ExpectGender,
                ShareType      = request.Data.ShareType,
                Title          = request.Data.Title,
                Content        = request.Data.Content,
                CreateTime     = DateTime.Now,
                UpdateTime     = DateTime.Now
            };

            if (!string.IsNullOrEmpty(request.Data.StopTime))
            {
                moment.StopTime = DateTime.Parse(request.Data.StopTime);
            }
            if (!string.IsNullOrEmpty(request.Data.Mobile))
            {
                userInfoDao.UpdateMobile(request.Head.UId, request.Data.Mobile);
            }
            if (!string.IsNullOrEmpty(request.Data.WeChatNo))
            {
                userInfoDao.UpdateWeChatNo(request.Head.UId, request.Data.WeChatNo);
            }
            if (!string.IsNullOrEmpty(request.Data.QQNo))
            {
                userInfoDao.UpdateQQNo(request.Head.UId, request.Data.QQNo);
            }
            momentDao.Insert(moment);
            return(response);
        }
Exemple #11
0
        public void Send_Activity_Cancel_MsgAsync(MomentEntity moment, List <long> userIds)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    if (userIds.IsNullOrEmpty() || moment == null)
                    {
                        return;
                    }
                    var token = GetAccessToken();
                    if (string.IsNullOrEmpty(token))
                    {
                        return;
                    }

                    string url = string.Format(CommonConst.Message_Send_Url_WeChat, token);

                    foreach (long uid in userIds)
                    {
                        var targetUserInfo = uerInfoBiz.GetUserInfoByUid(uid);
                        var momentUserInfo = uerInfoBiz.GetUserInfoByUid(moment.UId);
                        if (targetUserInfo == null || momentUserInfo == null)
                        {
                            continue;
                        }
                        var message = new MessageContext <ActivityCancelMsgDTO>()
                        {
                            touser       = targetUserInfo.OpenId,
                            access_token = token,
                            template_id  = CommonConst.Activity_Cancel_TmplId_WeChat,
                            page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                            data         = new ActivityCancelMsgDTO()
                            {
                                thing1 = new Value(string.Format("{0}:{1}", moment.Title, moment.Content).CutText(20)),
                                date2  = new Value(moment.CreateTime.ToString("yyyy年MM月dd日 HH:mm")),
                                name3  = new Value(momentUserInfo.NickName),
                                thing4 = new Value("活动取消,点击查看详情")
                            }
                        };
                        HttpHelper.HttpPost <MessageContext <ActivityCancelMsgDTO>, WeChatResponseDTO>(url, message, 5);
                    }
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Activity_Cancel_MsgAsync", ex);
            }
        }
        public static string GetShareTitle(MomentEntity moment)
        {
            if (moment == null)
            {
                return(null);
            }
            var stringBuilder = new StringBuilder();

            if (!string.IsNullOrEmpty(moment.Title))
            {
                stringBuilder.AppendFormat("{0}:", moment.Title);
            }
            if (!string.IsNullOrEmpty(moment.Content))
            {
                stringBuilder.Append(moment.Content);
            }
            return(stringBuilder.ToString());
        }
Exemple #13
0
        public void Send_Activity_Join_MsgAsync(MomentEntity moment, long targetUserId, bool joinSuccess, string joinMsg)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    var targetUserInfo = uerInfoBiz.GetUserInfoByUid(targetUserId);
                    var token          = GetAccessToken();
                    if (targetUserInfo == null || moment == null || string.IsNullOrEmpty(token))
                    {
                        return;
                    }

                    string title = string.Format("{0}:{1}", moment.Title, moment.Content);
                    string place = moment.IsOffLine ? moment.Place : "线上活动";
                    string state = joinSuccess ? "加入成功" : "加入失败";
                    var message  = new MessageContext <ActivityJoinMsgDTO>()
                    {
                        touser       = targetUserInfo.OpenId,
                        access_token = token,
                        template_id  = CommonConst.Activity_Join_TmplId_WeChat,
                        page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                        data         = new ActivityJoinMsgDTO()
                        {
                            thing2  = new Value(title.CutText(20)),
                            thing3  = new Value(place.CutText(20)),
                            phrase1 = new Value(state),
                            thing9  = new Value(joinMsg)
                        }
                    };


                    string url = string.Format(CommonConst.Message_Send_Url_WeChat, token);

                    HttpHelper.HttpPost <MessageContext <ActivityJoinMsgDTO>, WeChatResponseDTO>(url, message, 5);
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Activity_Join_MsgAsync", ex);
            }
        }
Exemple #14
0
        public void Send_Activity_Join_MsgAsync(MomentEntity moment, long targetUserId, bool joinSuccess, string joinMsg)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    var targetUserInfo = uerInfoBiz.GetUserInfoByUid(targetUserId);
                    var token          = GetAccessToken();
                    if (targetUserInfo == null || moment == null || string.IsNullOrEmpty(token))
                    {
                        return;
                    }

                    string title = string.Format("{0}:{1}", moment.Title, moment.Content);
                    string place = moment.IsOffLine ? moment.Place : "线上活动";
                    string state = joinSuccess ? "加入成功" : "加入失败";
                    var message  = new MessageContext <Dictionary <string, Value> >()
                    {
                        touser       = targetUserInfo.OpenId,
                        access_token = token,
                        template_id  = CommonConst.Activity_Join_TmplId_QQ,
                        page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                        data         = new Dictionary <string, Value>()
                        {
                            { "keyword1", new Value(title.CutText(20)) },
                            { "keyword2", new Value(place) },
                            { "keyword3", new Value(state) },
                            { "keyword4", new Value(joinMsg.CutText(20)) },
                            { "keyword5", new Value(DateTime.Now.ToString("yyyy年MM月dd日 HH:mm")) }
                        }
                    };

                    string url = string.Format(CommonConst.Message_Send_Url_QQ, token);

                    HttpHelper.HttpPost <MessageContext <Dictionary <string, Value> >, WeChatResponseDTO>(url, message, 5);
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Moment_Publish_MsgAsync", ex);
            }
        }
Exemple #15
0
        public void Send_Moment_Join_MsgAsync(MomentEntity moment, long targetUserId, string momentUserOpenId)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    var targetUserInfo = uerInfoBiz.GetUserInfoByUid(targetUserId);
                    if (targetUserInfo == null || moment == null)
                    {
                        return;
                    }
                    var token = GetAccessToken();
                    if (string.IsNullOrEmpty(token))
                    {
                        return;
                    }
                    var message = new MessageContext <Dictionary <string, Value> >()
                    {
                        touser       = momentUserOpenId,
                        access_token = token,
                        template_id  = CommonConst.Moment_Join_TmplId_QQ,
                        page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                        data         = new Dictionary <string, Value>()
                        {
                            { "keyword1", new Value(string.Format("{0}:{1}", moment.Title, moment.Content).CutText(20)) },
                            { "keyword2", new Value(targetUserInfo.NickName.CutText(20)) },
                            { "keyword3", new Value(DateTime.Now.ToString("yyyy年MM月dd日 HH:mm")) },
                            { "keyword4", new Value("申请参与该活动,请审批") }
                        }
                    };

                    string url = string.Format(CommonConst.Message_Send_Url_QQ, token);

                    HttpHelper.HttpPost <MessageContext <Dictionary <string, Value> >, WeChatResponseDTO>(url, message, 5);
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Moment_Publish_MsgAsync", ex);
            }
        }
Exemple #16
0
        public void Send_Moment_Publish_MsgAsync(MomentEntity moment, string targetUser, string remark)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    var token = GetAccessToken();
                    if (string.IsNullOrEmpty(token))
                    {
                        return;
                    }

                    string title = string.Format("{0}:{1}", moment.Title, moment.Content);
                    string place = moment.IsOffLine ? moment.Place : "线上活动";
                    string state = moment.State == MomentStateEnum.正常发布中 ? "审核通过" : "审核不通过";
                    var message  = new MessageContext <MomentPublishMsgDTO>()
                    {
                        touser       = targetUser,
                        access_token = token,
                        template_id  = CommonConst.Moment_Publish_TmplId_WeChat,
                        page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                        data         = new MomentPublishMsgDTO()
                        {
                            thing2  = new Value(title.CutText(20)),
                            thing7  = new Value(place.CutText(20)),
                            phrase5 = new Value(state),
                            thing8  = new Value(remark.CutText(20)),
                            date4   = new Value(DateTime.Now.ToString("yyyy年MM月dd日 HH:mm"))
                        }
                    };

                    string url = string.Format(CommonConst.Message_Send_Url_WeChat, token);

                    HttpHelper.HttpPost <MessageContext <MomentPublishMsgDTO>, WeChatResponseDTO>(url, message, 5);
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Moment_Publish_MsgAsync", ex);
            }
        }
Exemple #17
0
        public void Send_Moment_Publish_MsgAsync(MomentEntity moment, string targetUser, string remark)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    var token = GetAccessToken();
                    if (string.IsNullOrEmpty(token))
                    {
                        return;
                    }

                    string title = string.Format("{0}:{1}", moment.Title, moment.Content);
                    string state = moment.State == MomentStateEnum.正常发布中 ? "审核通过" : "审核不通过";
                    var message  = new MessageContext <Dictionary <string, Value> >()
                    {
                        touser       = targetUser,
                        access_token = token,
                        template_id  = CommonConst.Moment_Publish_TmplId_QQ,
                        page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                        data         = new Dictionary <string, Value>()
                        {
                            { "keyword1", new Value(title.CutText(20)) },
                            { "keyword2", new Value(moment.CreateTime.ToString("yyyy年MM月dd日 HH:mm")) },
                            { "keyword3", new Value(state) },
                            { "keyword4", new Value(remark.CutText(20)) }
                        }
                    };

                    string url = string.Format(CommonConst.Message_Send_Url_QQ, token);

                    HttpHelper.HttpPost <MessageContext <Dictionary <string, Value> >, WeChatResponseDTO>(url, message, 5);
                });
            }
            catch (Exception ex)
            {
                log.Error("Send_Moment_Publish_MsgAsync", ex);
            }
        }
Exemple #18
0
        public void Send_Moment_Join_MsgAsync(MomentEntity moment, long targetUserId, string momentUserOpenId)
        {
            try
            {
                var targetUserInfo = uerInfoBiz.GetUserInfoByUid(targetUserId);
                if (targetUserInfo == null || moment == null)
                {
                    return;
                }
                var token = GetAccessToken();
                if (string.IsNullOrEmpty(token))
                {
                    return;
                }

                var message = new MessageContext <MomentJoinMsgDTO>()
                {
                    touser       = momentUserOpenId,
                    access_token = token,
                    template_id  = CommonConst.Moment_Join_TmplId_WeChat,
                    page         = string.Format(CommonConst.BingoSharePageUrl, moment.MomentId.ToString()),
                    data         = new MomentJoinMsgDTO()
                    {
                        thing1 = new Value(string.Format("{0}:{1}", moment.Title, moment.Content).CutText(20)),
                        thing2 = new Value(targetUserInfo.NickName.CutText(20)),
                        thing3 = new Value("申请参与该活动,请审批")
                    }
                };
                string url = string.Format(CommonConst.Message_Send_Url_WeChat, token);

                HttpHelper.HttpPost <MessageContext <MomentJoinMsgDTO>, WeChatResponseDTO>(url, message, 5);
            }
            catch (Exception ex)
            {
                log.Error("Send_Moment_Join_MsgAsync", ex);
            }
        }
Exemple #19
0
 public void Send_Activity_Cancel_MsgAsync(MomentEntity moment, List <long> userIds)
 {
     return;
 }
Exemple #20
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, "申请提交成功"));
        }
Exemple #21
0
 public static bool IsOverCount(MomentEntity moment)
 {
     return(moment.ApplyCount >= moment.NeedCount);
 }