Example #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);
        }
Example #2
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);
        }
Example #3
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);
 }
Example #4
0
 /// <summary>
 /// ctor
 /// </summary>
 public ExChangeRechargeCode(TblUserJxs jxs, TnetReginfo userInfo, RechargeCodeRuleInfo rule, TblUserJxs jsxParent,
                             int sid, int pNodeId, bool isPromotion, string nodecode)
 {
     this.UserJxs              = jxs;
     this.UserInfo             = userInfo;
     this.Sid                  = sid;
     this.PNodeId              = pNodeId;
     this.RechargeCodeRuleInfo = rule;
     this.JsxParent            = jsxParent;
     this.IsPromotion          = isPromotion;
     this.Nodecode             = isPromotion ? nodecode : "";
     this.IsOpenCzs            = nodecode == "OpenFbap";
 }
Example #5
0
        /// <summary>
        /// 获取信友圈消息[首页]
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public FriMessageCollection GetMsgHome(ReqGetMsgHome req)
        {
            TnetReginfo          reginfo = HttpContext.Current.GetRegInfo();
            FriMessageCollection result  = new FriMessageCollection();
            var queryMsg = from msg in db.VpxinMessageSet
                           where msg.Localnodeid == req.Nodeid && msg.Createtime > req.StartTime
                           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,
                Hisid       = msg.Hisid
            };

            result.Messages = queryMsg.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize).ToList();
            bool isResult = IsMessage(result.Messages);

            int[] infos        = result.Messages.Select(a => a.Infoid).ToArray();
            var   queryComment = from mu in db.TpxinMessageUesrSet
                                 join comment in db.TpxinCommentHisSet on new { mu.Typeid, mu.Infoid } equals new { Typeid = 1, Infoid = comment.Hisid }
            join msg in db.TpxinMessageSet on comment.Infoid equals msg.Infoid
            where mu.Nodeid == reginfo.Nodeid && msg.Createtime > req.StartTime && infos.Contains(msg.Infoid)
            orderby comment.Createtime ascending
            select new CommentDto
            {
                Content    = comment.Content,
                Createtime = comment.Createtime,
                Hisid      = comment.Hisid,
                Infoid     = comment.Infoid,
                Nodeid     = comment.Nodeid,
                Phisid     = comment.Phisid,
                Pnodeid    = comment.Pnodeid
            };

            result.Comments = queryComment.ToList();
            return(result);
        }
Example #6
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));
            }
        }
Example #7
0
        /// <summary>
        /// 调用ue支付
        /// </summary>
        /// <param name="regInfo"></param>
        /// <param name="Price"></param>
        /// <returns></returns>
        private bool ChargeVDian_DosUEPrepare(TnetReginfo regInfo, decimal Price)
        {
            TpcnUepayconfig ueConfig = db.TpcnUepayconfigSet.FirstOrDefault(a => a.Typeid == 2);

            if (ueConfig == null || ueConfig.Id <= 0)
            {
                Alert("获取UE支付配置失败");
                return(false);
            }
            //获取配置DOS兑换V点比例
            TappConfig config     = db.TappConfigSet.FirstOrDefault(a => a.Propertyname == "chargerate");
            decimal    chargerate = config == null ? 0.01M : decimal.Parse(config.Propertyvalue);
            decimal    amount     = decimal.Parse(Price.ToString()) * chargerate;

            if (amount < 0.01M)
            {
                amount = 0.01M;
            }
            Currency     currency = new Currency(CurrencyType.DOS_矿沙, amount);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis {
                Typeid = 20001, Nodeid = regInfo.Nodeid, BusinessParams = Price.ToString(), Amount = total, Unit = unit, Freezeids = "", Createtime = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            if (db.SaveChanges() <= 0)
            {
                Alert("生成UE订单失败");
                return(false);
            }
            ChargeUE = new ChargeDto
            {
                businesstypeid = 20001,
                amount         = total,
                unit           = unit,
                body           = "充值V点",
                subject        = "充值V点",
                orderno        = uePayHis.Id.ToString(),
                paycode        = ueConfig.Paycode,
                noticeurl      = Helper.DomainUrl + "/UENotice/Success",
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss")
            };
            return(true);
        }
Example #8
0
        /// <summary>
        /// SV扣除
        /// </summary>
        /// <param name="nodecode">用户账号</param>
        /// <param name="amount">金额</param>
        /// <param name="subject">商品名</param>
        /// <returns></returns>
        private bool Transfer_SV(string nodecode, decimal amount, string subject)
        {
            if (!CheckSign())
            {
                return(false);
            }

            //TssoOpenUser openUser = db.TssoOpenUserSet.Where(d => d.Openid == nodecode && d.Opentype == 4).FirstOrDefault();
            //if (openUser == null)
            //{
            //    Alert("没有绑定PCN账号");
            //    return false;
            //}
            TnetReginfo reginfo = db.TnetReginfoSet.FirstOrDefault(c => c.Nodecode == nodecode || c.Mobileno == nodecode);

            if (reginfo == null)
            {
                Alert("用户账号不存在");
                return(false);
            }
            PurseFactory purseFactory = new PurseFactory(wcfProxy);
            Purse        fromPurse    = new Purse(OwnerType.个人钱包, reginfo.Nodeid, PurseType.现金钱包, CurrencyType.RMB, wcfProxy);
            Purse        toPurse      = purseFactory.SystemPurseRand(reginfo.Nodeid);
            Currency     currency     = new Currency(CurrencyType.RMB, amount);

            if (fromPurse.UsableBalance < currency.ConvertTo(fromPurse.CurrencyType).Amount)
            {
                Alert("余额不足");
                log.Info("支付转账失败:余额不足," + fromPurse.UsableBalance);
                return(false);
            }
            int            reasonid = 33180;//广州豪盾游戏充值
            TransferResult transferResult;

            transferResult = wcfProxy.Transfer(fromPurse, toPurse, currency, reasonid, subject);
            if (!transferResult.IsSuccess)
            {
                Alert("转账失败");
                log.Info("支付转账失败:" + transferResult.Message);
                return(false);
            }
            TransferId = transferResult.TransferId;

            return(true);
        }
Example #9
0
        /// <summary>
        /// 支付检查
        /// </summary>
        /// <param name="nodeid"></param>
        /// <param name="payPwd"></param>
        /// <param name="sumNum">总数量</param>
        /// <param name="amount">总价(数量*价格)</param>
        /// <returns></returns>
        private (bool, TpxinPaiConfig, TpxinUserinfo) PayCheck(int nodeid, string payPwd, int sumNum, decimal amount)
        {
            ExchangeFacade facade = new ExchangeFacade();
            TnetReginfo    user   = new TnetReginfo();

            if (!facade.CheckPwd(nodeid, payPwd, ref user))
            {
                Alert(facade.PromptInfo.Message);
                return(false, null, null);
            }
            var now      = DateTime.Now;
            int monthDay = DateTime.DaysInMonth(now.Year, now.Month);
            var next     = new DateTime(now.Year, now.Month, monthDay).AddHours(12);

            if (next <= now)
            {
                Alert("已超过截止日期,不能竞拍");
                return(false, null, null);
            }
            var config = GetConfig();

            if (config == null)
            {
                Alert("本月没有竞拍");
                return(false, null, null);
            }
            if (sumNum > config.Num)
            {
                Alert("竞拍数量大于总数量");
                return(false, null, null);
            }
            var pxinUser = db.TpxinUserinfoSet.Where(w => w.Nodeid == nodeid).FirstOrDefault();

            if (pxinUser == null)
            {
                Alert("不是相信app用户");
                return(false, null, null);
            }
            //if (pxinUser.P < amount)
            //{
            //    Alert("p点余额不足");
            //    return (false, null, null);
            //}
            return(true, config, pxinUser);
        }
Example #10
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);
        }
