示例#1
0
        /// <summary>
        /// 创建留言
        /// </summary>
        /// <param name="goodsleavewordinfo">要创建的留言信息</param>
        /// <param name="selleruid">卖家id</param>
        /// <param name="sendnotice">是否发送通知</param>
        /// <returns></returns>
        public static int CreateLeaveWord(Goodsleavewordinfo goodsLeaveWordInfo, int sellerUid, bool sendNotice)
        {
            goodsLeaveWordInfo.Postdatetime = DateTime.Now;
            goodsLeaveWordInfo.Usesig       = 0;
            goodsLeaveWordInfo.Invisible    = 0;
            goodsLeaveWordInfo.Htmlon       = 0;
            goodsLeaveWordInfo.Smileyoff    = 1;
            goodsLeaveWordInfo.Parseurloff  = 1;
            goodsLeaveWordInfo.Bbcodeoff    = 1;

            //当为买家时,则发送消息给卖家
            if (sendNotice && goodsLeaveWordInfo.Isbuyer == 1)
            {
                NoticeInfo noticeInfo = new NoticeInfo();
                //商品交易通知
                noticeInfo.Note         = Utils.HtmlEncode(string.Format("有买家 <a href=\"userinfo.aspx?userid={0}\">{1}</a> 给您留言, 请<a href =\"showgoods.aspx?goodsid={2}\">点击这里</a>查看详情.", goodsLeaveWordInfo.Uid, goodsLeaveWordInfo.Username, sellerUid));
                noticeInfo.Uid          = sellerUid;
                noticeInfo.Type         = NoticeType.GoodsLeaveWordNotice;
                noticeInfo.New          = 1;
                noticeInfo.Posterid     = goodsLeaveWordInfo.Uid;
                noticeInfo.Poster       = goodsLeaveWordInfo.Username;
                noticeInfo.Postdatetime = Utils.GetDateTime();

                Notices.CreateNoticeInfo(noticeInfo);
            }
            return(DbProvider.GetInstance().CreateGoodsLeaveWord(goodsLeaveWordInfo));
        }
示例#2
0
        public NotifyPage()
        {
            if (EPayments.CheckPayment(DNTRequest.GetString("notify_id")))//验证请求是否来自支付宝,或者是伪造的
            {
                //获取需要的信息
                int    orderStatus = EPayments.ConvertAlipayTradeStatus(DNTRequest.GetString("trade_status"));
                string orderCode   = DNTRequest.GetString("out_trade_no", true);
                string tradeNo     = DNTRequest.GetString("trade_no", true);

                if (string.IsNullOrEmpty(orderCode) || string.IsNullOrEmpty(tradeNo) || orderStatus <= 0)
                {
                    return;
                }

                CreditOrderInfo orderInfo = CreditOrders.GetCreditOrderInfoByOrderCode(orderCode);


                //如果订单状态为未成功交易
                if (orderInfo != null && orderInfo.OrderStatus < 2)
                {
                    float[] extcredits = new float[8];
                    extcredits[orderInfo.Credit - 1] = orderInfo.Amount;

                    if (UserCredits.UpdateUserExtCredits(orderInfo.Uid, extcredits, true) != 1)
                    {
                        orderStatus = 0;
                    }

                    CreditsLogs.AddCreditsLog(orderInfo.Uid, orderInfo.Uid, orderInfo.Credit, orderInfo.Credit, 0, orderInfo.Amount, Utils.GetDateTime(), 3);//添加积分兑换转账和充值记录

                    NoticeInfo notice = new NoticeInfo();
                    notice.Postdatetime = Utils.GetDateTime();
                    notice.Type         = NoticeType.GoodsTradeNotice;
                    notice.Poster       = "系统";
                    notice.Posterid     = 0;
                    notice.Uid          = orderInfo.Uid;
                    notice.Note         = string.Format("您购买的积分 {0} 已经成功充值,请<a href=\"usercpcreaditstransferlog.aspx\">查收</a>!(支付宝订单号:{1})", ForumUtils.ConvertCreditAndAmountToWord(orderInfo.Credit, orderInfo.Amount), tradeNo);
                    Notices.CreateNoticeInfo(notice);

                    CreditOrders.UpdateCreditOrderInfo(orderInfo.OrderId, tradeNo, orderStatus, Utils.GetDateTime());//修改积分订单记录状态
                }
                //判断当前请求是支付宝GET式(直接跳转)或者是服务器POST式(需返回success使得支付宝停止继续发送通知)
                if (DNTRequest.IsPost())
                {
                    HttpContext.Current.Response.Write("success");
                }
                else
                {
                    HttpContext.Current.Response.Redirect("../usercpcreaditstransferlog.aspx?paysuccess=true");
                }
            }
            else
            {
                HttpContext.Current.Response.Write("fail");
            }
        }
