Example #1
0
        public ActionResult WxPay(int productId, string payMethod)
        {
            pay_order      order   = this.CreateOrder(productId, payMethod);
            module_product product = entity.module_product.FirstOrDefault(p => p.id == order.product_id);
            var            setting = entity.lay_setting;

            WxPayData data = new WxPayData();

            data.SetValue("body", setting.FirstOrDefault(p => p.key == "sitename").value + product.name); //商品描述
            data.SetValue("attach", "attach");                                                            //附加数据
            data.SetValue("out_trade_no", order.number);                                                  //随机字符串
            data.SetValue("total_fee", (int)Math.Ceiling(order.price.Value * 100));                       //总金额
            //data.SetValue("total_fee", 1);//总金额
            data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss"));                         //交易起始时间
            data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss"));         //交易结束时间
            data.SetValue("goods_tag", "goods_tag");                                                      //商品标记
            data.SetValue("trade_type", "NATIVE");                                                        //交易类型
            data.SetValue("product_id", order.product_id);                                                //商品ID
            WxPayData result = WxPayApi.UnifiedOrder(data);                                               //调用统一下单接口
            string    url    = QRTool.CreateQR(result.GetValue("code_url").ToString());                   //获得统一下单接口返回的二维码链接

            ViewBag.url = url;

            ViewBag.name     = product.name;
            ViewBag.price    = product.price;
            ViewBag.logo     = setting.FirstOrDefault(p => p.key == "logo").value;
            ViewBag.sitename = setting.FirstOrDefault(p => p.key == "sitename").value;
            return(View());
        }
Example #2
0
 public IActionResult GetQRImage(QRSettings settings)
 {
     try
     {
         string fileName = DateTime.Now.ToFileTime() + ".jpg";
         var    qrImg    = QRTool.GenerateQR(settings);
         qrImg.Save(_hostingEnvironment.ContentRootPath + @"\Images\" + fileName);
         return(Content(@"/QRImages/" + fileName));
     }
     catch (Exception e)
     {
         throw;
     }
 }
Example #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            _qrCodeStr1.texture = QRTool.GeneQRwithString1("方法一的二维码", 300, 300); // 显示String
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            _qrCodeStr2.texture = QRTool.GeneQRwithString2("方法二的二维码", 300, 300, Icon);//显示String,并且添加小图标
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            // 写入文件,并且 跳转到网址
            string path = @"D:\Desktop\22.jpg";
            QRTool.WriteToFile(path, QRTool.TexStyle.JPG, @"https://www.baidu.com/", 300, 300, Icon);
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            // 将bytes[] 数组转换到 Texture2D
            byte[] bytes = QRTool.TexConvertBytes(QRTool.GeneQRwithString2(@"https://www.baidu.com/", 300, 300, Icon), QRTool.TexStyle.JPG);
            _qrCodeStr3.texture = QRTool.BytesConvertTex2D(bytes, 300, 300);
        }

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            // 上传bytes到服务器 todo
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            // 接受服务器数据 todo
            //QRTool.SendQrToServer(@"D:\编程软件安装包\系统镜像文件\OS\OS X 10.11.1(15B42).cdr");
            stopwatch.Stop();
            print(stopwatch.ElapsedMilliseconds);
        }
    }