Beispiel #1
0
 public AsynMessage(M_Message msg)
 {
     TMM.Persistence.SqlMapper.Instance().SessionStore =
                 new IBatisNet.DataMapper.SessionStore.HybridWebThreadSessionStore(TMM.Persistence.SqlMapper.Instance().Id);
     this.messages = new Queue<M_Message>();
     this.messages.Enqueue(msg);
 }
Beispiel #2
0
 /// <summary>
 /// 格式化“回复消息”
 /// </summary>
 /// <returns></returns>
 public static string GetReplyMsg(M_Message msg,U_UserInfo sender)
 {
     string m = string.Empty;
     m = string.Format(
         "\r\n\r\n\r\n{3}以下是历史消息{3}\r\n{0},原发件人:{1}\r\n\r\n{2}",
         msg.CreateTime.ToString(),sender.TmmDispName,msg.Content,
         ConfigHelper.MsgSepChar);
     return m;
 }
Beispiel #3
0
        public void DoManualOperate(int userId, int accountWay, decimal amount, string remark)
        {
            try
            {
                UserService us = Context.GetService<UserService>();
                if (amount == 0)
                    throw new TmmException("金额不能为0");
                if (accountWay == 0)
                    throw new TmmException("请选择类型");
                if (accountWay == (int)AmountWay.MIn) {
                    if (amount <= 0)
                        throw new TmmException("增加金额不能小于0");
                }
                if (accountWay == (int)AmountWay.AOut)
                {
                    if (amount >= 0)
                        throw new TmmException("扣除金额不能大于0");
                }
                if (string.IsNullOrEmpty(remark))
                    throw new TmmException("备注不能为空");
                MAccount acc = us.MAccountBll.GetByUserId(userId);
                //写账户日志
                AccountLog log = new AccountLog() {
                    AccountWay = accountWay,
                    AdminRemark = remark,
                    Amount = amount,
                    CreateTime = DateTime.Now,
                    Ip = Utils.TmmUtils.IPAddress(),
                    UserId = userId

                };
                us.AccountLogBll.Insert(log);

                acc.Amount += amount;
                us.MAccountBll.Update(acc);
                //发消息-异步
                M_Message msg = new M_Message()
                {
                    Content = string.Format("【帐户通知】,您的账户由土木迷管理员{0}¥{1:F2}",
                    amount > 0 ? "充入" : "扣除", amount),
                    CreateTime = DateTime.Now,
                    IsRead = false,
                    Mtype = (int)Model.Enums.MessageType.Inform,
                    RecieverId = userId,
                    SenderId = Core.Helper.ConfigHelper.AdminUserId,
                    Title = "帐户通知"
                };
                Queue<M_Message> queueMsg = new Queue<M_Message>();
                queueMsg.Enqueue(msg);
                Common.AsynMessage am = new AsynMessage(queueMsg);
                am.Send();

                base.SuccessInfo();
                Redirect("account.do");
                return;
            }
            catch (TmmException te)
            {
                AddError(te.Message);
                Flash["accountWay"] = accountWay;
                Flash["amount"] = amount;
                Flash["remark"] = remark;
            }
            RedirectToReferrer();
        }
Beispiel #4
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(M_Message obj)
 {
     return dal.Update(obj);
 }
Beispiel #5
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(M_Message obj)
 {
     return dal.Insert(obj);
 }
Beispiel #6
0
        public void DoEditDoc([DataBind("DDocInfo")]DDocInfo doc,HttpPostedFile file)
        {
            try
            {
                //DocService us = Context.GetService<DocService>();
                UserService us = Context.GetService<UserService>();
                DDocInfo oldDoc = us.DocInfoBll.Get(doc.DocId);
                if (oldDoc != null)
                {
                    //更新缩略图
                    if (file != null && !string.IsNullOrEmpty(file.FileName))
                    {
                        string newThumbUrl = SaveNewDocThumbnail(file, oldDoc.ThumbnailUrl);
                        if (!string.IsNullOrEmpty(newThumbUrl))
                            oldDoc.ThumbnailUrl = newThumbUrl;
                    }
                    else
                        oldDoc.ThumbnailUrl = doc.ThumbnailUrl;

                    oldDoc.Title = doc.Title;
                    oldDoc.Description = doc.Description;
                    oldDoc.Tags = doc.Tags;
                    oldDoc.CateId = doc.CateId;
                    oldDoc.Price = doc.Price;
                    oldDoc.FlashUrl = doc.FlashUrl;
                    us.DocInfoBll.Update(oldDoc);
                    //更新标签表
                    if (!string.IsNullOrEmpty(oldDoc.Tags) && oldDoc.Tags != doc.Tags)
                    {
                        string[] tags = doc.Tags.Split(' ');
                        us.DTagBll.UpdateFromDoc(tags, oldDoc.DocId);
                    }

                    //异步通知用户文档被管理员更新
                    M_Message msg = new M_Message()
                    {
                        Content = string.Format("您上传的文档“{0}”被管理员更新", doc.Title),
                        CreateTime = DateTime.Now,
                        IsRead = false,
                        Mtype = (int)Model.Enums.MessageType.Inform,
                        RecieverId = oldDoc.UserId,
                        SenderId = Helper.ConfigHelper.AdminUserId,
                        Title = string.Format("您上传的文档“{0}”被管理员更新", doc.Title)
                    };
                    Common.AsynMessage am = new AsynMessage(msg);
                    am.Send();

                    Redirect("/admin/doc/index.do");
                    return;
                }
                throw new Exception("查询文档为空");
            }
            catch (Exception ex)
            {
                Utils.Log4Net.Error(ex);
                RedirectToReferrer();
            }
        }
