Commit 50da2ecedcd1b2e7f95cf715cdbf045c318defc7
1 parent
225c2318
Enhance LqStoreDashboardService to calculate consume performance using SQL query…
… for accurate metrics. Added urlAddress property to UsersCurrentAuthorizeModel for improved permission management.
Showing
2 changed files
with
38 additions
and
12 deletions
netcore/src/Modularity/Extend/NCC.Extend/LqStoreDashboardService.cs
| @@ -123,12 +123,33 @@ namespace NCC.Extend | @@ -123,12 +123,33 @@ namespace NCC.Extend | ||
| 123 | var billingCount = await billingQuery.CountAsync(); | 123 | var billingCount = await billingQuery.CountAsync(); |
| 124 | 124 | ||
| 125 | // 3. 获取消耗业绩和消耗次数 | 125 | // 3. 获取消耗业绩和消耗次数 |
| 126 | - var consumeQuery = _db.Queryable<LqXhHyhkEntity>() | ||
| 127 | - .Where(x => x.Md == input.StoreId && x.IsEffective == 1) | ||
| 128 | - .Where(x => x.Hksj.HasValue && x.Hksj.Value >= startDate && x.Hksj.Value <= endDateTime); | ||
| 129 | - | ||
| 130 | - var consumeAmount = await consumeQuery.SumAsync(x => (decimal?)x.Xfje) ?? 0m; | ||
| 131 | - var consumeCount = await consumeQuery.CountAsync(); | 126 | + // 消耗业绩只统计健康师的消耗业绩(从健康师消耗业绩表汇总),与健康师统计接口的计算方式完全一致 |
| 127 | + // 不包含科技部老师的消耗业绩 | ||
| 128 | + // 重要:必须同时满足两个条件: | ||
| 129 | + // 1. 耗卡记录属于该门店(hyhk.md = 门店ID) | ||
| 130 | + // 2. 健康师属于该门店(u.F_MDID = 门店ID) | ||
| 131 | + // 这样才能与健康师统计接口的计算逻辑完全一致 | ||
| 132 | + var consumePerformanceSql = $@" | ||
| 133 | + SELECT | ||
| 134 | + COALESCE(SUM(jksyj.jksyj), 0) as ConsumeAmount, | ||
| 135 | + COUNT(DISTINCT hyhk.F_Id) as ConsumeCount | ||
| 136 | + FROM lq_xh_jksyj jksyj | ||
| 137 | + INNER JOIN lq_xh_hyhk hyhk ON jksyj.glkdbh = hyhk.F_Id | ||
| 138 | + INNER JOIN BASE_USER u ON jksyj.jks = u.F_Id | ||
| 139 | + WHERE jksyj.jks IS NOT NULL | ||
| 140 | + AND jksyj.F_IsEffective = 1 | ||
| 141 | + AND hyhk.F_IsEffective = 1 | ||
| 142 | + AND hyhk.md = '{input.StoreId}' | ||
| 143 | + AND u.F_MDID = '{input.StoreId}' | ||
| 144 | + AND hyhk.hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}' | ||
| 145 | + AND hyhk.hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'"; | ||
| 146 | + var consumePerformanceResult = await _db.Ado.SqlQuerySingleAsync<dynamic>(consumePerformanceSql); | ||
| 147 | + var consumeAmount = consumePerformanceResult != null | ||
| 148 | + ? Convert.ToDecimal(consumePerformanceResult.ConsumeAmount ?? 0) | ||
| 149 | + : 0m; | ||
| 150 | + var consumeCount = consumePerformanceResult != null | ||
| 151 | + ? Convert.ToInt32(consumePerformanceResult.ConsumeCount ?? 0) | ||
| 152 | + : 0; | ||
| 132 | 153 | ||
| 133 | // 4. 获取退卡金额和退卡次数(使用实退金额) | 154 | // 4. 获取退卡金额和退卡次数(使用实退金额) |
| 134 | var refundQuery = _db.Queryable<LqHytkHytkEntity>() | 155 | var refundQuery = _db.Queryable<LqHytkHytkEntity>() |
| @@ -172,8 +193,8 @@ namespace NCC.Extend | @@ -172,8 +193,8 @@ namespace NCC.Extend | ||
| 172 | AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}' | 193 | AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}' |
| 173 | AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'"; | 194 | AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'"; |
| 174 | var personCountResult = await _db.Ado.SqlQueryAsync<dynamic>(personCountSql); | 195 | var personCountResult = await _db.Ado.SqlQueryAsync<dynamic>(personCountSql); |
| 175 | - var personCount = personCountResult?.FirstOrDefault() != null | ||
| 176 | - ? Convert.ToInt32(personCountResult.FirstOrDefault().PersonCount ?? 0) | 196 | + var personCount = personCountResult?.FirstOrDefault() != null |
| 197 | + ? Convert.ToInt32(personCountResult.FirstOrDefault().PersonCount ?? 0) | ||
| 177 | : 0; | 198 | : 0; |
| 178 | 199 | ||
| 179 | // 12. 获取项目数(消耗的项目总数,从品项明细表统计原始项目数) | 200 | // 12. 获取项目数(消耗的项目总数,从品项明细表统计原始项目数) |
| @@ -187,8 +208,8 @@ namespace NCC.Extend | @@ -187,8 +208,8 @@ namespace NCC.Extend | ||
| 187 | AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}' | 208 | AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}' |
| 188 | AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'"; | 209 | AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'"; |
| 189 | var projectCountResult = await _db.Ado.SqlQueryAsync<dynamic>(projectCountSql); | 210 | var projectCountResult = await _db.Ado.SqlQueryAsync<dynamic>(projectCountSql); |
| 190 | - var projectCount = projectCountResult?.FirstOrDefault() != null | ||
| 191 | - ? Convert.ToDecimal(projectCountResult.FirstOrDefault().ProjectCount ?? 0) | 211 | + var projectCount = projectCountResult?.FirstOrDefault() != null |
| 212 | + ? Convert.ToDecimal(projectCountResult.FirstOrDefault().ProjectCount ?? 0) | ||
| 192 | : 0m; | 213 | : 0m; |
| 193 | 214 | ||
| 194 | // 13. 计算客单价(消耗业绩/消耗人次) | 215 | // 13. 计算客单价(消耗业绩/消耗人次) |
| @@ -245,7 +266,7 @@ namespace NCC.Extend | @@ -245,7 +266,7 @@ namespace NCC.Extend | ||
| 245 | }; | 266 | }; |
| 246 | 267 | ||
| 247 | _logger.LogInformation("门店驾驶舱统计数据查询完成,门店ID:{StoreId},开单业绩:{BillingPerformance},消耗业绩:{ConsumePerformance},完成率:{CompletionRate}%,净业绩:{NetPerformance},开单次数:{BillingCount},消耗次数:{ConsumeCount},退卡次数:{RefundCount}", | 268 | _logger.LogInformation("门店驾驶舱统计数据查询完成,门店ID:{StoreId},开单业绩:{BillingPerformance},消耗业绩:{ConsumePerformance},完成率:{CompletionRate}%,净业绩:{NetPerformance},开单次数:{BillingCount},消耗次数:{ConsumeCount},退卡次数:{RefundCount}", |
| 248 | - input.StoreId, billingAmount, consumeAmount, completionRate, netPerformance, billingCount, consumeCount, refundCount); | 269 | + input.StoreId, (decimal)billingAmount, (decimal)consumeAmount, (decimal)completionRate, (decimal)netPerformance, (int)billingCount, (int)consumeCount, (int)refundCount); |
| 249 | 270 | ||
| 250 | return result; | 271 | return result; |
| 251 | } | 272 | } |
| @@ -547,7 +568,7 @@ namespace NCC.Extend | @@ -547,7 +568,7 @@ namespace NCC.Extend | ||
| 547 | 568 | ||
| 548 | // 按客单价和项目数分组,计算每个区间的会员数 | 569 | // 按客单价和项目数分组,计算每个区间的会员数 |
| 549 | var result = new List<CustomerPriceProjectRelationOutput>(); | 570 | var result = new List<CustomerPriceProjectRelationOutput>(); |
| 550 | - | 571 | + |
| 551 | if (memberData != null && memberData.Any()) | 572 | if (memberData != null && memberData.Any()) |
| 552 | { | 573 | { |
| 553 | var groupedData = memberData | 574 | var groupedData = memberData |
netcore/src/Modularity/System/NCC.System.Entitys/Model/Permission/UsersCurrent/UsersCurrentAuthorizeMoldel.cs
| @@ -35,5 +35,10 @@ namespace NCC.System.Entitys.Model.Permission.UsersCurrent | @@ -35,5 +35,10 @@ namespace NCC.System.Entitys.Model.Permission.UsersCurrent | ||
| 35 | /// 备注 | 35 | /// 备注 |
| 36 | /// </summary> | 36 | /// </summary> |
| 37 | public string description { get; set; } | 37 | public string description { get; set; } |
| 38 | + | ||
| 39 | + /// <summary> | ||
| 40 | + /// 功能地址 | ||
| 41 | + /// </summary> | ||
| 42 | + public string urlAddress { get; set; } | ||
| 38 | } | 43 | } |
| 39 | } | 44 | } |