Beispiel #1
0
        /// <summary>
        /// 修改背景图片
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public bool UpdateBackgImg(ReqUpdateBackgImg req)
        {
            //http://client.xiang-xin.net/images2/tempfile/20190817/f6745392-2006-42cf-b63a-8094e944a7b0.JPEG
            string tempUrl  = "/" + req.BackImg.Substring(req.BackImg.IndexOf("images2/", StringComparison.OrdinalIgnoreCase));
            string tempFile = HttpContext.Current.Request.MapPath(tempUrl).ToLower();
            string destFile = tempFile.Replace("tempfile", "backimg");
            string destDir  = Path.GetDirectoryName(destFile);

            if (!Directory.Exists(destDir))
            {
                Directory.CreateDirectory(destDir);
            }
            File.Move(tempFile, destFile);
            string        destUrl       = AppConfig.Userphoto.Trim('/') + "/" + destFile.Substring(destFile.IndexOf("backimg")).Replace("\\", "/");
            TnetReginfo   regInfo       = PxinCache.GetRegInfo(req.Nodeid);
            TpxinUserinfo tpxinUserinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == req.Nodeid);

            tpxinUserinfo.Backpic = destUrl;
            if (db.SaveChanges() <= 0)
            {
                Alert("修改背景图片失败");
                return(false);
            }
            Alert("修改背景图片成功", 1);
            return(true);
        }
Beispiel #2
0
 /// <summary>
 /// ue支付回调
 /// </summary>
 /// <param name="uePayHis"></param>
 /// <returns></returns>
 public bool ChargeVDian_Notice(TnetUepayhis uePayHis)
 {
     db.BeginTransaction();
     try
     {
         TnetReginfo regInfo = PxinCache.GetRegInfo(uePayHis.Nodeid);
         int         Price   = int.Parse(uePayHis.BusinessParams);
         if (!ChargeVDian_Pro(regInfo, Price))
         {
             db.Rollback();
             return(false);
         }
         uePayHis.BusinessId      = _businessID;
         uePayHis.Status          = 2;
         db.Entry(uePayHis).State = System.Data.Entity.EntityState.Modified;
         if (db.SaveChanges() <= 0)
         {
             Alert("更新订单状态失败");
             db.Rollback();
             return(false);
         }
     }
     catch (Exception ex)
     {
         log.Info("充值V点,支付回调失败。原因:" + ex);
         Alert("更新订单状态失败");
         db.Rollback();
         return(false);
     }
     db.Commit();
     return(true);
 }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        /// 验证密码
        /// </summary>
        /// <param name="nodeid"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public bool CheckPwd(int nodeid, string pwd)
        {
            var regInfo = PxinCache.GetRegInfo(nodeid);

            if (regInfo == null)
            {
                Alert("获取用户信息失败");
                return(false);
            }
            if (!CheckPayPwd(regInfo, pwd, false))
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// 充值V点
        /// </summary>
        /// <param name="chargeVDian"></param>
        /// <returns></returns>
        public bool ChargeVDian(ReqChargeVDian chargeVDian)
        {
            log.Info($"ChargeVDian,充值V点,nodeid={chargeVDian.Nodeid},充值数量={chargeVDian.Price}");
            TnetReginfo regInfo = PxinCache.GetRegInfo(chargeVDian.Nodeid);

            if (chargeVDian.PayType == 0)
            {
                //调用ue支付
                return(ChargeVDian_DosUEPrepare(regInfo, chargeVDian.Price));
            }
            else
            {
                return(ChargeVDian_SVPay(regInfo, chargeVDian.Price, chargeVDian.PayPwd));
            }
        }
Beispiel #6
0
        /// <summary>
        /// 购买表情-支付回调
        /// </summary>
        /// <param name="uepayhis"></param>
        /// <returns></returns>
        public bool BuyEmoticon_Notice(TnetUepayhis uepayhis)
        {
            var userInfo = PxinCache.GetRegInfo(uepayhis.Nodeid);

            if (userInfo == null)
            {
                Alert("获取用户信息失败");
                return(false);
            }
            int.TryParse(uepayhis.BusinessParams, out int id);

            var emotion = db.TpxinEmoticonMaterialSet.Where(c => c.Id == id).FirstOrDefault();
            var order   = db.TpxinEmoticonOrderSet.Where(c => c.Materialid == id && c.Nodeid == userInfo.Nodeid).FirstOrDefault();

            if (emotion == null)
            {
                Alert("要购买的表情不存在");
                return(false);
            }
            if (order != null)
            {
                Alert("重复购买");
                return(false);
            }

            try
            {
                db.BeginTransaction();
                if (!DownloadEmoticon_Pro(userInfo.Nodeid, uepayhis.Amount, emotion))
                {
                    Alert("生成表情订单失败");
                    db.Rollback();
                    return(false);
                }

                db.Commit();
                return(true);
            }
            catch (Exception e)
            {
                log.Error("购买表情-支付回调异常:" + e);
                Alert("购买表情-支付回调异常:" + e.Message);
                return(false);
            }
        }
Beispiel #7
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);
        }
