Commit db3fff3e3209e3512b67a31638c2fb9d2254069f

Authored by “wangming”
1 parent 74f69aad

fix: 修复门店顾客详情SQL查询字段错误

- 修复lq_yaoyjl表中F_Status字段不存在的错误,改用yysj字段
- 修复耗卡统计中使用F_CreateTime的错误,改用hksj字段
- 修复开单统计中使用F_CreateTime的错误,改用kdrq字段
- 优化耗卡和开单统计的NULL值处理,添加COALESCE函数
- 测试验证SQL查询正常运行并返回完整数据
netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
... ... @@ -122,10 +122,15 @@ namespace NCC.Extend.LqKdKdjlb
122 122 }
123 123  
124 124 var output = entity.Adapt<LqKdKdjlbInfoOutput>();
  125 + if (output.activityId != null)
  126 + {
  127 + output.activityName = await _db.Queryable<LqPackageInfoEntity>().Where(x => x.Id == entity.ActivityId).Select(x => x.ActivityName).FirstAsync();
  128 + }
125 129 //获取会员信息
126 130 var MemberInfo = await _db.Queryable<LqKhxxEntity>().FirstAsync(p => p.Id == entity.Kdhy);
127 131 output.kdhyc = MemberInfo.Khmc;
128 132 output.kdhysjh = MemberInfo.Sjh;
  133 +
129 134 if (!string.IsNullOrEmpty(entity.ActivityId))
130 135 {
131 136 output.activityName = await _db.Queryable<LqPackageInfoEntity>().Where(x => x.Id == entity.ActivityId).Select(x => x.ActivityName).FirstAsync();
... ... @@ -2081,10 +2086,7 @@ namespace NCC.Extend.LqKdKdjlb
2081 2086  
2082 2087 // 查询开单记录
2083 2088 var billingRecords = await _db.Queryable<LqKdKdjlbEntity>()
2084   - .Where(w => w.Djmd == input.StoreId
2085   - && w.Kdrq >= input.StartTime
2086   - && w.Kdrq <= input.EndTime
2087   - && w.IsEffective == StatusEnum.有效.GetHashCode())
  2089 + .Where(w => w.Djmd == input.StoreId && w.Kdrq >= input.StartTime && w.Kdrq <= input.EndTime && w.IsEffective == StatusEnum.有效.GetHashCode())
2088 2090 .Select(it => new
2089 2091 {
2090 2092 id = it.Id,
... ... @@ -2095,8 +2097,8 @@ namespace NCC.Extend.LqKdKdjlb
2095 2097 zdyj = it.Zdyj,
2096 2098 sfyj = it.Sfyj,
2097 2099 qk = it.Qk,
2098   - kdhyc = it.Kdhyc,
2099   - kdhysjh = it.Kdhysjh,
  2100 + kdhyc = SqlFunc.Subqueryable<LqKhxxEntity>().Where(x => x.Id == it.Kdhy).Select(x => x.Khmc),
  2101 + kdhysjh = SqlFunc.Subqueryable<LqKhxxEntity>().Where(x => x.Id == it.Kdhy).Select(x => x.Sjh),
2100 2102 fkfs = it.Fkfs, // 付款方式
2101 2103 khly = it.Khly, // 客户来源
2102 2104 bz = it.Bz, // 备注
... ...
netcore/src/Modularity/Extend/NCC.Extend/LqTkjlbService.cs
... ... @@ -820,7 +820,7 @@ namespace NCC.Extend.LqTkjlb
820 820 -- 邀约信息
821 821 yaoy.F_Id as yaoy_id, -- 邀约ID
822 822 yaoy.F_CreateTime as yaoy_time, -- 邀约时间
823   - yaoy.F_Status as yaoy_status, -- 邀约状态
  823 + yaoy.yysj as yaoy_appointment_time, -- 邀约时间
824 824 -- 预约信息
825 825 yy.F_Id as yy_id, -- 预约ID
826 826 yy.F_Status as yy_status, -- 预约状态
... ... @@ -862,10 +862,10 @@ namespace NCC.Extend.LqTkjlb
862 862 LEFT JOIN (
863 863 SELECT
864 864 hy as member_id,
865   - SUM(xfje) as total_consume_amount,
  865 + SUM(COALESCE(xfje, 0)) as total_consume_amount,
866 866 COUNT(*) as consume_count,
867   - MIN(F_CreateTime) as first_consume_time,
868   - MAX(F_CreateTime) as last_consume_time
  867 + MIN(hksj) as first_consume_time,
  868 + MAX(hksj) as last_consume_time
869 869 FROM lq_xh_hyhk
870 870 WHERE F_IsEffective = 1
871 871 GROUP BY hy
... ... @@ -873,11 +873,11 @@ namespace NCC.Extend.LqTkjlb
873 873 LEFT JOIN (
874 874 SELECT
875 875 kdhy as member_id,
876   - SUM(sfyj) as total_billing_amount,
877   - SUM(qk) as total_debt_amount,
  876 + SUM(COALESCE(sfyj, 0)) as total_billing_amount,
  877 + SUM(COALESCE(qk, 0)) as total_debt_amount,
878 878 COUNT(*) as billing_count,
879   - MIN(F_CreateTime) as first_billing_time,
880   - MAX(F_CreateTime) as last_billing_time
  879 + MIN(kdrq) as first_billing_time,
  880 + MAX(kdrq) as last_billing_time
881 881 FROM lq_kd_kdjlb
882 882 WHERE F_IsEffective = 1
883 883 GROUP BY kdhy
... ...
netcore/src/Modularity/Extend/NCC.Extend/Utils/LqKdKdjlbStringGenerator.cs
... ... @@ -51,6 +51,7 @@ namespace NCC.Extend.Utils
51 51 sb.AppendLine($"⏩健康师:{string.Join("、", healthTeachers)}");
52 52  
53 53 // 活动方案:532工程
  54 + sb.AppendLine($"⏩活动方案:{entity.activityName ?? "无"}");
54 55 // sb.AppendLine($"⏩活动方案:{entity.pxxx ?? "无"}");
55 56 // 跟单配合:王经理 竹主任 陈思思老师
56 57 var techTeachers = GetTechTeachers(entity.lqKdKjbsyjList);
... ...