/// <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); }
/// <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); }
public ActionResult Success() { string content = ApiAuth.GetRequestContent(); log.Info("PayorderNotice:" + content); PXinContext ctx = HttpContext.GetDbContext <PXinContext>(); TpcnUepayconfig ueConfig = ctx.TpcnUepayconfigSet.FirstOrDefault(c => c.Id == 1); if (ueConfig == null) { log.Info("获取UE支付配置失败"); return(Content("failed")); } PayHisDto payHis = new PayHisDto(); if (Request.Url.ToString().IndexOf("localhost") > 0) { #region 测试注释 payHis.Paystatus = 1;//测试默认为1付款成功 payHis.Orderno = Request["orderno"]; payHis.OrdernoUE = Request["orderue"]; #endregion } else { #region 测试注释 if (!ApiAuth.Verify(ueConfig.Accesssecret)) { log.Info("签名验证失败"); return(Content("failed")); } try { payHis = UeApi.RequestDeserializeObject <PayHisDto>(); } catch (Exception err) { log.Info(err); return(Content("failed")); } #endregion } if (payHis == null || string.IsNullOrEmpty(payHis.Orderno) || string.IsNullOrEmpty(payHis.OrdernoUE)) { log.Info("订单数据异常:" + JsonConvert.SerializeObject(payHis)); return(Content("fail")); } if (payHis.Paystatus == 1) { //付款成功状态 if (!PaySuccessNotice(payHis)) { return(Content("fail")); } } else { //其它状态不处理 log.Info("订单数据支付状态不等于1:" + JsonConvert.SerializeObject(payHis)); } return(Content("OK")); }