/// <summary>
/// 获取店铺财务总览
/// </summary>
/// <param name="shopId"></param>
/// <returns></returns>
public static ShopBillingIndex GetShopBillingIndex(long shopId)
{
var shopaccount = GetShopAccount(shopId);
ShopBillingIndex model = new ShopBillingIndex();
model.YesterDayOrders = OrderApplication.GetYesterDayOrdersNum(shopId);
model.YesterDayPayOrders = OrderApplication.GetYesterDayPayOrdersNum(shopId);
model.YesterDaySaleAmount = OrderApplication.GetYesterDaySaleAmount(shopId);
model.ShopAccout = shopaccount;
return model;
}
/// <summary>
/// 获取平台财务总览
/// </summary>
/// <param name="shopId"></param>
/// <returns></returns>
public static PlatBillingIndex GetPlatBillingIndex()
{
var platAccount = GetPlatAccount();
PlatBillingIndex model = new PlatBillingIndex();
model.YesterDayOrders = OrderApplication.GetYesterDayOrdersNum();
model.YesterDayPayOrders = OrderApplication.GetYesterDayPayOrdersNum();
model.YesterDaySaleAmount = OrderApplication.GetYesterDaySaleAmount();
model.PlatAccout = platAccount;
return model;
}
/// <summary>
/// 根据日期获取当前结算周期
/// </summary>
/// <returns></returns>
public static SettlementCycle GetCurrentBilingTime()
{
var settlementCycle = SiteSettingApplication.GetSiteSettings().WeekSettlement;
var end = _iBillingService.GetLastSettlementTime();
return GetDateBilingTime(settlementCycle, end, DateTime.Now);
}
/// <summary>
/// 根据日期获取该日期的结算周期
/// </summary>
/// <returns></returns>
public static SettlementCycle GetDateBilingTime(int settlementCycle, DateTime? endDate, DateTime dt)
{
SettlementCycle model = new SettlementCycle();
var end = endDate;
if (!end.HasValue)
{
model.StartTime = DateTime.Now.Date;
model.EndTime = model.StartTime.AddDays(settlementCycle);
}
else
{
var now = dt.Date;
var days = (now - end.Value.Date).Days; //和最后结算时间相差的天数
var d = days % settlementCycle;
var newend = now.AddDays(settlementCycle - d);
var newStart = newend.AddDays(-settlementCycle);
model.StartTime = newStart;
model.EndTime = newend;
}
return model;
}