Example #11
0
 /// <summary>
 /// 认证参数基础检查
 /// </summary>
 /// <param name="nodeid"></param>
 /// <param name="regInfo"></param>
 /// <param name="nodeInfo"></param>
 /// <param name="authLog"></param>
 /// <param name="authByPcn"></param>
 /// <returns></returns>
 private bool AuthBasicCheck(int nodeid, out TnetReginfo regInfo, out TnetNodeinfo nodeInfo, out TzcAuthLog authLog, bool authByPcn = false)
 {
     regInfo  = db.TnetReginfoSet.FirstOrDefault(c => c.Nodeid == nodeid);
     nodeInfo = db.TnetNodeinfoSet.FirstOrDefault(f => f.Nodeid == nodeid);
     authLog  = db.TzcAuthLogSet.FirstOrDefault(f => f.Nodeid == nodeid);
     if (regInfo.Isconfirmed == 1 && (nodeInfo == null || authLog == null))
     {
         Alert("数据异常,请联系管理员");
         log.Info($"用户:{nodeid} 认证数据异常");
         return(false);
     }
     if (regInfo.Isconfirmed == 0 && (nodeInfo != null || authLog != null))
     {
         Alert("数据异常,请联系管理员");
         log.Info($"用户:{nodeid} 认证数据异常");
         return(false);
     }
     return(true);
 }
Example #12
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);
        }
Example #13
0
        /// <summary>
        /// SV充值V点
        /// </summary>
        /// <param name="regInfo"></param>
        /// <param name="Price"></param>
        /// <param name="payPwd"></param>
        /// <param name="isCheckPayPwd"></param>
        /// <returns></returns>
        public bool ChargeVDian_SVPay(TnetReginfo regInfo, decimal Price, string payPwd, bool isCheckPayPwd = true)
        {
            //检查支付密码
            if (isCheckPayPwd && !CheckPayPwd(regInfo, payPwd, true))
            {
                //Alert("支付密码错误");
                return(false);
            }
            BeginTransfer();
            Purse    fromPurse = purseFactory.UserCVPurse(regInfo.Nodeid);
            Purse    toPurse   = purseFactory.SystemPurseRand(regInfo.Nodeid);
            Currency currency  = new Currency(CurrencyType.RMB, Price * 0.1m); //1sv=10v点

            if (fromPurse.UsableBalance < currency.Amount)
            {
                Alert("转账钱包余额不足", -100);//此Result在自动充值V点中使用
                return(false);
            }
            var result = Transfer(fromPurse, toPurse, currency, 12, "SV充值V点");

            if (!result.IsSuccess)
            {
                EndTransfer(false);
                return(false);
            }
            db.BeginTransaction();
            if (!ChargeVDian_Pro(regInfo, Price))
            {
                db.Rollback();
                EndTransfer(false);
                return(false);
            }

            db.Commit();
            EndTransfer(true);
            return(result.IsSuccess);
        }
Example #14
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
            });
        }
Example #15
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);
        }
Example #16
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);
        }
