Commit 0591a856 authored by 吴春's avatar 吴春

提交查询退款接口

parent c868afd6
...@@ -109,15 +109,9 @@ namespace Mall.WebApi.App_Code ...@@ -109,15 +109,9 @@ namespace Mall.WebApi.App_Code
var res = new ResponseHandler(); var res = new ResponseHandler();
var tradeType = res.GetParameter("trade_type"); var tradeType = res.GetParameter("trade_type");
LogHelper.Write(null, "Notify支付回调:res-" + res.ToString());
RB_MiniProgram_Extend model = new RB_MiniProgram_Extend(); RB_MiniProgram_Extend model = new RB_MiniProgram_Extend();
model = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 0, TenantId = 0 }); model = programModule.GetMiniProgramModule(new RB_MiniProgram_Extend { MallBaseId = 0, TenantId = 0 });
//if (tradeType.Equals("APP"))
// res.SetKey(EheMall.WeChat.Common.WeChatConfig.GetOpenKey());
//if (tradeType.Equals("MWEB"))
// res.SetKey(EheMall.WeChat.Common.WeChatConfig.GetOpenKey());
//if (tradeType.Equals("JSAPI "))
// res.SetKey(EheMall.WeChat.Common.WeChatConfig.GetOpenKey());
//else
res.SetKey(model.WeChatApiSecret); res.SetKey(model.WeChatApiSecret);
//判断签名 //判断签名
if (res.IsWXsign(out string error)) if (res.IsWXsign(out string error))
...@@ -255,42 +249,101 @@ namespace Mall.WebApi.App_Code ...@@ -255,42 +249,101 @@ namespace Mall.WebApi.App_Code
}; };
} }
} }
else
{//查询退款情况
packageReq = new RequestHandler(); var errCodeDes = xe.GetElement("err_code_des") == null ? "" : xe.GetElement("err_code_des").Value;
packageReq.SetKey(model.WeChatApiSecret); var returnMsg = xe.GetElement("return_msg") == null ? "" : xe.GetElement("return_msg").Value;
packageReq.SetParameter("appid", model.MiniAppId);
packageReq.SetParameter("mch_id", model.WeChatPayMerchants); return new BaseResult() { IsSuccess = false, Message = returnMsg + errCodeDes };
packageReq.SetParameter("nonce_str", GetNoncestr()); #endregion
packageReq.SetParameter("sign", packageReq.CreateMd5Sign(_accessor)); }
packageReq.SetParameter("out_refund_no", param.RefundNumber);
// <summary>
/// 查询退款状态
/// </summary>
/// <param name="param"></param>
/// <returns></returns>
public BaseResult Refundquery(PayParam param, RB_MiniProgram_Extend model, IHttpContextAccessor _accessor)
{
if (param.TotalFee == null || param.RefundFee == null || string.IsNullOrWhiteSpace(param.OrderNumber) || string.IsNullOrWhiteSpace(param.RefundNumber))
{
return new BaseResult() { IsSuccess = false, Message = "参数错误!" };
}
#region 微信退款
var packageReq = new RequestHandler();
packageReq.SetKey(model.WeChatApiSecret);
packageReq.SetParameter("appid", model.MiniAppId);
packageReq.SetParameter("mch_id", model.WeChatPayMerchants);
packageReq.SetParameter("nonce_str", GetNoncestr());
packageReq.SetParameter("sign", packageReq.CreateMd5Sign(_accessor));
packageReq.SetParameter("out_refund_no", param.RefundNumber);//商户系统内部的退款单号
reqXml = packageReq.ParseXml(); var reqXml = packageReq.ParseXml();
result = Common.Pay.WeChatPat.HttpHelper.Post(new HttpParam() var result = Common.Pay.WeChatPat.HttpHelper.Post(new HttpParam()
{
Url = "https://api.mch.weixin.qq.com/pay/refundquery",
PostParam = reqXml,
Encoding = Common.Pay.WeChatPat.HttpHelper.GetRequestEncoding(_accessor.HttpContext.Request),
});
var xe = XElement.Parse(result, LoadOptions.SetLineInfo);
var returnCode = xe.GetElement("return_code").Value;
string outTradeNo = xe.GetElement("out_refund_no_0").Value;
if (returnCode.Equals("SUCCESS"))
{
string refundStatus = xe.GetElement("refund_status_0").Value;
if (!string.IsNullOrWhiteSpace(refundStatus) && refundStatus.Equals("SUCCESS"))
{ {
Url = "https://api.mch.weixin.qq.com/pay/refundquery", //在外面回写订单
PostParam = reqXml, return new BaseResult()
Encoding = Common.Pay.WeChatPat.HttpHelper.GetRequestEncoding(_accessor.HttpContext.Request), {
}); IsSuccess = true,
Data = new Dictionary<string, string>
xe = XElement.Parse(result, LoadOptions.SetLineInfo); {
returnCode = xe.GetElement("return_code").Value; { "OrderNumber", outTradeNo},
if (returnCode.Equals("SUCCESS")) { "refundStatus",refundStatus}
}
};
}
else
{ {
//在外面回写订单
return new BaseResult()
{
IsSuccess = false,
Data = new Dictionary<string, string>
{
{ "OrderNumber", outTradeNo},
{ "refundStatus",refundStatus}
}
};
} }
} }
var errCodeDes = xe.GetElement("err_code_des") == null ? "" : xe.GetElement("err_code_des").Value; var errCodeDes = xe.GetElement("err_code_des") == null ? "" : xe.GetElement("err_code_des").Value;
var returnMsg = xe.GetElement("return_msg") == null ? "" : xe.GetElement("return_msg").Value; var returnMsg = xe.GetElement("return_msg") == null ? "" : xe.GetElement("return_msg").Value;
return new BaseResult() { IsSuccess = false, Message = returnMsg + errCodeDes }; return new BaseResult()
{
IsSuccess = false,
Message = returnMsg + errCodeDes,
Data = new Dictionary<string, string>
{
{ "OrderNumber", outTradeNo}
}
};
#endregion #endregion
} }
/// <summary> /// <summary>
/// 企业付款 /// 企业付款
/// </summary> /// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment