示例#1
0
        /// <summary>
        /// 添加举报信友圈信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool CreateReport(ReqReport req)
        {
            TnetReginfo  regInfo      = PxinCache.GetRegInfo(req.Nodeid);
            TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.InfoId && a.Status == 1);

            if (tpxinMessage == null)
            {
                Alert("信友圈信息不存在");
                return(false);
            }
            TpxinReport tpxinReport = db.TpxinReportSet.FirstOrDefault(a => a.Infoid == req.InfoId && a.Satatus == 0 && a.Nodeid == req.Nodeid);

            if (tpxinReport != null)
            {
                Alert("您已举报该信友圈,请等待管理员审核");
                return(false);
            }
            db.TpxinReportSet.Add(new TpxinReport
            {
                Createtime = DateTime.Now,
                Infoid     = req.InfoId,
                Nodeid     = regInfo.Nodeid,
                Reason     = req.Reason,
                Remarks    = req.Remarks,
                Satatus    = 0
            });
            if (db.SaveChanges() <= 0)
            {
                Alert("举报失败");
                return(false);
            }
            Alert("举报成功", 1);
            return(true);
        }
示例#2
0
 private bool CheckParam()
 {
     if (MsgId > 0)
     {
         message = db.TpxinMessageSet.FirstOrDefault(c => c.Infoid == MsgId);
     }
     if (message == null)
     {
         log.Info($"{nameof(MsgId)}={MsgId}:消息不存在");
         return(false);
     }
     return(true);
 }
示例#3
0
        /// <summary>
        /// 删除信友圈
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool DeleteMsg(ReqDeleteMsg req)
        {
            TnetReginfo  regInfo = PxinCache.GetRegInfo(req.Nodeid);
            TpxinMessage message = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Status == 1);

            if (message == null)
            {
                Alert("删除的信友圈不存在");
                return(false);
            }
            message.Status = 0;
            if (db.SaveChanges() <= 0)
            {
                Alert("删除信友圈失败");
                return(false);
            }
            Alert("删除信友圈成功", 1);
            return(true);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        public void Execute()
        {
            string guidStr = Guid.NewGuid().ToString();

            log.Info($"开始调用消息分发{guidStr}");
            if (!Try(CheckParam))
            {
                return;
            }
            db.Configuration.AutoDetectChangesEnabled = false;
            if (Try(ExecuteCore))
            {
                log.Info($"调用消息分发成功-结束{guidStr}");
            }
            else
            {
                log.Info($"调用消息分发失败-结束{guidStr}");
            }
            db.Configuration.AutoDetectChangesEnabled = true;
            MsgId   = 0;
            message = null;
        }
