예제 #1
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(WXPayNoticeEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
예제 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
            JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
            {
                Message = "支付通知接口被调用"
            });


            #region 获取url参数
            //签名类型,取值: MD5MD5 、RSA RSA,默认: MD5
            var signType = context.Request.QueryString["sign_type"];
            //版本号,默认为 1.0
            var serviceVersion = context.Request.QueryString["service_version"];
            //字符编码 ,取值: GBKGBK 、UTFUTFUTF-8,默认: GBKGBK 。
            var inputCharset = context.Request.QueryString["input_charset"];
            //签名
            var sign = context.Request.QueryString["sign"];
            //多密钥支持的序号,默认 1
            var signKeyIndex = context.Request.QueryString["sign_key_index"];
            //1-即时到账 其他保留
            var tradeMode = context.Request.QueryString["trade_mode"];
            //支付结果:0—成功 其他保留
            var tradeState = context.Request.QueryString["trade_state"];
            //支付结果信息,成功时为空
            var payInfo = context.Request.QueryString["pay_info"];
            //商户号,也即之前步骤的 商户号,也即之前步骤的 partnerid,由微信统一分配的 10 位正整数 (120XXXXXXX)号
            var partner = context.Request.QueryString["partner"];
            //银行类型,在微信中使用 WX
            var bankType = context.Request.QueryString["bank_type"];
            //银行订单号
            var bankBillno = context.Request.QueryString["bank_billno"];
            //支付金额,单位为分如果 支付金额,单位为分如果 支付金额,单位为分如果 discount 有值,通知的 total_fee + discount = 请求的 total_fee
            var totalFee = context.Request.QueryString["total_fee"];
            //现金支付币种 ,目前只支持人民币 默认值是 1-人民币
            var feeType = context.Request.QueryString["fee_type"];
            //支付结果通知 id ,对于某些特定商 户,只返回通知 id ,要求商户据此查询交易结果
            var notifyId = context.Request.QueryString["notify_id"];
            //交易号, 28 位长的数值,其中前 位长的数值,其中前 10 位为商户号,之后 8位为订单产生 的日期,如 20090415,最后 10 位是流水号。
            var transactionId = context.Request.QueryString["transaction_id"];
            //商户系统的订单号,与请求一致。
            var outTradeNo = context.Request.QueryString["out_trade_no"];
            //商户 数据包,原样返回
            var attach = context.Request.QueryString["attach"];
            //支付完成时间,格式为yyyyMMddhhmmss ,如 2009 年 12 月 27 日 9点 10 分 10 秒表示为 秒表示为 20091227091010。时区为 GMT+8 beijing
            var timeEnd = context.Request.QueryString["time_end"];
            //物流费用,单位分默认0。如果有值,必须保证 transport_fee + product_fee = total_fee
            var transportFee = context.Request.QueryString["transport_fee"];
            //物品费用,单位分。如果有值必须保证 transport_fee + product_fee = total_fee
            var productFee = context.Request.QueryString["product_fee"];
            //折扣价格,单位分.如果有值,通知的 total_fee + discount =  请求的 total_fee
            var discount = context.Request.QueryString["discount"];
            //对应买家账号的一个加密串
            var buyerAlias = context.Request.QueryString["buyer_alias"];

            #endregion



            var appSignature = string.Empty;
            var appId        = string.Empty;
            var isSubscribe  = string.Empty;
            var timeStamp    = string.Empty;
            var nonceStr     = string.Empty;
            var openID       = string.Empty;

            using (var stream = context.Request.InputStream)
            {
                using (var rd = new StreamReader(stream, Encoding.UTF8))
                {
                    var xmlStr = rd.ReadToEnd();
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "传入内容:" + xmlStr
                    });
                    var doc = new XmlDocument();
                    doc.LoadXml(xmlStr);
                    nonceStr     = doc.SelectSingleNode("xml/NonceStr").InnerText;
                    appSignature = doc.SelectSingleNode("xml/AppSignature").InnerText;
                    appId        = doc.SelectSingleNode("xml/AppId").InnerText;
                    isSubscribe  = doc.SelectSingleNode("xml/IsSubscribe").InnerText;
                    timeStamp    = doc.SelectSingleNode("xml/TimeStamp").InnerText;
                    openID       = doc.SelectSingleNode("xml/OpenId").InnerText;
                }
            }

            #region

            var customerWxMappingBll = new TCustomerWeiXinMappingBLL(Default.GetAPLoggingSession(""));

            var customerId = customerWxMappingBll.GetCustomerIdByAppId(appId);

            if (customerId == "")
            {
                throw new APIException("客户ID为空")
                      {
                          ErrorCode = 121
                      };
            }


            var currentUserInfo = Default.GetBSLoggingSession(customerId, "1");


            var wxPayNoticeEntity = new WXPayNoticeEntity
            {
                SignType       = signType,
                Sign           = sign,
                ServiceVersion = serviceVersion,
                InputCharset   = inputCharset,
                SignKeyIndex   = Convert.ToInt32(signKeyIndex),
                TradeMode      = Convert.ToInt32(tradeMode),
                TradeState     = Convert.ToInt32(tradeState),
                PayInfo        = payInfo,
                Partner        = partner,
                BankType       = bankType,
                BankBillno     = bankBillno,
                TotalFee       = Convert.ToInt32(totalFee),
                FeeType        = Convert.ToInt32(feeType),
                NotifyId       = notifyId,
                TransactionId  = transactionId,
                OutTradeNo     = outTradeNo,
                Attach         = attach,
                TimeEnd        = timeEnd,
                TransportFee   = Convert.ToInt32(transportFee),
                ProductFee     = Convert.ToInt32(productFee),
                Discount       = Convert.ToInt32(discount),
                BuyerAlias     = buyerAlias,
                AppId          = appId,
                TimeStamp      = Convert.ToInt32(timeStamp),
                NonceStr       = nonceStr,
                OpenId         = openID,
                AppSignature   = appSignature,
                IsSubscribe    = 1,
                CustomerId     = customerId
            };

            var wxPayNoticeBll = new WXPayNoticeBLL(currentUserInfo);

            var entity = wxPayNoticeBll.QueryByEntity(new WXPayNoticeEntity()
            {
                OutTradeNo = outTradeNo,
                OpenId     = openID
            }, null);
            if (entity != null)
            {
                wxPayNoticeBll.Delete(entity);
            }
            wxPayNoticeBll.Create(wxPayNoticeEntity);

            //将请求数据记录到表中、方便维权的时候试用
            //1.向表中记录该笔支付是否成功,如不成功,将失败原因记录下来【status = 1 成功 0 失败 2 支付金额与订单金额不符】

            //2.判断支付是否成功
            //if (tradeState == "0")//成功
            //{
            //    //3.根据订单号查询该笔订单的金额是否相符,如不符合,记录信息,查看原因

            //}
            //else//失败
            //{
            //    //
            //}

            if (tradeState == "0")
            {
                //根据customerid获取channelid;
                var channelBll = new TPaymentTypeCustomerMappingBLL(currentUserInfo);
                var channelId  = channelBll.GetChannelIdByCustomerId(customerId);

                var paras = "ChannelID=" + channelId + "&outTradeNo=" + outTradeNo;

                var url = System.Configuration.ConfigurationManager.AppSettings["wxNativePayNotifyUrl"];
                JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                {
                    Message = url + "?" + paras
                });
                var response = JIT.Utility.Web.HttpClient.PostQueryString(url, paras);
                JIT.Utility.Log.Loggers.Debug(new Utility.Log.DebugLogInfo()
                {
                    Message = response
                });
            }

            #region 向表中记录调用的微信接口

            var wxInterfaceLogBll    = new WXInterfaceLogBLL(currentUserInfo);
            var wxInterfaceLogEntity = new WXInterfaceLogEntity();
            wxInterfaceLogEntity.LogId        = Guid.NewGuid();
            wxInterfaceLogEntity.InterfaceUrl = System.Configuration.ConfigurationManager.AppSettings["wxNativePayNotifyUrl"];
            wxInterfaceLogEntity.AppId        = appId;
            wxInterfaceLogEntity.OpenId       = openID;
            wxInterfaceLogEntity.RequestParam = wxPayNoticeEntity.ToJSON();
            wxInterfaceLogEntity.IsSuccess    = 1;
            wxInterfaceLogBll.Create(wxInterfaceLogEntity);

            #endregion


            context.Response.Write("success");


            #endregion
        }
예제 #3
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(WXPayNoticeEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
예제 #4
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <WXPayNoticeEntity> PagedQueryByEntity(WXPayNoticeEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
예제 #5
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public WXPayNoticeEntity[] QueryByEntity(WXPayNoticeEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
예제 #6
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(WXPayNoticeEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
예제 #7
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(WXPayNoticeEntity pEntity)
 {
     _currentDAO.Update(pEntity);
 }