namespace com.hitrust.trustpay.client.b2c { using com.hitrust.trustpay.client; using System; public class OrderItem { private string iProductID; private string iProductName; private int iQty; private double iUnitPrice; public const int PRODUCT_ID_LEN = 20; public const int PRODUCT_NAME_LEN = 50; public OrderItem() { this.iProductID = ""; this.iProductName = ""; this.iUnitPrice = 0.0; this.iQty = 0; } public OrderItem(com.hitrust.trustpay.client.XMLDocument aXMLDocument) { this.iProductID = ""; this.iProductName = ""; this.iUnitPrice = 0.0; this.iQty = 0; this.ProductID = aXMLDocument.getValueNoNull("ProductID"); this.ProductName = aXMLDocument.getValueNoNull("ProductName"); try { this.UnitPrice = double.Parse(aXMLDocument.getValueNoNull("UnitPrice")); } catch (Exception) { } try { this.Qty = int.Parse(aXMLDocument.getValueNoNull("Qty")); } catch (Exception) { } } public OrderItem(string aProductID, string aProductName, double aUnitPrice, int aQty) { this.iProductID = ""; this.iProductName = ""; this.iUnitPrice = 0.0; this.iQty = 0; this.ProductID = aProductID; this.ProductName = aProductName; this.UnitPrice = aUnitPrice; this.Qty = aQty; } public virtual string isValid() { if (this.iProductID == null) { return "产品编号为空"; } if (this.iProductName == null) { return "产品名称为空"; } if (this.iUnitPrice <= 0.0) { return "产品单价小于等于零"; } if (this.iQty <= 0) { return "产品数量小于等于零"; } if (this.iProductID.Length == 0) { return "产品编号长度为零"; } if (SupportClass.ToSByteArray(SupportClass.ToByteArray(this.iProductID)).Length > 20) { return "产品编号超长"; } if (this.iProductName.Length == 0) { return "产品名称长度为零"; } if (SupportClass.ToSByteArray(SupportClass.ToByteArray(this.iProductName)).Length > 50) { return "产品名称超长"; } if (!DataVerifier.isValidAmount(this.iUnitPrice, 2)) { return "产品单价不合法"; } return ""; } public virtual double Amount { get { return (this.iUnitPrice * this.iQty); } } public virtual string ProductID { get { return this.iProductID; } set { this.iProductID = value.Trim(); } } public virtual string ProductName { get { return this.iProductName; } set { this.iProductName = value.Trim(); } } public virtual int Qty { get { return this.iQty; } set { this.iQty = value; } } public virtual double UnitPrice { get { return this.iUnitPrice; } set { this.iUnitPrice = value; } } public virtual com.hitrust.trustpay.client.XMLDocument XMLDocument { get { return new com.hitrust.trustpay.client.XMLDocument(string.Concat(new object[] { "", this.iProductID, "", this.iProductName, "", this.iUnitPrice, "", this.iQty, "" })); } } } }