Commit ed836f3257e4a0b9b3a5bf401ba3102d2054039d

Authored by 李宇
2 parents 04f9fdae 89aadf42

Merge branch 'master' of http://39.98.150.180/antissoft/lvqianmeiye_ERP

netcore/src/Modularity/Extend/NCC.Extend/LqDailyReportService.cs
... ... @@ -410,43 +410,48 @@ namespace NCC.Extend
410 410 }
411 411  
412 412 // 第二步:统计各事业部的开单业绩
  413 + // 重要:门店归属事业部应该从门店目标表(lq_md_target)中获取,不同月份的归属可能不一样
  414 + // 通过 lq_md_target 表关联门店和事业部,确保使用指定月份的事业部归属关系
413 415 var businessUnitIds = businessUnitDict.Keys.ToList();
414 416 var unitIdsStr = string.Join("','", businessUnitIds);
415 417  
416 418 var billingPerformanceSql = $@"
417 419 SELECT
418   - store.syb as BusinessUnitId,
  420 + target.F_BusinessUnit as BusinessUnitId,
419 421 COALESCE(SUM(billing.sfyj), 0) as BillingPerformance
420 422 FROM lq_kd_kdjlb billing
421   - INNER JOIN lq_mdxx store ON billing.djmd = store.F_Id
422   - INNER JOIN base_organize o ON store.syb = o.F_Id
  423 + INNER JOIN lq_md_target target ON billing.djmd = target.F_StoreId AND target.F_Month = '{month}'
  424 + INNER JOIN base_organize o ON target.F_BusinessUnit = o.F_Id
423 425 WHERE billing.F_IsEffective = 1
  426 + AND target.F_BusinessUnit IS NOT NULL
424 427 AND o.F_Category = 'department'
425 428 AND (o.F_DeleteMark IS NULL OR o.F_DeleteMark != 1)
426 429 AND o.F_FullName IN ('事业一部', '事业二部', '事业三部', '事业四部', '事业五部', '事业六部')
427 430 AND DATE(billing.kdrq) >= '{startDate:yyyy-MM-dd}'
428 431 AND DATE(billing.kdrq) <= '{endDate:yyyy-MM-dd}'
429   - AND store.syb IN ('{unitIdsStr}')
430   - GROUP BY store.syb";
  432 + AND target.F_BusinessUnit IN ('{unitIdsStr}')
  433 + GROUP BY target.F_BusinessUnit";
431 434  
432 435 var billingPerformanceData = await _db.Ado.SqlQueryAsync<dynamic>(billingPerformanceSql);
433 436  
434 437 // 第三步:统计各事业部的退卡金额(使用实退金额,如果没有则使用退卡总金额)
  438 + // 重要:门店归属事业部应该从门店目标表(lq_md_target)中获取,不同月份的归属可能不一样
435 439 var refundPerformanceSql = $@"
436 440 SELECT
437   - store.syb as BusinessUnitId,
  441 + target.F_BusinessUnit as BusinessUnitId,
438 442 COALESCE(SUM(COALESCE(refund.F_ActualRefundAmount, refund.tkje, 0)), 0) as RefundPerformance
439 443 FROM lq_hytk_hytk refund
440   - INNER JOIN lq_mdxx store ON refund.md = store.F_Id
441   - INNER JOIN base_organize o ON store.syb = o.F_Id
  444 + INNER JOIN lq_md_target target ON refund.md = target.F_StoreId AND target.F_Month = '{month}'
  445 + INNER JOIN base_organize o ON target.F_BusinessUnit = o.F_Id
442 446 WHERE refund.F_IsEffective = 1
  447 + AND target.F_BusinessUnit IS NOT NULL
443 448 AND o.F_Category = 'department'
444 449 AND (o.F_DeleteMark IS NULL OR o.F_DeleteMark != 1)
445 450 AND o.F_FullName IN ('事业一部', '事业二部', '事业三部', '事业四部', '事业五部', '事业六部')
446 451 AND DATE(refund.tksj) >= '{startDate:yyyy-MM-dd}'
447 452 AND DATE(refund.tksj) <= '{endDate:yyyy-MM-dd}'
448   - AND store.syb IN ('{unitIdsStr}')
449   - GROUP BY store.syb";
  453 + AND target.F_BusinessUnit IN ('{unitIdsStr}')
  454 + GROUP BY target.F_BusinessUnit";
450 455  
451 456 var refundPerformanceData = await _db.Ado.SqlQueryAsync<dynamic>(refundPerformanceSql);
452 457  
... ...
netcore/src/Modularity/Extend/NCC.Extend/LqStoreDashboardService.cs
... ... @@ -123,12 +123,33 @@ namespace NCC.Extend
123 123 var billingCount = await billingQuery.CountAsync();
124 124  
125 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 154 // 4. 获取退卡金额和退卡次数(使用实退金额)
134 155 var refundQuery = _db.Queryable<LqHytkHytkEntity>()
... ... @@ -172,8 +193,8 @@ namespace NCC.Extend
172 193 AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}'
173 194 AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'";
174 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 198 : 0;
178 199  
179 200 // 12. 获取项目数(消耗的项目总数,从品项明细表统计原始项目数)
... ... @@ -187,8 +208,8 @@ namespace NCC.Extend
187 208 AND xh.Hksj >= '{startDate:yyyy-MM-dd HH:mm:ss}'
188 209 AND xh.Hksj <= '{endDateTime:yyyy-MM-dd HH:mm:ss}'";
189 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 213 : 0m;
193 214  
194 215 // 13. 计算客单价(消耗业绩/消耗人次)
... ... @@ -245,7 +266,7 @@ namespace NCC.Extend
245 266 };
246 267  
247 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 271 return result;
251 272 }
... ... @@ -547,7 +568,7 @@ namespace NCC.Extend
547 568  
548 569 // 按客单价和项目数分组,计算每个区间的会员数
549 570 var result = new List<CustomerPriceProjectRelationOutput>();
550   -
  571 +
551 572 if (memberData != null && memberData.Any())
552 573 {
553 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 35 /// 备注
36 36 /// </summary>
37 37 public string description { get; set; }
  38 +
  39 + /// <summary>
  40 + /// 功能地址
  41 + /// </summary>
  42 + public string urlAddress { get; set; }
38 43 }
39 44 }
... ...