2025-06-17 09:31:12 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Runtime.UI.Data
|
|
|
|
|
{
|
|
|
|
|
public class ShoppingCart
|
|
|
|
|
{
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public string userName = string.Empty;
|
|
|
|
|
public string userModie = string.Empty;
|
|
|
|
|
public string userEmail = string.Empty;
|
|
|
|
|
public List<ShoppingCartData> datas = new List<ShoppingCartData>();
|
|
|
|
|
public string totalQuantity = "0";
|
|
|
|
|
public string itemsSubTotal = "0";
|
|
|
|
|
public string discount = "0";
|
|
|
|
|
public string totalAmount = "0";
|
2025-06-17 09:31:12 +08:00
|
|
|
|
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public void AddData(ShoppingCartData data)
|
|
|
|
|
{
|
|
|
|
|
datas.Add(data);
|
|
|
|
|
UpdateDatas();
|
|
|
|
|
}
|
2025-06-17 09:31:12 +08:00
|
|
|
|
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public void UpdateDatas()
|
|
|
|
|
{
|
|
|
|
|
totalQuantity = datas.Count.ToString();
|
|
|
|
|
itemsSubTotal = string.Empty;
|
|
|
|
|
discount = string.Empty;
|
|
|
|
|
totalAmount = string.Empty;
|
|
|
|
|
|
|
|
|
|
int i = 0, d = 0, t = 0;
|
|
|
|
|
foreach (var shoppingCartData in datas)
|
|
|
|
|
{
|
|
|
|
|
i += shoppingCartData.bookAmount * shoppingCartData.count;
|
|
|
|
|
d += shoppingCartData.bookDiscount * shoppingCartData.count;
|
|
|
|
|
t += shoppingCartData.bookAmount * shoppingCartData.count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemsSubTotal = i.ToString();
|
|
|
|
|
discount = d.ToString();
|
|
|
|
|
totalAmount = t.ToString();
|
|
|
|
|
}
|
2025-06-17 09:31:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public class ShoppingCartData
|
2025-06-17 09:31:12 +08:00
|
|
|
|
{
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public string bookName;
|
|
|
|
|
public int bookAmount;
|
|
|
|
|
public int bookDiscount;
|
|
|
|
|
public int count;
|
|
|
|
|
public byte[] previewImage;
|
|
|
|
|
public byte[] tifImage;
|
2025-06-17 09:31:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|