/// <summary> /// /// </summary> protected void Application_Start() { //log4net.Config.XmlConfigurator.Configure(); log.Info("Pxin Start"); AssemblyConfig.InitWebAssembly(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); CurrencyConfig.Register(); var TimeServiceStart = System.Configuration.ConfigurationManager.AppSettings["TimeServiceStart"]; if (string.IsNullOrEmpty(TimeServiceStart) || TimeServiceStart == "1") { PxinSerivce.Register(); } }
/// <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); }
/// <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); }
/// <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 }); }
public Respbase TestCommentPush(int commentid) { PxinSerivce.EnqueueComment(commentid); return(new Respbase()); }