示例#3
0
 /// <summary>
 /// 发送相册图片评论通知
 /// </summary>
 /// <param name="pcomment">评论信息</param>
 private void SendPhotoComment(PhotoCommentInfo pcomment)
 {
     //当回复人与相册所有人不是同一人时,则向相册所有人发送通知
     if (album.Userid != pcomment.Userid && pcomment.Commentid > 0)
     {
         NoticeInfo noticeinfo = new NoticeInfo();
         noticeinfo.Note         = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 评论了您的{2}--\"{3}\" , 请<a href =\"showphoto.aspx?photoid={4}&reply={5}#comments\">点击这里</a>查看详情.", pcomment.Userid, pcomment.Username, config.Albumname, album.Title, pcomment.Photoid, pcomment.Commentid));
         noticeinfo.Type         = NoticeType.AlbumCommentNotice;
         noticeinfo.New          = 1;
         noticeinfo.Posterid     = pcomment.Userid;
         noticeinfo.Poster       = pcomment.Username;
         noticeinfo.Postdatetime = Utils.GetDateTime();
         noticeinfo.Uid          = album.Userid;
         Notices.CreateNoticeInfo(noticeinfo);
     }
 }
示例#4
0
        /// <summary>
        /// 日志评论通知
        /// </summary>
        /// <param name="commentinfo">日志评论信息</param>
        public void SendSpaceCommentNotice(SpaceCommentInfo commentinfo)
        {
            //要回复的用户id
            int replyuserid = DNTRequest.GetInt("userid", 0);

            //当日志有效时
            if (commentinfo.PostID > 0)
            {
                SpacePostInfo __spacepostsinfo = BlogProvider.GetSpacepostsInfo(Space.Data.DbProvider.GetInstance().GetSpacePost(commentinfo.PostID));
                //当日志有效时
                if (__spacepostsinfo != null)
                {
                    NoticeInfo __noticeinfo = new NoticeInfo();
                    __noticeinfo.Type         = NoticeType.SpaceCommentNotice;
                    __noticeinfo.New          = 1;
                    __noticeinfo.Posterid     = commentinfo.Uid;
                    __noticeinfo.Poster       = commentinfo.Author;
                    __noticeinfo.Postdatetime = Utils.GetDateTime();

                    //当回复人与评论作者不是同一人时,则向评论作者发送通知
                    if (__noticeinfo.Posterid != replyuserid && replyuserid > 0)
                    {
                        __noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 回复了您的日志信息 <a href =\"viewspacepost.aspx?postid={3}\">{4}</a>.", commentinfo.Uid, commentinfo.Author, config.Spacename, commentinfo.PostID, __spacepostsinfo.Title));
                        __noticeinfo.Uid  = replyuserid;
                        Notices.CreateNoticeInfo(__noticeinfo);
                    }

                    //当上面通知的用户与该空间日志作者不同,则还要向主题作者发通知
                    if (__noticeinfo.Posterid != __spacepostsinfo.Uid && __spacepostsinfo.Uid > 0)
                    {
                        __noticeinfo.Note = Utils.HtmlEncode(string.Format("<a href=\"userinfo.aspx?userid={0}\">{1}</a> 评论了您的{2}日志 <a href =\"viewspacepost.aspx?postid={3}\">{4}</a>.", commentinfo.Uid, commentinfo.Author, config.Spacename, commentinfo.PostID, __spacepostsinfo.Title));
                        __noticeinfo.Uid  = __spacepostsinfo.Uid;
                        Notices.CreateNoticeInfo(__noticeinfo);
                    }
                }
            }
        }
