Exemplo n.º 1
0
        public static StatusReport SetWXPayInfo(string xmlValue)
        {
            StatusReport sr        = new StatusReport();
            WXPayResult  payResult = new WXPayResult();

            payResult = GetWXPayResult(xmlValue);
            string sqlString = " if not exists (select ID from 基础_小程序收费情况 where 微信支付单号 = @微信支付单号) " +
                               " insert into 基础_小程序收费情况 (openid,费用名称,收费说明,付款银行,订单金额,现金支付金额,货币种类,商户号,订单编号,支付完成时间,微信支付单号) " +
                               " select @openid,@费用名称,@收费说明,@付款银行,@订单金额,@现金支付金额,@货币种类,@商户号,@订单编号,@支付完成时间,@微信支付单号" +
                               " select @@identity ";

            sr = SQLHelper.Insert("cloudsy", sqlString,
                                  new SqlParameter("openid", payResult.openid),
                                  new SqlParameter("费用名称", payResult.fee_name),
                                  new SqlParameter("收费说明", payResult.attach),
                                  new SqlParameter("付款银行", payResult.bank_type),
                                  new SqlParameter("订单金额", payResult.total_fee),
                                  new SqlParameter("现金支付金额", payResult.cash_fee),
                                  new SqlParameter("货币种类", payResult.fee_type),
                                  new SqlParameter("商户号", payResult.mch_id),
                                  new SqlParameter("订单编号", payResult.out_trade_no),
                                  new SqlParameter("支付完成时间", payResult.time_end),
                                  new SqlParameter("微信支付单号", payResult.transaction_id));
            using (StreamWriter sw = new StreamWriter("D:\\1_importTemp\\TestFile1.txt"))
            {
                sw.WriteLine(sr.result.ToString());
            }
            return(sr);
        }
Exemplo n.º 2
0
        private static WXPayResult GetWXPayResult(string xmlResult)
        {
            WXPayResult payResult = new WXPayResult();

            try
            {
                byte[]    array     = Encoding.UTF8.GetBytes(xmlResult);
                Stream    stream    = new MemoryStream(array);
                XDocument xDocument = new XDocument();
                xDocument = XDocument.Load(stream);
                XElement     root         = xDocument.Root;
                string       attach       = root.Element("attach").Value;
                AttachObject attachObject = new AttachObject();
                attachObject           = JsonConvert.DeserializeObject <AttachObject>(attach);
                payResult.fee_name     = attachObject.fn;
                payResult.mch_id       = root.Element("mch_id").Value;
                payResult.bank_type    = root.Element("bank_type").Value;
                payResult.cash_fee     = Convert.ToDouble(root.Element("cash_fee").Value) / 100;
                payResult.fee_type     = root.Element("fee_type").Value;
                payResult.openid       = root.Element("openid").Value;
                payResult.out_trade_no = root.Element("out_trade_no").Value;
                string time = root.Element("time_end").Value;
                payResult.time_end       = time.Substring(0, 4) + "-" + time.Substring(4, 2) + "-" + time.Substring(6, 2) + " " + time.Substring(8, 2) + ":" + time.Substring(10, 2) + ":" + time.Substring(12, 2);
                payResult.total_fee      = Convert.ToDouble(root.Element("total_fee").Value) / 100;
                payResult.transaction_id = root.Element("transaction_id").Value;
                if (attachObject.fn == "看园定金")
                {
                    payResult.attach = attachObject.fn + ":" + attachObject.name + "的家长" + attachObject.rn + "交费" + attachObject.tc + "元";
                }
                else
                {
                    SignUp s = SignUpDal.GetSignUpInfo(attachObject.kn, attachObject.id);
                    payResult.attach = attachObject.fn + ":" + s.name + "的家长" + s.relateName + "交费" + attachObject.tc + "元";
                }
            }
            catch (Exception exp)
            {
                using (StreamWriter sw = new StreamWriter("D:\\1_importTemp\\TestFile5.txt"))
                {
                    sw.WriteLine("error:" + exp.Message);
                }
            }
            return(payResult);
        }