Example #17
0
        /// <summary>
        /// 识别驾驶证
        /// </summary>
        public bool DrivLicense(TnetReginfo regInfo, string imageurl, string imageurl2, string fileno)
        {
            TnetDriveLicLog driveLicLog = db.TnetDriveLicLogSet.FirstOrDefault(x => x.Nodeid == regInfo.Nodeid);

            if (driveLicLog != null)
            {
                if (imageurl == driveLicLog.Cardimg && fileno == driveLicLog.Fileno)
                {
                    Alert("修改驾驶证成功");
                    return(true);
                }
                if (driveLicLog.Status == 1)
                {
                    Alert("您的驾驶证不能修改");
                    return(false);
                }
            }

            string filePath1 = FileService.GetPhysicsFilePath(imageurl);
            string img       = HttpUtility.UrlEncode(GetImageBase64(filePath1));

            BaiduLicense.DrivReq req = new BaiduLicense.DrivReq
            {
                image            = img,
                detect_direction = "true"
            };
            BaiduLicense.DrivResp resp = null;
            try
            {
                //调用百度接口识别驾驶证
                resp = BaiduLicense.DrivSearch(req);
                if (!string.IsNullOrEmpty(resp.error_code))
                {
                    Alert("识别驾驶证错误");
                    return(false);
                }
                if (string.IsNullOrEmpty(resp.words_result.证号.words) || string.IsNullOrEmpty(resp.words_result.准驾车型.words) || string.IsNullOrEmpty(resp.words_result.姓名.words))
                {
                    Alert("识别驾驶证错误");
                    return(false);
                }
                TnetDriveLicLog driveLicLog1 = db.TnetDriveLicLogSet.FirstOrDefault(x => x.Cardno == resp.words_result.证号.words);
                if (driveLicLog1 != null)
                {
                    Alert("该驾驶证已被使用");
                    return(false);
                }
                //TnetNodeinfo tnet_Nodeinfo = db.TnetNodeinfoSet.FirstOrDefault(x => x.Nodeid == regInfo.Nodeid);
                //if (tnet_Nodeinfo == null)
                //{
                //    Alert("获取注册信息失败");
                //    return false;
                //}


                //if (tnet_Nodeinfo.NAME.Trim() != resp.words_result.姓名.words.Trim())
                //{
                //    Alert("您上传的驾驶证姓名【" + resp.words_result.姓名.words + "】与认证用户名字【" + tnet_Nodeinfo.NAME + "】不一致");
                //    return false;
                //}

                //if (tnet_Nodeinfo.IDCARDNO.Trim() != resp.words_result.证号.words.Trim())
                //{
                //    Alert("您上传的驾驶证证件号【" + resp.words_result.证号.words + "】与认证用户证件号【" + tnet_Nodeinfo.IDCARDNO + "】不一致");
                //    return false;
                //}
                if (driveLicLog == null)
                {
                    driveLicLog = new TnetDriveLicLog();
                }
                //识别成功添加到驾驶证识别表
                driveLicLog.Name     = resp.words_result.姓名.words;
                driveLicLog.Addr     = resp.words_result.住址 == null ? "" : resp.words_result.住址.words;
                driveLicLog.Birthday = resp.words_result.出生日期 == null ? "" : resp.words_result.出生日期.words;
                FileService fileService = new FileService();
                DateTime    now         = DateTime.Now;
                driveLicLog.Cardimg         = fileService.CombinePicUrl(imageurl, now, FileActionType.驾驶证行驶证);
                driveLicLog.CardimgAppendix = fileService.CombinePicUrl(imageurl2, now, FileActionType.驾驶证副页);
                driveLicLog.Cardno          = resp.words_result.证号 == null ? "" : resp.words_result.证号.words;
                driveLicLog.Country         = resp.words_result.国籍 == null ? "" : resp.words_result.国籍.words;
                driveLicLog.Enddate         = resp.words_result.至 == null ? "" : resp.words_result.至.words;
                driveLicLog.VehicleType     = resp.words_result.准驾车型 == null ? "" : resp.words_result.准驾车型.words;
                driveLicLog.ValidPeriod     = resp.words_result.效期限 == null ? "" : resp.words_result.效期限.words;
                driveLicLog.Sex             = resp.words_result.性别 == null ? "" : resp.words_result.性别.words;
                driveLicLog.Nodeid          = regInfo.Nodeid;
                driveLicLog.Firtdate        = resp.words_result.初次领证日期 == null ? "" : resp.words_result.初次领证日期.words;
                driveLicLog.Remarks         = "";
                driveLicLog.Status          = 1;
                driveLicLog.Fileno          = fileno;
                driveLicLog.Createtime      = DateTime.Now;


                if (driveLicLog.Id > 0)
                {
                    ////修改
                    //if (!driveLicLog.Update())
                    //{
                    //    log.Info("修改驾驶证失败,原因:" + driveLicLog.DebugInfo.SqlExecutable);
                    //    Alert("修改驾驶证失败");
                    //    return false;
                    //}
                }
                else
                {
                    //添加
                    db.TnetDriveLicLogSet.Add(driveLicLog);
                    //if (!driveLicLog.Insert())
                    //{
                    //    log.Info("添加驾驶证失败,原因:" + driveLicLog.DebugInfo.SqlExecutable);
                    //    Alert("添加驾驶证失败");
                    //    return false;
                    //}
                }
                if (db.SaveChanges() <= 0)
                {
                    Alert("保存驾驶证失败");
                    log.Info("保存驾驶证失败,原因:" + db.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Alert(ex.Message);
                return(false);
            }
            Alert("识别驾驶证成功");
            return(true);
        }
Example #18
0
        /// <summary>
        /// 识别行驶证
        /// </summary>
        public bool VehicleLicense(TnetReginfo regInfo, string vehiclelicenseimg)
        {
            TnetVehicleLicLog vehicleLicLog = db.TnetVehicleLicLogSet.FirstOrDefault(x => x.Nodeid == regInfo.Nodeid);

            if (vehicleLicLog != null)
            {
                if (vehiclelicenseimg == vehicleLicLog.Cardimg)
                {
                    Alert("修改行驶证成功");
                    return(true);
                }
                if (vehicleLicLog.Status == 1)
                {
                    Alert("您的行驶证不能修改");
                    return(false);
                }
            }
            string filePath1 = HttpContext.Current.Server.MapPath(vehiclelicenseimg);
            string img       = HttpUtility.UrlEncode(GetImageBase64(filePath1));

            BaiduLicense.VehicleReq req = new BaiduLicense.VehicleReq
            {
                image            = img,
                detect_direction = "true"
            };
            BaiduLicense.VehicleResp resp = null;
            try
            {
                //调用百度接口识别行驶证
                resp = BaiduLicense.VehicleSearch(req);
                if (!string.IsNullOrEmpty(resp.error_code))
                {
                    Alert("识别行驶证错误");
                    return(false);
                }
                if (string.IsNullOrEmpty(resp.words_result.品牌型号.words) || string.IsNullOrEmpty(resp.words_result.发动机号码.words) || string.IsNullOrEmpty(resp.words_result.号牌号码.words))
                {
                    Alert("识别行驶证错误");
                    return(false);
                }
                TnetVehicleLicLog vehicleLicLog1 = db.TnetVehicleLicLogSet.FirstOrDefault(x => x.Licplateno == resp.words_result.号牌号码.words);
                if (vehicleLicLog1 != null)
                {
                    Alert("该行驶证已被使用");
                    return(false);
                }

                //TnetNodeinfo tnet_Nodeinfo = db.TnetNodeinfoSet.FirstOrDefault(x => x.Nodeid == regInfo.Nodeid);
                //if (tnet_Nodeinfo == null)
                //{
                //    Alert("您不是认证用户请先认证");
                //    return false;
                //}
                //if (tnet_Nodeinfo.NAME.Trim() != resp.words_result.所有人.words.Trim())
                //{
                //    Alert("您上传的行驶证所有人【" + resp.words_result.所有人.words + "】与认证用户名字【" + tnet_Nodeinfo.NAME + "】不一致");
                //    return false;
                //}

                if (vehicleLicLog == null)
                {
                    vehicleLicLog = new TnetVehicleLicLog();
                }
                //识别成功添加到行驶证识别表
                vehicleLicLog.Belonger     = resp.words_result.所有人.words;
                vehicleLicLog.Address      = resp.words_result.住址 == null ? "" : resp.words_result.住址.words;
                vehicleLicLog.Brandmodel   = resp.words_result.品牌型号 == null ? "" : resp.words_result.品牌型号.words;
                vehicleLicLog.Cardimg      = vehiclelicenseimg;
                vehicleLicLog.Carliccode   = resp.words_result.车辆识别代号 == null ? "" : resp.words_result.车辆识别代号.words;
                vehicleLicLog.Createtime   = DateTime.Now;
                vehicleLicLog.Cartype      = resp.words_result.车辆类型 == null ? "" : resp.words_result.车辆类型.words;
                vehicleLicLog.Engineno     = resp.words_result.发动机号码 == null ? "" : resp.words_result.发动机号码.words;
                vehicleLicLog.Firtdate     = resp.words_result.发证日期 == null ? "" : resp.words_result.发证日期.words;
                vehicleLicLog.Registertime = resp.words_result.注册日期 == null ? "" : resp.words_result.注册日期.words;
                vehicleLicLog.Licplateno   = resp.words_result.号牌号码 == null ? "" : resp.words_result.号牌号码.words;
                vehicleLicLog.Usenature    = resp.words_result.使用性质 == null ? "" : resp.words_result.使用性质.words;
                vehicleLicLog.Nodeid       = regInfo.Nodeid;
                vehicleLicLog.Remarks      = "";
                vehicleLicLog.Status       = 1;

                if (vehicleLicLog.Id > 0)
                {
                    ////修改
                    //if (!vehicleLicLog.Update())
                    //{
                    //    log.Info("修改行驶证失败,原因:" + vehicleLicLog.DebugInfo.SqlExecutable);
                    //    Alert("修改行驶证失败");
                    //    return false;
                    //}
                }
                else
                {
                    //添加
                    db.TnetVehicleLicLogSet.Add(vehicleLicLog);
                    //if (!vehicleLicLog.Insert())
                    //{
                    //    log.Info("添加行驶证失败,原因:" + vehicleLicLog.DebugInfo.SqlExecutable);
                    //    Alert("添加行驶证失败");
                    //    return false;
                    //}
                }
                if (db.SaveChanges() <= 0)
                {
                    Alert("保存行驶证失败");
                    log.Info("保存行驶证失败,原因:" + db.Message);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                log.Info("行驶证改动异常,原因:" + ex);
                Alert(ex.Message);
                return(false);
            }
            Alert("验证行驶证成功");
            return(true);
        }
Example #19
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);
        }
Example #20
0
        /// <summary>
        /// ue支付(调用ue客户端时使用)
        /// </summary>
        /// <param name="db">数据库上下文</param>
        /// <param name="userInfo">支付用户</param>
        /// <param name="uePayConfigTypeId">业务类型</param>
        /// <param name="currencyType">货币类型</param>
        /// <param name="amount">支付金额</param>
        /// <param name="uePayHisTypeId">业务类型</param>
        /// <param name="businessParams">业务相关参数</param>
        /// <param name="body">商品描述</param>
        /// <param name="subject">商品名称</param>
        /// <param name="freezeids">冻结ID列</param>
        /// <param name="pNodeId">父NodeId(eg:经销商支付时就需要要获取它的上级专营商的NodeId)</param>
        /// <returns></returns>
        public static async Task <DosWithUePayDto> DosWithUePay(
            PXinContext db, TnetReginfo userInfo,
            int uePayConfigTypeId, CurrencyType currencyType, decimal amount, int uePayHisTypeId, string businessParams,
            string body, string subject,
            string freezeids = "", int pNodeId = 0)
        {
            var ueConfig = await db.TpcnUepayconfigSet.FirstOrDefaultAsync(p => p.Typeid == uePayConfigTypeId);

            if (ueConfig == null)
            {
                log.Info("获取UE支付配置失败");
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "获取UE支付配置失败"
                });
            }
            Currency     currency = new Currency(currencyType, amount);
            decimal      total    = currency.Amount;
            int          unit     = currency.Type.CurrencyId;
            TnetUepayhis uePayHis = new TnetUepayhis {
                Typeid = uePayHisTypeId, Nodeid = userInfo.Nodeid, BusinessParams = businessParams, Amount = total, Unit = unit, Freezeids = freezeids, Createtime = DateTime.Now
            };

            db.TnetUepayhisSet.Add(uePayHis);
            var falg = await db.SaveChangesAsync() > 0;

            if (!falg)
            {
                log.Info("生成UE订单失败,NodeId=:" + uePayHis.Nodeid);
                return(new DosWithUePayDto()
                {
                    IsSuccess = false, Message = "生成UE订单失败"
                });
            }
            var recvNodeCode = "";

            if (pNodeId > 0)//代理人支付时,获取充值商帐号(收钱帐号),向它支付
            {
                var parentUserInfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    RegInfoKey = pNodeId.ToString()
                });
                if (parentUserInfo == null)
                {
                    log.Info("获取上级用户信息失败,NodeId=:" + uePayHis.Nodeid);
                    return(new DosWithUePayDto()
                    {
                        IsSuccess = false, Message = "获取上级用户信息失败"
                    });
                }
                recvNodeCode = parentUserInfo.Nodecode;
            }
            var chargeDto = new ChargeDto
            {
                businesstypeid = uePayHisTypeId,
                amount         = total,
                unit           = unit,
                body           = body,
                subject        = subject,
                orderno        = uePayHis.Id.ToString(),
                createtime     = uePayHis.Createtime.ToString("yyyy-MM-dd HH:mm:ss"),
                paycode        = ueConfig.Paycode,
                recvfromid     = pNodeId > 0 ? 6 : 0,
                recvaccount    = recvNodeCode,
                noticeurl      = Common.Facade.Helper.DomainUrl + "/UENotice/Success"
            };
            var chargeStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(chargeDto)));

            return(new DosWithUePayDto()
            {
                IsSuccess = true, ChargeStr = chargeStr, OrderNo = chargeDto.orderno
            });
        }
