public Respbase CreateReward(ReqCreateReward req) { FriFacade facade = new FriFacade(); bool result = facade.CreateReward(req); return(facade.PromptInfo); }
/// <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); }