示例#5
0
        public override bool Run(CommandParameter commandParam, ref string result)
        {
            //如果是桌面程序则需要验证用户身份
            if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (commandParam.LocalUid < 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList);
                    return(false);
                }
                //如果当前用户不是管理员
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid).Radminid != 1)
                {
                    result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList);
                    return(false);
                }
            }

            if (!commandParam.CheckRequiredParams("notification"))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            //给当前登录用户发送通知可以将to_ids设置为空
            if (commandParam.LocalUid < 1 && (!commandParam.CheckRequiredParams("to_ids") || !Utils.IsNumericList(commandParam.GetDNTParam("to_ids").ToString())))
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList);
                return(false);
            }

            string ids = commandParam.GetDNTParam("to_ids").ToString();

            string notification = commandParam.GetDNTParam("notification").ToString();

            string[] to_ids;
            if (ids == string.Empty)
            {
                to_ids    = new string[1];
                to_ids[0] = commandParam.LocalUid.ToString();
            }
            else
            {
                to_ids = commandParam.GetDNTParam("to_ids").ToString().Split(',');
            }

            string        successfulIds = string.Empty;
            ShortUserInfo shortUserInfo = null;

            if (commandParam.LocalUid > 0)
            {
                shortUserInfo = Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid);
            }

            foreach (string id in to_ids)
            {
                if (Utils.StrToInt(id, 0) < 1)
                {
                    continue;
                }

                NoticeInfo noticeinfo = new NoticeInfo();
                noticeinfo.Uid          = Utils.StrToInt(id, 0);
                noticeinfo.New          = 1;
                noticeinfo.Postdatetime = Utils.GetDateTime();

                //如果应用程序没有指定来源id,则会将当前应用程序id的hash值作为来源ID,若不指定来源id,用户的通知列表中只存在一条最新的应用程序通知
                noticeinfo.Fromid = commandParam.GetIntParam("from_id", Utils.BKDEHash(commandParam.AppInfo.APIKey, 113));
                //如果应用程序指定了来源id,则通知类型为“应用程序自定义通知”,否则是“应用程序通知”
                noticeinfo.Type = commandParam.CheckRequiredParams("from_id") ? NoticeType.ApplicationCustomNotice : NoticeType.ApplicationNotice;

                if (commandParam.LocalUid > 0)
                {
                    noticeinfo.Poster   = shortUserInfo == null ? "" : shortUserInfo.Username;
                    noticeinfo.Posterid = commandParam.LocalUid;
                }
                else
                {
                    noticeinfo.Poster   = "";
                    noticeinfo.Posterid = 0;
                }
                noticeinfo.Note = Utils.EncodeHtml(notification);//需要做ubb标签转换

                if (Notices.CreateNoticeInfo(noticeinfo) > 0)
                {
                    successfulIds += (id + ",");
                }
            }

            if (successfulIds.Length > 0)
            {
                successfulIds = successfulIds.Remove(successfulIds.Length - 1);
            }
            if (commandParam.Format == FormatType.JSON)
            {
                result = string.Format("\"{0}\"", successfulIds);
            }
            else
            {
                NotificationSendResponse nsr = new NotificationSendResponse();
                nsr.Result = successfulIds;
                result     = SerializationHelper.Serialize(nsr);
            }
            return(true);
        }
