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

252 lines
7.3 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;
private decimal inStorageAmount;
private string inStorageAmountStr;
private decimal outStorageAmount;
private string outStorageAmountStr;
/// <summary>
/// 耗材费
/// </summary>
private decimal consumableAmount;
private string consumableAmountStr;
///// <summary>
///// 仓储费
///// </summary>
//private decimal storageAmount;
//private string storageAmountStr;
private decimal packagingLaborAmount;
private string packagingLaborAmountStr;
/// <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 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;
}
}
}
}