You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

65 lines
2.2 KiB

using System;
using BWP.ABCClient.Businesses.Type;
using BWP.ABCClient.Exceptions;
using BWP.ABCClient.Market;
namespace BWP.ABCClient.Businesses
{
public class MarketOrderApply : BusinessBase<OrderApplyRequest, OrderApplyResponse>
{
public MarketOrderApply()
: base(BusinessTypes.Market)
{
RequestObj = OrderApplyRequest.New();
}
public string BuyerCustomer { get; set; }
public string BuyerCustName { get; set; }
public string SalerCustomer { get; set; }
public string SalerCustName { get; set; }
public string PaymentUrl { get; set; }
protected override void AfterRequest()
{
var errorMessage = ResponseObj.Message.Control.ReturnMessage ?? string.Empty ;
Log.AddNewLine(string.Format("交易结果:[{0}]", ResponseObj.Message.Control.ReturnCode));
Log.AddNewLine(string.Format("返回信息:[{0}]", errorMessage));
Log.Commit();
if (ResponseObj.Message.Control.ReturnCode != "0000") {
throw new ResponseException(ResponseObj.Message.Control.ReturnCode, errorMessage);
}
PaymentUrl=ResponseObj.Message.Parameters.ReturnURL;
}
protected override void BeforeRequest()
{
if (string.IsNullOrEmpty(SequenceNo)) {
throw new Exception("交易流水号不能为空,SequenceNo");
}
if (string.IsNullOrEmpty(BuyerCustomer)) {
throw new Exception("付款帐户不能为空,BuyerCustomer");
}
if (string.IsNullOrEmpty(BuyerCustName)) {
throw new Exception("付款人不能为空,BuyerCustName");
}
if (string.IsNullOrEmpty(SalerCustomer)) {
throw new Exception("收款帐户不能为空,SalerCustomer");
}
if (string.IsNullOrEmpty(SalerCustName)) {
throw new Exception("收款人不能为空,SalerCustName");
}
RequestObj.Message.Control.MerchantID = MerchantID;
RequestObj.Message.Control.MerchantTrxNo = SequenceNo;
RequestObj.Message.Parameters.OrderNo = SequenceNo;
RequestObj.Message.Parameters.BuyerCustName = BuyerCustName;
RequestObj.Message.Parameters.BuyerCustomer = BuyerCustomer;
RequestObj.Message.Parameters.SalerCustName = SalerCustName;
RequestObj.Message.Parameters.SalerCustomer = SalerCustomer;
RequestObj.Message.Parameters.PayAmount = Amount.ToString("f2");
}
}
}