Example #21
0
        /// <summary>
        /// 获取信友圈-根据用户查询
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public FriMessageCollection GetMsg(ReqGetMsg req)
        {
            FriMessageCollection result  = new FriMessageCollection();
            TnetReginfo          regInfo = db.TnetReginfoSet.Find(req.Snodeid);

            if (regInfo == null)
            {
                Alert("用户不存在");
                return(null);
            }
            //当前用户是否是查看用户好友
            List <TchatFriend> friList = db.TchatFriendSet.Where(c => c.Friendstatus == 1 && (c.Mynodeid == req.Nodeid || c.Friendnodeid == req.Nodeid)).ToList();
            //查看用户是达人时不是好友也可以查看他的朋友圈
            var user = db.TnetReginfoSet.Where(c => c.Nodeid == req.Snodeid).FirstOrDefault();

            if ((user?.Isenterprise != 3 && user?.Isenterprise != 4))
            {
                if (!(friList.Select(a => a.Mynodeid).Contains(req.Snodeid) || friList.Select(a => a.Friendnodeid).Contains(req.Snodeid)))
                {
                    Alert("请添加好友再查看该用户信友圈");
                    return(null);
                }
            }

            var query = from msg in db.TpxinMessageSet
                        join tp in db.TpxinPayhisSet.Where(a => a.Nodeid == req.Nodeid) on msg.Infoid equals tp.Infoid into tp_join
                        from tp in tp_join.DefaultIfEmpty()
                        join tp2 in db.TpxinPraiseSet.Where(a => a.Fromnodeid == req.Nodeid) on msg.Infoid equals tp2.Infoid into tp2_join
                        from tp2 in tp2_join.DefaultIfEmpty()
                        where msg.Nodeid == req.Snodeid && msg.Status == 1
                        select new MessageDto
            {
                Commentnum  = msg.Commentnum,
                Createtime  = msg.Createtime,
                Down        = msg.Down,
                Infoid      = msg.Infoid,
                Up          = msg.Up,
                Nodeid      = msg.Nodeid,
                Localnodeid = req.Nodeid,
                Ispay       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 1 : 0,
                IsUp        = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == 1) ? 1 : 0,
                IsDown      = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == -1) ? 1 : 0,
                Reward      = tp2 == null ? 0 : tp2.Reward,
                Price       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 0 : msg.Price,
                Content     = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Content : (msg.Content.Substring(0, 5) + "..."),
                Video       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Video : "",
                Sound       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Sound : "",
                Picurl      = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Picurl : ""
            };


            result.Messages = query.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize).ToList();//进行分页
            int[] infos         = result.Messages.Select(a => a.Infoid).ToArray();
            int[] mynodeids     = friList.Select(a => a.Mynodeid).ToArray();
            int[] Friendnodeids = friList.Select(a => a.Friendnodeid).ToArray();
            var   queryComment  = from comment in db.TpxinCommentHisSet
                                  join msg in db.TpxinMessageSet on comment.Infoid equals msg.Infoid
                                  where infos.Contains(msg.Infoid) && (mynodeids.Contains(comment.Nodeid) || Friendnodeids.Contains(comment.Nodeid))
                                  orderby comment.Createtime ascending
                                  select new CommentDto
            {
                Content    = comment.Content,
                Createtime = comment.Createtime,
                Hisid      = comment.Hisid,
                Infoid     = comment.Infoid,
                Nodeid     = comment.Nodeid,
                Phisid     = comment.Phisid,
                Pnodeid    = comment.Pnodeid
            };

            result.Comments = queryComment.ToList();
            return(result);
        }
