/// <summary> /// 获取门店销售单排名信息 /// </summary> /// <param name="shopId"></param> /// <returns></returns> public async Task <ResponseBase> ProcessAction(long shopId) { var ranksAll = await _shopRetailRankBll.GetLastShopRetailRank((int)ShopRetailRankTypeEnum.Growth); if (!ranksAll.Any()) { return(new ResponsePagingBase().GetResponseError(StatusCode.ShopRetailRank60001, "未查询到排名信息")); } var ranksValid = ranksAll.Where(p => p.IsLimit == false).OrderBy(p => p.Rank).ToList(); var myrank = ranksAll.FirstOrDefault(p => p.ShopId == shopId); if (ranksValid.Count > _shopRetailRankConfig.ShowCount) { ranksValid = ranksValid.GetRange(0, _shopRetailRankConfig.ShowCount); } var responseView = GetResponseView(myrank, ranksAll, ranksValid); var limitShops = await _shopRetailRankLimitBll.GetShopRetailRankWinner(shopId); if (limitShops != null) { return(GetIsWinnerResponse(responseView)); } if (myrank == null) { return(GetBillCountZero(responseView)); } if (myrank.BillCount >= _shopRetailRankConfig.MinBillCountGrowth) { return(GetBillCountEnough(responseView)); } return(GetBillCountNotEnough(responseView)); }
/// <summary> /// 执行生成门店零售单排名 /// </summary> private void Process() { var winners = _shopRetailRankWinnerBll.GetShopRetailRankWinner().Result; var growthData = GetShopRetailRankedOfGrowth(winners, out var limitGrowthShops); var kingData = GetShopRetailRankedOfKing(winners, out var limitKingShops); var excelPath = SaveExcel(growthData, kingData); SendMailAboutRank(excelPath); _shopRetailRankBll.DelShopRetailRank(DateTime.Now.AddMonths(-1)).Wait(); _shopRetailRankBll.MarkShopRetailRankOld(); _shopRetailRankBll.AddShopRetailRank(growthData).Wait(); _shopRetailRankBll.AddShopRetailRank(kingData).Wait(); _shopRetailRankBll.AddShopRetailRank(limitGrowthShops).Wait(); _shopRetailRankBll.AddShopRetailRank(limitKingShops).Wait(); HandleWinner(growthData); }