using System; namespace BBWY.Client.Models { public class ManualEditCostOrderSku : NotifyObject { /// /// 发货运费 /// private decimal deliveryExpressFreight; private string deliveryExpressFreightStr; /// /// 单件成本 /// private decimal unitCost; /// /// Sku成本(商品成本) /// private decimal skuAmount; private string skuAmountStr; /// /// 采购运费 /// private decimal purchaseFreight; private string purchaseFreightStr; /// /// 头程运费 /// private decimal firstFreight; private string firstFreightStr; private decimal inStorageAmount; private string inStorageAmountStr; private decimal outStorageAmount; private string outStorageAmountStr; /// /// 耗材费 /// private decimal consumableAmount; private string consumableAmountStr; ///// ///// 仓储费 ///// //private decimal storageAmount; //private string storageAmountStr; private decimal packagingLaborAmount; private string packagingLaborAmountStr; /// /// 总计(不含发货运费) /// private decimal totalCost; /// /// SkuId /// public string Id { get; set; } public int ItemTotal { get; set; } public string ProductId { get; set; } public string ProductItemNum { get; set; } public double Price { get; set; } /// /// Sku标题 /// public string Title { get; set; } public string Logo { get; set; } public decimal DeliveryExpressFreight { get => deliveryExpressFreight; set { if (Set(ref deliveryExpressFreight, value)) { OnAmountChanged?.Invoke(); } } } public decimal UnitCost { get => unitCost; set { Set(ref unitCost, value); } } public decimal SkuAmount { get => skuAmount; set { if (Set(ref skuAmount, value)) { CalculationCost(); } } } public decimal PurchaseFreight { get => purchaseFreight; set { if (Set(ref purchaseFreight, value)) { CalculationCost(); } } } public decimal FirstFreight { get => firstFreight; set { if (Set(ref firstFreight, value)) { CalculationCost(); } } } public decimal ConsumableAmount { get => consumableAmount; set { if (Set(ref consumableAmount, value)) { CalculationCost(); } } } //public decimal StorageAmount { get => storageAmount; set { if (Set(ref storageAmount, value)) { CalculationCost(); } } } public decimal TotalCost { get => totalCost; set { if (Set(ref totalCost, value)) { OnAmountChanged?.Invoke(); } } } private void CalculationCost() { TotalCost = SkuAmount + PurchaseFreight + FirstFreight + InStorageAmount + OutStorageAmount + ConsumableAmount + PackagingLaborAmount; UnitCost = ItemTotal == 0 ? 0 : TotalCost / ItemTotal; } public Action OnAmountChanged { get; set; } public string SkuAmountStr { get => skuAmountStr; set { if (Set(ref skuAmountStr, value)) { if (decimal.TryParse(skuAmountStr, out decimal d)) SkuAmount = d; } } } public string PurchaseFreightStr { get => purchaseFreightStr; set { if (Set(ref purchaseFreightStr, value)) { if (decimal.TryParse(purchaseFreightStr, out decimal d)) PurchaseFreight = d; } } } public string FirstFreightStr { get => firstFreightStr; set { if (Set(ref firstFreightStr, value)) { if (decimal.TryParse(firstFreightStr, out decimal d)) FirstFreight = d; } } } public string ConsumableAmountStr { get => consumableAmountStr; set { if (Set(ref consumableAmountStr, value)) { if (decimal.TryParse(consumableAmountStr, out decimal d)) ConsumableAmount = d; } } } //public string StorageAmountStr //{ // get => storageAmountStr; set // { // if (Set(ref storageAmountStr, value)) // { // if (decimal.TryParse(storageAmountStr, out decimal d)) // StorageAmount = d; // } // } //} public string DeliveryExpressFreightStr { get => deliveryExpressFreightStr; set { if (Set(ref deliveryExpressFreightStr, value)) { if (decimal.TryParse(deliveryExpressFreightStr, out decimal d)) DeliveryExpressFreight = d; } } } public decimal InStorageAmount { get => inStorageAmount; set { if (Set(ref inStorageAmount, value)) CalculationCost(); } } public string InStorageAmountStr { get => inStorageAmountStr; set { if (Set(ref inStorageAmountStr, value)) if (decimal.TryParse(inStorageAmountStr, out decimal d)) InStorageAmount = d; } } public decimal OutStorageAmount { get => outStorageAmount; set { if (Set(ref outStorageAmount, value)) CalculationCost(); } } public string OutStorageAmountStr { get => outStorageAmountStr; set { if (Set(ref outStorageAmountStr, value)) if (decimal.TryParse(outStorageAmountStr, out decimal d)) OutStorageAmount = d; } } public decimal PackagingLaborAmount { get => packagingLaborAmount; set { if (Set(ref packagingLaborAmount, value)) CalculationCost(); } } public string PackagingLaborAmountStr { get => packagingLaborAmountStr; set { if (Set(ref packagingLaborAmountStr, value)) if (decimal.TryParse(packagingLaborAmountStr, out decimal d)) packagingLaborAmount = d; } } } }