示例#5
0
        /// <summary>
        /// 点赞或踩
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool CreateAttitude(ReqCreateAttitude req)
        {
            TnetReginfo  regInfo      = PxinCache.GetRegInfo(req.Nodeid);
            TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Status == 1);

            if (tpxinMessage == null)
            {
                Alert("信友圈信息不存在");
                return(false);
            }
            if (req.Isupdown != -1 && req.Isupdown != 1)
            {
                Alert("参数不正确");
                return(false);
            }
            if (regInfo.Nodeid == tpxinMessage.Nodeid)
            {
                Alert("不能自己给自己点赞或踩");
                return(false);
            }
            if (tpxinMessage.Price > 0)
            {
                TpxinPayhis tpxinPayhis = db.TpxinPayhisSet.FirstOrDefault(a => a.Infoid == tpxinMessage.Infoid && a.Nodeid == req.Nodeid && a.Typeid == 3);
                if (tpxinPayhis == null)
                {
                    Alert("请支付V点查看后点赞或踩");
                    return(false);
                }
            }
            TpxinPraise tpxinPraise = db.TpxinPraiseSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Fromnodeid == req.Nodeid);

            if (tpxinPraise != null && tpxinPraise.Status != 0)
            {
                Alert("一个文章只能点赞或踩一次");
                return(false);
            }
            try
            {
                db.BeginTransaction();
                if (tpxinPraise == null)
                {
                    //添加信友圈踩赞历史表
                    tpxinPraise = new TpxinPraise
                    {
                        Infoid     = req.Infoid,
                        Createtime = DateTime.Now,
                        Fromnodeid = req.Nodeid,
                        Tonodeid   = tpxinMessage.Nodeid,
                        Remarks    = "",
                        Reward     = 0,
                        Status     = req.Isupdown
                    };
                    db.TpxinPraiseSet.Add(tpxinPraise);
                }
                else
                {
                    tpxinPraise.Status = req.Isupdown;
                }
                //查询法比用户信息
                TpxinUserinfo userinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == tpxinMessage.Nodeid);
                if (userinfo == null)
                {
                    Alert("用户不存在");
                    db.Rollback();
                    return(false);
                }
                if (req.Isupdown == 1)
                {
                    //添加文章表的赞的次数
                    tpxinMessage.Up += 1;
                    //增加一个用户p点
                    userinfo.Up += 1;
                }
                else
                {
                    //添加文章表的踩的次数
                    tpxinMessage.Down += 1;
                    //减去一个用户p点
                    userinfo.Down += 1;
                }
                ////添加金额变化记录
                //var amount = req.Isupdown == 1 ? 1 : -1;
                //var reason = req.Isupdown == 1 ? AmountChangeReason.PraiseArticle : AmountChangeReason.TreadArticle;
                ////var tpxinMsgUser = PxinCache.GetRegInfo(userinfo.Nodeid);//db.TchatUserSet.First(c => c.Nodeid == userinfo.Nodeid);//

                //var remarks = (req.Isupdown == 1 ? "赞-" : "踩-") + regInfo.Nodename;
                //var amountChangeHis = CreateAmountChangeHis(tpxinMessage.Nodeid, 2, amount, (int)reason, Guid.NewGuid().ToString(), remarks);
                //db.TpxinAmountChangeHisSet.Add(amountChangeHis);

                #region 由VP服务来处理V点P点操作
                if (db.SaveChanges() <= 0)
                {
                    Alert("操作失败");
                    log.Error("点赞点踩失败,提交db失败:" + db.Message);
                    db.Rollback();
                    return(false);
                }
                var vp     = new VPHelper();
                var result = vp.SetP(new VPAuction
                {
                    Nodeid     = tpxinMessage.Nodeid,
                    Reason     = (int)(req.Isupdown == 1 ? AmountChangeReason.PraiseArticle : AmountChangeReason.TreadArticle),
                    Remark     = (req.Isupdown == 1 ? "赞-" : "踩-") + regInfo.Nodename,
                    Amount     = req.Isupdown == 1 ? 1 : -1,
                    Transferid = tpxinPraise.Hisid.ToString(),
                });
                if (result.Result <= 0)
                {
                    Alert(result.Message, result.Result);
                    db.Rollback();
                    return(false);
                }
                db.Commit();
                #endregion
            }
            catch (Exception ex)
            {
                log.Info("点赞或踩失败,原因:" + ex);
                Alert("操作失败");
                db.Rollback();
                return(false);
            }
            Alert("操作成功", 1);
            return(true);
        }
示例#6
0
        /// <summary>
        /// 评论
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool CreateComment(ReqCreateComment req)
        {
            if (req.Content.Length > 100)
            {
                Alert("评论不能超过100字哦");
                return(false);
            }
            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);

            TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Status == 1);

            if (tpxinMessage == null)
            {
                Alert("信友圈信息不存在");
                return(false);
            }
            //发布文章的用户不只是自己的要支付V点
            if (tpxinMessage.Price > 0 && tpxinMessage.Nodeid != regInfo.Nodeid)
            {
                TpxinPayhis tpxinPayhis = db.TpxinPayhisSet.FirstOrDefault(a => a.Infoid == tpxinMessage.Infoid && a.Nodeid == req.Nodeid && a.Typeid == 3);
                if (tpxinPayhis == null)
                {
                    Alert("请支付V点查看后评论");
                    return(false);
                }
            }
            int Pnodeid = 0;

            if (req.Phisid > 0)
            {
                TpxinCommentHis His = db.TpxinCommentHisSet.FirstOrDefault(a => a.Hisid == req.Phisid && a.Status == 1 && a.Infoid == req.Infoid);
                if (His == null)
                {
                    Alert("回复的评论不存在,或已删除");
                    return(false);
                }
                Pnodeid = His.Nodeid;
                if (Pnodeid == req.Nodeid)
                {
                    Alert("自己不能回复自己的评论");
                    return(false);
                }
            }
            //添加评论历史表
            TpxinCommentHis commentHis = new TpxinCommentHis
            {
                Nodeid     = req.Nodeid,
                Content    = req.Content,
                Createtime = DateTime.Now,
                Infoid     = req.Infoid,
                Remarks    = "",
                Status     = 1,
                Phisid     = req.Phisid,
                Pnodeid    = Pnodeid
            };

            db.TpxinCommentHisSet.Add(commentHis);
            //添加文章评论次数
            tpxinMessage.Commentnum += 1;
            if (db.SaveChanges() <= 0)
            {
                Alert("评论失败");
                return(false);
            }
            PxinSerivce.EnqueueComment(commentHis.Hisid);
            Alert("评论成功", 1);
            CommentHisId = commentHis.Hisid;
            return(true);
        }