Example #22
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);
        }
Example #23
0
        /// <summary>
        /// V点扣除
        /// </summary>
        /// <param name="nodecode">用户账号</param>
        /// <param name="amount">金额</param>
        /// <param name="subject">商品名</param>
        /// <returns></returns>
        private bool Transfer_VD(string nodecode, decimal amount, string subject)
        {
            if (!CheckSign())
            {
                return(false);
            }

            //TssoOpenUser openUser = db.TssoOpenUserSet.Where(d => d.Openid == nodecode && d.Opentype == 4).FirstOrDefault();
            //if (openUser == null)
            //{
            //    Alert("没有绑定PCN账号");
            //    return false;
            //}
            TnetReginfo reginfo = db.TnetReginfoSet.FirstOrDefault(c => c.Nodecode == nodecode || c.Mobileno == nodecode);

            if (reginfo == null)
            {
                Alert("用户账号不存在");
                return(false);
            }
            var user = db.TpxinUserinfoSet.Where(c => c.Nodeid == reginfo.Nodeid).FirstOrDefault();

            if (user == null)
            {
                Alert("用户不存在");
                return(false);
            }

            //if (user.V < amount * 10)
            //{
            //    Alert("余额不足");
            //    return false;
            //}

            //比例1:10
            //decimal before = user.V;
            //user.V -= amount * 10;
            ////添加金额变化记录
            //var amountChangeHis = new TpxinAmountChangeHis()
            //{
            //    Nodeid = user.Nodeid,
            //    Typeid = 1,
            //    Amount = -amount * 10,
            //    Reason = 9,
            //    Transferid = Guid.NewGuid().ToString(),
            //    Createtime = DateTime.Now,
            //    Remarks = subject,
            //    Amountbefore = before,
            //    Amountafter = user.V
            //};
            //db.TpxinAmountChangeHisSet.Add(amountChangeHis);
            //if (db.SaveChanges() <= 0)
            //{
            //    Alert("V点失败");
            //    return false;
            //}

            //TransferId = amountChangeHis.Hisid;
            #region 调用VP接口扣除V点
            var id  = db.GetPrimaryKeyValue <TpxinAmountChangeHis>();
            var req = new VPChargeVDian()
            {
                Amount     = -amount * 10,
                Nodeid     = user.Nodeid,
                Reason     = 9,
                Remark     = subject,
                Transferid = id.ToString(),
            };
            var vp     = new VPHelper();
            var result = vp.SetV(req);
            if (result.Result <= 0)
            {
                Alert(result.Message);
                log.Error($"Transfer_VD扣减V点失败,Nodeid:{user.Nodeid};原因:{result.Message}");
                return(false);
            }
            TransferId = id;
            #endregion
            return(true);
        }