Beispiel #7
0
 /// <summary>
 /// 设置中标
 /// </summary>
 /// <param name="joinId"></param>
 public void SetZb(int joinId)
 {
     try
     {
         DocService ds = Context.GetService<DocService>();
         UserService us = Context.GetService<UserService>();
         U_UserInfo u = base.GetUser();
         //投稿对象
         TJoinDoc tj = ds.TJoinDocBll.Get(joinId);
         //是否已经中标了
         if (tj.IsWin)
             throw new TmmException("此投稿已经设置为中标");
         //悬赏对象
         TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId);
         //余额检测
         decimal ye = us.MAccountBll.GetByUserId(u.UserId).Amount;
         if (ye < trDoc.Price)
             throw new TmmException("您的余额不足,请先充值");
         //扣除需求方余额
         us.MAccountBll.AccountExpend(u.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(),trDoc.Title);
         //为投稿人增加余额
         us.MAccountBll.AddAmount(tj.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(),trDoc.Title);
         //更改原文档的owner
         DDocInfo doc = ds.DDocInfoBll.Get(tj.DocId);
         doc.UserId = u.UserId;
         doc.IsTaskDoc = false;
         ds.DDocInfoBll.Update(doc);
         PropertyBag["doc"] = doc;
         //更改投稿文档的状态
         tj.IsWin = true;
         tj.WinTime = DateTime.Now;
         ds.TJoinDocBll.Update(tj);
         //发送通知
         M_Message msg = new M_Message() {
             Mtype = (int)Model.Enums.MessageType.Inform,
             SenderId = ConfigHelper.AdminUserId,
             RecieverId = tj.UserId,
             Title = "您的投稿被选中",
             IsRead = false,
             CreateTime = DateTime.Now,
             Content = string.Format("您的投稿【{0}】被{1}设置中标,获得收入¥{2}",
                 tj.Title,"<a href='/home/" + u.UserId + ".html' target='_blank'>"+u.TmmDispName+"</a>"
                 , string.Format("{0:N2}", trDoc.Price))
         };
         us.MessageBll.Insert(msg);
     }
     catch (TmmException te)
     {
         AddError(te.Message);
         RedirectToReferrer();
     }
 }
Beispiel #8
0
        /// <summary>
        /// 删除投稿
        /// </summary>
        /// <param name="joinIds"></param>
        public void DeleteContribute(int[] joinIds)
        {
            DocService ds = Context.GetService<DocService>();
            Queue<M_Message> queueMsg = new Queue<M_Message>();
            foreach (int joinId in joinIds)
            {
                TJoinDoc joinDoc = ds.TJoinDocBll.Get(joinId);
                if (joinDoc != null) {
                    //更新悬赏文档的投稿数量
                    TReqDoc reqDoc = ds.TReqDocBll.Get(joinDoc.TId);
                    if (reqDoc != null) {
                        if (reqDoc.DocCount > 0) {
                            reqDoc.DocCount -= 1;
                            ds.TReqDocBll.Update(reqDoc);
                        }
                    }
                    //删除原始文档
                    ds.DDocInfoBll.Delete(joinDoc.DocId);
                    //删除投稿记录
                    ds.TJoinDocBll.Delete(joinId);
                    //给投稿人发消息
                    M_Message msg = new M_Message()
                    {
                        Content = string.Format("您上传的投稿文档【{0}】因违反相关规定,该文章已被管理员删除", joinDoc.Title),
                        CreateTime = DateTime.Now,
                        IsRead = false,
                        Mtype = (int)Model.Enums.MessageType.Inform,
                        RecieveDeleteFlag = false,
                        RecieverId = joinDoc.UserId,
                        SendDeleteFlag = false,
                        SenderId = Helper.ConfigHelper.AdminUserId,
                        Title = "投稿文档删除通知"
                    };
                    queueMsg.Enqueue(msg);
                    //给悬赏人发消息
                    msg = new M_Message()
                    {
                        Content = string.Format("您收到的投稿文档【{0}】因违反相关规定,该文章已被管理员删除", joinDoc.Title),
                        CreateTime = DateTime.Now,
                        IsRead = false,
                        Mtype = (int)Model.Enums.MessageType.Inform,
                        RecieveDeleteFlag = false,
                        RecieverId = reqDoc.UserId,
                        SendDeleteFlag = false,
                        SenderId = Helper.ConfigHelper.AdminUserId,
                        Title = "投稿文档删除通知"
                    };
                    queueMsg.Enqueue(msg);
                }
            }
            //异步发送消息
            AsynMessage am = new AsynMessage(queueMsg);
            am.Send();

            AddSuccess("操作成功");
            RedirectToReferrer();
        }
