Himall商城BillingApplication获取店铺财务总览、根据日期获取该日期的结算周期

  ///


        /// 获取店铺财务总览
        ///

        ///
        ///
        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;
        }


        ///


        /// 获取平台财务总览
        ///

        ///
        ///
        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;
        }

        ///


        /// 根据日期获取当前结算周期
        ///

        ///
        public static SettlementCycle GetCurrentBilingTime()
        {
            var settlementCycle = SiteSettingApplication.GetSiteSettings().WeekSettlement;
            var end = _iBillingService.GetLastSettlementTime();
            return GetDateBilingTime(settlementCycle, end, DateTime.Now);
        }


        ///


        /// 根据日期获取该日期的结算周期
        ///

        ///
        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;
        }

你可能感兴趣的:(java,spring,servlet)