/// <summary> /// 订单撤销 /// </summary> /// <param name="queryRequset">请求内容</param> /// <returns></returns> public static CancelResponseModel Cancel(CancelModel requestModel) { AlipayTradeCancelRequest cancelRequst = new AlipayTradeCancelRequest(); cancelRequst.BizContent = JsonConvert.SerializeObject(requestModel); LogUtil.WriteAlipayLog("订单撤销请求", "请求参数", cancelRequst.BizContent); Dictionary <string, string> paramsDict = (Dictionary <string, string>)cancelRequst.GetParameters(); AlipayTradeCancelResponse cancelResponse = _client.Execute(cancelRequst); LogUtil.WriteAlipayLog("撤销订单响应", "响应参数", cancelResponse.Body); return(new CancelResponseModel { msg = cancelResponse.Msg, code = cancelResponse.Code, subcode = cancelResponse.SubCode, submsg = cancelResponse.SubMsg, action = cancelResponse.Action, out_trade_no = cancelResponse.OutTradeNo, retry_flag = cancelResponse.RetryFlag, trade_no = cancelResponse.TradeNo }); }
public void cancelOrderRetry(object o) { int retryCount = 10; for (int i = 0; i < retryCount; ++i) { Thread.Sleep(5000); AlipayTradeCancelRequest cancelRequest = new AlipayTradeCancelRequest(); cancelRequest.BizContent = o.ToString(); Dictionary <string, string> paramsDict = (Dictionary <string, string>)cancelRequest.GetParameters(); AlipayTradeCancelResponse cancelResponse = m_Client.Execute(cancelRequest); if (null != cancelResponse) { if (cancelResponse.Code == ResultCode.FAIL) { //if (cancelResponse.Body.Contains("\"retry_flag\":\"N\"")) if (cancelResponse.RetryFlag == "N") // 再重試也不會成功 { break; } } if ((cancelResponse.Code == ResultCode.SUCCESS)) { break; } } if (i == retryCount - 1) { // 处理到最后一次,还是未撤销成功,需要在商户数据库中对此单最标记,人工介入处理 } } }