Example #24
0
        /// <summary>
        /// 第三方支付接口
        /// </summary>
        public Respbase <ThridPayDto> ThridPartyPay(ThridPayReq req)
        {
            TnetReginfo reginfo = HttpContext.Current.GetRegInfo();

            if (string.IsNullOrEmpty(reginfo.UserpwdBak))
            {
                log.Info("未设置支付密码,nodeid=" + reginfo.Nodeid);
                return(new Respbase <ThridPayDto> {
                    Result = -5, Message = "支付密码未设置"
                });
            }

            var partner = db.TpcnThirdPartnerSet.FirstOrDefault(x => x.Accesskeyid == req.SecretKey);

            if (partner == null)
            {
                return(new Respbase <ThridPayDto> {
                    Result = -2, Message = "secretkey不存在"
                });
            }
            byte[] c   = Convert.FromBase64String(req.Pwd);
            string pwd = System.Text.Encoding.UTF8.GetString(c);

            if (!UserPwd.Check(pwd, reginfo.UserpwdBak, reginfo.Nodeid, reginfo.Nodecode))
            {
                log.Info("支付密码不正确,nodeid=" + reginfo.Nodeid);
                return(new Respbase <ThridPayDto> {
                    Result = -5, Message = "支付密码不正确"
                });
            }

            var payhis = db.TpcnThirdPayhisSet.FirstOrDefault(x => x.Orderno == req.Orderno);

            if (payhis != null && payhis.Hisid > 0)
            {
                log.Info("订单号已存在,orderno:" + req.Orderno);
                return(new Respbase <ThridPayDto> {
                    Result = -6, Message = "订单号已存在,orderno:" + req.Orderno
                });
            }
            db.BeginTransaction();
            //添加历史
            payhis             = InitPcnThirdPayhis();
            payhis.Nodeid      = reginfo.Nodeid;
            payhis.Partnerid   = partner.Id; //-------------------------
            payhis.Amount      = req.Amount; //人民币
            payhis.Orderno     = req.Orderno;
            payhis.Paytype     = req.PayType;
            payhis.Body        = req.Body;
            payhis.Subject     = req.Subject;
            payhis.Notifyurl   = req.Noticeurl;
            payhis.Transferids = "0";//transferids.ToString();
            db.TpcnThirdPayhisSet.Add(payhis);
            if (db.SaveChanges() <= 0)
            {
                log.Info("写支付历史失败:" + db.Message + ",payhis:" + JsonConvert.SerializeObject(payhis));
                db.Rollback();
                return(new Respbase <ThridPayDto> {
                    Result = -8, Message = "写支付历史失败"
                });
            }
            int transferids = 0;

            //开启转账
            BeginTransfer();
            if (req.PayType == 3000)
            {
                //SV-相信
                if (!Transfer_SV(reginfo.Nodecode, req.Amount, req.Subject))
                {
                    db.Rollback();
                    EndTransfer(false);
                    return(new Respbase <ThridPayDto> {
                        Result = -1, Message = PromptInfo.Message
                    });
                }
                //string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                //string sign = Md5.SignString(time + AppConfig.AppSecurityString);
                //PurseFacade facade = new PurseFacade();
                //var ret = facade.ThridPartyPay_Pro(new ThridPartyPayReq { Nodecode = reginfo.Nodecode, Amount = req.Amount, Subject = req.Subject, ReqTime = time, Sign = sign });
                //if (ret.Result <= 0)
                //{
                //    db.Rollback();
                //    EndTransfer(false);
                //    return new Respbase<ThridPayDto> { Result = -1, Message = ret.Message };
                //}
                else
                {
                    transferids = TransferId;
                    //transferids = ret.Data.TransferId;
                }
            }
            else if (req.PayType == 3001)
            {
                //SV-V点
                if (!Transfer_VD(reginfo.Nodecode, req.Amount, req.Subject))
                {
                    db.Rollback();
                    EndTransfer(false);
                    return(new Respbase <ThridPayDto> {
                        Result = -1, Message = PromptInfo.Message
                    });
                }
                else
                {
                    transferids = TransferId;
                }
            }
            else
            {
                db.Rollback();
                EndTransfer(false);
                return(new Respbase <ThridPayDto> {
                    Result = -1, Message = "参数错误"
                });
            }

            payhis.Transferids = transferids.ToString();
            if (db.SaveChanges() <= 0)
            {
                log.Info("修改支付历史失败:" + db.Message + ",payhis:" + JsonConvert.SerializeObject(payhis));
                db.Rollback();
                EndTransfer(false);
                return(new Respbase <ThridPayDto> {
                    Result = -8, Message = "修改支付历史失败"
                });
            }

            EndTransfer();
            db.Commit();
            ThridPayDto dto = new ThridPayDto
            {
                Orderno  = req.Orderno,
                OrderPcn = payhis.Hisid.ToString()
            };

            PxinSerivce.EnqueueNotice(payhis.Hisid);

            return(new Respbase <ThridPayDto> {
                Result = 1, Message = "支付成功", Data = dto
            });
        }
