예제 #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);
        }
예제 #2
0
        private (bool, int id) PayNew(ReqPayAuction req, TpxinUserinfo pxinUser, TpxinPaiConfig config)
        {
            var price  = req.MinPrice;
            var amount = price * req.Num;
            var now    = DateTime.Now;
            var sql    = "select * from vpxin_pai_his";
            var list   = db.Database.SqlQuery <AuctionHisDto>(sql).ToList();
            var nums   = list.Sum(s => s.Num);
            //var minprice = list.Where(w => w.Afternum <= config.Num).OrderBy(o => o.Price).Select(s => s.Price).FirstOrDefault();
            var id = db.GetPrimaryKeyValue <TpxinPaiHis>();

            if (req.Num + nums <= config.Num)
            {
                //竞拍操作
                var paihis = new TpxinPaiHis
                {
                    Hisid      = id,
                    Configid   = config.Configid,
                    Createtime = now,
                    Nodeid     = req.Nodeid,
                    Num        = req.Num,
                    Price      = price,
                    Totalprice = amount,
                    Rankinfo   = null,
                    Status     = 0,
                    Remarks    = $"{price}p点",
                };
                db.TpxinPaiHisSet.Add(paihis);
            }
            else
            {
                var numeq = list.Where(w => w.Price >= price).Sum(s => s.Num);
                if (req.Num + numeq > config.Num)
                {
                    log.Info($"竞拍失败-大于最低价:购买数量超过剩余总数;购买数量:{req.Num};已竞拍数:{numeq};当前价:{price}");
                    Alert("竞拍价格低于当前最低价");
                    return(false, 0);
                }
                //竞拍操作
                var paihis = new TpxinPaiHis
                {
                    Hisid      = id,
                    Configid   = config.Configid,
                    Createtime = now,
                    Nodeid     = req.Nodeid,
                    Num        = req.Num,
                    Price      = price,
                    Totalprice = amount,
                    Rankinfo   = null,
                    Status     = 0,
                    Remarks    = $"{price}p点",
                };
                db.TpxinPaiHisSet.Add(paihis);
            }
            return(true, id);
        }
예제 #3
0
        /// <summary>
        /// 添加信友圈信息
        /// </summary>
        /// <param name="Nodeid"></param>
        /// <returns></returns>
        public bool AddUserInfo(int Nodeid)
        {
            TpxinUserinfo userinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == Nodeid);

            if (userinfo == null)
            {
                db.TpxinUserinfoSet.Add(new TpxinUserinfo
                {
                    Nodeid     = Nodeid,
                    Backpic    = "",
                    Createtime = DateTime.Now,
                    Up         = 0,
                    Down       = 0,
                    P          = 0,
                    V          = 0,
                    Remarks    = ""
                });
                if (db.SaveChanges() <= 0)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #4
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);
        }
예제 #5
0
        /// <summary>
        /// 支付V点流程
        /// </summary>
        /// <param name="regInfo"></param>
        /// <param name="Price"></param>
        /// <returns></returns>
        public bool ChargeVDian_Pro(TnetReginfo regInfo, decimal Price)
        {
            TpxinUserinfo userinfo = db.TpxinUserinfoSet.FirstOrDefault(a => a.Nodeid == regInfo.Nodeid);

            if (userinfo == null)
            {
                userinfo = new TpxinUserinfo
                {
                    Nodeid     = regInfo.Nodeid,
                    Backpic    = "",
                    Createtime = DateTime.Now,
                    Up         = 0,
                    Down       = 0,
                    P          = 0,
                    V          = 0,
                    Remarks    = ""
                };
                db.TpxinUserinfoSet.Add(userinfo);
            }
            //1.添加 信友圈付费V点历史表 TPXIN_PAYHIS
            TpxinPayhis payhis = new TpxinPayhis
            {
                Createtime = DateTime.Now,
                Infoid     = 0,
                Typeid     = 1,
                Nodeid     = regInfo.Nodeid,
                Tonodeid   = 0,
                Price      = Price,
                Remarks    = "充值V点"
            };

            //2.修改用户信息表的v点
            db.TpxinPayhisSet.Add(payhis);
            //userinfo.V += Price;
            //3.添加金额变化记录
            //var amountChangeHis = CreateAmountChangeHis(regInfo.Nodeid, 1, Price, (int)AmountChangeReason.ChargeVDian, Guid.NewGuid().ToString(), "充值V点");
            //db.TpxinAmountChangeHisSet.Add(amountChangeHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("充值V点失败");
                return(false);
            }
            //由VP服务处理V点
            var vp     = new VPHelper();
            var result = vp.SetV(new VPChargeVDian
            {
                Amount     = Price,
                Nodeid     = regInfo.Nodeid,
                Reason     = (int)AmountChangeReason.ChargeVDian,
                Remark     = "充值V点",
                Transferid = payhis.Hisid.ToString(),
            });

            if (result.Result <= 0)
            {
                Alert("充值V点失败");
                log.Error("充值V点失败:" + result.Message);
                return(false);
            }
            _businessID = payhis.Hisid;
            return(true);
        }