Commit 1f96867ec452904a46d535433d9012f382b5c995
1 parent
83e25a9e
feat: 新增消耗目标业绩和完成率统计
- 在GetBusinessStatistics方法中新增消耗目标业绩统计 - 目标业绩来自门店信息表的xhyj字段 - 计算消耗完成率(耗卡总金额 / 消耗目标业绩 * 100) - 支持门店ID过滤 - 更新输出DTO和相关接口文档
Showing
2 changed files
with
36 additions
and
1 deletions
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqReport/BusinessStatisticsOutput.cs
| ... | ... | @@ -34,5 +34,15 @@ namespace NCC.Extend.Entitys.Dto.LqReport |
| 34 | 34 | /// 退卡人数 |
| 35 | 35 | /// </summary> |
| 36 | 36 | public int RefundCount { get; set; } |
| 37 | + | |
| 38 | + /// <summary> | |
| 39 | + /// 消耗目标业绩(所有门店xhyj字段的总和) | |
| 40 | + /// </summary> | |
| 41 | + public decimal TargetConsumeAmount { get; set; } | |
| 42 | + | |
| 43 | + /// <summary> | |
| 44 | + /// 消耗完成率(耗卡总金额 / 消耗目标业绩 * 100) | |
| 45 | + /// </summary> | |
| 46 | + public decimal ConsumeCompletionRate { get; set; } | |
| 37 | 47 | } |
| 38 | 48 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
| ... | ... | @@ -721,6 +721,8 @@ namespace NCC.Extend |
| 721 | 721 | /// - BillingCount: 开单人数(按客户去重) |
| 722 | 722 | /// - ConsumeCount: 耗卡人数(按客户去重) |
| 723 | 723 | /// - RefundCount: 退卡人数(按客户去重) |
| 724 | + /// - TargetConsumeAmount: 消耗目标业绩(所有门店xhyj字段的总和) | |
| 725 | + /// - ConsumeCompletionRate: 消耗完成率(百分比) | |
| 724 | 726 | /// </remarks> |
| 725 | 727 | /// <param name="input">查询参数</param> |
| 726 | 728 | /// <returns>业务统计数据</returns> |
| ... | ... | @@ -811,6 +813,27 @@ namespace NCC.Extend |
| 811 | 813 | var refundCount = Convert.ToInt32(refundResult?.FirstOrDefault()?.refund_count ?? 0); |
| 812 | 814 | var refundAmount = Convert.ToDecimal(refundResult?.FirstOrDefault()?.refund_amount ?? 0m); |
| 813 | 815 | |
| 816 | + // 第四步:获取消耗目标业绩(所有门店xhyj字段的总和) | |
| 817 | + var targetSql = "SELECT COALESCE(SUM(CAST(md.xhyj AS DECIMAL(18,2))), 0) as target_consume_amount FROM lq_mdxx md WHERE 1=1"; | |
| 818 | + object targetParameters = null; | |
| 819 | + | |
| 820 | + if (input.StoreIds != null && input.StoreIds.Any()) | |
| 821 | + { | |
| 822 | + targetSql += " AND md.F_Id IN @storeIds"; | |
| 823 | + targetParameters = new { storeIds = input.StoreIds }; | |
| 824 | + } | |
| 825 | + | |
| 826 | + var targetResult = await _db.Ado.SqlQueryAsync<dynamic>(targetSql, targetParameters); | |
| 827 | + var targetConsumeAmount = Convert.ToDecimal(targetResult?.FirstOrDefault()?.target_consume_amount ?? 0m); | |
| 828 | + | |
| 829 | + // 计算消耗完成率 | |
| 830 | + var consumeCompletionRate = 0m; | |
| 831 | + if (targetConsumeAmount > 0) | |
| 832 | + { | |
| 833 | + consumeCompletionRate = (consumeAmount / targetConsumeAmount) * 100m; | |
| 834 | + consumeCompletionRate = decimal.Round(consumeCompletionRate, 2); | |
| 835 | + } | |
| 836 | + | |
| 814 | 837 | var result = new BusinessStatisticsOutput |
| 815 | 838 | { |
| 816 | 839 | TotalBillingAmount = billingAmount, |
| ... | ... | @@ -818,7 +841,9 @@ namespace NCC.Extend |
| 818 | 841 | TotalRefundAmount = refundAmount, |
| 819 | 842 | BillingCount = billingCount, |
| 820 | 843 | ConsumeCount = consumeCount, |
| 821 | - RefundCount = refundCount | |
| 844 | + RefundCount = refundCount, | |
| 845 | + TargetConsumeAmount = targetConsumeAmount, | |
| 846 | + ConsumeCompletionRate = consumeCompletionRate | |
| 822 | 847 | }; |
| 823 | 848 | |
| 824 | 849 | return result; | ... | ... |