Beispiel #9
0
 public void DoExchange(decimal orderId)
 {
     OrderService os = Context.GetService<OrderService>();
     TOrder o = os.TOrderBll.Get(orderId);
     o.Status = (int)OrderStatus.AdminDoExchange;
     o.UpdateTime = DateTime.Now;
     os.TOrderBll.Update(o);
     //写账户日志
     AccountLog accLog = new AccountLog() {
         AccountWay = (int)AmountWay.EOut,
         Amount = -o.Total,
         CreateTime = DateTime.Now,
         Ip = Utils.TmmUtils.IPAddress(),
         OrderId = o.OrderId,
         UserId = o.UserId,
         PayWay = 0,
         AdminRemark = "兑换"
     };
     os.MAccountLogBll.Insert(accLog);
     //更新账户信息
     MAccount acc = os.MAccountBll.GetByUserId(o.UserId);
     acc.FrozenAmount -= o.Total;
     acc.TotalExchange += o.Total;
     acc.UpdateTime = DateTime.Now;
     os.MAccountBll.Update(acc);
     //发系统消息
     M_Message msg = new M_Message() {
         SenderId = Helper.ConfigHelper.AdminUserId,
         RecieverId = o.UserId,
         CreateTime = DateTime.Now,
         IsRead = false,
         Mtype = (int)Model.Enums.MessageType.Inform,
         Title = "您的兑换申请已经被受理",
         Content = string.Format("您的兑换申请已被管理员受理,请注意查收您的{0}账号",o.Remark == "1" ? "支付宝" : "银行")
     };
     Service.Bll.User.M_MessageBLL msgBll = new TMM.Service.Bll.User.M_MessageBLL();
     msgBll.Insert(msg);
     base.SuccessInfo();
     RedirectToReferrer();
 }
Beispiel #10
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(M_Message obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "M_Message.Insert";
     return SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
 }
Beispiel #11
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(M_Message obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "M_Message.Update";
     int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
     return result > 0 ? true : false;
 }
Beispiel #12
0
 public void DoSendMsg(string uids, int mtype, string title, string content)
 {
     UserService us = Context.GetService<UserService>();
     string[] ids = uids.Split(',');
     foreach (string s in ids)
     {
         M_Message msg = new M_Message() {
             Content = content,
             CreateTime = DateTime.Now,
             IsRead = false,
             Mtype = mtype,
             RecieverId = int.Parse(s),
             SenderId = ConfigHelper.AdminUserId,
             Title = title
         };
         us.MessageBll.Insert(msg);
     }
     base.SuccessInfo();
     RedirectToReferrer();
 }
Beispiel #13
0
 /// <summary>
 /// 支付成功后给上传人返利
 /// </summary>
 protected void AddAmountForUploader(
     decimal orderId,int uploaderId,decimal amount,
     OrderService os,int docId,string docTitle,int buyerId,int payway)
 {
     //先写入账户日志
     AccountLog al = new AccountLog() {
         OrderId = orderId,
         UserId = uploaderId,
         Amount = amount,
         AccountWay = (int)AmountWay.INCOME,
         Ip = Utils.TmmUtils.IPAddress(),
         PayWay = payway
     };
     int a = os.MAccountLogBll.Insert(al);
     //账户增加收入
     if (a > 0) {
         os.MAccountBll.AddAmount(uploaderId, amount);
     }
     //发送系统通知
     string tmp = "您的文档<a href='/p-{0}.html' target='_blank'>{1}</a>"
         + "被<a href='/home/{2}.html' target='_blank'>{3}</a>下载,获得收入¥{4}";
     M_Message msg = new M_Message() {
         SenderId = Helper.ConfigHelper.AdminUserId,
         Title = "恭喜您获得文档销售收入",
         CreateTime = DateTime.Now,
         Content = string.Format(tmp,docId,docTitle,buyerId,Helper.UserHelper.GetUserById(buyerId).TmmDispName,amount),
         IsRead = false,
         Mtype = (int)Model.Enums.MessageType.Inform,
         RecieverId = uploaderId
     };
     Service.Bll.User.M_MessageBLL mbll = new TMM.Service.Bll.User.M_MessageBLL();
     mbll.Insert(msg);
 }