예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static JResult GetNativePayQrCode(NativePayData data)
        {
            var nativePay = new NativePay();

            //var data = new NativePayData
            //{
            //    Body = "快拍立信拍车定金",//商品描述
            //    Attach = "testAttach",//附加数据
            //    TotalFee = 1,//总金额
            //    ProductId = "prodid",//商品ID
            //    OutTradeNo = WxPayApi.GenerateOutTradeNo(),//订单编号
            //    GoodsTag = "testgood"
            //};

            var result = nativePay.GetPayUrl(data);

            if (result.errcode != 0)
            {
                return result;
            }

            //生成二维码
            var bitmap = BarCodeUtility.CreateBarcode(result.errmsg.ToString(), 240, 240);

            var ran = new Random();
            var key = string.Concat("wxpay", DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));
            var stream = BarCodeUtility.BitmapToStream(bitmap);
            //上传图片到七牛云
            var qinniu = new QiniuUtility();
            var qrcode = qinniu.Put(stream, "", key);
            return JResult._jResult(0, qrcode);
        }
예제 #2
0
        public string FileUpload()
        {
            var files = HttpContext.Current.Request.Files;
            if (files.Count == 0)
            {
                return "0";
            }

            var filename = string.Concat("card_logo_", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
            var filepath = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "TempFile\\", filename, ".jpg");

            try
            {
                files[0].SaveAs(filepath);

                //上传图片到七牛云
                var qinniu = new QiniuUtility();
                var qrcodeKey = qinniu.PutFile(filepath, "", filename);

                //删除本地临时文件
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }

                return qrcodeKey;
            }
            catch (Exception ex)
            {
                return "-2";
            }
        }
예제 #3
0
        public string FileUpload(string type)
        {
            var files = HttpContext.Current.Request.Files;
            if (files.Count == 0)
            {
                return "0";
            }

            try
            {
                var keys = "";
                for (var i = 0;i < files.Count; i++)
                {
                    var filename = string.Concat(type + "_", DateTime.Now.ToString("yyyyMMddHHmmssfff"), ".jpg");
                    var filepath = QiniuUtility.GetFilePath(filename);

                    files[i].SaveAs(filepath);

                    //上传图片到七牛云
                    var qinniu = new QiniuUtility();
                    var qrcodeKey = qinniu.PutFile(filepath, "", filename);

                    //删除本地临时文件
                    if (File.Exists(filepath))
                    {
                        File.Delete(filepath);
                    }

                    keys += qrcodeKey + ",";
                }

                return keys.TrimEnd(',');
            }
            catch (Exception ex)
            {
                LoggerFactories.CreateLogger().Write("上傳文件異常:", TraceEventType.Error, ex);
                return "-2";
            }
        }
예제 #4
0
        public void WxPayQrCodeTest()
        {
            NativePayData data = new NativePayData();
            data.Body="ccntest";//商品描述
            data.Attach ="ccntest";//附加数据
            data.TotalFee = 1;//总金额
            data.ProductId="123456789";//商品ID

            NativePay nativePay = new NativePay();
            string url2 = nativePay.GetPayUrl(data);

            var bitmap = BarCodeUtility.CreateBarcode(url2, 240, 240);

            var ran = new Random(Guid.NewGuid().GetHashCode());
            var key = string.Concat("wxpay", DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));

            var stream = BarCodeUtility.BitmapToStream(bitmap);
            //上传图片到七牛云
            var qinniu = new QiniuUtility();
            var qrcode = qinniu.Put(stream,"", key);
            stream.Dispose();
        }