Example #25
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);
        }
Example #26
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);
        }
Example #27
0
        private void AuthSignature(HttpActionContext actionContext)
        {
            if (actionContext.ActionDescriptor.GetCustomAttributes <AnonymousAttribute>().Count() > 0 ||
                actionContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes <AnonymousAttribute>().Count() > 0)
            {
                return;
            }
            //log.Info("===============ReqUrl=" + HttpContext.Current.Request.Url.ToString());
            //log.Info("===============ReqContent=" + Helper.GetRequestContent());
            //#pragma warning disable IDE0019 // 使用模式匹配
            Reqbase req = actionContext.ActionArguments.First().Value as Reqbase;

            //#pragma warning restore IDE0019 // 使用模式匹配
            if (req == null)
            {
                WriteErrLog("参数匹配失败", "");
                actionContext.Response = new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadRequest, Content = new StringContent(JsonWinner.SerializeObjectPropertyNameLower(new Respbase {
                        Result = -1, Message = "参数匹配错误"
                    }))
                };
                return;
            }
            if (!actionContext.ModelState.IsValid)
            {
                string modelStateMsg = GetModelError(actionContext.ModelState.Values.SelectMany(c => c.Errors));
                WriteErrLog("参数验证错误", modelStateMsg);
                actionContext.Response = new HttpResponseMessage {
                    StatusCode = HttpStatusCode.BadRequest, Content = new StringContent(JsonWinner.SerializeObjectPropertyNameLower(new Respbase {
                        Result = -1, Message = "参数验证错误"
                    }))
                };
                return;
            }

            var         unLogin = actionContext.ActionDescriptor.GetCustomAttributes <UnLoginAttribute>().FirstOrDefault();//如果没有UnLoginAttribute特性标记则校验用户
            TnetReginfo regInfo = null;

            if (unLogin == null)
            {
                regInfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    RegInfoKey = req.Nodeid.ToString()
                });
                if (regInfo == null)
                {
                    WriteErrLog("用户不存在", $"nodeid={req.Nodeid}");
                    actionContext.Response = new HttpResponseMessage {
                        StatusCode = HttpStatusCode.BadRequest, Content = new StringContent(JsonWinner.SerializeObjectPropertyNameLower(new Respbase {
                            Result = -1, Message = "用户不存在"
                        }))
                    };
                    return;
                }
            }
            if (!CommonConfig.SignValidationDisabled)
            {
                //DvUZIrmKXs
                if (!req.Sign.Equals(Helper.GetSign(req.Nodeid, req.Sid, req.Tm, CommonConfig.ApiAuthString), StringComparison.OrdinalIgnoreCase) &&
                    !req.Sign.Equals(Helper.GetSign(req.Nodeid, req.Sid, req.Tm, "DvUZIrmKXs"), StringComparison.OrdinalIgnoreCase) &&
                    !req.Sign.Equals(Helper.GetSign(req.Nodeid, req.Sid, req.Tm, CommonConfig.CasAuthString), StringComparison.OrdinalIgnoreCase) &&
                    !req.Sign.Equals(Helper.GetSign(req.Nodeid, req.Sid, req.Tm, ConfigurationManager.AppSettings["PcnAuthString"]), StringComparison.OrdinalIgnoreCase))
                {
                    WriteErrLog("参数签名错误", JsonConvert.SerializeObject(req));
                    actionContext.Response = new HttpResponseMessage {
                        StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent(JsonWinner.SerializeObjectPropertyNameLower(new Respbase {
                            Result = -1, Message = "参数签名错误"
                        }))
                    };
                    return;
                }
            }

            if (regInfo != null)
            {
                HttpContext.Current.Items.Add("CurrentUser", regInfo);
            }
        }
