/// <summary> /// 获取描述信息(无HTML) /// </summary> /// <param name="content"></param> /// <param name="length"></param> /// <param name="startIndex"></param> /// <returns></returns> public static string GetDescript(string content, int length = 0, int startIndex = 0) { if (VerifyHelper.IsEmpty(content)) { return(""); } if (length == 0) { length = IntHelper.Get(SettingConfig.GetValue(KeyModel.Config.Setting.KeyDescriptLength)); } content = HtmlsHelper.Remove(HtmlsHelper.Decode(content)); return(StringHelper.ToCutString(content, length, startIndex: startIndex)); }
/// <summary> /// 获取使用次数 /// </summary> /// <returns></returns> public static int GetUseTimes() { if (!WpfHelper.RegistryIsExist(Registry.LocalMachine, REGISTRYPATH, USETIMES)) { WpfHelper.RegistrySet(Registry.LocalMachine, REGISTRYPATH, USETIMES, "0"); } var userTimes = IntHelper.Get(WpfHelper.RegistryGet(Registry.LocalMachine, REGISTRYPATH, USETIMES), -1); if (userTimes < 0) { throw new DbxException(EnumCode.注册表异常); } return(userTimes); }
/// <summary> /// 增加使用次数 /// </summary> /// <returns></returns> public static void AddUseTimes() { if (!WpfHelper.RegistryIsExist(Registry.LocalMachine, REGISTRYPATH, USETIMES)) { throw new DbxException(EnumCode.注册表异常); } var userTimes = IntHelper.Get(WpfHelper.RegistryGet(Registry.LocalMachine, REGISTRYPATH, USETIMES), -1); if (userTimes < 0) { throw new DbxException(EnumCode.注册表异常); } WpfHelper.RegistrySet(Registry.LocalMachine, REGISTRYPATH, USETIMES, (userTimes + 1).ToString()); }
/** * 生成直接支付url,支付url有效期为2小时,模式二 * @param productId 商品ID * @return 模式二URL */ public static string GetPayUrl(string rechargeRecordId, string tags, string descript, decimal moneyValue, out string tradeNo) { tradeNo = RandHelper.GenerateNonceStr(); WxPayData data = new WxPayData(); data.SetValue("body", descript); //商品描述 data.SetValue("attach", ""); //附加数据 data.SetValue("out_trade_no", tradeNo); //随机字符串 data.SetValue("total_fee", StringHelper.Get(IntHelper.Get(moneyValue * 100))); //总金额 data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //交易起始时间 data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); //交易结束时间 data.SetValue("goods_tag", tags); //商品标记 data.SetValue("trade_type", "NATIVE"); //交易类型 data.SetValue("product_id", rechargeRecordId); //商品ID WxPayData result = UnifiedOrder(data); //调用统一下单接口 string url = result.GetValue("code_url").ToString(); //获得统一下单接口返回的二维码链接 return(url); }