|
|
namespace com.hitrust.trustpay.client.b2c
|
|
|
{
|
|
|
using client;
|
|
|
using util.GZip;
|
|
|
using System;
|
|
|
using System.IO;
|
|
|
|
|
|
public class SettleRequest : TrxRequest
|
|
|
{
|
|
|
private string iSettleDate;
|
|
|
private string iSettleEndHour;
|
|
|
private string iSettleStartHour;
|
|
|
private string iSettleType;
|
|
|
|
|
|
public SettleRequest() : base("B2C")
|
|
|
{
|
|
|
this.iSettleDate = "";
|
|
|
this.iSettleStartHour = "";
|
|
|
this.iSettleEndHour = "";
|
|
|
this.iSettleType = "";
|
|
|
}
|
|
|
|
|
|
protected internal override void checkRequest()
|
|
|
{
|
|
|
if (!DataVerifier.isValidDate(this.iSettleDate)) {
|
|
|
throw new TrxException("1101", "商户提交的交易资料不合法", "对账日期不合法!");
|
|
|
}
|
|
|
if ((!this.iSettleType.Equals("TRX") && !this.iSettleType.Equals("SETTLE")) && !this.iSettleType.Equals("TRXBYHOUR")) {
|
|
|
throw new TrxException("1101", "商户提交的交易资料不合法", "对账类型不合法!");
|
|
|
}
|
|
|
if (this.iSettleType.Equals("TRXBYHOUR")) {
|
|
|
if (this.iSettleStartHour.Trim().Equals("") || this.iSettleEndHour.Trim().Equals("")) {
|
|
|
throw new TrxException("1101", "商户提交的交易资料不合法", "对账起止时间不合法,必须输入0-23之间的有效时间段!");
|
|
|
}
|
|
|
this.iSettleStartHour = (this.iSettleStartHour.Length < 2) ? ("0" + this.iSettleStartHour) : this.iSettleStartHour;
|
|
|
this.iSettleEndHour = (this.iSettleEndHour.Length < 2) ? ("0" + this.iSettleEndHour) : this.iSettleEndHour;
|
|
|
if (((this.iSettleStartHour.CompareTo("0") < 0) || (this.iSettleStartHour.CompareTo("23") > 0)) || (((this.iSettleEndHour.CompareTo("0") < 0) || (this.iSettleEndHour.CompareTo("23") > 0)) || (this.iSettleStartHour.CompareTo(this.iSettleEndHour) > 0))) {
|
|
|
throw new TrxException("1101", "商户提交的交易资料不合法", "对账起止时间不合法,必须输入0-23之间的有效时间段,且截止时间不小于开始时间!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected internal override TrxResponse constructResponse(XMLDocument aResponseMessage)
|
|
|
{
|
|
|
string str = "";
|
|
|
GZipInputStream stream = null;
|
|
|
StreamReader reader = null;
|
|
|
try {
|
|
|
string data = aResponseMessage.getValueNoNull("ZIPDetailRecords");
|
|
|
Base64 base2 = new Base64();
|
|
|
MemoryStream baseInputStream = new MemoryStream(base2.decode(data));
|
|
|
stream = new GZipInputStream(baseInputStream);
|
|
|
reader = new StreamReader(stream);
|
|
|
str = reader.ReadToEnd();
|
|
|
} catch (Exception exception) {
|
|
|
throw new TrxException("1304", "解压缩交易记录时发生错误", exception.Message);
|
|
|
} finally {
|
|
|
if (reader != null) {
|
|
|
try {
|
|
|
reader.Close();
|
|
|
} catch (Exception) {}
|
|
|
}
|
|
|
if (stream != null) {
|
|
|
try {
|
|
|
stream.Close();
|
|
|
} catch (Exception) {}
|
|
|
}
|
|
|
}
|
|
|
return new TrxResponse(new XMLDocument(aResponseMessage.ToString() + "<DetailRecords>" + str + "</DetailRecords>"));
|
|
|
}
|
|
|
|
|
|
protected internal override XMLDocument RequestMessage
|
|
|
{
|
|
|
get { return new XMLDocument("<TrxRequest><TrxType>Settle</TrxType><SettleDate>" + this.iSettleDate + "</SettleDate><SettleStartHour>" + this.iSettleStartHour + "</SettleStartHour><SettleEndHour>" + this.iSettleEndHour + "</SettleEndHour><SettleType>" + this.iSettleType + "</SettleType><ZIP>YES</ZIP></TrxRequest>"); }
|
|
|
}
|
|
|
|
|
|
public virtual string SettleDate
|
|
|
{
|
|
|
get { return this.iSettleDate; }
|
|
|
set { this.iSettleDate = value.Trim(); }
|
|
|
}
|
|
|
|
|
|
public virtual string SettleEndHour
|
|
|
{
|
|
|
get { return this.iSettleEndHour; }
|
|
|
set { this.iSettleEndHour = value.Trim(); }
|
|
|
}
|
|
|
|
|
|
public virtual string SettleStartHour
|
|
|
{
|
|
|
get { return this.iSettleStartHour; }
|
|
|
set { this.iSettleStartHour = value.Trim(); }
|
|
|
}
|
|
|
|
|
|
public virtual string SettleType
|
|
|
{
|
|
|
get { return this.iSettleType; }
|
|
|
set { this.iSettleType = value.Trim(); }
|
|
|
}
|
|
|
}
|
|
|
}
|