示例#7
0
        /// <summary>
        /// 发布信友圈信息
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool CreateMsg(ReqPxinMessage req)
        {
            TnetReginfo  regInfo      = PxinCache.GetRegInfo(req.Nodeid);
            TpxinMessage tpxinMessage = new TpxinMessage
            {
                Infoid     = db.GetPrimaryKeyValue <TpxinMessage>(),
                Nodeid     = req.Nodeid,
                Price      = req.Price,
                Content    = req.Content,
                Picurl     = req.Picurl,
                Sound      = req.Sound,
                Video      = req.Video,
                Createtime = DateTime.Now,
                Remarks    = "",
                Status     = 1,
                Up         = 0,
                Down       = 0,
                Commentnum = 0
            };

            try
            {
                db.BeginTransaction();
                //添加信友圈信息
                db.TpxinMessageSet.Add(tpxinMessage);

                //发布信息扣一个v点
                //1.添加v点历史
                db.TpxinPayhisSet.Add(new TpxinPayhis
                {
                    Nodeid     = req.Nodeid,
                    Tonodeid   = 0,
                    Createtime = DateTime.Now,
                    Infoid     = tpxinMessage.Infoid,
                    Price      = -1,
                    Remarks    = "发布文章",
                    Typeid     = 2
                });
                //2.扣掉信友圈信息表的V点数量
                //TpxinUserinfo userinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == req.Nodeid);
                //userinfo.V -= 1;
                //if (userinfo.V < 0)
                //{
                //    Alert("发布信友圈失败,V点不足", -100);
                //    return false;
                //}
                ////添加金额变化记录
                //var amountChangeHis = CreateAmountChangeHis(req.Nodeid, 1, -1, (int)AmountChangeReason.PublishArticle, Guid.NewGuid().ToString(), "发布文章");
                //db.TpxinAmountChangeHisSet.Add(amountChangeHis);

                #region 由VP服务来处理V点P点操作
                if (db.SaveChanges() <= 0)
                {
                    Alert("发布信友圈失败");
                    log.Error("发布信友圈失败,提交db失败:" + db.Message);
                    db.Rollback();
                    return(false);
                }
                var vp     = new VPHelper();
                var result = vp.SetV(new VPChargeVDian
                {
                    Nodeid     = req.Nodeid,
                    Amount     = -1,
                    Reason     = (int)AmountChangeReason.PublishArticle,
                    Remark     = "发布文章",
                    Transferid = tpxinMessage.Infoid.ToString(),
                });
                if (result.Result <= 0)
                {
                    Alert(result.Message, result.Result);
                    db.Rollback();
                    return(false);
                }
                db.Commit();
                #endregion
            }
            catch (Exception ex)
            {
                log.Error("发布信友圈失败,原因" + ex);
                Alert("发布信友圈失败");
                db.Rollback();
                return(false);
            }
            Alert("发布信友圈成功", 1);
            PxinSerivce.EnqueueMsg(tpxinMessage.Infoid);
            return(true);
        }