Beispiel #8
0
        /// <summary>
        /// V点交易记录 历史
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public List <PxinPayhisDto> GetVDianHis(ReqGetPVDianHis req)
        {
            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);
            var         query   = from pay in db.VpxinPayhisSet

                                  where pay.Nodeid == regInfo.Nodeid
                                  select new PxinPayhisDto
            {
                Hisid      = pay.Hisid,
                Price      = pay.Price,
                Nodename   = pay.Nodename,
                Createtime = pay.Createtime,
                Typeid     = pay.Typeid
            };

            query = query.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize);//进行分页
            List <PxinPayhisDto> HisList = query.ToList();

            return(HisList);
        }
Beispiel #9
0
        /// <summary>
        /// 获取调起ue参数
        /// </summary>
        /// <param name="nodeid"></param>
        /// <param name="price"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        private OpenInfUeoDto GetUESignInfo(int nodeid, decimal price, int id)
        {
            var userInfo = PxinCache.GetRegInfo(nodeid);

            if (userInfo == null)
            {
                Alert("获取用户基本信息失败");
                return(null);
            }
            var result = UePayHelper.DosWithUePay(db, userInfo, 1, CurrencyType.DOS_矿沙, price, 20004, id.ToString(), "购买表情", "购买表情").Result;

            if (!result.IsSuccess)
            {
                Alert(result.Message);
                return(null);
            }
            return(new OpenInfUeoDto
            {
                ChargeStr = result.ChargeStr,
                Sign = Common.Mvc.Md5.SignString(result.ChargeStr + AppConfig.AppSecurityString).ToUpper(),
                OrderNo = result.OrderNo
            });
        }
Beispiel #10
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        public NovemberActivityDosPayDto NovemberActivityDosPay(NovemberActivityDosPayReq req)
        {
            log.Info($"11月活动-迪拜见证之旅支付服务费,nodeid={req.Nodeid},服务费={req.Price}");

            if (!NovemberActivityDosPayCheck(req))
            {
                return(null);
            }
            TnetReginfo regInfo        = PxinCache.GetRegInfo(req.Nodeid);
            var         businessParams = 11 + "|" + req.BusinessIdStr + "|" + req.PayType + "|" + req.HisIdStr + "|" + req.ActivityId;
            var         uePayResult    = UEPay.UePayHelper.DosWithUePay(db, regInfo, 1, CurrencyType.DOS_矿沙, req.Price, 20008, businessParams, "11月活动-迪拜见证之旅支付服务费", "11月活动-迪拜见证之旅支付服务费").Result;

            if (!uePayResult.IsSuccess)
            {
                Alert(uePayResult.Message);
                return(null);
            }
            return(new NovemberActivityDosPayDto
            {
                ChargeStr = uePayResult.ChargeStr,
                Sign = Common.Mvc.Md5.SignString(uePayResult.ChargeStr + AppConfig.AppSecurityString).ToUpper(),
                OrderNo = uePayResult.OrderNo
            });
        }