示例#6
0
        /// <summary>
        /// 发送通知
        /// </summary>
        /// <returns></returns>
        public string Send()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }
                if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid).Radminid != 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            if (!CheckRequiredParams("notification"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            if (GetParam("to_ids") == null)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            if (Uid < 1 && (!CheckRequiredParams("to_ids") || !Utils.IsNumericArray(GetParam("to_ids").ToString().Split(','))))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            string ids = GetParam("to_ids").ToString();

            string notification = GetParam("notification").ToString();

            string[] to_ids;
            if (ids == string.Empty)
            {
                to_ids    = new string[1];
                to_ids[0] = Uid.ToString();
            }
            else
            {
                to_ids = GetParam("to_ids").ToString().Split(',');
            }

            string        successfulIds = string.Empty;
            ShortUserInfo shortUserInfo = null;

            if (Uid > 0)
            {
                shortUserInfo = Discuz.Forum.Users.GetShortUserInfo(Uid);
            }
            foreach (string id in to_ids)
            {
                if (Utils.StrToInt(id, 0) < 1)
                {
                    continue;
                }
                NoticeInfo noticeinfo = new NoticeInfo();
                noticeinfo.Uid          = Utils.StrToInt(id, 0);
                noticeinfo.New          = 1;
                noticeinfo.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (Uid > 0)
                {
                    //ShortUserInfo shortUserInfo = Discuz.Forum.Users.GetShortUserInfo(Uid);
                    noticeinfo.Poster   = shortUserInfo == null ? "" : shortUserInfo.Username;
                    noticeinfo.Posterid = Uid;
                }
                else
                {
                    noticeinfo.Poster   = "";
                    noticeinfo.Posterid = 0;
                }
                noticeinfo.Note = Utils.EncodeHtml(notification);//需要做ubb标签转换

                if (Notices.CreateNoticeInfo(noticeinfo) > 0)
                {
                    successfulIds += (id + ",");
                }
            }

            if (successfulIds.Length > 0)
            {
                successfulIds = successfulIds.Remove(successfulIds.Length - 1);
            }
            if (Format == FormatType.JSON)
            {
                return(string.Format("\"{0}\"", successfulIds));
            }


            NotificationSendResponse nsr = new NotificationSendResponse();

            nsr.Result = successfulIds;
            return(SerializationHelper.Serialize(nsr));
        }
示例#7
0
        /// <summary>
        /// 根据交易日志的状态发送相应通知
        /// </summary>
        /// <param name="__goodstradelog">交易日志信息</param>
        /// <returns>是否发送成功</returns>
        public static bool SendNotice(Goodstradeloginfo goodsTradeLog)
        {
            string noticeContent = "这是由论坛系统自动发送的通知短消息.<BR />";
            bool   isSendNotice  = false;
            int    noticeUid     = 0;
            int    posterId      = 0;
            string poster        = "";
            string pageName      = goodsTradeLog.Offline == 1 ? "offlinetrade.aspx" : "onlinetrade.aspx";

            switch ((TradeStatusEnum)goodsTradeLog.Status)
            {
            case TradeStatusEnum.UnStart:
            {
                noticeContent = string.Format("买家 {0} 购买您的商品 {1}. 但交易尚未生效, 等待您的确认, 请<a href =\"" + pageName + "?goodstradelogid={2}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Buyer,
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Id);
                isSendNotice = true;
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                break;
            }

            case TradeStatusEnum.WAIT_SELLER_SEND_GOODS:
            {
                noticeContent = string.Format("买家 {0} 购买您的商品 {1}. 买家已付款, 等待您发货, 请<a href =\"" + pageName + "?goodstradelogid={2}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Buyer,
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Id);
                isSendNotice = true;
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                break;
            }

            case TradeStatusEnum.WAIT_BUYER_CONFIRM_GOODS:
            {
                noticeContent = string.Format("您购买的商品 {0} . 卖家 {1} 已发货, 等待您的确认, 请<a href =\"" + pageName + "?goodstradelogid={2}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Seller,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Buyerid;
                posterId     = goodsTradeLog.Sellerid;
                poster       = goodsTradeLog.Seller;
                isSendNotice = true;
                break;
            }

            case TradeStatusEnum.WAIT_SELLER_AGREE:
            {
                noticeContent = string.Format("买家 {0} 等待你同意退款, 请<a href =\"" + pageName + "?goodstradelogid={1}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Buyer,
                                              goodsTradeLog.Id);
                isSendNotice = true;
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                break;
            }

            case TradeStatusEnum.SELLER_REFUSE_BUYER:
            {
                noticeContent = string.Format("卖家 {0} 拒绝您的条件, 等待您修改条件, 请<a href =\"" + pageName + "?goodstradelogid={1}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Seller,
                                              goodsTradeLog.Id);
                isSendNotice = true;
                noticeUid    = goodsTradeLog.Buyerid;
                posterId     = goodsTradeLog.Sellerid;
                poster       = goodsTradeLog.Seller;
                break;
            }

            case TradeStatusEnum.WAIT_BUYER_RETURN_GOODS:
            {
                noticeContent = string.Format("卖家 {0} 同意退款, 等待您退货, 请<a href =\"" + pageName + "?goodstradelogid={1}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Seller,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Buyerid;
                posterId     = goodsTradeLog.Sellerid;
                poster       = goodsTradeLog.Seller;
                isSendNotice = true;
                break;
            }

            case TradeStatusEnum.WAIT_SELLER_CONFIRM_GOODS:
            {
                noticeContent = string.Format("买家 {0} 已退货, 等待您收货, 请<a href =\"" + pageName + "?goodstradelogid={1}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Buyer,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                isSendNotice = true;
                break;
            }

            case TradeStatusEnum.TRADE_FINISHED:
            {
                noticeContent = string.Format("商品 {0} 已交易成功, 请<a href =\"goodsrate.aspx?goodstradelogid={1}\">点击这里</a>给对方评分.",
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                isSendNotice = true;
                break;
            }

            case TradeStatusEnum.TRADE_CLOSED:
            {
                noticeContent = string.Format("商品 {0} 交易失败, 卖家取消交易, 请<a href =\"goodsrate.aspx?goodstradelogid={1}\">点击这里</a>查看详情.",
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Sellerid;
                posterId     = goodsTradeLog.Buyerid;
                poster       = goodsTradeLog.Buyername;
                isSendNotice = true;
                break;
            }

            case TradeStatusEnum.REFUND_SUCCESS:
            {
                noticeContent = string.Format("商品 {0} 已退款成功, 请<a href =\"goodsrate.aspx?goodstradelogid={1}\">点击这里</a>给对方评分.",
                                              goodsTradeLog.Subject,
                                              goodsTradeLog.Id);
                noticeUid    = goodsTradeLog.Buyerid;
                posterId     = goodsTradeLog.Sellerid;
                poster       = goodsTradeLog.Seller;
                isSendNotice = true;
                break;
            }
            }

            //发送通知
            if (isSendNotice)
            {
                NoticeInfo noticeInfo = new NoticeInfo();
                //商品交易通知
                noticeInfo.Note         = Utils.HtmlEncode(noticeContent);
                noticeInfo.Uid          = noticeUid;
                noticeInfo.Type         = NoticeType.GoodsTradeNotice;
                noticeInfo.New          = 1;
                noticeInfo.Posterid     = posterId;
                noticeInfo.Poster       = poster;
                noticeInfo.Postdatetime = Utils.GetDateTime();

                Notices.CreateNoticeInfo(noticeInfo);
            }
            return(true);
        }