using Newtonsoft.Json; using NPoco; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace POSV.Entity.Report { /// /// 营业分析 /// [Serializable] public class BusinessSummary { public BusinessSummary() { } /// /// 单号 /// [JsonProperty(PropertyName = "name")] [Column("name")] public string Name { get; set; } /// /// 人数 /// [JsonProperty(PropertyName = "people")] [Column("people")] public int People { get; set; } /// /// 单数 /// [JsonProperty(PropertyName = "count")] [Column("count")] public int Count { get; set; } /// /// 销售金额 /// [JsonProperty(PropertyName = "amount")] [Column("amount")] public decimal Amount { get; set; } /// /// 优惠金额 /// [JsonProperty(PropertyName = "discountAmount")] [Column("discountAmount")] public decimal DiscountAmount { get; set; } /// /// 应收金额 /// [JsonProperty(PropertyName = "receivableAmount")] [Column("receivableAmount")] public decimal ReceivableAmount { get; set; } // /// /// 赠送金额 /// [JsonProperty(PropertyName = "zsAmount")] [Column("zsAmount")] public decimal ZsAmount { get; set; } // private decimal _ticketPrice = 0; /// /// 单均 /// [Ignore] public decimal TicketPrice { get { this._ticketPrice = ToRound(this.ReceivableAmount / (this.Count == 0 ?1 : this.Count),2); return _ticketPrice; } set { this._ticketPrice = value; } } // private decimal _peoplePrice = 0; /// /// 人均 /// [Ignore] public decimal PeoplePrice { get { this._peoplePrice = ToRound(this.ReceivableAmount / (this.People==0?1:this.People),2); return _peoplePrice; } set { this._peoplePrice = value; } } // private decimal _otherAmount = 0; /// /// 其他优惠 /// [Ignore] public decimal OtherAmount { get { this._otherAmount = ToRound(this.DiscountAmount-this.ZsAmount,2); return _otherAmount; } set { this._otherAmount = value; } } // /// /// decimal保留指定位数小数 /// /// 原始数量 /// 保留小数位数 /// 截取指定小数位数后的数量字符串 public decimal ToRound(decimal num, int scale) { string strDecimal = Math.Round(num, scale, MidpointRounding.AwayFromZero).ToString(); int index = strDecimal.IndexOf("."); if (index == -1 || strDecimal.Length < index + scale + 1) { strDecimal = string.Format("{0:F" + scale + "}", num); } else { int length = index; if (scale != 0) { length = index + scale + 1; } strDecimal = strDecimal.Substring(0, length); } decimal result; decimal.TryParse(strDecimal, out result); return result; } } }