Commit de92a5de06df298002bf91d23cb62df2acf947ad
Merge branch 'master' of http://39.98.150.180/antissoft/lvqianmeiye_ERP
Showing
26 changed files
with
838 additions
and
171 deletions
.vscode/settings.json
[已用]创建门店每日耗卡统计视图.sql
| ... | ... | @@ -23,7 +23,7 @@ SELECT |
| 23 | 23 | COUNT(DISTINCT hk.hy) AS member_count, -- 消费会员数 |
| 24 | 24 | hk.hksj AS create_time -- 创建时间 |
| 25 | 25 | FROM lq_xh_hyhk hk |
| 26 | -LEFT JOIN lq_xh_pxmx px ON hk.F_Id = px.glkdbh | |
| 26 | +LEFT JOIN lq_xh_pxmx px ON hk.F_Id = px.F_ConsumeInfoId | |
| 27 | 27 | WHERE hk.hksj IS NOT NULL |
| 28 | 28 | GROUP BY hk.md, hk.mdbh, hk.mdmc, DATE(hk.hksj), hk.hksj |
| 29 | 29 | ORDER BY hk.md, DATE(hk.hksj) DESC; | ... | ... |
netcore/src/Application/NCC.API.Tenant/NCC.API.Tenant/Properties/launchSettings.json
netcore/src/Application/NCC.API/Properties/launchSettings.json
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | "NCC.API": { |
| 19 | 19 | "commandName": "Project", |
| 20 | 20 | "dotnetRunMessages": "true", |
| 21 | - "launchBrowser": true, | |
| 21 | + "launchBrowser": false, | |
| 22 | 22 | "applicationUrl": "http://localhost:2011", //58504 |
| 23 | 23 | "environmentVariables": { |
| 24 | 24 | "ASPNETCORE_ENVIRONMENT": "Development" | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqEvent/PersonDataOutput.cs
0 → 100644
| 1 | +using System; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Dto.LqEvent | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 人员统计数据输出 | |
| 7 | + /// </summary> | |
| 8 | + public class PersonDataOutput | |
| 9 | + { | |
| 10 | + /// <summary> | |
| 11 | + /// 用户ID | |
| 12 | + /// </summary> | |
| 13 | + public string UserId { get; set; } | |
| 14 | + | |
| 15 | + /// <summary> | |
| 16 | + /// 用户姓名 | |
| 17 | + /// </summary> | |
| 18 | + public string UserName { get; set; } | |
| 19 | + | |
| 20 | + /// <summary> | |
| 21 | + /// 门店ID | |
| 22 | + /// </summary> | |
| 23 | + public string StoreId { get; set; } | |
| 24 | + | |
| 25 | + /// <summary> | |
| 26 | + /// 门店名称 | |
| 27 | + /// </summary> | |
| 28 | + public string StoreName { get; set; } | |
| 29 | + | |
| 30 | + /// <summary> | |
| 31 | + /// 战队名称 | |
| 32 | + /// </summary> | |
| 33 | + public string TeamName { get; set; } | |
| 34 | + | |
| 35 | + /// <summary> | |
| 36 | + /// 个人目标数 | |
| 37 | + /// </summary> | |
| 38 | + public int PersonalTarget { get; set; } | |
| 39 | + | |
| 40 | + /// <summary> | |
| 41 | + /// 完成目标数 | |
| 42 | + /// </summary> | |
| 43 | + public int CompletedTarget { get; set; } | |
| 44 | + | |
| 45 | + /// <summary> | |
| 46 | + /// 完成率(百分比) | |
| 47 | + /// </summary> | |
| 48 | + public decimal CompletionRate { get; set; } | |
| 49 | + | |
| 50 | + /// <summary> | |
| 51 | + /// 排名 | |
| 52 | + /// </summary> | |
| 53 | + public int Ranking { get; set; } | |
| 54 | + | |
| 55 | + /// <summary> | |
| 56 | + /// 最后拓客时间 | |
| 57 | + /// </summary> | |
| 58 | + public DateTime? LastExpansionTime { get; set; } | |
| 59 | + } | |
| 60 | +} | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqEvent/StoreDataOutput.cs
0 → 100644
| 1 | +using System; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Dto.LqEvent | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 门店统计数据输出 | |
| 7 | + /// </summary> | |
| 8 | + public class StoreDataOutput | |
| 9 | + { | |
| 10 | + /// <summary> | |
| 11 | + /// 门店ID | |
| 12 | + /// </summary> | |
| 13 | + public string StoreId { get; set; } | |
| 14 | + | |
| 15 | + /// <summary> | |
| 16 | + /// 门店名称 | |
| 17 | + /// </summary> | |
| 18 | + public string StoreName { get; set; } | |
| 19 | + | |
| 20 | + /// <summary> | |
| 21 | + /// 目前总目标数 | |
| 22 | + /// </summary> | |
| 23 | + public int TotalTarget { get; set; } | |
| 24 | + | |
| 25 | + /// <summary> | |
| 26 | + /// 门店完成目标数 | |
| 27 | + /// </summary> | |
| 28 | + public int CompletedTarget { get; set; } | |
| 29 | + | |
| 30 | + /// <summary> | |
| 31 | + /// 完成率(百分比) | |
| 32 | + /// </summary> | |
| 33 | + public decimal CompletionRate { get; set; } | |
| 34 | + | |
| 35 | + /// <summary> | |
| 36 | + /// 排名 | |
| 37 | + /// </summary> | |
| 38 | + public int Ranking { get; set; } | |
| 39 | + } | |
| 40 | +} | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/LqKdKdjlbCrInput.cs
| ... | ... | @@ -49,7 +49,6 @@ namespace NCC.Extend.Entitys.Dto.LqKdKdjlb |
| 49 | 49 | /// 实付业绩 |
| 50 | 50 | /// </summary> |
| 51 | 51 | public decimal sfyj { get; set; } |
| 52 | - | |
| 53 | 52 | /// <summary> |
| 54 | 53 | /// 欠款 |
| 55 | 54 | /// </summary> |
| ... | ... | @@ -60,10 +59,6 @@ namespace NCC.Extend.Entitys.Dto.LqKdKdjlb |
| 60 | 59 | /// </summary> |
| 61 | 60 | public string ckfs { get; set; } |
| 62 | 61 | |
| 63 | - /// <summary> | |
| 64 | - /// 储扣明细 | |
| 65 | - /// </summary> | |
| 66 | - public string ckmx { get; set; } | |
| 67 | 62 | |
| 68 | 63 | /// <summary> |
| 69 | 64 | /// 付款方式 | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/LqKdKdjlbListOutput.cs
| ... | ... | @@ -58,10 +58,10 @@ namespace NCC.Extend.Entitys.Dto.LqKdKdjlb |
| 58 | 58 | public string ckfs { get; set; } |
| 59 | 59 | |
| 60 | 60 | /// <summary> |
| 61 | - /// 储扣明细 | |
| 61 | + /// 储扣总金额 | |
| 62 | 62 | /// </summary> |
| 63 | - public string ckmx { get; set; } | |
| 64 | - | |
| 63 | + public decimal deductAmount { get; set; } | |
| 64 | + | |
| 65 | 65 | /// <summary> |
| 66 | 66 | /// 付款方式 |
| 67 | 67 | /// </summary> | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKdKdjlb/LqKdKdjlbListQueryInput.cs
| ... | ... | @@ -68,12 +68,7 @@ namespace NCC.Extend.Entitys.Dto.LqKdKdjlb |
| 68 | 68 | /// 储扣方式 |
| 69 | 69 | /// </summary> |
| 70 | 70 | public string ckfs { get; set; } |
| 71 | - | |
| 72 | - /// <summary> | |
| 73 | - /// 储扣明细 | |
| 74 | - /// </summary> | |
| 75 | - public string ckmx { get; set; } | |
| 76 | - | |
| 71 | + | |
| 77 | 72 | /// <summary> |
| 78 | 73 | /// 付款方式 |
| 79 | 74 | /// </summary> | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKhxx/LqKhxxCrInput.cs
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKhxx/LqKhxxInfoOutput.cs
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKhxx/LqKhxxListOutput.cs
| ... | ... | @@ -53,11 +53,6 @@ namespace NCC.Extend.Entitys.Dto.LqKhxx |
| 53 | 53 | public string zjdlsj { get; set; } |
| 54 | 54 | |
| 55 | 55 | /// <summary> |
| 56 | - /// 客户目前归属 | |
| 57 | - /// </summary> | |
| 58 | - public string khmqgs { get; set; } | |
| 59 | - | |
| 60 | - /// <summary> | |
| 61 | 56 | /// 归属门店 |
| 62 | 57 | /// </summary> |
| 63 | 58 | public string gsmd { get; set; } |
| ... | ... | @@ -135,6 +130,6 @@ namespace NCC.Extend.Entitys.Dto.LqKhxx |
| 135 | 130 | /// <summary> |
| 136 | 131 | /// 添加时间 |
| 137 | 132 | /// </summary> |
| 138 | - public string createTime { get; set; } | |
| 133 | + public DateTime createTime { get; set; } | |
| 139 | 134 | } |
| 140 | 135 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKhxx/LqKhxxListQueryInput.cs
| ... | ... | @@ -64,11 +64,6 @@ namespace NCC.Extend.Entitys.Dto.LqKhxx |
| 64 | 64 | public string zjdlsj { get; set; } |
| 65 | 65 | |
| 66 | 66 | /// <summary> |
| 67 | - /// 客户目前归属 | |
| 68 | - /// </summary> | |
| 69 | - public string khmqgs { get; set; } | |
| 70 | - | |
| 71 | - /// <summary> | |
| 72 | 67 | /// 归属门店 |
| 73 | 68 | /// </summary> |
| 74 | 69 | public string gsmd { get; set; } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqYcsdJsj/LqYcsdJsjByUserMonthOutput.cs
| ... | ... | @@ -8,51 +8,51 @@ namespace NCC.Extend.Entitys.Dto.LqYcsdJsj |
| 8 | 8 | /// <summary> |
| 9 | 9 | /// 金三角ID |
| 10 | 10 | /// </summary> |
| 11 | - public string JsjId { get; set; } | |
| 11 | + public string jsjId { get; set; } | |
| 12 | 12 | |
| 13 | 13 | /// <summary> |
| 14 | 14 | /// 金三角名称 |
| 15 | 15 | /// </summary> |
| 16 | - public string JsjName { get; set; } | |
| 16 | + public string jsjName { get; set; } | |
| 17 | 17 | |
| 18 | 18 | /// <summary> |
| 19 | 19 | /// 月份 |
| 20 | 20 | /// </summary> |
| 21 | - public string Month { get; set; } | |
| 21 | + public string month { get; set; } | |
| 22 | 22 | |
| 23 | 23 | /// <summary> |
| 24 | 24 | /// 门店ID |
| 25 | 25 | /// </summary> |
| 26 | - public string StoreId { get; set; } | |
| 26 | + public string storeId { get; set; } | |
| 27 | 27 | |
| 28 | 28 | /// <summary> |
| 29 | 29 | /// 门店名称 |
| 30 | 30 | /// </summary> |
| 31 | - public string StoreName { get; set; } | |
| 31 | + public string storeName { get; set; } | |
| 32 | 32 | |
| 33 | 33 | /// <summary> |
| 34 | 34 | /// 用户ID |
| 35 | 35 | /// </summary> |
| 36 | - public string UserId { get; set; } | |
| 36 | + public string userId { get; set; } | |
| 37 | 37 | |
| 38 | 38 | /// <summary> |
| 39 | 39 | /// 用户姓名 |
| 40 | 40 | /// </summary> |
| 41 | - public string UserName { get; set; } | |
| 41 | + public string userName { get; set; } | |
| 42 | 42 | |
| 43 | 43 | /// <summary> |
| 44 | 44 | /// 是否顾问 |
| 45 | 45 | /// </summary> |
| 46 | - public int IsLeader { get; set; } | |
| 46 | + public int isLeader { get; set; } | |
| 47 | 47 | |
| 48 | 48 | /// <summary> |
| 49 | 49 | /// 状态 |
| 50 | 50 | /// </summary> |
| 51 | - public string Status { get; set; } | |
| 51 | + public string status { get; set; } | |
| 52 | 52 | |
| 53 | 53 | /// <summary> |
| 54 | 54 | /// 排序 |
| 55 | 55 | /// </summary> |
| 56 | - public int SortOrder { get; set; } | |
| 56 | + public int sortOrder { get; set; } | |
| 57 | 57 | } |
| 58 | 58 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_kd_kdjlb/LqKdKdjlbEntity.cs
| ... | ... | @@ -52,6 +52,7 @@ namespace NCC.Extend.Entitys.lq_kd_kdjlb |
| 52 | 52 | /// </summary> |
| 53 | 53 | [SugarColumn(ColumnName = "zdyj")] |
| 54 | 54 | public decimal Zdyj { get; set; } |
| 55 | + | |
| 55 | 56 | |
| 56 | 57 | /// <summary> |
| 57 | 58 | /// 实付业绩 |
| ... | ... | @@ -60,6 +61,12 @@ namespace NCC.Extend.Entitys.lq_kd_kdjlb |
| 60 | 61 | public decimal Sfyj { get; set; } |
| 61 | 62 | |
| 62 | 63 | /// <summary> |
| 64 | + /// 储扣总金额 | |
| 65 | + /// </summary> | |
| 66 | + [SugarColumn(ColumnName = "F_DeductAmount")] | |
| 67 | + public decimal DeductAmount { get; set; } | |
| 68 | + | |
| 69 | + /// <summary> | |
| 63 | 70 | /// 欠款 |
| 64 | 71 | /// </summary> |
| 65 | 72 | [SugarColumn(ColumnName = "qk")] |
| ... | ... | @@ -72,12 +79,6 @@ namespace NCC.Extend.Entitys.lq_kd_kdjlb |
| 72 | 79 | public string Ckfs { get; set; } |
| 73 | 80 | |
| 74 | 81 | /// <summary> |
| 75 | - /// 储扣明细 | |
| 76 | - /// </summary> | |
| 77 | - [SugarColumn(ColumnName = "ckmx")] | |
| 78 | - public string Ckmx { get; set; } | |
| 79 | - | |
| 80 | - /// <summary> | |
| 81 | 82 | /// 付款方式 |
| 82 | 83 | /// </summary> |
| 83 | 84 | [SugarColumn(ColumnName = "fkfs")] | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_khxx/LqKhxxEntity.cs
| ... | ... | @@ -66,12 +66,6 @@ namespace NCC.Extend.Entitys.lq_khxx |
| 66 | 66 | public string Zjdlsj { get; set; } |
| 67 | 67 | |
| 68 | 68 | /// <summary> |
| 69 | - /// 客户目前归属 | |
| 70 | - /// </summary> | |
| 71 | - [SugarColumn(ColumnName = "khmqgs")] | |
| 72 | - public string Khmqgs { get; set; } | |
| 73 | - | |
| 74 | - /// <summary> | |
| 75 | 69 | /// 归属门店 |
| 76 | 70 | /// </summary> |
| 77 | 71 | [SugarColumn(ColumnName = "gsmd")] |
| ... | ... | @@ -165,6 +159,6 @@ namespace NCC.Extend.Entitys.lq_khxx |
| 165 | 159 | /// 添加时间 |
| 166 | 160 | /// </summary> |
| 167 | 161 | [SugarColumn(ColumnName = "F_CreateTime")] |
| 168 | - public string CreateTime { get; set; } | |
| 162 | + public DateTime CreateTime { get; set; } = DateTime.Now; | |
| 169 | 163 | } |
| 170 | 164 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_statistics_gold_triangle/LqStatisticsGoldTriangleEntity.cs
0 → 100644
| 1 | +using NCC.Common.Const; | |
| 2 | +using SqlSugar; | |
| 3 | +using System; | |
| 4 | + | |
| 5 | +namespace NCC.Extend.Entitys.lq_statistics_gold_triangle | |
| 6 | +{ | |
| 7 | + /// <summary> | |
| 8 | + /// 金三角开卡业绩统计数据表 | |
| 9 | + /// </summary> | |
| 10 | + [SugarTable("lq_statistics_gold_triangle")] | |
| 11 | + [Tenant(ClaimConst.TENANT_ID)] | |
| 12 | + public class LqStatisticsGoldTriangleEntity | |
| 13 | + { | |
| 14 | + /// <summary> | |
| 15 | + /// 主键ID | |
| 16 | + /// </summary> | |
| 17 | + [SugarColumn(ColumnName = "F_Id", IsPrimaryKey = true)] | |
| 18 | + public string Id { get; set; } | |
| 19 | + | |
| 20 | + /// <summary> | |
| 21 | + /// 金三角ID | |
| 22 | + /// </summary> | |
| 23 | + [SugarColumn(ColumnName = "F_GoldTriangleId")] | |
| 24 | + public string GoldTriangleId { get; set; } | |
| 25 | + | |
| 26 | + /// <summary> | |
| 27 | + /// 金三角名称 | |
| 28 | + /// </summary> | |
| 29 | + [SugarColumn(ColumnName = "F_GoldTriangleName")] | |
| 30 | + public string GoldTriangleName { get; set; } | |
| 31 | + | |
| 32 | + /// <summary> | |
| 33 | + /// 统计月份(YYYYMM) | |
| 34 | + /// </summary> | |
| 35 | + [SugarColumn(ColumnName = "F_StatisticsMonth")] | |
| 36 | + public string StatisticsMonth { get; set; } | |
| 37 | + | |
| 38 | + /// <summary> | |
| 39 | + /// 门店ID | |
| 40 | + /// </summary> | |
| 41 | + [SugarColumn(ColumnName = "F_StoreId")] | |
| 42 | + public string StoreId { get; set; } | |
| 43 | + | |
| 44 | + /// <summary> | |
| 45 | + /// 门店名称 | |
| 46 | + /// </summary> | |
| 47 | + [SugarColumn(ColumnName = "F_StoreName")] | |
| 48 | + public string StoreName { get; set; } | |
| 49 | + | |
| 50 | + /// <summary> | |
| 51 | + /// 订单数量 | |
| 52 | + /// </summary> | |
| 53 | + [SugarColumn(ColumnName = "F_OrderCount")] | |
| 54 | + public int OrderCount { get; set; } | |
| 55 | + | |
| 56 | + /// <summary> | |
| 57 | + /// 总业绩金额 | |
| 58 | + /// </summary> | |
| 59 | + [SugarColumn(ColumnName = "F_TotalPerformance")] | |
| 60 | + public decimal TotalPerformance { get; set; } | |
| 61 | + | |
| 62 | + /// <summary> | |
| 63 | + /// 最后订单日期 | |
| 64 | + /// </summary> | |
| 65 | + [SugarColumn(ColumnName = "F_LastOrderDate")] | |
| 66 | + public DateTime? LastOrderDate { get; set; } | |
| 67 | + | |
| 68 | + /// <summary> | |
| 69 | + /// 首次订单日期 | |
| 70 | + /// </summary> | |
| 71 | + [SugarColumn(ColumnName = "F_FirstOrderDate")] | |
| 72 | + public DateTime? FirstOrderDate { get; set; } | |
| 73 | + | |
| 74 | + /// <summary> | |
| 75 | + /// 创建时间 | |
| 76 | + /// </summary> | |
| 77 | + [SugarColumn(ColumnName = "F_CreateTime")] | |
| 78 | + public DateTime CreateTime { get; set; } = DateTime.Now; | |
| 79 | + } | |
| 80 | +} | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Enum/MemberTypeEnum.cs
0 → 100644
| 1 | +using System.ComponentModel; | |
| 2 | + | |
| 3 | +namespace NCC.Extend.Entitys.Enum | |
| 4 | +{ | |
| 5 | + /// <summary> | |
| 6 | + /// 会员类型 | |
| 7 | + /// </summary> | |
| 8 | + public enum MemberTypeEnum | |
| 9 | + { | |
| 10 | + /// <summary> | |
| 11 | + /// 线索 | |
| 12 | + /// </summary> | |
| 13 | + [Description("线索")] | |
| 14 | + 线索 = 0, | |
| 15 | + | |
| 16 | + /// <summary> | |
| 17 | + /// 潜客 | |
| 18 | + /// </summary> | |
| 19 | + [Description("潜客")] | |
| 20 | + 潜客 = 1, | |
| 21 | + | |
| 22 | + /// <summary> | |
| 23 | + /// 新客 | |
| 24 | + /// </summary> | |
| 25 | + [Description("新客")] | |
| 26 | + 新客 = 2, | |
| 27 | + | |
| 28 | + /// <summary> | |
| 29 | + /// 老客 | |
| 30 | + /// </summary> | |
| 31 | + [Description("老客")] | |
| 32 | + 老客 = 3, | |
| 33 | + | |
| 34 | + } | |
| 35 | +} | |
| 0 | 36 | \ No newline at end of file | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqEventService.cs
| ... | ... | @@ -694,6 +694,212 @@ namespace NCC.Extend.LqEvent |
| 694 | 694 | } |
| 695 | 695 | #endregion |
| 696 | 696 | |
| 697 | + #region 根据活动ID获取门店的统计数据 | |
| 698 | + /// <summary> | |
| 699 | + /// 根据活动ID获取门店的统计数据 | |
| 700 | + /// </summary> | |
| 701 | + /// <remarks> | |
| 702 | + /// 根据活动ID查询该活动下所有门店的统计数据 | |
| 703 | + /// 返回门店的目标完成情况、完成率和排名信息 | |
| 704 | + /// | |
| 705 | + /// 示例请求: | |
| 706 | + /// ```json | |
| 707 | + /// GET /api/Extend/LqEvent/store-data/{eventId} | |
| 708 | + /// ``` | |
| 709 | + /// | |
| 710 | + /// 参数说明: | |
| 711 | + /// - eventId: 活动ID,必填参数 | |
| 712 | + /// | |
| 713 | + /// 返回信息包括: | |
| 714 | + /// - 门店信息(门店ID、门店名称) | |
| 715 | + /// - 目标统计(总目标数、完成目标数、完成率) | |
| 716 | + /// - 排名信息(按完成率排序) | |
| 717 | + /// </remarks> | |
| 718 | + /// <param name="eventId">活动ID</param> | |
| 719 | + /// <returns>门店统计数据列表</returns> | |
| 720 | + /// <response code="200">成功返回门店统计数据</response> | |
| 721 | + /// <response code="400">参数错误,活动ID不能为空</response> | |
| 722 | + [HttpGet("store-data/{eventId}")] | |
| 723 | + public async Task<dynamic> GetStoreDataByEventId(string eventId) | |
| 724 | + { | |
| 725 | + if (string.IsNullOrEmpty(eventId)) | |
| 726 | + { | |
| 727 | + throw NCCException.Oh("活动ID不能为空"); | |
| 728 | + } | |
| 729 | + | |
| 730 | + try | |
| 731 | + { | |
| 732 | + // 使用多表查询获取门店统计数据 | |
| 733 | + var storeData = await _db.Queryable<LqEventUserEntity, LqMdxxEntity, LqTkjlbEntity>( | |
| 734 | + (eventUser, store, tkjlb) => eventUser.EventId == eventId && eventUser.StoreId == store.Id && eventUser.UserId == tkjlb.ExpansionUserId && tkjlb.EventId == eventId | |
| 735 | + ) | |
| 736 | + .GroupBy((eventUser, store, tkjlb) => new { StoreId = store.Id, StoreName = store.Dm }) | |
| 737 | + .Select( | |
| 738 | + (eventUser, store, tkjlb) => | |
| 739 | + new StoreDataOutput | |
| 740 | + { | |
| 741 | + StoreId = store.Id, | |
| 742 | + StoreName = store.Dm, | |
| 743 | + TotalTarget = SqlFunc.AggregateSum(eventUser.EventTarget), | |
| 744 | + CompletedTarget = SqlFunc.AggregateCount(tkjlb.Id), | |
| 745 | + CompletionRate = 0, // 将在内存中计算 | |
| 746 | + Ranking = 0, // 将在内存中计算 | |
| 747 | + } | |
| 748 | + ) | |
| 749 | + .ToListAsync(); | |
| 750 | + | |
| 751 | + // 计算完成率和排名 | |
| 752 | + foreach (var store in storeData) | |
| 753 | + { | |
| 754 | + if (store.TotalTarget > 0) | |
| 755 | + { | |
| 756 | + store.CompletionRate = Math.Round((decimal)store.CompletedTarget / store.TotalTarget * 100, 2); | |
| 757 | + } | |
| 758 | + } | |
| 759 | + | |
| 760 | + // 按完成率降序排序并设置排名 | |
| 761 | + var rankedStores = storeData.OrderByDescending(s => s.CompletionRate).ThenByDescending(s => s.CompletedTarget).ToList(); | |
| 762 | + | |
| 763 | + for (int i = 0; i < rankedStores.Count; i++) | |
| 764 | + { | |
| 765 | + rankedStores[i].Ranking = i + 1; | |
| 766 | + } | |
| 767 | + | |
| 768 | + return rankedStores; | |
| 769 | + } | |
| 770 | + catch (Exception ex) | |
| 771 | + { | |
| 772 | + throw NCCException.Oh($"查询活动 {eventId} 门店统计数据失败: {ex.Message}", ex); | |
| 773 | + } | |
| 774 | + } | |
| 775 | + #endregion | |
| 776 | + | |
| 777 | + #region 根据活动ID获取人员统计数据 | |
| 778 | + | |
| 779 | + /// <summary> | |
| 780 | + /// 根据活动ID获取人员统计数据 | |
| 781 | + /// </summary> | |
| 782 | + /// <remarks> | |
| 783 | + /// 根据活动ID查询该活动下所有参与人员的统计数据 | |
| 784 | + /// 返回人员的个人目标完成情况、完成率和排名信息 | |
| 785 | + /// | |
| 786 | + /// 示例请求: | |
| 787 | + /// ```json | |
| 788 | + /// GET /api/Extend/LqEvent/person-data/{eventId} | |
| 789 | + /// ``` | |
| 790 | + /// | |
| 791 | + /// 参数说明: | |
| 792 | + /// - eventId: 活动ID,必填参数 | |
| 793 | + /// | |
| 794 | + /// 返回信息包括: | |
| 795 | + /// - 人员信息(用户ID、用户姓名、门店信息、战队信息) | |
| 796 | + /// - 目标统计(个人目标数、完成目标数、完成率) | |
| 797 | + /// - 排名信息(按完成率排序) | |
| 798 | + /// - 最后拓客时间 | |
| 799 | + /// </remarks> | |
| 800 | + /// <param name="eventId">活动ID</param> | |
| 801 | + /// <returns>人员统计数据列表</returns> | |
| 802 | + /// <response code="200">成功返回人员统计数据</response> | |
| 803 | + /// <response code="400">参数错误,活动ID不能为空</response> | |
| 804 | + [HttpGet("person-data/{eventId}")] | |
| 805 | + public async Task<dynamic> GetPersonDataByEventId(string eventId) | |
| 806 | + { | |
| 807 | + if (string.IsNullOrEmpty(eventId)) | |
| 808 | + { | |
| 809 | + throw NCCException.Oh("活动ID不能为空"); | |
| 810 | + } | |
| 811 | + | |
| 812 | + try | |
| 813 | + { | |
| 814 | + // 第一步:获取所有参与活动的人员基本信息 | |
| 815 | + var eventUsers = await _db.Queryable<LqEventUserEntity, UserEntity, LqMdxxEntity>( | |
| 816 | + (eventUser, user, store) => eventUser.EventId == eventId && eventUser.UserId == user.Id && eventUser.StoreId == store.Id | |
| 817 | + ) | |
| 818 | + .Select( | |
| 819 | + (eventUser, user, store) => | |
| 820 | + new | |
| 821 | + { | |
| 822 | + UserId = user.Id, | |
| 823 | + UserName = user.RealName, | |
| 824 | + StoreId = store.Id, | |
| 825 | + StoreName = store.Dm, | |
| 826 | + TeamName = eventUser.TeamName, | |
| 827 | + PersonalTarget = eventUser.EventTarget, | |
| 828 | + } | |
| 829 | + ) | |
| 830 | + .ToListAsync(); | |
| 831 | + // 第二步:获取每个用户的拓客统计数据 | |
| 832 | + var userIds = eventUsers.Select(u => u.UserId).ToList(); | |
| 833 | + var expansionStats = new Dictionary<string, (int Count, DateTime? LastTime)>(); | |
| 834 | + if (userIds.Any()) | |
| 835 | + { | |
| 836 | + // 分批查询拓客数据,避免IN查询过大 | |
| 837 | + const int batchSize = 500; | |
| 838 | + for (int i = 0; i < userIds.Count; i += batchSize) | |
| 839 | + { | |
| 840 | + var batch = userIds.Skip(i).Take(batchSize).ToList(); | |
| 841 | + var stats = await _db.Queryable<LqTkjlbEntity>() | |
| 842 | + .Where(tkjlb => tkjlb.EventId == eventId && batch.Contains(tkjlb.ExpansionUserId)) | |
| 843 | + .GroupBy(tkjlb => tkjlb.ExpansionUserId) | |
| 844 | + .Select(tkjlb => new | |
| 845 | + { | |
| 846 | + UserId = tkjlb.ExpansionUserId, | |
| 847 | + Count = SqlFunc.AggregateCount(tkjlb.Id), | |
| 848 | + LastTime = SqlFunc.AggregateMax(tkjlb.CreateTime), | |
| 849 | + }) | |
| 850 | + .ToListAsync(); | |
| 851 | + | |
| 852 | + foreach (var stat in stats) | |
| 853 | + { | |
| 854 | + expansionStats[stat.UserId] = (stat.Count, stat.LastTime); | |
| 855 | + } | |
| 856 | + } | |
| 857 | + } | |
| 858 | + | |
| 859 | + // 第三步:合并数据 | |
| 860 | + var personData = eventUsers | |
| 861 | + .Select(eventUser => new PersonDataOutput | |
| 862 | + { | |
| 863 | + UserId = eventUser.UserId, | |
| 864 | + UserName = eventUser.UserName, | |
| 865 | + StoreId = eventUser.StoreId, | |
| 866 | + StoreName = eventUser.StoreName, | |
| 867 | + TeamName = eventUser.TeamName, | |
| 868 | + PersonalTarget = eventUser.PersonalTarget, | |
| 869 | + CompletedTarget = expansionStats.ContainsKey(eventUser.UserId) ? expansionStats[eventUser.UserId].Count : 0, | |
| 870 | + CompletionRate = 0, // 将在内存中计算 | |
| 871 | + Ranking = 0, // 将在内存中计算 | |
| 872 | + LastExpansionTime = expansionStats.ContainsKey(eventUser.UserId) ? expansionStats[eventUser.UserId].LastTime : null, | |
| 873 | + }) | |
| 874 | + .ToList(); | |
| 875 | + | |
| 876 | + // 计算完成率和排名 | |
| 877 | + foreach (var person in personData) | |
| 878 | + { | |
| 879 | + if (person.PersonalTarget > 0) | |
| 880 | + { | |
| 881 | + person.CompletionRate = Math.Round((decimal)person.CompletedTarget / person.PersonalTarget * 100, 2); | |
| 882 | + } | |
| 883 | + } | |
| 884 | + | |
| 885 | + // 按完成率降序排序并设置排名 | |
| 886 | + var rankedPersons = personData.OrderByDescending(p => p.CompletionRate).ThenByDescending(p => p.CompletedTarget).ToList(); | |
| 887 | + | |
| 888 | + for (int i = 0; i < rankedPersons.Count; i++) | |
| 889 | + { | |
| 890 | + rankedPersons[i].Ranking = i + 1; | |
| 891 | + } | |
| 892 | + | |
| 893 | + return rankedPersons; | |
| 894 | + } | |
| 895 | + catch (Exception ex) | |
| 896 | + { | |
| 897 | + throw NCCException.Oh($"查询活动 {eventId} 人员统计数据失败: {ex.Message}", ex); | |
| 898 | + } | |
| 899 | + } | |
| 900 | + | |
| 901 | + #endregion | |
| 902 | + | |
| 697 | 903 | #region Excel导入拓客活动用户 |
| 698 | 904 | |
| 699 | 905 | /// <summary> | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqGzService.cs
| ... | ... | @@ -26,6 +26,7 @@ using NCC.Extend.Entitys.lq_kd_pxmx; |
| 26 | 26 | using NCC.Extend.Entitys.lq_mdxx; |
| 27 | 27 | using NCC.Extend.Entitys.lq_xmzl; |
| 28 | 28 | using NCC.Extend.Entitys.lq_ycsd_jsj; |
| 29 | +using NCC.Extend.Entitys.lq_statistics_gold_triangle; | |
| 29 | 30 | using NCC.Extend.Interfaces.LqGz; |
| 30 | 31 | using NCC.FriendlyException; |
| 31 | 32 | using NCC.JsonSerialization; |
| ... | ... | @@ -57,6 +58,7 @@ namespace NCC.Extend.LqGz |
| 57 | 58 | _logger = logger; |
| 58 | 59 | } |
| 59 | 60 | |
| 61 | + #region 获取工资全字段 | |
| 60 | 62 | /// <summary> |
| 61 | 63 | /// 获取工资全字段 |
| 62 | 64 | /// </summary> |
| ... | ... | @@ -69,7 +71,9 @@ namespace NCC.Extend.LqGz |
| 69 | 71 | var output = entity.Adapt<LqGzInfoOutput>(); |
| 70 | 72 | return output; |
| 71 | 73 | } |
| 74 | + #endregion | |
| 72 | 75 | |
| 76 | + #region 获取工资全字段列表 | |
| 73 | 77 | /// <summary> |
| 74 | 78 | /// 获取工资全字段列表 |
| 75 | 79 | /// </summary> |
| ... | ... | @@ -286,7 +290,9 @@ namespace NCC.Extend.LqGz |
| 286 | 290 | .ToPagedListAsync(input.currentPage, input.pageSize); |
| 287 | 291 | return PageResult<LqGzListOutput>.SqlSugarPageResult(data); |
| 288 | 292 | } |
| 293 | + #endregion | |
| 289 | 294 | |
| 295 | + #region 新建工资全字段 | |
| 290 | 296 | /// <summary> |
| 291 | 297 | /// 新建工资全字段 |
| 292 | 298 | /// </summary> |
| ... | ... | @@ -302,7 +308,9 @@ namespace NCC.Extend.LqGz |
| 302 | 308 | if (!(isOk > 0)) |
| 303 | 309 | throw NCCException.Oh(ErrorCode.COM1000); |
| 304 | 310 | } |
| 311 | + #endregion | |
| 305 | 312 | |
| 313 | + #region 获取工资全字段无分页列表 | |
| 306 | 314 | /// <summary> |
| 307 | 315 | /// 获取工资全字段无分页列表 |
| 308 | 316 | /// </summary> |
| ... | ... | @@ -519,6 +527,9 @@ namespace NCC.Extend.LqGz |
| 519 | 527 | .ToListAsync(); |
| 520 | 528 | return data; |
| 521 | 529 | } |
| 530 | + #endregion | |
| 531 | + | |
| 532 | + #region 导出工资全字段 | |
| 522 | 533 | |
| 523 | 534 | /// <summary> |
| 524 | 535 | /// 导出工资全字段 |
| ... | ... | @@ -562,7 +573,9 @@ namespace NCC.Extend.LqGz |
| 562 | 573 | var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") }; |
| 563 | 574 | return output; |
| 564 | 575 | } |
| 576 | + #endregion | |
| 565 | 577 | |
| 578 | + #region 批量删除工资全字段 | |
| 566 | 579 | /// <summary> |
| 567 | 580 | /// 批量删除工资全字段 |
| 568 | 581 | /// </summary> |
| ... | ... | @@ -591,7 +604,9 @@ namespace NCC.Extend.LqGz |
| 591 | 604 | } |
| 592 | 605 | } |
| 593 | 606 | } |
| 607 | + #endregion | |
| 594 | 608 | |
| 609 | + #region 更新工资全字段 | |
| 595 | 610 | /// <summary> |
| 596 | 611 | /// 更新工资全字段 |
| 597 | 612 | /// </summary> |
| ... | ... | @@ -606,7 +621,9 @@ namespace NCC.Extend.LqGz |
| 606 | 621 | if (!(isOk > 0)) |
| 607 | 622 | throw NCCException.Oh(ErrorCode.COM1001); |
| 608 | 623 | } |
| 624 | + #endregion | |
| 609 | 625 | |
| 626 | + #region 删除工资全字段 | |
| 610 | 627 | /// <summary> |
| 611 | 628 | /// 删除工资全字段 |
| 612 | 629 | /// </summary> |
| ... | ... | @@ -620,6 +637,7 @@ namespace NCC.Extend.LqGz |
| 620 | 637 | if (!(isOk > 0)) |
| 621 | 638 | throw NCCException.Oh(ErrorCode.COM1002); |
| 622 | 639 | } |
| 640 | + #endregion | |
| 623 | 641 | |
| 624 | 642 | #region 业绩计算相关方法 |
| 625 | 643 | |
| ... | ... | @@ -896,5 +914,237 @@ namespace NCC.Extend.LqGz |
| 896 | 914 | } |
| 897 | 915 | |
| 898 | 916 | #endregion |
| 917 | + | |
| 918 | + #region 金三角统计数据保存 | |
| 919 | + | |
| 920 | + /// <summary> | |
| 921 | + /// 保存金三角开卡业绩统计数据 | |
| 922 | + /// </summary> | |
| 923 | + /// <remarks> | |
| 924 | + /// 根据金三角设定和开单记录统计金三角的业绩数据 | |
| 925 | + /// 使用直接SQL查询提高效率,完全按照原始SQL逻辑实现 | |
| 926 | + /// | |
| 927 | + /// 示例请求: | |
| 928 | + /// ```json | |
| 929 | + /// POST /api/Extend/LqGz/save-gold-triangle-statistics | |
| 930 | + /// { | |
| 931 | + /// "statisticsMonth": "202401" | |
| 932 | + /// } | |
| 933 | + /// ``` | |
| 934 | + /// </remarks> | |
| 935 | + /// <param name="statisticsMonth">统计月份(YYYYMM格式)</param> | |
| 936 | + /// <returns>保存结果</returns> | |
| 937 | + /// <response code="200">成功保存统计数据</response> | |
| 938 | + /// <response code="400">参数错误</response> | |
| 939 | + /// <response code="500">服务器内部错误</response> | |
| 940 | + [HttpPost("save-gold-triangle-statistics")] | |
| 941 | + public async Task<dynamic> SaveGoldTriangleStatistics(string statisticsMonth) | |
| 942 | + { | |
| 943 | + if (string.IsNullOrEmpty(statisticsMonth) || statisticsMonth.Length != 6) | |
| 944 | + { | |
| 945 | + throw NCCException.Oh("统计月份格式错误,请使用YYYYMM格式"); | |
| 946 | + } | |
| 947 | + | |
| 948 | + try | |
| 949 | + { | |
| 950 | + // 使用直接SQL查询,完全按照原始SQL逻辑 | |
| 951 | + var sql = @" | |
| 952 | + SELECT | |
| 953 | + jsj.F_Id AS JsjId, | |
| 954 | + jsj.jsj AS JsjName, | |
| 955 | + jsj.yf AS Month, | |
| 956 | + jsj.md AS StoreId, | |
| 957 | + md.dm AS StoreName, | |
| 958 | + COUNT(DISTINCT jksyj.glkdbh) AS OrderCount, | |
| 959 | + SUM(CAST(jksyj.jksyj AS DECIMAL(18,2))) AS TotalPerformance, | |
| 960 | + MAX(jksyj.yjsj) AS LastOrderDate, | |
| 961 | + MIN(jksyj.yjsj) AS FirstOrderDate | |
| 962 | + FROM lq_ycsd_jsj jsj | |
| 963 | + LEFT JOIN lq_kd_jksyj jksyj ON ( | |
| 964 | + jsj.F_Id = jksyj.jsj_id | |
| 965 | + AND YEAR(jksyj.yjsj) = SUBSTRING(jsj.yf, 1, 4) | |
| 966 | + AND MONTH(jksyj.yjsj) = SUBSTRING(jsj.yf, 5, 2) | |
| 967 | + ) | |
| 968 | + LEFT JOIN lq_mdxx md ON jsj.md = md.F_Id | |
| 969 | + WHERE jsj.yf = @statisticsMonth | |
| 970 | + AND jksyj.yjsj IS NOT NULL | |
| 971 | + AND jksyj.jksyj IS NOT NULL | |
| 972 | + AND jksyj.jksyj <> '' | |
| 973 | + AND jksyj.jksyj <> '0' | |
| 974 | + GROUP BY jsj.F_Id, jsj.jsj, jsj.yf, jsj.md, md.dm | |
| 975 | + ORDER BY jsj.yf DESC, TotalPerformance DESC"; | |
| 976 | + | |
| 977 | + var statisticsData = await _db.Ado.SqlQueryAsync<dynamic>(sql, new { statisticsMonth }); | |
| 978 | + | |
| 979 | + if (!statisticsData.Any()) | |
| 980 | + { | |
| 981 | + return new | |
| 982 | + { | |
| 983 | + Success = true, | |
| 984 | + Message = $"未找到 {statisticsMonth} 月份的金三角统计数据", | |
| 985 | + SavedCount = 0 | |
| 986 | + }; | |
| 987 | + } | |
| 988 | + | |
| 989 | + // 转换为实体对象并保存 | |
| 990 | + var entities = statisticsData.Select(data => new LqStatisticsGoldTriangleEntity | |
| 991 | + { | |
| 992 | + Id = YitIdHelper.NextId().ToString(), | |
| 993 | + GoldTriangleId = data.JsjId?.ToString(), | |
| 994 | + GoldTriangleName = data.JsjName?.ToString(), | |
| 995 | + StatisticsMonth = data.Month?.ToString(), | |
| 996 | + StoreId = data.StoreId?.ToString(), | |
| 997 | + StoreName = data.StoreName?.ToString(), | |
| 998 | + OrderCount = Convert.ToInt32(data.OrderCount), | |
| 999 | + TotalPerformance = Convert.ToDecimal(data.TotalPerformance), | |
| 1000 | + LastOrderDate = data.LastOrderDate as DateTime?, | |
| 1001 | + FirstOrderDate = data.FirstOrderDate as DateTime?, | |
| 1002 | + CreateTime = DateTime.Now | |
| 1003 | + }).ToList(); | |
| 1004 | + | |
| 1005 | + // 先删除该月份的历史数据 | |
| 1006 | + await _db.Deleteable<LqStatisticsGoldTriangleEntity>() | |
| 1007 | + .Where(x => x.StatisticsMonth == statisticsMonth) | |
| 1008 | + .ExecuteCommandAsync(); | |
| 1009 | + | |
| 1010 | + // 批量插入新数据 | |
| 1011 | + var savedCount = await _db.Insertable(entities).ExecuteCommandAsync(); | |
| 1012 | + | |
| 1013 | + _logger.LogInformation($"成功保存金三角统计数据 - 月份: {statisticsMonth}, 记录数: {savedCount}"); | |
| 1014 | + | |
| 1015 | + return new | |
| 1016 | + { | |
| 1017 | + Success = true, | |
| 1018 | + Message = $"成功保存 {savedCount} 条金三角统计数据", | |
| 1019 | + SavedCount = savedCount, | |
| 1020 | + StatisticsMonth = statisticsMonth | |
| 1021 | + }; | |
| 1022 | + } | |
| 1023 | + catch (Exception ex) | |
| 1024 | + { | |
| 1025 | + _logger.LogError(ex, $"保存金三角统计数据失败 - 月份: {statisticsMonth}"); | |
| 1026 | + throw NCCException.Oh($"保存金三角统计数据失败: {ex.Message}"); | |
| 1027 | + } | |
| 1028 | + } | |
| 1029 | + | |
| 1030 | + /// <summary> | |
| 1031 | + /// 测试金三角统计SQL查询 | |
| 1032 | + /// </summary> | |
| 1033 | + /// <remarks> | |
| 1034 | + /// 直接执行SQL查询,验证统计逻辑是否正确 | |
| 1035 | + /// | |
| 1036 | + /// 示例请求: | |
| 1037 | + /// ```json | |
| 1038 | + /// GET /api/Extend/LqGz/test-gold-triangle-sql?statisticsMonth=202401 | |
| 1039 | + /// ``` | |
| 1040 | + /// </remarks> | |
| 1041 | + /// <param name="statisticsMonth">统计月份(YYYYMM格式)</param> | |
| 1042 | + /// <returns>原始SQL查询结果</returns> | |
| 1043 | + /// <response code="200">成功返回查询结果</response> | |
| 1044 | + /// <response code="400">参数错误</response> | |
| 1045 | + [HttpGet("test-gold-triangle-sql")] | |
| 1046 | + public async Task<dynamic> TestGoldTriangleSql(string statisticsMonth) | |
| 1047 | + { | |
| 1048 | + if (string.IsNullOrEmpty(statisticsMonth) || statisticsMonth.Length != 6) | |
| 1049 | + { | |
| 1050 | + throw NCCException.Oh("统计月份格式错误,请使用YYYYMM格式"); | |
| 1051 | + } | |
| 1052 | + | |
| 1053 | + try | |
| 1054 | + { | |
| 1055 | + var sql = @" | |
| 1056 | + SELECT | |
| 1057 | + jsj.F_Id AS JsjId, | |
| 1058 | + jsj.jsj AS JsjName, | |
| 1059 | + jsj.yf AS Month, | |
| 1060 | + jsj.md AS StoreId, | |
| 1061 | + md.dm AS StoreName, | |
| 1062 | + COUNT(DISTINCT jksyj.glkdbh) AS OrderCount, | |
| 1063 | + SUM(CAST(jksyj.jksyj AS DECIMAL(18,2))) AS TotalPerformance, | |
| 1064 | + MAX(jksyj.yjsj) AS LastOrderDate, | |
| 1065 | + MIN(jksyj.yjsj) AS FirstOrderDate | |
| 1066 | + FROM lq_ycsd_jsj jsj | |
| 1067 | + LEFT JOIN lq_kd_jksyj jksyj ON ( | |
| 1068 | + jsj.F_Id = jksyj.jsj_id | |
| 1069 | + AND YEAR(jksyj.yjsj) = SUBSTRING(jsj.yf, 1, 4) | |
| 1070 | + AND MONTH(jksyj.yjsj) = SUBSTRING(jsj.yf, 5, 2) | |
| 1071 | + ) | |
| 1072 | + LEFT JOIN lq_mdxx md ON jsj.md = md.F_Id | |
| 1073 | + WHERE jsj.yf = @statisticsMonth | |
| 1074 | + AND jksyj.yjsj IS NOT NULL | |
| 1075 | + AND jksyj.jksyj IS NOT NULL | |
| 1076 | + AND jksyj.jksyj <> '' | |
| 1077 | + AND jksyj.jksyj <> '0' | |
| 1078 | + GROUP BY jsj.F_Id, jsj.jsj, jsj.yf, jsj.md, md.dm | |
| 1079 | + ORDER BY jsj.yf DESC, TotalPerformance DESC"; | |
| 1080 | + | |
| 1081 | + var result = await _db.Ado.SqlQueryAsync<dynamic>(sql, new { statisticsMonth }); | |
| 1082 | + | |
| 1083 | + return new | |
| 1084 | + { | |
| 1085 | + Success = true, | |
| 1086 | + Data = result, | |
| 1087 | + Count = result.Count, | |
| 1088 | + StatisticsMonth = statisticsMonth, | |
| 1089 | + Sql = sql | |
| 1090 | + }; | |
| 1091 | + } | |
| 1092 | + catch (Exception ex) | |
| 1093 | + { | |
| 1094 | + _logger.LogError(ex, $"测试金三角统计SQL失败 - 月份: {statisticsMonth}"); | |
| 1095 | + throw NCCException.Oh($"测试金三角统计SQL失败: {ex.Message}"); | |
| 1096 | + } | |
| 1097 | + } | |
| 1098 | + | |
| 1099 | + /// <summary> | |
| 1100 | + /// 获取金三角统计数据 | |
| 1101 | + /// </summary> | |
| 1102 | + /// <remarks> | |
| 1103 | + /// 查询指定月份的金三角统计数据 | |
| 1104 | + /// | |
| 1105 | + /// 示例请求: | |
| 1106 | + /// ```json | |
| 1107 | + /// GET /api/Extend/LqGz/get-gold-triangle-statistics?statisticsMonth=202401 | |
| 1108 | + /// ``` | |
| 1109 | + /// </remarks> | |
| 1110 | + /// <param name="statisticsMonth">统计月份(YYYYMM格式)</param> | |
| 1111 | + /// <returns>统计数据列表</returns> | |
| 1112 | + /// <response code="200">成功返回统计数据</response> | |
| 1113 | + /// <response code="400">参数错误</response> | |
| 1114 | + [HttpGet("get-gold-triangle-statistics")] | |
| 1115 | + public async Task<dynamic> GetGoldTriangleStatistics(string statisticsMonth) | |
| 1116 | + { | |
| 1117 | + if (string.IsNullOrEmpty(statisticsMonth)) | |
| 1118 | + { | |
| 1119 | + throw NCCException.Oh("统计月份不能为空"); | |
| 1120 | + } | |
| 1121 | + | |
| 1122 | + try | |
| 1123 | + { | |
| 1124 | + var statistics = await _db.Queryable<LqStatisticsGoldTriangleEntity>() | |
| 1125 | + .Where(x => x.StatisticsMonth == statisticsMonth) | |
| 1126 | + .OrderBy(x => x.TotalPerformance, OrderByType.Desc) | |
| 1127 | + .ToListAsync(); | |
| 1128 | + | |
| 1129 | + return new | |
| 1130 | + { | |
| 1131 | + Success = true, | |
| 1132 | + Data = statistics, | |
| 1133 | + Count = statistics.Count, | |
| 1134 | + StatisticsMonth = statisticsMonth | |
| 1135 | + }; | |
| 1136 | + } | |
| 1137 | + catch (Exception ex) | |
| 1138 | + { | |
| 1139 | + _logger.LogError(ex, $"查询金三角统计数据失败 - 月份: {statisticsMonth}"); | |
| 1140 | + throw NCCException.Oh($"查询金三角统计数据失败: {ex.Message}"); | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | + #endregion | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 899 | 1149 | } |
| 900 | 1150 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqHzfService.cs
| 1 | -using NCC.Common.Core.Manager; | |
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Threading.Tasks; | |
| 5 | +using Mapster; | |
| 6 | +using Microsoft.AspNetCore.Mvc; | |
| 7 | +using NCC.ClayObject; | |
| 8 | +using NCC.Common.Configuration; | |
| 9 | +using NCC.Common.Core.Manager; | |
| 2 | 10 | using NCC.Common.Enum; |
| 3 | 11 | using NCC.Common.Extension; |
| 4 | 12 | using NCC.Common.Filter; |
| 13 | +using NCC.Common.Helper; | |
| 14 | +using NCC.Common.Model.NPOI; | |
| 15 | +using NCC.DataEncryption; | |
| 5 | 16 | using NCC.Dependency; |
| 6 | 17 | using NCC.DynamicApiController; |
| 7 | -using NCC.FriendlyException; | |
| 18 | +using NCC.Extend.Entitys.Dto.LqHzf; | |
| 19 | +using NCC.Extend.Entitys.lq_hzf; | |
| 8 | 20 | using NCC.Extend.Interfaces.LqHzf; |
| 9 | -using Mapster; | |
| 10 | -using Microsoft.AspNetCore.Mvc; | |
| 21 | +using NCC.FriendlyException; | |
| 22 | +using NCC.JsonSerialization; | |
| 11 | 23 | using SqlSugar; |
| 12 | -using System; | |
| 13 | -using System.Collections.Generic; | |
| 14 | -using System.Linq; | |
| 15 | -using System.Threading.Tasks; | |
| 16 | -using NCC.Extend.Entitys.lq_hzf; | |
| 17 | -using NCC.Extend.Entitys.Dto.LqHzf; | |
| 18 | 24 | using Yitter.IdGenerator; |
| 19 | -using NCC.Common.Helper; | |
| 20 | -using NCC.JsonSerialization; | |
| 21 | -using NCC.Common.Model.NPOI; | |
| 22 | -using NCC.Common.Configuration; | |
| 23 | -using NCC.DataEncryption; | |
| 24 | -using NCC.ClayObject; | |
| 25 | 25 | |
| 26 | 26 | namespace NCC.Extend.LqHzf |
| 27 | 27 | { |
| 28 | 28 | /// <summary> |
| 29 | 29 | /// 合作方服务 |
| 30 | 30 | /// </summary> |
| 31 | - [ApiDescriptionSettings(Tag = "Extend",Name = "LqHzf", Order = 200)] | |
| 31 | + [ApiDescriptionSettings(Tag = "Extend", Name = "LqHzf", Order = 200)] | |
| 32 | 32 | [Route("api/Extend/[controller]")] |
| 33 | 33 | public class LqHzfService : ILqHzfService, IDynamicApiController, ITransient |
| 34 | 34 | { |
| ... | ... | @@ -39,11 +39,9 @@ namespace NCC.Extend.LqHzf |
| 39 | 39 | /// <summary> |
| 40 | 40 | /// 初始化一个<see cref="LqHzfService"/>类型的新实例 |
| 41 | 41 | /// </summary> |
| 42 | - public LqHzfService( | |
| 43 | - ISqlSugarRepository<LqHzfEntity> lqHzfRepository, | |
| 44 | - IUserManager userManager) | |
| 42 | + public LqHzfService(ISqlSugarRepository<LqHzfEntity> lqHzfRepository, IUserManager userManager) | |
| 45 | 43 | { |
| 46 | - _lqHzfRepository = lqHzfRepository; | |
| 44 | + _lqHzfRepository = lqHzfRepository; | |
| 47 | 45 | _db = _lqHzfRepository.Context; |
| 48 | 46 | _userManager = userManager; |
| 49 | 47 | } |
| ... | ... | @@ -62,10 +60,10 @@ namespace NCC.Extend.LqHzf |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | /// <summary> |
| 65 | - /// 获取合作方列表 | |
| 66 | - /// </summary> | |
| 67 | - /// <param name="input">请求参数</param> | |
| 68 | - /// <returns></returns> | |
| 63 | + /// 获取合作方列表 | |
| 64 | + /// </summary> | |
| 65 | + /// <param name="input">请求参数</param> | |
| 66 | + /// <returns></returns> | |
| 69 | 67 | [HttpGet("")] |
| 70 | 68 | public async Task<dynamic> GetList([FromQuery] LqHzfListQueryInput input) |
| 71 | 69 | { |
| ... | ... | @@ -75,14 +73,17 @@ namespace NCC.Extend.LqHzf |
| 75 | 73 | .WhereIF(!string.IsNullOrEmpty(input.hzmc), p => p.Hzmc.Contains(input.hzmc)) |
| 76 | 74 | .WhereIF(!string.IsNullOrEmpty(input.hzfczb), p => p.Hzfczb.Equals(input.hzfczb)) |
| 77 | 75 | .WhereIF(!string.IsNullOrEmpty(input.skf), p => p.Skf.Contains(input.skf)) |
| 78 | - .Select(it=> new LqHzfListOutput | |
| 76 | + .Select(it => new LqHzfListOutput | |
| 79 | 77 | { |
| 80 | 78 | id = it.Id, |
| 81 | - hzmc=it.Hzmc, | |
| 82 | - hzfczb=it.Hzfczb, | |
| 83 | - skf=it.Skf, | |
| 84 | - }).MergeTable().OrderBy(sidx+" "+input.sort).ToPagedListAsync(input.currentPage, input.pageSize); | |
| 85 | - return PageResult<LqHzfListOutput>.SqlSugarPageResult(data); | |
| 79 | + hzmc = it.Hzmc, | |
| 80 | + hzfczb = it.Hzfczb, | |
| 81 | + skf = it.Skf, | |
| 82 | + }) | |
| 83 | + .MergeTable() | |
| 84 | + .OrderBy(sidx + " " + input.sort) | |
| 85 | + .ToPagedListAsync(input.currentPage, input.pageSize); | |
| 86 | + return PageResult<LqHzfListOutput>.SqlSugarPageResult(data); | |
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | /// <summary> |
| ... | ... | @@ -97,14 +98,15 @@ namespace NCC.Extend.LqHzf |
| 97 | 98 | var entity = input.Adapt<LqHzfEntity>(); |
| 98 | 99 | entity.Id = YitIdHelper.NextId().ToString(); |
| 99 | 100 | var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); |
| 100 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000); | |
| 101 | + if (!(isOk > 0)) | |
| 102 | + throw NCCException.Oh(ErrorCode.COM1000); | |
| 101 | 103 | } |
| 102 | 104 | |
| 103 | 105 | /// <summary> |
| 104 | - /// 获取合作方无分页列表 | |
| 105 | - /// </summary> | |
| 106 | - /// <param name="input">请求参数</param> | |
| 107 | - /// <returns></returns> | |
| 106 | + /// 获取合作方无分页列表 | |
| 107 | + /// </summary> | |
| 108 | + /// <param name="input">请求参数</param> | |
| 109 | + /// <returns></returns> | |
| 108 | 110 | [NonAction] |
| 109 | 111 | public async Task<dynamic> GetNoPagingList([FromQuery] LqHzfListQueryInput input) |
| 110 | 112 | { |
| ... | ... | @@ -114,21 +116,24 @@ namespace NCC.Extend.LqHzf |
| 114 | 116 | .WhereIF(!string.IsNullOrEmpty(input.hzmc), p => p.Hzmc.Contains(input.hzmc)) |
| 115 | 117 | .WhereIF(!string.IsNullOrEmpty(input.hzfczb), p => p.Hzfczb.Equals(input.hzfczb)) |
| 116 | 118 | .WhereIF(!string.IsNullOrEmpty(input.skf), p => p.Skf.Contains(input.skf)) |
| 117 | - .Select(it=> new LqHzfListOutput | |
| 119 | + .Select(it => new LqHzfListOutput | |
| 118 | 120 | { |
| 119 | 121 | id = it.Id, |
| 120 | - hzmc=it.Hzmc, | |
| 121 | - hzfczb=it.Hzfczb, | |
| 122 | - skf=it.Skf, | |
| 123 | - }).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync(); | |
| 124 | - return data; | |
| 122 | + hzmc = it.Hzmc, | |
| 123 | + hzfczb = it.Hzfczb, | |
| 124 | + skf = it.Skf, | |
| 125 | + }) | |
| 126 | + .MergeTable() | |
| 127 | + .OrderBy(sidx + " " + input.sort) | |
| 128 | + .ToListAsync(); | |
| 129 | + return data; | |
| 125 | 130 | } |
| 126 | 131 | |
| 127 | 132 | /// <summary> |
| 128 | - /// 导出合作方 | |
| 129 | - /// </summary> | |
| 130 | - /// <param name="input">请求参数</param> | |
| 131 | - /// <returns></returns> | |
| 133 | + /// 导出合作方 | |
| 134 | + /// </summary> | |
| 135 | + /// <param name="input">请求参数</param> | |
| 136 | + /// <returns></returns> | |
| 132 | 137 | [HttpGet("Actions/Export")] |
| 133 | 138 | public async Task<dynamic> Export([FromQuery] LqHzfListQueryInput input) |
| 134 | 139 | { |
| ... | ... | @@ -143,7 +148,8 @@ namespace NCC.Extend.LqHzf |
| 143 | 148 | { |
| 144 | 149 | exportData = await this.GetNoPagingList(input); |
| 145 | 150 | } |
| 146 | - List<ParamsModel> paramList = "[{\"value\":\"合作编号\",\"field\":\"id\"},{\"value\":\"合作名称\",\"field\":\"hzmc\"},{\"value\":\"合作分成占比\",\"field\":\"hzfczb\"},{\"value\":\"收款方\",\"field\":\"skf\"},]".ToList<ParamsModel>(); | |
| 151 | + List<ParamsModel> paramList = | |
| 152 | + "[{\"value\":\"合作编号\",\"field\":\"id\"},{\"value\":\"合作名称\",\"field\":\"hzmc\"},{\"value\":\"合作分成占比\",\"field\":\"hzfczb\"},{\"value\":\"收款方\",\"field\":\"skf\"},]".ToList<ParamsModel>(); | |
| 147 | 153 | ExcelConfig excelconfig = new ExcelConfig(); |
| 148 | 154 | excelconfig.FileName = "合作方.xls"; |
| 149 | 155 | excelconfig.HeadFont = "微软雅黑"; |
| ... | ... | @@ -162,11 +168,7 @@ namespace NCC.Extend.LqHzf |
| 162 | 168 | var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName; |
| 163 | 169 | ExcelExportHelper<LqHzfListOutput>.Export(exportData, excelconfig, addPath); |
| 164 | 170 | var fileName = _userManager.UserId + "|" + addPath + "|xls"; |
| 165 | - var output = new | |
| 166 | - { | |
| 167 | - name = excelconfig.FileName, | |
| 168 | - url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") | |
| 169 | - }; | |
| 171 | + var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") }; | |
| 170 | 172 | return output; |
| 171 | 173 | } |
| 172 | 174 | |
| ... | ... | @@ -186,7 +188,7 @@ namespace NCC.Extend.LqHzf |
| 186 | 188 | //开启事务 |
| 187 | 189 | _db.BeginTran(); |
| 188 | 190 | //批量删除合作方 |
| 189 | - await _db.Deleteable<LqHzfEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 191 | + await _db.Deleteable<LqHzfEntity>().In(d => d.Id, ids).ExecuteCommandAsync(); | |
| 190 | 192 | //关闭事务 |
| 191 | 193 | _db.CommitTran(); |
| 192 | 194 | } |
| ... | ... | @@ -210,7 +212,8 @@ namespace NCC.Extend.LqHzf |
| 210 | 212 | { |
| 211 | 213 | var entity = input.Adapt<LqHzfEntity>(); |
| 212 | 214 | var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| 213 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001); | |
| 215 | + if (!(isOk > 0)) | |
| 216 | + throw NCCException.Oh(ErrorCode.COM1001); | |
| 214 | 217 | } |
| 215 | 218 | |
| 216 | 219 | /// <summary> |
| ... | ... | @@ -223,7 +226,8 @@ namespace NCC.Extend.LqHzf |
| 223 | 226 | var entity = await _db.Queryable<LqHzfEntity>().FirstAsync(p => p.Id == id); |
| 224 | 227 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 225 | 228 | var isOk = await _db.Deleteable<LqHzfEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); |
| 226 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | |
| 229 | + if (!(isOk > 0)) | |
| 230 | + throw NCCException.Oh(ErrorCode.COM1002); | |
| 227 | 231 | } |
| 228 | 232 | } |
| 229 | 233 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqKdKdjlbService.cs
| ... | ... | @@ -25,6 +25,7 @@ using NCC.Extend.Entitys.lq_kd_jksyj; |
| 25 | 25 | using NCC.Extend.Entitys.lq_kd_kdjlb; |
| 26 | 26 | using NCC.Extend.Entitys.lq_kd_kjbsyj; |
| 27 | 27 | using NCC.Extend.Entitys.lq_kd_pxmx; |
| 28 | +using NCC.Extend.Entitys.lq_khxx; | |
| 28 | 29 | using NCC.Extend.Entitys.lq_xmzl; |
| 29 | 30 | using NCC.Extend.Interfaces.LqKdKdjlb; |
| 30 | 31 | using NCC.Extend.Utils; |
| ... | ... | @@ -191,7 +192,6 @@ namespace NCC.Extend.LqKdKdjlb |
| 191 | 192 | .WhereIF(!string.IsNullOrEmpty(input.sfyj), p => p.Sfyj.Equals(input.sfyj)) |
| 192 | 193 | .WhereIF(!string.IsNullOrEmpty(input.qk), p => p.Qk.Equals(input.qk)) |
| 193 | 194 | .WhereIF(!string.IsNullOrEmpty(input.ckfs), p => p.Ckfs.Equals(input.ckfs)) |
| 194 | - .WhereIF(!string.IsNullOrEmpty(input.ckmx), p => p.Ckmx.Contains(input.ckmx)) | |
| 195 | 195 | .WhereIF(!string.IsNullOrEmpty(input.fkfs), p => p.Fkfs.Equals(input.fkfs)) |
| 196 | 196 | .WhereIF(!string.IsNullOrEmpty(input.fkyy), p => p.Fkyy.Equals(input.fkyy)) |
| 197 | 197 | .WhereIF(!string.IsNullOrEmpty(input.fkpd), p => p.Fkpd.Contains(input.fkpd)) |
| ... | ... | @@ -219,12 +219,12 @@ namespace NCC.Extend.LqKdKdjlb |
| 219 | 219 | sfyj = it.Sfyj, |
| 220 | 220 | qk = it.Qk, |
| 221 | 221 | ckfs = it.Ckfs, |
| 222 | - ckmx = it.Ckmx, | |
| 223 | 222 | fkfs = it.Fkfs, |
| 224 | 223 | fkyy = it.Fkyy, |
| 225 | 224 | fkpd = it.Fkpd, |
| 226 | 225 | khly = it.Khly, |
| 227 | 226 | tjr = it.Tjr, |
| 227 | + deductAmount = it.DeductAmount, | |
| 228 | 228 | sfskdd = it.Sfskdd, |
| 229 | 229 | jj = it.Jj, |
| 230 | 230 | bz = it.Bz, |
| ... | ... | @@ -263,6 +263,7 @@ namespace NCC.Extend.LqKdKdjlb |
| 263 | 263 | _db.BeginTran(); |
| 264 | 264 | //新增开单记录表记录 |
| 265 | 265 | entity.CreateUser = userInfo.userId; |
| 266 | + entity.DeductAmount = input.lqKdKdjlbDeductList.Sum(x => x.Amount ?? 0);//计算储扣总金额 | |
| 266 | 267 | var newEntity = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync(); |
| 267 | 268 | //循环品相信息 |
| 268 | 269 | // 收集所有需要插入的实体,然后批量插入 |
| ... | ... | @@ -347,6 +348,10 @@ namespace NCC.Extend.LqKdKdjlb |
| 347 | 348 | } |
| 348 | 349 | } |
| 349 | 350 | } |
| 351 | + //通过会员id查询会员信息 | |
| 352 | + var memberInfo = await _db.Queryable<LqKhxxEntity>().Where(u => u.Id == entity.Kdhy).FirstAsync(); | |
| 353 | + memberInfo.Khlx = "老客"; | |
| 354 | + await _db.Updateable(memberInfo).ExecuteCommandAsync(); | |
| 350 | 355 | // 批量插入扣款信息 |
| 351 | 356 | if (allDeductEntities.Any()) |
| 352 | 357 | { |
| ... | ... | @@ -442,7 +447,6 @@ namespace NCC.Extend.LqKdKdjlb |
| 442 | 447 | .WhereIF(!string.IsNullOrEmpty(input.sfyj), p => p.Sfyj.Equals(input.sfyj)) |
| 443 | 448 | .WhereIF(!string.IsNullOrEmpty(input.qk), p => p.Qk.Equals(input.qk)) |
| 444 | 449 | .WhereIF(!string.IsNullOrEmpty(input.ckfs), p => p.Ckfs.Equals(input.ckfs)) |
| 445 | - .WhereIF(!string.IsNullOrEmpty(input.ckmx), p => p.Ckmx.Contains(input.ckmx)) | |
| 446 | 450 | .WhereIF(!string.IsNullOrEmpty(input.fkfs), p => p.Fkfs.Equals(input.fkfs)) |
| 447 | 451 | .WhereIF(!string.IsNullOrEmpty(input.fkyy), p => p.Fkyy.Equals(input.fkyy)) |
| 448 | 452 | .WhereIF(!string.IsNullOrEmpty(input.fkpd), p => p.Fkpd.Contains(input.fkpd)) |
| ... | ... | @@ -470,7 +474,7 @@ namespace NCC.Extend.LqKdKdjlb |
| 470 | 474 | sfyj = it.Sfyj, |
| 471 | 475 | qk = it.Qk, |
| 472 | 476 | ckfs = it.Ckfs, |
| 473 | - ckmx = it.Ckmx, | |
| 477 | + deductAmount = it.DeductAmount, | |
| 474 | 478 | fkfs = it.Fkfs, |
| 475 | 479 | fkyy = it.Fkyy, |
| 476 | 480 | fkpd = it.Fkpd, | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs
| ... | ... | @@ -16,8 +16,10 @@ using NCC.Common.Model.NPOI; |
| 16 | 16 | using NCC.DataEncryption; |
| 17 | 17 | using NCC.Dependency; |
| 18 | 18 | using NCC.DynamicApiController; |
| 19 | +using NCC.Extend.Entitys.Dto.Common; | |
| 19 | 20 | using NCC.Extend.Entitys.Dto.LqKhxx; |
| 20 | 21 | using NCC.Extend.Entitys.Dto.LqXhHyhk; |
| 22 | +using NCC.Extend.Entitys.Enum; | |
| 21 | 23 | using NCC.Extend.Entitys.lq_hytk_hytk; |
| 22 | 24 | using NCC.Extend.Entitys.lq_hytk_mx; |
| 23 | 25 | using NCC.Extend.Entitys.lq_kd_kdjlb; |
| ... | ... | @@ -90,7 +92,6 @@ namespace NCC.Extend.LqKhxx |
| 90 | 92 | .WhereIF(!string.IsNullOrEmpty(input.gzhzt), p => p.Gzhzt.Equals(input.gzhzt)) |
| 91 | 93 | .WhereIF(!string.IsNullOrEmpty(input.wxnc), p => p.Wxnc.Contains(input.wxnc)) |
| 92 | 94 | .WhereIF(!string.IsNullOrEmpty(input.wxxcxzt), p => p.Wxxcxzt.Equals(input.wxxcxzt)) |
| 93 | - .WhereIF(!string.IsNullOrEmpty(input.khmqgs), p => p.Khmqgs.Equals(input.khmqgs)) | |
| 94 | 95 | .WhereIF(!string.IsNullOrEmpty(input.gsmd), p => p.Gsmd.Contains(input.gsmd)) |
| 95 | 96 | .WhereIF(!string.IsNullOrEmpty(input.khlx), p => p.Khlx.Equals(input.khlx)) |
| 96 | 97 | .WhereIF(!string.IsNullOrEmpty(input.khjd), p => p.Khjd.Equals(input.khjd)) |
| ... | ... | @@ -114,7 +115,6 @@ namespace NCC.Extend.LqKhxx |
| 114 | 115 | wxnc = it.Wxnc, |
| 115 | 116 | wxxcxzt = it.Wxxcxzt, |
| 116 | 117 | zjdlsj = it.Zjdlsj, |
| 117 | - khmqgs = it.Khmqgs, | |
| 118 | 118 | gsmd = it.Gsmd, |
| 119 | 119 | zcsj = it.Zcsj, |
| 120 | 120 | khlx = it.Khlx, |
| ... | ... | @@ -157,7 +157,6 @@ namespace NCC.Extend.LqKhxx |
| 157 | 157 | } |
| 158 | 158 | var entity = input.Adapt<LqKhxxEntity>(); |
| 159 | 159 | entity.Id = YitIdHelper.NextId().ToString(); |
| 160 | - | |
| 161 | 160 | // 处理客户消费字段:将数组转换为逗号分隔的字符串 |
| 162 | 161 | if (input.khxf != null && input.khxf.Count > 0) |
| 163 | 162 | { |
| ... | ... | @@ -203,7 +202,6 @@ namespace NCC.Extend.LqKhxx |
| 203 | 202 | .WhereIF(!string.IsNullOrEmpty(input.wxxcxzt), p => p.Wxxcxzt.Equals(input.wxxcxzt)) |
| 204 | 203 | // .WhereIF(queryZjdlsj != null, p => p.Zjdlsj >= new DateTime(startZjdlsj.ToDate().Year, startZjdlsj.ToDate().Month, startZjdlsj.ToDate().Day, 0, 0, 0)) |
| 205 | 204 | // .WhereIF(queryZjdlsj != null, p => p.Zjdlsj <= new DateTime(endZjdlsj.ToDate().Year, endZjdlsj.ToDate().Month, endZjdlsj.ToDate().Day, 23, 59, 59)) |
| 206 | - .WhereIF(!string.IsNullOrEmpty(input.khmqgs), p => p.Khmqgs.Equals(input.khmqgs)) | |
| 207 | 205 | .WhereIF(!string.IsNullOrEmpty(input.gsmd), p => p.Gsmd.Contains(input.gsmd)) |
| 208 | 206 | .WhereIF(queryZcsj != null, p => p.Zcsj >= new DateTime(startZcsj.ToDate().Year, startZcsj.ToDate().Month, startZcsj.ToDate().Day, 0, 0, 0)) |
| 209 | 207 | .WhereIF(queryZcsj != null, p => p.Zcsj <= new DateTime(endZcsj.ToDate().Year, endZcsj.ToDate().Month, endZcsj.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -233,7 +231,6 @@ namespace NCC.Extend.LqKhxx |
| 233 | 231 | wxnc = it.Wxnc, |
| 234 | 232 | wxxcxzt = it.Wxxcxzt, |
| 235 | 233 | zjdlsj = it.Zjdlsj, |
| 236 | - khmqgs = it.Khmqgs, | |
| 237 | 234 | gsmd = it.Gsmd, |
| 238 | 235 | zcsj = it.Zcsj, |
| 239 | 236 | khlx = it.Khlx, |
| ... | ... | @@ -282,7 +279,7 @@ namespace NCC.Extend.LqKhxx |
| 282 | 279 | DateTime? endYinlsr = queryYinlsr != null ? Ext.GetDateTime(queryYinlsr.Last()) : null; |
| 283 | 280 | |
| 284 | 281 | var data = await _db.Queryable<LqKhxxEntity>() |
| 285 | - .Where(p => p.Khmqgs == "线索池") // 固定查询线索池客户 | |
| 282 | + .Where(p => p.Khlx == "线索") // 固定查询线索池客户 | |
| 286 | 283 | .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) |
| 287 | 284 | .WhereIF(!string.IsNullOrEmpty(input.khmc), p => p.Khmc.Contains(input.khmc)) |
| 288 | 285 | .WhereIF(!string.IsNullOrEmpty(input.sjh), p => p.Sjh.Contains(input.sjh)) |
| ... | ... | @@ -291,7 +288,6 @@ namespace NCC.Extend.LqKhxx |
| 291 | 288 | .WhereIF(!string.IsNullOrEmpty(input.gzhzt), p => p.Gzhzt.Equals(input.gzhzt)) |
| 292 | 289 | .WhereIF(!string.IsNullOrEmpty(input.wxnc), p => p.Wxnc.Contains(input.wxnc)) |
| 293 | 290 | .WhereIF(!string.IsNullOrEmpty(input.wxxcxzt), p => p.Wxxcxzt.Equals(input.wxxcxzt)) |
| 294 | - .WhereIF(!string.IsNullOrEmpty(input.khmqgs), p => p.Khmqgs.Equals(input.khmqgs)) | |
| 295 | 291 | .WhereIF(!string.IsNullOrEmpty(input.gsmd), p => p.Gsmd.Contains(input.gsmd)) |
| 296 | 292 | .WhereIF(queryZcsj != null, p => p.Zcsj >= new DateTime(startZcsj.ToDate().Year, startZcsj.ToDate().Month, startZcsj.ToDate().Day, 0, 0, 0)) |
| 297 | 293 | .WhereIF(queryZcsj != null, p => p.Zcsj <= new DateTime(endZcsj.ToDate().Year, endZcsj.ToDate().Month, endZcsj.ToDate().Day, 23, 59, 59)) |
| ... | ... | @@ -321,7 +317,6 @@ namespace NCC.Extend.LqKhxx |
| 321 | 317 | wxnc = it.Wxnc, |
| 322 | 318 | wxxcxzt = it.Wxxcxzt, |
| 323 | 319 | zjdlsj = it.Zjdlsj, |
| 324 | - khmqgs = it.Khmqgs, | |
| 325 | 320 | gsmd = it.Gsmd, |
| 326 | 321 | zcsj = it.Zcsj, |
| 327 | 322 | khlx = it.Khlx, |
| ... | ... | @@ -570,10 +565,10 @@ namespace NCC.Extend.LqKhxx |
| 570 | 565 | TotalPurchased = x.ProjectNumber, |
| 571 | 566 | ConsumedCount = SqlFunc.Subqueryable<LqXhPxmxEntity>().Where(y => y.BillingItemId == x.Id).Sum(y => SqlFunc.ToDecimal(y.ProjectNumber)), |
| 572 | 567 | RefundedCount = SqlFunc.Subqueryable<LqHytkMxEntity>().Where(y => y.BillingItemId == x.Id).Sum(y => SqlFunc.ToDecimal(y.ProjectNumber)), |
| 573 | - RemainingCount = | |
| 574 | - x.ProjectNumber | |
| 575 | - - SqlFunc.Subqueryable<LqXhPxmxEntity>().Where(y => y.BillingItemId == x.Id).Sum(y => SqlFunc.ToDecimal(y.ProjectNumber)) | |
| 576 | - - SqlFunc.Subqueryable<LqHytkMxEntity>().Where(y => y.BillingItemId == x.Id).Sum(y => SqlFunc.ToDecimal(y.ProjectNumber)), | |
| 568 | + }) | |
| 569 | + .Mapper(x => | |
| 570 | + { | |
| 571 | + x.RemainingCount = x.TotalPurchased - x.ConsumedCount - x.RefundedCount; | |
| 577 | 572 | }) |
| 578 | 573 | .ToListAsync(); |
| 579 | 574 | return new MemberRemainingItemsOutput |
| ... | ... | @@ -590,5 +585,25 @@ namespace NCC.Extend.LqKhxx |
| 590 | 585 | } |
| 591 | 586 | } |
| 592 | 587 | #endregion |
| 588 | + | |
| 589 | + #region 获取会员类型枚举内容 | |
| 590 | + /// <summary> | |
| 591 | + /// 获取会员类型枚举内容 | |
| 592 | + /// </summary> | |
| 593 | + /// <returns>扣款类型枚举列表</returns> | |
| 594 | + [HttpGet("deduct-types")] | |
| 595 | + public List<EnumOutput> GetDeductTypes() | |
| 596 | + { | |
| 597 | + return Enum.GetValues<MemberTypeEnum>() | |
| 598 | + .Select(e => new EnumOutput | |
| 599 | + { | |
| 600 | + Value = (int)e, | |
| 601 | + Name = e.ToString(), | |
| 602 | + Description = e.GetDescription(), | |
| 603 | + }) | |
| 604 | + .ToList(); | |
| 605 | + } | |
| 606 | + #endregion | |
| 607 | + | |
| 593 | 608 | } |
| 594 | 609 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqTkjlbService.cs
| ... | ... | @@ -19,6 +19,7 @@ using NCC.Extend.Entitys.Dto.LqTkjlb; |
| 19 | 19 | using NCC.Extend.Entitys.lq_event; |
| 20 | 20 | using NCC.Extend.Entitys.lq_eventuser; |
| 21 | 21 | using NCC.Extend.Entitys.lq_khxx; |
| 22 | +using NCC.Extend.Entitys.lq_mdxx; | |
| 22 | 23 | using NCC.Extend.Entitys.lq_ryzl; |
| 23 | 24 | using NCC.Extend.Entitys.lq_tkjlb; |
| 24 | 25 | using NCC.Extend.Interfaces.LqTkjlb; |
| ... | ... | @@ -145,14 +146,14 @@ namespace NCC.Extend.LqTkjlb |
| 145 | 146 | /// <param name="input">参数</param> |
| 146 | 147 | /// <returns></returns> |
| 147 | 148 | [HttpPost("")] |
| 148 | - public async Task Create([FromBody] LqTkjlbCrInput input) | |
| 149 | + public async Task<dynamic> Create([FromBody] LqTkjlbCrInput input) | |
| 149 | 150 | { |
| 150 | 151 | var userInfo = await _userManager.GetUserInfo(); |
| 151 | 152 | //通过input.dhhm去查询用户信息 |
| 152 | 153 | var user = _db.Queryable<LqKhxxEntity>().Where(u => u.Sjh == input.customerPhone).Any(); |
| 153 | 154 | if (user) |
| 154 | 155 | { |
| 155 | - throw NCCException.Oh("该手机号码已存在于会员或线索池中"); | |
| 156 | + return NCCException.Oh("该手机号码已存在于会员或线索池中"); | |
| 156 | 157 | } |
| 157 | 158 | // 使用事务确保数据一致性 |
| 158 | 159 | var result = await _db.Ado.UseTranAsync(async () => |
| ... | ... | @@ -179,18 +180,22 @@ namespace NCC.Extend.LqTkjlb |
| 179 | 180 | MemberInfo.Id = YitIdHelper.NextId().ToString(); |
| 180 | 181 | MemberInfo.Khmc = entity.CustomerName; |
| 181 | 182 | MemberInfo.Sjh = input.customerPhone; // 设置手机号 |
| 182 | - MemberInfo.Khmqgs = "线索池"; | |
| 183 | + MemberInfo.Khlx = "线索"; | |
| 183 | 184 | MemberInfo.Dah = "GK" + DateTime.Now.ToString("yyyyMMddHHmmss"); |
| 184 | 185 | var memberResult = await _db.Insertable(MemberInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); |
| 185 | 186 | if (!(memberResult > 0)) |
| 187 | + { | |
| 186 | 188 | throw NCCException.Oh("创建客户信息失败"); |
| 187 | - return true; | |
| 189 | + } | |
| 190 | + var storeinfo = await _db.Queryable<LqMdxxEntity>().Where(u => u.Id == eventUserInfo.StoreId).FirstAsync(); | |
| 191 | + return new { entity = entity, storeinfo = storeinfo }; | |
| 188 | 192 | }); |
| 189 | 193 | |
| 190 | 194 | if (!result.IsSuccess) |
| 191 | 195 | { |
| 192 | - throw NCCException.Oh($"创建拓客记录失败:{result.ErrorMessage}"); | |
| 196 | + return NCCException.Oh($"创建拓客记录失败:{result.ErrorMessage}"); | |
| 193 | 197 | } |
| 198 | + return result.Data; | |
| 194 | 199 | } |
| 195 | 200 | #endregion |
| 196 | 201 | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqYaoyjlService.cs
| ... | ... | @@ -28,7 +28,7 @@ namespace NCC.Extend.LqYaoyjl |
| 28 | 28 | /// <summary> |
| 29 | 29 | /// 邀约记录服务 |
| 30 | 30 | /// </summary> |
| 31 | - [ApiDescriptionSettings(Tag = "Extend",Name = "LqYaoyjl", Order = 200)] | |
| 31 | + [ApiDescriptionSettings(Tag = "Extend", Name = "LqYaoyjl", Order = 200)] | |
| 32 | 32 | [Route("api/Extend/[controller]")] |
| 33 | 33 | public class LqYaoyjlService : ILqYaoyjlService, IDynamicApiController, ITransient |
| 34 | 34 | { |
| ... | ... | @@ -43,7 +43,7 @@ namespace NCC.Extend.LqYaoyjl |
| 43 | 43 | ISqlSugarRepository<LqYaoyjlEntity> lqYaoyjlRepository, |
| 44 | 44 | IUserManager userManager) |
| 45 | 45 | { |
| 46 | - _lqYaoyjlRepository = lqYaoyjlRepository; | |
| 46 | + _lqYaoyjlRepository = lqYaoyjlRepository; | |
| 47 | 47 | _db = _lqYaoyjlRepository.Context; |
| 48 | 48 | _userManager = userManager; |
| 49 | 49 | } |
| ... | ... | @@ -87,18 +87,18 @@ namespace NCC.Extend.LqYaoyjl |
| 87 | 87 | .WhereIF(queryLxsj != null, p => p.Lxsj >= new DateTime(startLxsj.ToDate().Year, startLxsj.ToDate().Month, startLxsj.ToDate().Day, 0, 0, 0)) |
| 88 | 88 | .WhereIF(queryLxsj != null, p => p.Lxsj <= new DateTime(endLxsj.ToDate().Year, endLxsj.ToDate().Month, endLxsj.ToDate().Day, 23, 59, 59)) |
| 89 | 89 | .WhereIF(!string.IsNullOrEmpty(input.lxjl), p => p.Lxjl.Contains(input.lxjl)) |
| 90 | - .Select(it=> new LqYaoyjlListOutput | |
| 90 | + .Select(it => new LqYaoyjlListOutput | |
| 91 | 91 | { |
| 92 | 92 | id = it.Id, |
| 93 | - yyr=it.Yyr, | |
| 94 | - yysj=it.Yysj, | |
| 95 | - yykh=it.Yykh, | |
| 96 | - yykhxm=it.Yykhxm, | |
| 97 | - dhsfyx=it.Dhsfyx, | |
| 98 | - lxsj=it.Lxsj, | |
| 99 | - lxjl=it.Lxjl, | |
| 100 | - }).MergeTable().OrderBy(sidx+" "+input.sort).ToPagedListAsync(input.currentPage, input.pageSize); | |
| 101 | - return PageResult<LqYaoyjlListOutput>.SqlSugarPageResult(data); | |
| 93 | + yyr = it.Yyr, | |
| 94 | + yysj = it.Yysj, | |
| 95 | + yykh = it.Yykh, | |
| 96 | + yykhxm = it.Yykhxm, | |
| 97 | + dhsfyx = it.Dhsfyx, | |
| 98 | + lxsj = it.Lxsj, | |
| 99 | + lxjl = it.Lxjl, | |
| 100 | + }).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize); | |
| 101 | + return PageResult<LqYaoyjlListOutput>.SqlSugarPageResult(data); | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /// <summary> |
| ... | ... | @@ -142,18 +142,18 @@ namespace NCC.Extend.LqYaoyjl |
| 142 | 142 | .WhereIF(queryLxsj != null, p => p.Lxsj >= new DateTime(startLxsj.ToDate().Year, startLxsj.ToDate().Month, startLxsj.ToDate().Day, 0, 0, 0)) |
| 143 | 143 | .WhereIF(queryLxsj != null, p => p.Lxsj <= new DateTime(endLxsj.ToDate().Year, endLxsj.ToDate().Month, endLxsj.ToDate().Day, 23, 59, 59)) |
| 144 | 144 | .WhereIF(!string.IsNullOrEmpty(input.lxjl), p => p.Lxjl.Contains(input.lxjl)) |
| 145 | - .Select(it=> new LqYaoyjlListOutput | |
| 145 | + .Select(it => new LqYaoyjlListOutput | |
| 146 | 146 | { |
| 147 | 147 | id = it.Id, |
| 148 | - yyr=it.Yyr, | |
| 149 | - yysj=it.Yysj, | |
| 150 | - yykh=it.Yykh, | |
| 151 | - yykhxm=it.Yykhxm, | |
| 152 | - dhsfyx=it.Dhsfyx, | |
| 153 | - lxsj=it.Lxsj, | |
| 154 | - lxjl=it.Lxjl, | |
| 155 | - }).MergeTable().OrderBy(sidx+" "+input.sort).ToListAsync(); | |
| 156 | - return data; | |
| 148 | + yyr = it.Yyr, | |
| 149 | + yysj = it.Yysj, | |
| 150 | + yykh = it.Yykh, | |
| 151 | + yykhxm = it.Yykhxm, | |
| 152 | + dhsfyx = it.Dhsfyx, | |
| 153 | + lxsj = it.Lxsj, | |
| 154 | + lxjl = it.Lxjl, | |
| 155 | + }).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync(); | |
| 156 | + return data; | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /// <summary> |
| ... | ... | @@ -175,7 +175,7 @@ namespace NCC.Extend.LqYaoyjl |
| 175 | 175 | { |
| 176 | 176 | exportData = await this.GetNoPagingList(input); |
| 177 | 177 | } |
| 178 | - List<ParamsModel> paramList = "[{\"value\":\"邀约编号\",\"field\":\"id\"},{\"value\":\"邀约人\",\"field\":\"yyr\"},{\"value\":\"邀约时间\",\"field\":\"yysj\"},{\"value\":\"邀约客户\",\"field\":\"yykh\"},{\"value\":\"邀约客户姓名\",\"field\":\"yykhxm\"},{\"value\":\"电话是否有效\",\"field\":\"dhsfyx\"},{\"value\":\"联系时间\",\"field\":\"lxsj\"},{\"value\":\"联系记录\",\"field\":\"lxjl\"},]".ToList<ParamsModel>(); | |
| 178 | + List<ParamsModel> paramList = "[{\"value\":\"邀约编号\",\"field\":\"id\"},{\"value\":\"邀约人\",\"field\":\"yyr\"},{\"value\":\"邀约时间\",\"field\":\"yysj\"},{\"value\":\"邀约客户\",\"field\":\"yykh\"},{\"value\":\"邀约客户姓名\",\"field\":\"yykhxm\"},{\"value\":\"电话是否有效\",\"field\":\"dhsfyx\"},{\"value\":\"联系时间\",\"field\":\"lxsj\"},{\"value\":\"联系记录\",\"field\":\"lxjl\"},]".ToList<ParamsModel>(); | |
| 179 | 179 | ExcelConfig excelconfig = new ExcelConfig(); |
| 180 | 180 | excelconfig.FileName = "邀约记录.xls"; |
| 181 | 181 | excelconfig.HeadFont = "微软雅黑"; |
| ... | ... | @@ -218,7 +218,7 @@ namespace NCC.Extend.LqYaoyjl |
| 218 | 218 | //开启事务 |
| 219 | 219 | _db.BeginTran(); |
| 220 | 220 | //批量删除邀约记录 |
| 221 | - await _db.Deleteable<LqYaoyjlEntity>().In(d => d.Id,ids).ExecuteCommandAsync(); | |
| 221 | + await _db.Deleteable<LqYaoyjlEntity>().In(d => d.Id, ids).ExecuteCommandAsync(); | |
| 222 | 222 | //关闭事务 |
| 223 | 223 | _db.CommitTran(); |
| 224 | 224 | } | ... | ... |
netcore/src/Modularity/Extend/NCC.Extend/LqYcsdJsjService.cs
| ... | ... | @@ -180,13 +180,14 @@ namespace NCC.Extend.LqYcsdJsj |
| 180 | 180 | } |
| 181 | 181 | // 查询门店信息 |
| 182 | 182 | var store = await _db.Queryable<LqMdxxEntity>().Where(x => x.Id == jsj.Md).FirstAsync(); |
| 183 | - return new | |
| 183 | + return new LqYcsdJsjByUserMonthOutput | |
| 184 | 184 | { |
| 185 | 185 | jsjId = jsj.Id, |
| 186 | 186 | jsjName = jsj.Jsj, |
| 187 | 187 | month = jsj.Yf, |
| 188 | 188 | storeId = jsj.Md, |
| 189 | 189 | storeName = store?.Dm, |
| 190 | + userId = jsjUser.UserId, | |
| 190 | 191 | userName = jsjUser.UserName, |
| 191 | 192 | isLeader = jsjUser.IsLeader, |
| 192 | 193 | status = jsjUser.Status, |
| ... | ... | @@ -256,16 +257,16 @@ namespace NCC.Extend.LqYcsdJsj |
| 256 | 257 | |
| 257 | 258 | return new LqYcsdJsjByUserMonthOutput |
| 258 | 259 | { |
| 259 | - JsjId = jsj.Id, | |
| 260 | - JsjName = jsj.Jsj, | |
| 261 | - Month = jsj.Yf, | |
| 262 | - StoreId = jsj.Md, | |
| 263 | - StoreName = store?.Dm, | |
| 264 | - UserId = jsjUser.UserId, | |
| 265 | - UserName = jsjUser.UserName, | |
| 266 | - IsLeader = jsjUser.IsLeader, | |
| 267 | - Status = jsjUser.Status, | |
| 268 | - SortOrder = jsjUser.SortOrder, | |
| 260 | + jsjId = jsj.Id, | |
| 261 | + jsjName = jsj.Jsj, | |
| 262 | + month = jsj.Yf, | |
| 263 | + storeId = jsj.Md, | |
| 264 | + storeName = store?.Dm, | |
| 265 | + userId = jsjUser.UserId, | |
| 266 | + userName = jsjUser.UserName, | |
| 267 | + isLeader = jsjUser.IsLeader, | |
| 268 | + status = jsjUser.Status, | |
| 269 | + sortOrder = jsjUser.SortOrder, | |
| 269 | 270 | }; |
| 270 | 271 | } |
| 271 | 272 | #endregion | ... | ... |