Example #28
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);
        }
Example #29
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);
        }
Example #30
0
        /// <summary>
        /// 将资金回收到系统
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public Respbase <RecoveryDto> Recovery(PurseRecoveryReq req)
        {
            TnetReginfo tnet_reginfo = null;

            if (req.Nodeid > 0)
            {
                tnet_reginfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    KeyType = 0, RegInfoKey = req.Nodeid.ToString()
                });
            }
            else
            {
                tnet_reginfo = CommonApiTransfer.Instance.GetTnetReginfo(new GetRegInfoReq {
                    KeyType = 1, RegInfoKey = req.Nodecode.ToString()
                });
            }
            if (!UserPwd.Check(req.Paypwd, tnet_reginfo.UserpwdBak, tnet_reginfo.Nodeid, tnet_reginfo.Nodecode))
            {
                return(this.Fail <RecoveryDto>("支付密码错误"));
            }
            if (tnet_reginfo == null)
            {
                log.Info($"Recovery接口,获取用户信息失败,UE账号={req.Nodecode}");
                return(this.Fail <RecoveryDto>("获取用户信息失败"));
            }

            if (req.Reason <= 0)
            {
                log.Info($"Recovery接口,参数错误,Reason={req.Reason}");
                return(this.Fail <RecoveryDto>("参数错误"));
            }

            //检查typeid
            TnetPurseConfig purse_config = db.TnetPurseConfigSet.Where(c => c.Infoid == req.Pursetype).FirstOrDefault();

            if (purse_config == null)
            {
                log.Info($"Recovery接口,获取钱包信息失败,Infoid={req.Pursetype}");
                return(this.Fail <RecoveryDto>("获取钱包信息失败"));
            }

            //检查完毕,开始转账
            BalanceWcfProxy wcfProxy = new BalanceWcfProxy(db.NewTradeId);

            if (!wcfProxy.OpenSession())
            {
                return(this.Fail <RecoveryDto>($"不能建立会话,{wcfProxy.PromptInfo}"));
            }
            if (!wcfProxy.BeginTransaction())
            {
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>($"事务开启失败,{wcfProxy.PromptInfo}"));
            }
            PurseFactory purseFactory = new PurseFactory(wcfProxy);
            Purse        fromPurse    = new Purse((OwnerType)1, tnet_reginfo.Nodeid, (PurseType)purse_config.Pursetype, purse_config.Subid, new CurrencyType(purse_config.Currencytype), wcfProxy);
            Purse        toPurse      = purseFactory.SystemPurseRand(tnet_reginfo.Nodeid);//到系统钱包
            Currency     currency     = new Currency(CurrencyType.RMB, req.Amount);

            if (req.currencytype > 0)
            {
                currency = new Currency(new CurrencyType(req.currencytype), req.Amount);
            }
            //转账
            log.Info($"Recovery接口,开始回收,frompurseid={fromPurse.PurseId},到钱包ID={toPurse.PurseId},金额={currency.Amount},单位={currency.CurrencyUnit}");
            TransferResult transferResult = wcfProxy.Transfer(fromPurse, toPurse, currency, req.Reason, req.Remarks);

            if (!transferResult.IsSuccess)
            {
                log.Info("Recovery接口,转账失败:" + transferResult.Message);
                wcfProxy.Rollback();
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>(transferResult.Message));
            }
            log.Info($"Recovery接口,回收成功,账号={tnet_reginfo.Nodecode},类型={req.Pursetype},金额={currency.Amount},单位={currency.CurrencyUnit},备注={req.Remarks}");
            if (!wcfProxy.Commit())
            {
                wcfProxy.CloseSession();
                return(this.Fail <RecoveryDto>("转账提交失败"));
            }
            return(this.Ok("操作成功", new RecoveryDto {
                TransferId = transferResult.TransferId.ToString()
            }));
        }