示例#8
0
        /// <summary>
        /// 支付V点(查看文章)
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public MessageDto PayVDian(ReqPayVDian req)
        {
            #region 数据验证
            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);
            if (regInfo == null)
            {
                Alert("用户不存在");
                return(null);
            }
            //检查支付密码
            //if (!CheckPayPwd(regInfo, req.Pwd, false))
            //{
            //    Alert("支付密码错误");
            //    return false;
            //}

            TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.InfoID && a.Status == 1);
            if (tpxinMessage == null)
            {
                Alert("文章不存在");
                return(null);
            }
            if (tpxinMessage.Price == 0)
            {
                Alert("该文章不需要收费");
                return(null);
            }
            if (tpxinMessage.Nodeid == regInfo.Nodeid)
            {
                Alert("不能给自己的文章付费");
                return(null);
            }
            //TpxinUserinfo tpxinUserinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == regInfo.Nodeid);
            var vp     = new VPHelper();
            var vpDian = vp.GetTpxinUserinfo(regInfo.Nodeid);
            if (vpDian.VDianBalance < tpxinMessage.Price)
            {
                Alert("V点余额不足,请先充值");
                return(null);
            }
            TpxinPayhis pay = db.TpxinPayhisSet.FirstOrDefault(a => a.Infoid == tpxinMessage.Infoid && a.Nodeid == regInfo.Nodeid && a.Typeid == 3);
            if (pay != null)
            {
                Alert("您已支付查看文章费用");
                return(null);
            }

            #endregion
            try
            {
                db.BeginTransaction();
                //添加查看用户v点支付历史
                TpxinPayhis payhis = new TpxinPayhis()
                {
                    Createtime = DateTime.Now,
                    Infoid     = tpxinMessage.Infoid,
                    Typeid     = 3,
                    Nodeid     = regInfo.Nodeid,
                    Tonodeid   = tpxinMessage.Nodeid,
                    Price      = tpxinMessage.Price,
                    Remarks    = "查看文章"
                };
                db.TpxinPayhisSet.Add(payhis);
                //减去查看用户v点数量
                //TpxinUserinfo userinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == regInfo.Nodeid);
                //if (userinfo.V <= 0)
                //{
                //    Alert("支付失败,V点不足");
                //    return null;
                //}
                //userinfo.V -= tpxinMessage.Price;
                //var transferId = Guid.NewGuid().ToString();

                //增加发布用户v点数量
                //TpxinUserinfo userinfo1 = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == tpxinMessage.Nodeid);
                //userinfo1.V += tpxinMessage.Price;

                var tpxinMsgUser = PxinCache.GetRegInfo(tpxinMessage.Nodeid);
                var nodeName     = tpxinMsgUser == null ? "" : tpxinMsgUser.Nodename;

                //添加金额变化记录
                //var reduce = CreateAmountChangeHis(regInfo.Nodeid, 1, -tpxinMessage.Price, (int)AmountChangeReason.ViewArticle, transferId, $"查看付费-{nodeName}");
                //db.TpxinAmountChangeHisSet.Add(reduce);

                //var add = CreateAmountChangeHis(tpxinMessage.Nodeid, 1, tpxinMessage.Price, (int)AmountChangeReason.ViewArticle, transferId, $"查看收款-{regInfo.Nodename}");
                //db.TpxinAmountChangeHisSet.Add(add);

                if (db.SaveChanges() <= 0)
                {
                    Alert("支付失败:" + db.Message);
                    log.Error("查看文章,支付失败,db:" + db.Message);
                    db.Rollback();
                    return(null);
                }
                //VP服务设置V点

                var result = vp.SetV(new VPPayVDian
                {
                    FromNodeid = regInfo.Nodeid,
                    FromRemark = $"查看付费-{Helper.FilterChar(nodeName)}",
                    ToNodeid   = tpxinMessage.Nodeid,
                    ToRemark   = $"查看收款-{Helper.FilterChar(regInfo.Nodename)}",
                    Amount     = tpxinMessage.Price,
                    Reason     = (int)AmountChangeReason.ViewArticle,
                    Transferid = payhis.Hisid.ToString(),
                });
                if (result.Result <= 0)
                {
                    Alert(result.Message, result.Result);
                    db.Rollback();
                    return(null);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                log.Info("查看文章,支付失败。原因:" + ex);
                Alert("支付失败");
                db.Rollback();
                return(null);
            }

            var query = from msg in db.VpxinMessageSet
                        where msg.Infoid == req.InfoID
                        select new MessageDto
            {
                Commentnum  = msg.Commentnum,
                Nodeid      = msg.Msgnodeid,
                Localnodeid = msg.Localnodeid,
                Content     = msg.Content,
                Createtime  = msg.Createtime,
                Down        = msg.Down,
                Infoid      = msg.Infoid,
                Ispay       = msg.Ispay,
                Picurl      = msg.Picurl,
                Price       = msg.Price,
                Reward      = msg.Reward,
                Sound       = msg.Sound,
                Up          = msg.Up,
                Video       = msg.Video,
                IsDown      = msg.IsDown,
                IsUp        = msg.IsUp
            };
            MessageDto msgModel = query.FirstOrDefault();
            Alert("支付成功", 1);
            return(msgModel);
        }
