步步为盈
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.

203 lines
6.0 KiB

using System;
namespace BBWY.Client.Models
{
public class ManualEditCostOrderSku : NotifyObject
{
/// <summary>
/// 发货运费
/// </summary>
private decimal deliveryExpressFreight;
private string deliveryExpressFreightStr;
/// <summary>
/// 单件成本
/// </summary>
private decimal unitCost;
/// <summary>
/// Sku成本(商品成本)
/// </summary>
private decimal skuAmount;
private string skuAmountStr;
/// <summary>
/// 采购运费
/// </summary>
private decimal purchaseFreight;
private string purchaseFreightStr;
/// <summary>
/// 头程运费
/// </summary>
private decimal firstFreight;
private string firstFreightStr;
/// <summary>
/// 操作费
/// </summary>
private decimal operationAmount;
private string operationAmountStr;
/// <summary>
/// 耗材费
/// </summary>
private decimal consumableAmount;
private string consumableAmountStr;
/// <summary>
/// 仓储费
/// </summary>
private decimal storageAmount;
private string storageAmountStr;
/// <summary>
/// 总计(不含发货运费)
/// </summary>
private decimal totalCost;
/// <summary>
/// SkuId
/// </summary>
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; }
/// <summary>
/// Sku标题
/// </summary>
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 OperationAmount { get => operationAmount; set { if (Set(ref operationAmount, 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 + OperationAmount + ConsumableAmount + StorageAmount;
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 OperationAmountStr
{
get => operationAmountStr; set
{
if (Set(ref operationAmountStr, value))
{
if (decimal.TryParse(operationAmountStr, out decimal d))
OperationAmount = d;
}
}
}
public string DeliveryExpressFreightStr
{
get => deliveryExpressFreightStr; set
{
if (Set(ref deliveryExpressFreightStr, value))
{
if (decimal.TryParse(deliveryExpressFreightStr, out decimal d))
DeliveryExpressFreight = d;
}
}
}
}
}