示例#1
0
 public JsonResult DownLoadBill([FromBody] DownLoadBill downLoadBill)
 {
     try
     {
         _log.Info("下载对账单");
         DownLoadBillBack downLoadBillBack;
         string           message;
         var result = wxHandle.DownLoadBill(downLoadBill, out downLoadBillBack, out message);
         return(BuildJsonResult(downLoadBillBack, result, message));
     }
     catch (Exception exc)
     {
         _log.Fatal(exc, $"下载对账单:{exc.Message}");
         return(BuildJsonResult <DownLoadBillBack>(null, false, exc.Message));
     }
 }
示例#2
0
        /// <summary>
        /// 下载对账单
        /// </summary>
        /// <returns></returns>
        static DownLoadBillBack DownLoadBill()
        {
            var apps         = File.ReadAllLines(@"D:\cert.txt");
            var payHandle    = new PayHandle();
            var downLoadBill = new DownLoadBill
            {
                AppID    = apps[0],
                MchID    = apps[1],
                Key      = apps[3],
                BillDate = "20170509",
                BillType = "SUCCESS"
            };
            var downLoadBillBack = payHandle.Send(downLoadBill) as DownLoadBillBack;

            return(downLoadBillBack);
        }
示例#3
0
        /// <summary>
        /// 下载对帐单
        /// </summary>
        /// <param name="downLoadBill">对帐单请求实体</param>
        /// <param name="downLoadBillBack">对帐单应答实体</param>
        /// <param name="message">错误信息</param>
        /// <returns>交易是否成功</returns>
        internal bool DownLoadBill(DownLoadBill downLoadBill, out DownLoadBillBack downLoadBillBack, out string message)
        {
            _log.Info("下载对账单 DownLoadBill 开始");
            var data = new WxPayData();

            if (string.IsNullOrEmpty(downLoadBill.Bill_Date) || string.IsNullOrEmpty(downLoadBill.Bill_Type))
            {
                message = "对账单日期,账单类型 不能为空";
                _log.Error(message);
                downLoadBillBack = null;
                return(false);
            }
            data.SetValue("bill_date", downLoadBill.Bill_Date);
            data.SetValue("bill_type", downLoadBill.Bill_Type);
            if (!string.IsNullOrEmpty(downLoadBill.Tar_Type))
            {
                data.SetValue("tar_type", downLoadBill.Tar_Type);
            }
            //下载对帐单
            _log.Info("WxPayApi.DownloadBill");
            var result = WxPayApi.DownloadBill(data);

            _log.Info("DownLoadBill", "DownLoadBill process complete, result : " + result.ToXml());
            var return_code = result.GetValue("return_code")?.ToString().ToUpper();
            var result_code = result.GetValue("result_code")?.ToString().ToUpper();

            if (return_code == null && result_code == null)
            {
                _log.Info("下载对账单成功!");
                downLoadBillBack = new DownLoadBillBack()
                {
                    BackData = result.GetValue("result")?.ToString()
                };
                message = "";
                return(true);
            }
            else
            {
                var return_msg   = result.GetValue("return_msg");
                var err_code_des = result.GetValue("err_code_des");
                message = $"{return_msg},{err_code_des}";
                _log.Error($"下载对账单失败:{message}");
                downLoadBillBack = null;
                return(false);
            }
        }