示例#9
0
        /// <summary>
        /// 打赏
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool CreateReward(ReqCreateReward req)
        {
            if (req.Reward > 100)
            {
                Alert("打赏金额不能超过100V");
                return(false);
            }
            TnetReginfo  regInfo      = PxinCache.GetRegInfo(req.Nodeid);
            TpxinMessage tpxinMessage = db.TpxinMessageSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Status == 1);

            if (tpxinMessage == null)
            {
                Alert("信友圈信息不存在");
                return(false);
            }
            if (regInfo.Nodeid == tpxinMessage.Nodeid)
            {
                Alert("不能自己给自己打赏");
                return(false);
            }
            if (tpxinMessage.Price > 0)
            {
                TpxinPayhis tpxinPayhis = db.TpxinPayhisSet.FirstOrDefault(a => a.Infoid == tpxinMessage.Infoid && a.Nodeid == req.Nodeid && a.Typeid == 3);
                if (tpxinPayhis == null)
                {
                    Alert("请支付V点查看后点赞或踩");
                    return(false);
                }
            }
            TpxinPraise tpxinPraise = db.TpxinPraiseSet.FirstOrDefault(a => a.Infoid == req.Infoid && a.Fromnodeid == req.Nodeid);

            if (tpxinPraise != null && tpxinPraise.Reward > 0)
            {
                Alert("一个文章只能打赏一次");
                return(false);
            }
            #region 由VP服务设置V点
            try
            {
                db.BeginTransaction();
                if (tpxinPraise == null)
                {
                    //添加打赏用户踩赞历史表
                    tpxinPraise = new TpxinPraise
                    {
                        Infoid     = req.Infoid,
                        Createtime = DateTime.Now,
                        Fromnodeid = req.Nodeid,
                        Tonodeid   = tpxinMessage.Nodeid,
                        Remarks    = "",
                        Reward     = req.Reward,
                        Status     = 0
                    };
                    db.TpxinPraiseSet.Add(tpxinPraise);
                }
                else
                {
                    tpxinPraise.Reward = req.Reward;
                }

                var tpxinMsgUser = PxinCache.GetRegInfo(tpxinMessage.Nodeid);
                if (db.SaveChanges() <= 0)
                {
                    Alert("打赏失败");
                    log.Error("打赏失败,提交db失败:" + db.Message);
                    db.Rollback();
                    return(false);
                }
                var vp     = new VPHelper();
                var result = vp.SetV(new VPPayVDian
                {
                    FromNodeid = req.Nodeid,
                    FromRemark = $"打赏-{Helper.FilterChar(tpxinMsgUser.Nodename)}",
                    ToNodeid   = tpxinMessage.Nodeid,
                    ToRemark   = $"赏金-{Helper.FilterChar(regInfo.Nodename)}",
                    Amount     = req.Reward,
                    Reason     = (int)AmountChangeReason.Reward,
                    Transferid = tpxinPraise.Hisid.ToString(),
                });
                if (result.Result <= 0)
                {
                    Alert(result.Message, result.Result);
                    db.Rollback();
                    return(false);
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                Alert("打赏失败");
                log.Error("打赏失败,异常:" + ex);
                db.Rollback();
                return(false);
            }
            #endregion
            Alert("打赏成功", 1);
            return(true);
        }
示例#10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public void Execute(TpxinMessage message)
 {
     this.message = message;
     Execute();
 }
示例#11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="message"></param>
 public MsgDispatchService(TpxinMessage message)
 {
     this.message = message;
 }