Beispiel #11
0
        /// <summary>
        /// ue支付回调
        /// </summary>
        public bool OctoberActivityDosUEPay_Notice(TnetUepayhis uePayHis)
        {
            db.BeginTransaction();
            try
            {
                TnetReginfo regInfo = PxinCache.GetRegInfo(uePayHis.Nodeid);
                string[]    paras   = uePayHis.BusinessParams.Split('|');

                if (int.TryParse(paras[0], out int month) && month == 10)//10月活动
                {
                    if (paras.Length != 5)
                    {
                        Alert("OctoberActivityDosUEPay_Notice TnetUepayhis.BusinessParams 数据有问题");
                        db.Rollback();
                        return(false);
                    }
                    string   ids    = paras[1];
                    string[] idsArr = ids.Split('_');
                    foreach (var item in idsArr)
                    {
                        int id     = int.Parse(item);
                        var entity = db.TpxinOctoberActivitySet.FirstOrDefault(x => x.Id == id);
                        if (paras[2] == "1")
                        {
                            entity.Ptransferids  = uePayHis.Id.ToString();
                            entity.Ptransfertime = DateTime.Now;
                            //entity.Pamount = decimal.Parse(paras[3]);
                        }
                        else
                        {
                            entity.Transferids  = uePayHis.Id.ToString();
                            entity.Transfertime = DateTime.Now;
                            //entity.Amount = decimal.Parse(paras[3]);
                        }
                        if (!string.IsNullOrWhiteSpace(entity.Transferids) && !string.IsNullOrWhiteSpace(entity.Ptransferids))
                        {
                            entity.Status = 2;
                        }
                        else
                        {
                            entity.Status = 1;
                        }
                    }
                }
                else
                {
                    if (!NovemberActivityDosPay_Pro(paras, uePayHis))
                    {
                        db.Rollback();
                        return(false);
                    }
                }
                uePayHis.BusinessId = 0;
                uePayHis.Status     = 2;
                if (db.Entry(uePayHis).State == EntityState.Detached)
                {
                    db.TnetUepayhisSet.Attach(uePayHis);
                    db.Entry(uePayHis).State = EntityState.Modified;
                }
                if (db.SaveChanges() <= 0)
                {
                    Alert("更新订单状态失败");
                    db.Rollback();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                log.Info("支付回调失败。原因:" + ex);
                db.Rollback();
                return(false);
            }
            db.Commit();
            return(true);
        }
Beispiel #12
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        public bool OctoberActivityDosUEPrepare(OctoberActivityDosUEPrepareReq req)
        {
            log.Info($"十月送手机活动支付服务费,nodeid={req.Nodeid},服务费={req.Price}");
            var activity = db.TpxinActivitySet.FirstOrDefault(p => p.Id == req.ActivityId);

            if (activity == null)
            {
                Alert("找不到活动信息,请重试");
                return(false);
            }
            DateTime now = DateTime.Now;

            if (AppConfig.IsUseSms && !(now >= activity.PayStarttime && now <= activity.PayEndtime))
            {
                Alert("缴费时间已过期");
                return(false);
            }
            string[] ids = req.DataId.Split('_');
            if (req.PayType == 2)
            {
                if (ids.Length != 1)
                {
                    Alert("只能支付一个");
                    return(false);
                }
                var cnt = db.TpxinOctoberActivitySet.Count(x => x.Nodeid == req.Nodeid && x.Transferids != null && x.ActivityId == req.ActivityId);
                if (cnt > 0)
                {
                    Alert("已经存在缴过费的记录,只能支付一个");
                    return(false);
                }
            }
            foreach (string sid in ids)
            {
                int tid    = Convert.ToInt32(sid);
                var entity = db.TpxinOctoberActivitySet.FirstOrDefault(x => x.Id == tid);
                if (req.PayType == 1)
                {
                    if (!string.IsNullOrEmpty(entity.Ptransferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
                if (req.PayType == 2)
                {
                    if (!string.IsNullOrEmpty(entity.Transferids))
                    {
                        Alert("不能选中已缴费的记录,请重新打开当前页面");
                        return(false);
                    }
                }
            }

            TnetReginfo regInfo = PxinCache.GetRegInfo(req.Nodeid);

            TpcnUepayconfig ueConfig = db.TpcnUepayconfigSet.FirstOrDefault(a => a.Typeid == 1);

            if (ueConfig == null || ueConfig.Id <= 0)
            {
                Alert("获取UE支付配置失败");
                return(false);
            }
            Currency     currency = new Currency(CurrencyType.DOS_矿沙, req.Price);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis
            {
                Typeid         = 20008,
                Nodeid         = regInfo.Nodeid,
                BusinessParams = 10 + "|" + req.DataId + "|" + req.PayType + "|" + req.Nodeid + "|" + req.Price.ToString(),
                Amount         = total,
                Unit           = unit,
                Freezeids      = "",
                Createtime     = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("生成UE订单失败");
                return(false);
            }
            var charge = new ChargeDto
            {
                businesstypeid = 20008,
                amount         = total,
                unit           = unit,
                body           = "十月送手机活动支付服务费",
                subject        = "十月送手机活动支付服务费",
                orderno        = uePayHis.Id.ToString(),
                paycode        = ueConfig.Paycode,
                noticeurl      = Helper.DomainUrl + "/UENotice/Success",
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss")
            };

            UEPayCallDto         = new UePayCallDto();
            UEPayCallDto.Charge  = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(charge)));
            UEPayCallDto.sign    = Md5.SignString(UEPayCallDto.Charge + AppConfig.AppSecurityString);
            UEPayCallDto.orderno = uePayHis.Id.ToString();
            return(true);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #16
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);
        }
Beispiel #17
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);
        }