Commit 920afb2990718eadf81ef3fc57bc3442eeed9ed8
1 parent
c842ad9a
修改了一摩尔的东西,我一个人在客户这边,好安静。
Showing
9 changed files
with
384 additions
and
175 deletions
antis-ncc-admin/src/views/lqKhxx/Form.vue
| @@ -207,30 +207,6 @@ | @@ -207,30 +207,6 @@ | ||
| 207 | </el-form-item> | 207 | </el-form-item> |
| 208 | </el-col> | 208 | </el-col> |
| 209 | 209 | ||
| 210 | - <!-- 到店记录 --> | ||
| 211 | - <el-col :span="24"> | ||
| 212 | - <div class="form-section-title"> | ||
| 213 | - <i class="el-icon-date"></i> | ||
| 214 | - <span>到店记录</span> | ||
| 215 | - </div> | ||
| 216 | - </el-col> | ||
| 217 | - | ||
| 218 | - <!-- 消费信息 --> | ||
| 219 | - <el-col :span="24"> | ||
| 220 | - <div class="form-section-title"> | ||
| 221 | - <i class="el-icon-money"></i> | ||
| 222 | - <span>消费信息</span> | ||
| 223 | - </div> | ||
| 224 | - </el-col> | ||
| 225 | - | ||
| 226 | - <!-- 余额信息 --> | ||
| 227 | - <el-col :span="24"> | ||
| 228 | - <div class="form-section-title"> | ||
| 229 | - <i class="el-icon-coin"></i> | ||
| 230 | - <span>余额信息</span> | ||
| 231 | - </div> | ||
| 232 | - </el-col> | ||
| 233 | - | ||
| 234 | <!-- 备注信息 --> | 210 | <!-- 备注信息 --> |
| 235 | <el-col :span="24"> | 211 | <el-col :span="24"> |
| 236 | <div class="form-section-title"> | 212 | <div class="form-section-title"> |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqKhxx/LqKhxxOrderTypeOutput.cs
0 → 100644
| 1 | +using System; | ||
| 2 | + | ||
| 3 | +namespace NCC.Extend.Entitys.Dto.LqKhxx | ||
| 4 | +{ | ||
| 5 | + /// <summary> | ||
| 6 | + /// 客户订单类型输出 | ||
| 7 | + /// </summary> | ||
| 8 | + public class LqKhxxOrderTypeOutput | ||
| 9 | + { | ||
| 10 | + /// <summary> | ||
| 11 | + /// 客户ID | ||
| 12 | + /// </summary> | ||
| 13 | + public string CustomerId { get; set; } | ||
| 14 | + | ||
| 15 | + /// <summary> | ||
| 16 | + /// 订单类型 (first_order: 首单, repeat_order: 升单) | ||
| 17 | + /// </summary> | ||
| 18 | + public string OrderType { get; set; } | ||
| 19 | + | ||
| 20 | + /// <summary> | ||
| 21 | + /// 是否有开单记录 | ||
| 22 | + /// </summary> | ||
| 23 | + public bool HasOrderRecord { get; set; } | ||
| 24 | + | ||
| 25 | + /// <summary> | ||
| 26 | + /// 开单记录数量 | ||
| 27 | + /// </summary> | ||
| 28 | + public int OrderCount { get; set; } | ||
| 29 | + } | ||
| 30 | +} |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Dto/LqTkjlb/LqTkjlbCrInput.cs
| @@ -12,56 +12,50 @@ namespace NCC.Extend.Entitys.Dto.LqTkjlb | @@ -12,56 +12,50 @@ namespace NCC.Extend.Entitys.Dto.LqTkjlb | ||
| 12 | /// 拓客编号 | 12 | /// 拓客编号 |
| 13 | /// </summary> | 13 | /// </summary> |
| 14 | public string id { get; set; } | 14 | public string id { get; set; } |
| 15 | - | 15 | + |
| 16 | /// <summary> | 16 | /// <summary> |
| 17 | /// 拓客时间 | 17 | /// 拓客时间 |
| 18 | /// </summary> | 18 | /// </summary> |
| 19 | public DateTime? tksj { get; set; } | 19 | public DateTime? tksj { get; set; } |
| 20 | - | ||
| 21 | - /// <summary> | ||
| 22 | - /// 拓客人员 | ||
| 23 | - /// </summary> | ||
| 24 | - public string tkry { get; set; } | ||
| 25 | - | 20 | + |
| 26 | /// <summary> | 21 | /// <summary> |
| 27 | /// 顾客姓名 | 22 | /// 顾客姓名 |
| 28 | /// </summary> | 23 | /// </summary> |
| 29 | public string gkxm { get; set; } | 24 | public string gkxm { get; set; } |
| 30 | - | 25 | + |
| 31 | /// <summary> | 26 | /// <summary> |
| 32 | /// 电话号码 | 27 | /// 电话号码 |
| 33 | /// </summary> | 28 | /// </summary> |
| 34 | public string dhhm { get; set; } | 29 | public string dhhm { get; set; } |
| 35 | - | 30 | + |
| 36 | /// <summary> | 31 | /// <summary> |
| 37 | /// 购买张数 | 32 | /// 购买张数 |
| 38 | /// </summary> | 33 | /// </summary> |
| 39 | public int? gmzs { get; set; } | 34 | public int? gmzs { get; set; } |
| 40 | - | 35 | + |
| 41 | /// <summary> | 36 | /// <summary> |
| 42 | /// 支付方式 | 37 | /// 支付方式 |
| 43 | /// </summary> | 38 | /// </summary> |
| 44 | public string zffs { get; set; } | 39 | public string zffs { get; set; } |
| 45 | - | 40 | + |
| 46 | /// <summary> | 41 | /// <summary> |
| 47 | /// 是否加微信 | 42 | /// 是否加微信 |
| 48 | /// </summary> | 43 | /// </summary> |
| 49 | public string sfjwx { get; set; } | 44 | public string sfjwx { get; set; } |
| 50 | - | 45 | + |
| 51 | /// <summary> | 46 | /// <summary> |
| 52 | /// 备注 | 47 | /// 备注 |
| 53 | /// </summary> | 48 | /// </summary> |
| 54 | public string bz { get; set; } | 49 | public string bz { get; set; } |
| 55 | - | 50 | + |
| 56 | /// <summary> | 51 | /// <summary> |
| 57 | - /// 所属门店 | 52 | + /// 拓客人员 |
| 58 | /// </summary> | 53 | /// </summary> |
| 59 | - public string ssmd { get; set; } | ||
| 60 | - | 54 | + public string tkry { get; set; } |
| 55 | + | ||
| 61 | /// <summary> | 56 | /// <summary> |
| 62 | - /// 所属战队 | 57 | + /// 拓客活动id |
| 63 | /// </summary> | 58 | /// </summary> |
| 64 | - public string sszd { get; set; } | ||
| 65 | - | 59 | + public string eventId { get; set; } |
| 66 | } | 60 | } |
| 67 | } | 61 | } |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_khxx/LqKhxxEntity.cs
| @@ -160,5 +160,11 @@ namespace NCC.Extend.Entitys.lq_khxx | @@ -160,5 +160,11 @@ namespace NCC.Extend.Entitys.lq_khxx | ||
| 160 | /// </summary> | 160 | /// </summary> |
| 161 | [SugarColumn(ColumnName = "ml")] | 161 | [SugarColumn(ColumnName = "ml")] |
| 162 | public string Ml { get; set; } | 162 | public string Ml { get; set; } |
| 163 | + | ||
| 164 | + /// <summary> | ||
| 165 | + /// 添加时间 | ||
| 166 | + /// </summary> | ||
| 167 | + [SugarColumn(ColumnName = "F_CreateTime")] | ||
| 168 | + public DateTime CreateTime { get; set; } = DateTime.Now; | ||
| 163 | } | 169 | } |
| 164 | } | 170 | } |
netcore/src/Modularity/Extend/NCC.Extend.Entitys/Entity/lq_tkjlb/LqTkjlbEntity.cs
| @@ -64,7 +64,13 @@ namespace NCC.Extend.Entitys.lq_tkjlb | @@ -64,7 +64,13 @@ namespace NCC.Extend.Entitys.lq_tkjlb | ||
| 64 | public string Bz { get; set; } | 64 | public string Bz { get; set; } |
| 65 | 65 | ||
| 66 | /// <summary> | 66 | /// <summary> |
| 67 | - /// 所属门店 | 67 | + /// 拓客活动id |
| 68 | + /// </summary> | ||
| 69 | + [SugarColumn(ColumnName = "F_EventId")] | ||
| 70 | + public string EventId { get; set; } | ||
| 71 | + | ||
| 72 | + /// <summary> | ||
| 73 | + /// 所属组织 | ||
| 68 | /// </summary> | 74 | /// </summary> |
| 69 | [SugarColumn(ColumnName = "ssmd")] | 75 | [SugarColumn(ColumnName = "ssmd")] |
| 70 | public string Ssmd { get; set; } | 76 | public string Ssmd { get; set; } |
netcore/src/Modularity/Extend/NCC.Extend.Interfaces/ILqKhxxService.cs
| 1 | -namespace NCC.Extend.Interfaces.LqKhxx | 1 | +using System.Threading.Tasks; |
| 2 | +using NCC.Common.Filter; | ||
| 3 | +using NCC.Extend.Entitys.Dto.LqKhxx; | ||
| 4 | + | ||
| 5 | +namespace NCC.Extend.Interfaces.LqKhxx | ||
| 2 | { | 6 | { |
| 3 | public interface ILqKhxxService | 7 | public interface ILqKhxxService |
| 4 | { | 8 | { |
| 9 | + /// <summary> | ||
| 10 | + /// 获取线索池客户列表 | ||
| 11 | + /// </summary> | ||
| 12 | + /// <param name="input">查询参数</param> | ||
| 13 | + /// <returns>线索池客户列表</returns> | ||
| 14 | + Task<PageResult<LqKhxxListOutput>> GetLeadsPoolList(LqKhxxListQueryInput input); | ||
| 15 | + | ||
| 16 | + /// <summary> | ||
| 17 | + /// 获取客户订单类型(首单/升单) | ||
| 18 | + /// </summary> | ||
| 19 | + /// <param name="customerId">客户ID</param> | ||
| 20 | + /// <returns>客户订单类型信息</returns> | ||
| 21 | + Task<LqKhxxOrderTypeOutput> GetCustomerOrderType(string customerId); | ||
| 5 | } | 22 | } |
| 6 | -} | ||
| 7 | \ No newline at end of file | 23 | \ No newline at end of file |
| 24 | +} |
netcore/src/Modularity/Extend/NCC.Extend/LqKhxxService.cs
| @@ -148,6 +148,12 @@ namespace NCC.Extend.LqKhxx | @@ -148,6 +148,12 @@ namespace NCC.Extend.LqKhxx | ||
| 148 | public async Task Create([FromBody] LqKhxxCrInput input) | 148 | public async Task Create([FromBody] LqKhxxCrInput input) |
| 149 | { | 149 | { |
| 150 | var userInfo = await _userManager.GetUserInfo(); | 150 | var userInfo = await _userManager.GetUserInfo(); |
| 151 | + //判断手机号是否存在 | ||
| 152 | + var user = _db.Queryable<LqKhxxEntity>().Where(u => u.Sjh == input.sjh).Any(); | ||
| 153 | + if (user) | ||
| 154 | + { | ||
| 155 | + throw NCCException.Oh("该会员已存在"); | ||
| 156 | + } | ||
| 151 | var entity = input.Adapt<LqKhxxEntity>(); | 157 | var entity = input.Adapt<LqKhxxEntity>(); |
| 152 | entity.Id = YitIdHelper.NextId().ToString(); | 158 | entity.Id = YitIdHelper.NextId().ToString(); |
| 153 | var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | 159 | var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); |
| @@ -243,6 +249,131 @@ namespace NCC.Extend.LqKhxx | @@ -243,6 +249,131 @@ namespace NCC.Extend.LqKhxx | ||
| 243 | } | 249 | } |
| 244 | #endregion | 250 | #endregion |
| 245 | 251 | ||
| 252 | + #region 获取线索池客户列表 | ||
| 253 | + /// <summary> | ||
| 254 | + /// 获取线索池客户列表 | ||
| 255 | + /// </summary> | ||
| 256 | + /// <param name="input">查询参数</param> | ||
| 257 | + /// <returns>线索池客户列表</returns> | ||
| 258 | + [HttpGet("leads-pool")] | ||
| 259 | + public async Task<PageResult<LqKhxxListOutput>> GetLeadsPoolList([FromQuery] LqKhxxListQueryInput input) | ||
| 260 | + { | ||
| 261 | + var sidx = input.sidx == null ? "id" : input.sidx; | ||
| 262 | + List<string> queryZjdlsj = input.zjdlsj != null ? input.zjdlsj.Split(',').ToObeject<List<string>>() : null; | ||
| 263 | + DateTime? startZjdlsj = queryZjdlsj != null ? Ext.GetDateTime(queryZjdlsj.First()) : null; | ||
| 264 | + DateTime? endZjdlsj = queryZjdlsj != null ? Ext.GetDateTime(queryZjdlsj.Last()) : null; | ||
| 265 | + List<string> queryZcsj = input.zcsj != null ? input.zcsj.Split(',').ToObeject<List<string>>() : null; | ||
| 266 | + DateTime? startZcsj = queryZcsj != null ? Ext.GetDateTime(queryZcsj.First()) : null; | ||
| 267 | + DateTime? endZcsj = queryZcsj != null ? Ext.GetDateTime(queryZcsj.Last()) : null; | ||
| 268 | + List<string> queryYanglsr = input.yanglsr != null ? input.yanglsr.Split(',').ToObeject<List<string>>() : null; | ||
| 269 | + DateTime? startYanglsr = queryYanglsr != null ? Ext.GetDateTime(queryYanglsr.First()) : null; | ||
| 270 | + DateTime? endYanglsr = queryYanglsr != null ? Ext.GetDateTime(queryYanglsr.Last()) : null; | ||
| 271 | + List<string> queryYinlsr = input.yinlsr != null ? input.yinlsr.Split(',').ToObeject<List<string>>() : null; | ||
| 272 | + DateTime? startYinlsr = queryYinlsr != null ? Ext.GetDateTime(queryYinlsr.First()) : null; | ||
| 273 | + DateTime? endYinlsr = queryYinlsr != null ? Ext.GetDateTime(queryYinlsr.Last()) : null; | ||
| 274 | + | ||
| 275 | + var data = await _db.Queryable<LqKhxxEntity>() | ||
| 276 | + .Where(p => p.Khmqgs == "线索池") // 固定查询线索池客户 | ||
| 277 | + .WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id)) | ||
| 278 | + .WhereIF(!string.IsNullOrEmpty(input.khmc), p => p.Khmc.Contains(input.khmc)) | ||
| 279 | + .WhereIF(!string.IsNullOrEmpty(input.sjh), p => p.Sjh.Contains(input.sjh)) | ||
| 280 | + .WhereIF(!string.IsNullOrEmpty(input.dah), p => p.Dah.Contains(input.dah)) | ||
| 281 | + .WhereIF(!string.IsNullOrEmpty(input.xb), p => p.Xb.Equals(input.xb)) | ||
| 282 | + .WhereIF(!string.IsNullOrEmpty(input.gzhzt), p => p.Gzhzt.Equals(input.gzhzt)) | ||
| 283 | + .WhereIF(!string.IsNullOrEmpty(input.wxnc), p => p.Wxnc.Contains(input.wxnc)) | ||
| 284 | + .WhereIF(!string.IsNullOrEmpty(input.wxxcxzt), p => p.Wxxcxzt.Equals(input.wxxcxzt)) | ||
| 285 | + .WhereIF(!string.IsNullOrEmpty(input.khmqgs), p => p.Khmqgs.Equals(input.khmqgs)) | ||
| 286 | + .WhereIF(!string.IsNullOrEmpty(input.gsmd), p => p.Gsmd.Contains(input.gsmd)) | ||
| 287 | + .WhereIF(queryZcsj != null, p => p.Zcsj >= new DateTime(startZcsj.ToDate().Year, startZcsj.ToDate().Month, startZcsj.ToDate().Day, 0, 0, 0)) | ||
| 288 | + .WhereIF(queryZcsj != null, p => p.Zcsj <= new DateTime(endZcsj.ToDate().Year, endZcsj.ToDate().Month, endZcsj.ToDate().Day, 23, 59, 59)) | ||
| 289 | + .WhereIF(!string.IsNullOrEmpty(input.khlx), p => p.Khlx.Equals(input.khlx)) | ||
| 290 | + .WhereIF(!string.IsNullOrEmpty(input.khjd), p => p.Khjd.Equals(input.khjd)) | ||
| 291 | + .WhereIF(!string.IsNullOrEmpty(input.khxf), p => p.Khxf.Contains(input.khxf)) | ||
| 292 | + .WhereIF(!string.IsNullOrEmpty(input.xfpc), p => p.Xfpc.Equals(input.xfpc)) | ||
| 293 | + .WhereIF(!string.IsNullOrEmpty(input.tjr), p => p.Tjr.Contains(input.tjr)) | ||
| 294 | + .WhereIF(!string.IsNullOrEmpty(input.fzgw), p => p.Fzgw.Contains(input.fzgw)) | ||
| 295 | + .WhereIF(!string.IsNullOrEmpty(input.mrs), p => p.Mrs.Contains(input.mrs)) | ||
| 296 | + .WhereIF(!string.IsNullOrEmpty(input.jdqd), p => p.Jdqd.Contains(input.jdqd)) | ||
| 297 | + .WhereIF(!string.IsNullOrEmpty(input.lxdz), p => p.Lxdz.Contains(input.lxdz)) | ||
| 298 | + .WhereIF(!string.IsNullOrEmpty(input.bz), p => p.Bz.Contains(input.bz)) | ||
| 299 | + .WhereIF(queryYanglsr != null, p => p.Yanglsr >= new DateTime(startYanglsr.ToDate().Year, startYanglsr.ToDate().Month, startYanglsr.ToDate().Day, 0, 0, 0)) | ||
| 300 | + .WhereIF(queryYanglsr != null, p => p.Yanglsr <= new DateTime(endYanglsr.ToDate().Year, endYanglsr.ToDate().Month, endYanglsr.ToDate().Day, 23, 59, 59)) | ||
| 301 | + .WhereIF(queryYinlsr != null, p => p.Yinlsr >= new DateTime(startYinlsr.ToDate().Year, startYinlsr.ToDate().Month, startYinlsr.ToDate().Day, 0, 0, 0)) | ||
| 302 | + .WhereIF(queryYinlsr != null, p => p.Yinlsr <= new DateTime(endYinlsr.ToDate().Year, endYinlsr.ToDate().Month, endYinlsr.ToDate().Day, 23, 59, 59)) | ||
| 303 | + .WhereIF(!string.IsNullOrEmpty(input.ml), p => p.Ml.Contains(input.ml)) | ||
| 304 | + .Select(it => new LqKhxxListOutput | ||
| 305 | + { | ||
| 306 | + id = it.Id, | ||
| 307 | + khmc = it.Khmc, | ||
| 308 | + sjh = it.Sjh, | ||
| 309 | + dah = it.Dah, | ||
| 310 | + xb = it.Xb, | ||
| 311 | + gzhzt = it.Gzhzt, | ||
| 312 | + wxnc = it.Wxnc, | ||
| 313 | + wxxcxzt = it.Wxxcxzt, | ||
| 314 | + zjdlsj = it.Zjdlsj, | ||
| 315 | + khmqgs = it.Khmqgs, | ||
| 316 | + gsmd = it.Gsmd, | ||
| 317 | + zcsj = it.Zcsj, | ||
| 318 | + khlx = it.Khlx, | ||
| 319 | + khjd = it.Khjd, | ||
| 320 | + khxf = it.Khxf, | ||
| 321 | + xfpc = it.Xfpc, | ||
| 322 | + tjr = it.Tjr, | ||
| 323 | + fzgw = it.Fzgw, | ||
| 324 | + mrs = it.Mrs, | ||
| 325 | + jdqd = it.Jdqd, | ||
| 326 | + lxdz = it.Lxdz, | ||
| 327 | + bz = it.Bz, | ||
| 328 | + yanglsr = it.Yanglsr, | ||
| 329 | + yinlsr = it.Yinlsr, | ||
| 330 | + ml = it.Ml, | ||
| 331 | + }) | ||
| 332 | + .MergeTable() | ||
| 333 | + .OrderBy(sidx + " " + input.sort) | ||
| 334 | + .ToPagedListAsync(input.currentPage, input.pageSize); | ||
| 335 | + return PageResult<LqKhxxListOutput>.SqlSugarPageResult(data); | ||
| 336 | + } | ||
| 337 | + #endregion | ||
| 338 | + | ||
| 339 | + #region 获取客户订单类型 | ||
| 340 | + /// <summary> | ||
| 341 | + /// 获取客户订单类型(首单/升单) | ||
| 342 | + /// </summary> | ||
| 343 | + /// <param name="customerId">客户ID</param> | ||
| 344 | + /// <returns>客户订单类型信息</returns> | ||
| 345 | + [HttpGet("order-type/{customerId}")] | ||
| 346 | + public async Task<LqKhxxOrderTypeOutput> GetCustomerOrderType(string customerId) | ||
| 347 | + { | ||
| 348 | + if (string.IsNullOrEmpty(customerId)) | ||
| 349 | + { | ||
| 350 | + throw NCCException.Oh("客户ID不能为空"); | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + // 查询客户是否存在 | ||
| 354 | + var customerExists = await _db.Queryable<LqKhxxEntity>().Where(c => c.Id == customerId).AnyAsync(); | ||
| 355 | + | ||
| 356 | + if (!customerExists) | ||
| 357 | + { | ||
| 358 | + throw NCCException.Oh("客户不存在"); | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + // 查询开单记录数量 | ||
| 362 | + var orderCount = await _db.Queryable<LqKdKdjlbEntity>().Where(o => o.Kdhy == customerId).CountAsync(); | ||
| 363 | + | ||
| 364 | + var hasOrderRecord = orderCount > 0; | ||
| 365 | + var orderType = hasOrderRecord ? "repeat_order" : "first_order"; | ||
| 366 | + | ||
| 367 | + return new LqKhxxOrderTypeOutput | ||
| 368 | + { | ||
| 369 | + CustomerId = customerId, | ||
| 370 | + OrderType = orderType, | ||
| 371 | + HasOrderRecord = hasOrderRecord, | ||
| 372 | + OrderCount = orderCount, | ||
| 373 | + }; | ||
| 374 | + } | ||
| 375 | + #endregion | ||
| 376 | + | ||
| 246 | #region 导出客户资料 | 377 | #region 导出客户资料 |
| 247 | /// <summary> | 378 | /// <summary> |
| 248 | /// 导出客户资料 | 379 | /// 导出客户资料 |
netcore/src/Modularity/Extend/NCC.Extend/LqTkjlbService.cs
| @@ -16,6 +16,8 @@ using NCC.DataEncryption; | @@ -16,6 +16,8 @@ using NCC.DataEncryption; | ||
| 16 | using NCC.Dependency; | 16 | using NCC.Dependency; |
| 17 | using NCC.DynamicApiController; | 17 | using NCC.DynamicApiController; |
| 18 | using NCC.Extend.Entitys.Dto.LqTkjlb; | 18 | using NCC.Extend.Entitys.Dto.LqTkjlb; |
| 19 | +using NCC.Extend.Entitys.lq_eventuser; | ||
| 20 | +using NCC.Extend.Entitys.lq_khxx; | ||
| 19 | using NCC.Extend.Entitys.lq_ryzl; | 21 | using NCC.Extend.Entitys.lq_ryzl; |
| 20 | using NCC.Extend.Entitys.lq_tkjlb; | 22 | using NCC.Extend.Entitys.lq_tkjlb; |
| 21 | using NCC.Extend.Interfaces.LqTkjlb; | 23 | using NCC.Extend.Interfaces.LqTkjlb; |
| @@ -123,19 +125,41 @@ namespace NCC.Extend.LqTkjlb | @@ -123,19 +125,41 @@ namespace NCC.Extend.LqTkjlb | ||
| 123 | public async Task Create([FromBody] LqTkjlbCrInput input) | 125 | public async Task Create([FromBody] LqTkjlbCrInput input) |
| 124 | { | 126 | { |
| 125 | var userInfo = await _userManager.GetUserInfo(); | 127 | var userInfo = await _userManager.GetUserInfo(); |
| 126 | - var entity = input.Adapt<LqTkjlbEntity>(); | ||
| 127 | - entity.Id = YitIdHelper.NextId().ToString(); | ||
| 128 | - string mobile = _db.Queryable<UserEntity>().Where(u => u.Id == input.tkry).Select(u => u.MobilePhone).First(); | ||
| 129 | - var ry = _db.Queryable<LqRyzlEntity>().Where(u => u.Sjh == mobile).First(); | ||
| 130 | - if (ry != null) | 128 | + //通过input.dhhm去查询用户信息 |
| 129 | + var user = _db.Queryable<LqKhxxEntity>().Where(u => u.Sjh == input.dhhm).Any(); | ||
| 130 | + if (user) | ||
| 131 | { | 131 | { |
| 132 | - entity.Ssmd = ry.Dm == null ? "" : ry.Dm; | ||
| 133 | - entity.Sszd = ry.Zd == null ? "" : ry.Zd; | 132 | + throw NCCException.Oh("该手机号码已存在于会员或线索池中"); |
| 134 | } | 133 | } |
| 134 | + // 使用事务确保数据一致性 | ||
| 135 | + var result = await _db.Ado.UseTranAsync(async () => | ||
| 136 | + { | ||
| 137 | + //通过input.eventId去查询拓客活动信息 | ||
| 138 | + var eventUserInfo = await _db.Queryable<LqEventUserEntity>().Where(u => u.EventId == input.eventId && u.UserId == input.tkry).FirstAsync(); | ||
| 139 | + // 创建拓客记录 | ||
| 140 | + var entity = input.Adapt<LqTkjlbEntity>(); | ||
| 141 | + entity.Id = YitIdHelper.NextId().ToString(); | ||
| 142 | + entity.Sszd = eventUserInfo.TeamName; | ||
| 143 | + var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | ||
| 144 | + if (!(isOk > 0)) | ||
| 145 | + throw NCCException.Oh("创建拓客记录失败"); | ||
| 146 | + // 创建客户信息 | ||
| 147 | + LqKhxxEntity MemberInfo = new LqKhxxEntity(); | ||
| 148 | + MemberInfo.Id = YitIdHelper.NextId().ToString(); | ||
| 149 | + MemberInfo.Khmc = entity.Gkxm; | ||
| 150 | + MemberInfo.Sjh = input.dhhm; // 设置手机号 | ||
| 151 | + MemberInfo.Khmqgs = "线索池"; | ||
| 152 | + MemberInfo.Dah = "GK" + DateTime.Now.ToString("yyyyMMddHHmmss"); | ||
| 153 | + var memberResult = await _db.Insertable(MemberInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | ||
| 154 | + if (!(memberResult > 0)) | ||
| 155 | + throw NCCException.Oh("创建客户信息失败"); | ||
| 156 | + return true; | ||
| 157 | + }); | ||
| 135 | 158 | ||
| 136 | - var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | ||
| 137 | - if (!(isOk > 0)) | ||
| 138 | - throw NCCException.Oh(ErrorCode.COM1000); | 159 | + if (!result.IsSuccess) |
| 160 | + { | ||
| 161 | + throw NCCException.Oh($"创建拓客记录失败:{result.ErrorMessage}"); | ||
| 162 | + } | ||
| 139 | } | 163 | } |
| 140 | #endregion | 164 | #endregion |
| 141 | 165 |
netcore/src/Modularity/Extend/NCC.Extend/LqYcsdJsjService.cs
| 1 | -using NCC.Common.Core.Manager; | 1 | +using System; |
| 2 | +using System.Collections.Generic; | ||
| 3 | +using System.Globalization; | ||
| 4 | +using System.Linq; | ||
| 5 | +using System.Threading.Tasks; | ||
| 6 | +using Mapster; | ||
| 7 | +using Microsoft.AspNetCore.Mvc; | ||
| 8 | +using NCC.ClayObject; | ||
| 9 | +using NCC.Common.Configuration; | ||
| 10 | +using NCC.Common.Core.Manager; | ||
| 2 | using NCC.Common.Enum; | 11 | using NCC.Common.Enum; |
| 3 | using NCC.Common.Extension; | 12 | using NCC.Common.Extension; |
| 4 | using NCC.Common.Filter; | 13 | using NCC.Common.Filter; |
| 14 | +using NCC.Common.Helper; | ||
| 15 | +using NCC.Common.Model.NPOI; | ||
| 16 | +using NCC.DataEncryption; | ||
| 5 | using NCC.Dependency; | 17 | using NCC.Dependency; |
| 6 | using NCC.DynamicApiController; | 18 | using NCC.DynamicApiController; |
| 7 | -using NCC.FriendlyException; | ||
| 8 | -using NCC.Extend.Interfaces.LqYcsdJsj; | ||
| 9 | -using Mapster; | ||
| 10 | -using Microsoft.AspNetCore.Mvc; | ||
| 11 | -using SqlSugar; | ||
| 12 | -using System; | ||
| 13 | -using System.Collections.Generic; | ||
| 14 | -using System.Globalization; | ||
| 15 | -using System.Linq; | ||
| 16 | -using System.Threading.Tasks; | ||
| 17 | -using NCC.Extend.Entitys.lq_ycsd_jsj; | 19 | +using NCC.Extend.Entitys.Dto.LqYcsdJsj; |
| 18 | using NCC.Extend.Entitys.lq_jinsanjiao_user; | 20 | using NCC.Extend.Entitys.lq_jinsanjiao_user; |
| 19 | -using NCC.Extend.Entitys.lq_mdxx; | ||
| 20 | using NCC.Extend.Entitys.lq_kd_jksyj; | 21 | using NCC.Extend.Entitys.lq_kd_jksyj; |
| 21 | -using NCC.Extend.Entitys.Dto.LqYcsdJsj; | ||
| 22 | -using Yitter.IdGenerator; | ||
| 23 | -using NCC.Common.Helper; | 22 | +using NCC.Extend.Entitys.lq_mdxx; |
| 23 | +using NCC.Extend.Entitys.lq_ycsd_jsj; | ||
| 24 | +using NCC.Extend.Interfaces.LqYcsdJsj; | ||
| 25 | +using NCC.FriendlyException; | ||
| 24 | using NCC.JsonSerialization; | 26 | using NCC.JsonSerialization; |
| 25 | -using NCC.Common.Model.NPOI; | ||
| 26 | -using NCC.Common.Configuration; | ||
| 27 | -using NCC.DataEncryption; | ||
| 28 | -using NCC.ClayObject; | 27 | +using SqlSugar; |
| 28 | +using Yitter.IdGenerator; | ||
| 29 | 29 | ||
| 30 | namespace NCC.Extend.LqYcsdJsj | 30 | namespace NCC.Extend.LqYcsdJsj |
| 31 | { | 31 | { |
| @@ -43,7 +43,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -43,7 +43,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 43 | /// <summary> | 43 | /// <summary> |
| 44 | /// 初始化一个<see cref="LqYcsdJsjService"/>类型的新实例 | 44 | /// 初始化一个<see cref="LqYcsdJsjService"/>类型的新实例 |
| 45 | /// </summary> | 45 | /// </summary> |
| 46 | - public LqYcsdJsjService(ISqlSugarRepository<LqYcsdJsjEntity> lqYcsdJsjRepository,IUserManager userManager) | 46 | + public LqYcsdJsjService(ISqlSugarRepository<LqYcsdJsjEntity> lqYcsdJsjRepository, IUserManager userManager) |
| 47 | { | 47 | { |
| 48 | _lqYcsdJsjRepository = lqYcsdJsjRepository; | 48 | _lqYcsdJsjRepository = lqYcsdJsjRepository; |
| 49 | _db = _lqYcsdJsjRepository.Context; | 49 | _db = _lqYcsdJsjRepository.Context; |
| @@ -75,7 +75,8 @@ namespace NCC.Extend.LqYcsdJsj | @@ -75,7 +75,8 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 75 | public async Task<dynamic> GetDetail(string id) | 75 | public async Task<dynamic> GetDetail(string id) |
| 76 | { | 76 | { |
| 77 | var entity = await _db.Queryable<LqYcsdJsjEntity>().FirstAsync(p => p.Id == id); | 77 | var entity = await _db.Queryable<LqYcsdJsjEntity>().FirstAsync(p => p.Id == id); |
| 78 | - if (entity == null) throw NCCException.Oh(ErrorCode.COM1005); | 78 | + if (entity == null) |
| 79 | + throw NCCException.Oh(ErrorCode.COM1005); | ||
| 79 | 80 | ||
| 80 | var output = entity.Adapt<LqYcsdJsjInfoOutput>(); | 81 | var output = entity.Adapt<LqYcsdJsjInfoOutput>(); |
| 81 | 82 | ||
| @@ -90,24 +91,20 @@ namespace NCC.Extend.LqYcsdJsj | @@ -90,24 +91,20 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 90 | userName = x.UserName, | 91 | userName = x.UserName, |
| 91 | isLeader = x.IsLeader, | 92 | isLeader = x.IsLeader, |
| 92 | sortOrder = x.SortOrder, | 93 | sortOrder = x.SortOrder, |
| 93 | - status = x.Status | 94 | + status = x.Status, |
| 94 | }) | 95 | }) |
| 95 | .ToListAsync(); | 96 | .ToListAsync(); |
| 96 | 97 | ||
| 97 | - return new | ||
| 98 | - { | ||
| 99 | - jsj = output, | ||
| 100 | - members = members | ||
| 101 | - }; | 98 | + return new { jsj = output, members = members }; |
| 102 | } | 99 | } |
| 103 | #endregion | 100 | #endregion |
| 104 | 101 | ||
| 105 | #region 获取金三角设定列表 | 102 | #region 获取金三角设定列表 |
| 106 | /// <summary> | 103 | /// <summary> |
| 107 | - /// 获取金三角设定列表 | ||
| 108 | - /// </summary> | ||
| 109 | - /// <param name="input">请求参数</param> | ||
| 110 | - /// <returns></returns> | 104 | + /// 获取金三角设定列表 |
| 105 | + /// </summary> | ||
| 106 | + /// <param name="input">请求参数</param> | ||
| 107 | + /// <returns></returns> | ||
| 111 | [HttpGet("")] | 108 | [HttpGet("")] |
| 112 | public async Task<dynamic> GetList([FromQuery] LqYcsdJsjListQueryInput input) | 109 | public async Task<dynamic> GetList([FromQuery] LqYcsdJsjListQueryInput input) |
| 113 | { | 110 | { |
| @@ -122,8 +119,11 @@ namespace NCC.Extend.LqYcsdJsj | @@ -122,8 +119,11 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 122 | id = it.Id, | 119 | id = it.Id, |
| 123 | yf = it.Yf, | 120 | yf = it.Yf, |
| 124 | md = it.Md, | 121 | md = it.Md, |
| 125 | - jsj = it.Jsj | ||
| 126 | - }).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize); | 122 | + jsj = it.Jsj, |
| 123 | + }) | ||
| 124 | + .MergeTable() | ||
| 125 | + .OrderBy(sidx + " " + input.sort) | ||
| 126 | + .ToPagedListAsync(input.currentPage, input.pageSize); | ||
| 127 | return PageResult<LqYcsdJsjListOutput>.SqlSugarPageResult(data); | 127 | return PageResult<LqYcsdJsjListOutput>.SqlSugarPageResult(data); |
| 128 | } | 128 | } |
| 129 | #endregion | 129 | #endregion |
| @@ -143,8 +143,10 @@ namespace NCC.Extend.LqYcsdJsj | @@ -143,8 +143,10 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 143 | id = it.Id, | 143 | id = it.Id, |
| 144 | yf = it.Yf, | 144 | yf = it.Yf, |
| 145 | md = it.Md, | 145 | md = it.Md, |
| 146 | - jsj = it.Jsj | ||
| 147 | - }).MergeTable().ToListAsync(); | 146 | + jsj = it.Jsj, |
| 147 | + }) | ||
| 148 | + .MergeTable() | ||
| 149 | + .ToListAsync(); | ||
| 148 | return data; | 150 | return data; |
| 149 | } | 151 | } |
| 150 | #endregion | 152 | #endregion |
| @@ -168,15 +170,15 @@ namespace NCC.Extend.LqYcsdJsj | @@ -168,15 +170,15 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 168 | if (jsjUser == null) | 170 | if (jsjUser == null) |
| 169 | { | 171 | { |
| 170 | return null; | 172 | return null; |
| 171 | - } | 173 | + } |
| 172 | // 查询金三角信息 | 174 | // 查询金三角信息 |
| 173 | - var jsj = await _db.Queryable<LqYcsdJsjEntity>().Where(x => x.Id == jsjUser.JsjId && x.Yf == currentMonth).FirstAsync(); | 175 | + var jsj = await _db.Queryable<LqYcsdJsjEntity>().Where(x => x.Id == jsjUser.JsjId && x.Yf == currentMonth).FirstAsync(); |
| 174 | if (jsj == null) | 176 | if (jsj == null) |
| 175 | { | 177 | { |
| 176 | return null; | 178 | return null; |
| 177 | } | 179 | } |
| 178 | // 查询门店信息 | 180 | // 查询门店信息 |
| 179 | - var store = await _db.Queryable<LqMdxxEntity>() .Where(x => x.Id == jsj.Md).FirstAsync(); | 181 | + var store = await _db.Queryable<LqMdxxEntity>().Where(x => x.Id == jsj.Md).FirstAsync(); |
| 180 | return new | 182 | return new |
| 181 | { | 183 | { |
| 182 | jsjId = jsj.Id, | 184 | jsjId = jsj.Id, |
| @@ -187,7 +189,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -187,7 +189,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 187 | userName = jsjUser.UserName, | 189 | userName = jsjUser.UserName, |
| 188 | isLeader = jsjUser.IsLeader, | 190 | isLeader = jsjUser.IsLeader, |
| 189 | status = jsjUser.Status, | 191 | status = jsjUser.Status, |
| 190 | - sortOrder = jsjUser.SortOrder | 192 | + sortOrder = jsjUser.SortOrder, |
| 191 | }; | 193 | }; |
| 192 | } | 194 | } |
| 193 | #endregion | 195 | #endregion |
| @@ -228,9 +230,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -228,9 +230,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 228 | } | 230 | } |
| 229 | 231 | ||
| 230 | // 验证金三角名称是否已存在 | 232 | // 验证金三角名称是否已存在 |
| 231 | - var existingJsj = await _db.Queryable<LqYcsdJsjEntity>() | ||
| 232 | - .Where(x => x.Yf == input.yf && x.Md == input.md && x.Jsj == input.jsj) | ||
| 233 | - .FirstAsync(); | 233 | + var existingJsj = await _db.Queryable<LqYcsdJsjEntity>().Where(x => x.Yf == input.yf && x.Md == input.md && x.Jsj == input.jsj).FirstAsync(); |
| 234 | if (existingJsj != null) | 234 | if (existingJsj != null) |
| 235 | { | 235 | { |
| 236 | throw NCCException.Oh(ErrorCode.COM1000, "该门店该月份已存在同名金三角"); | 236 | throw NCCException.Oh(ErrorCode.COM1000, "该门店该月份已存在同名金三角"); |
| @@ -239,19 +239,18 @@ namespace NCC.Extend.LqYcsdJsj | @@ -239,19 +239,18 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 239 | { | 239 | { |
| 240 | // 开启事务 | 240 | // 开启事务 |
| 241 | _db.BeginTran(); | 241 | _db.BeginTran(); |
| 242 | - // 1. 创建门店T区(如果不存在) | ||
| 243 | - await CreateOrUpdateStoreTArea(input.yf, input.md, userInfo.userId); | ||
| 244 | - // 2. 创建金三角基础信息 | 242 | + // 1. 创建金三角基础信息 |
| 245 | var entity = input.Adapt<LqYcsdJsjEntity>(); | 243 | var entity = input.Adapt<LqYcsdJsjEntity>(); |
| 246 | entity.Id = YitIdHelper.NextId().ToString(); | 244 | entity.Id = YitIdHelper.NextId().ToString(); |
| 247 | var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); | 245 | var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); |
| 248 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000); | ||
| 249 | - // 3. 创建金三角成员绑定关系 | 246 | + if (!(isOk > 0)) |
| 247 | + throw NCCException.Oh(ErrorCode.COM1000); | ||
| 248 | + // 2 创建金三角成员绑定关系 | ||
| 250 | if (input.members != null && input.members.Count > 0) | 249 | if (input.members != null && input.members.Count > 0) |
| 251 | { | 250 | { |
| 252 | await CreateJsjMembers(entity.Id, input.members, userInfo.userId); | 251 | await CreateJsjMembers(entity.Id, input.members, userInfo.userId); |
| 253 | } | 252 | } |
| 254 | - // 4. 创建站点战队T区(如果金三角不是T区且不是单人) | 253 | + // 3. 创建站点战队T区(如果金三角不是T区且不是单人) |
| 255 | if (!input.jsj.EndsWith("T区") && input.members != null && input.members.Count > 1) | 254 | if (!input.jsj.EndsWith("T区") && input.members != null && input.members.Count > 1) |
| 256 | { | 255 | { |
| 257 | await CreateOrUpdateTeamTArea(input.yf, input.jsj, input.md, userInfo.userId); | 256 | await CreateOrUpdateTeamTArea(input.yf, input.jsj, input.md, userInfo.userId); |
| @@ -270,10 +269,10 @@ namespace NCC.Extend.LqYcsdJsj | @@ -270,10 +269,10 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 270 | 269 | ||
| 271 | #region 获取金三角设定无分页列表 | 270 | #region 获取金三角设定无分页列表 |
| 272 | /// <summary> | 271 | /// <summary> |
| 273 | - /// 获取金三角设定无分页列表 | ||
| 274 | - /// </summary> | ||
| 275 | - /// <param name="input">请求参数</param> | ||
| 276 | - /// <returns></returns> | 272 | + /// 获取金三角设定无分页列表 |
| 273 | + /// </summary> | ||
| 274 | + /// <param name="input">请求参数</param> | ||
| 275 | + /// <returns></returns> | ||
| 277 | [NonAction] | 276 | [NonAction] |
| 278 | public async Task<dynamic> GetNoPagingList([FromQuery] LqYcsdJsjListQueryInput input) | 277 | public async Task<dynamic> GetNoPagingList([FromQuery] LqYcsdJsjListQueryInput input) |
| 279 | { | 278 | { |
| @@ -288,18 +287,21 @@ namespace NCC.Extend.LqYcsdJsj | @@ -288,18 +287,21 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 288 | id = it.Id, | 287 | id = it.Id, |
| 289 | yf = it.Yf, | 288 | yf = it.Yf, |
| 290 | md = it.Md, | 289 | md = it.Md, |
| 291 | - jsj = it.Jsj | ||
| 292 | - }).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync(); | 290 | + jsj = it.Jsj, |
| 291 | + }) | ||
| 292 | + .MergeTable() | ||
| 293 | + .OrderBy(sidx + " " + input.sort) | ||
| 294 | + .ToListAsync(); | ||
| 293 | return data; | 295 | return data; |
| 294 | } | 296 | } |
| 295 | #endregion | 297 | #endregion |
| 296 | 298 | ||
| 297 | #region 导出金三角设定 | 299 | #region 导出金三角设定 |
| 298 | /// <summary> | 300 | /// <summary> |
| 299 | - /// 导出金三角设定 | ||
| 300 | - /// </summary> | ||
| 301 | - /// <param name="input">请求参数</param> | ||
| 302 | - /// <returns></returns> | 301 | + /// 导出金三角设定 |
| 302 | + /// </summary> | ||
| 303 | + /// <param name="input">请求参数</param> | ||
| 304 | + /// <returns></returns> | ||
| 303 | [HttpGet("Actions/Export")] | 305 | [HttpGet("Actions/Export")] |
| 304 | public async Task<dynamic> Export([FromQuery] LqYcsdJsjListQueryInput input) | 306 | public async Task<dynamic> Export([FromQuery] LqYcsdJsjListQueryInput input) |
| 305 | { | 307 | { |
| @@ -314,7 +316,8 @@ namespace NCC.Extend.LqYcsdJsj | @@ -314,7 +316,8 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 314 | { | 316 | { |
| 315 | exportData = await this.GetNoPagingList(input); | 317 | exportData = await this.GetNoPagingList(input); |
| 316 | } | 318 | } |
| 317 | - List<ParamsModel> paramList = "[{\"value\":\"主键\",\"field\":\"id\"},{\"value\":\"月份\",\"field\":\"yf\"},{\"value\":\"门店\",\"field\":\"md\"},{\"value\":\"金三角\",\"field\":\"jsj\"}]".ToList<ParamsModel>(); | 319 | + List<ParamsModel> paramList = |
| 320 | + "[{\"value\":\"主键\",\"field\":\"id\"},{\"value\":\"月份\",\"field\":\"yf\"},{\"value\":\"门店\",\"field\":\"md\"},{\"value\":\"金三角\",\"field\":\"jsj\"}]".ToList<ParamsModel>(); | ||
| 318 | ExcelConfig excelconfig = new ExcelConfig(); | 321 | ExcelConfig excelconfig = new ExcelConfig(); |
| 319 | excelconfig.FileName = "金三角设定.xls"; | 322 | excelconfig.FileName = "金三角设定.xls"; |
| 320 | excelconfig.HeadFont = "微软雅黑"; | 323 | excelconfig.HeadFont = "微软雅黑"; |
| @@ -333,11 +336,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -333,11 +336,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 333 | var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName; | 336 | var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName; |
| 334 | ExcelExportHelper<LqYcsdJsjListOutput>.Export(exportData, excelconfig, addPath); | 337 | ExcelExportHelper<LqYcsdJsjListOutput>.Export(exportData, excelconfig, addPath); |
| 335 | var fileName = _userManager.UserId + "|" + addPath + "|xls"; | 338 | var fileName = _userManager.UserId + "|" + addPath + "|xls"; |
| 336 | - var output = new | ||
| 337 | - { | ||
| 338 | - name = excelconfig.FileName, | ||
| 339 | - url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") | ||
| 340 | - }; | 339 | + var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") }; |
| 341 | return output; | 340 | return output; |
| 342 | } | 341 | } |
| 343 | #endregion | 342 | #endregion |
| @@ -385,10 +384,11 @@ namespace NCC.Extend.LqYcsdJsj | @@ -385,10 +384,11 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 385 | { | 384 | { |
| 386 | var entity = input.Adapt<LqYcsdJsjEntity>(); | 385 | var entity = input.Adapt<LqYcsdJsjEntity>(); |
| 387 | var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); | 386 | var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); |
| 388 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001); | 387 | + if (!(isOk > 0)) |
| 388 | + throw NCCException.Oh(ErrorCode.COM1001); | ||
| 389 | } | 389 | } |
| 390 | #endregion | 390 | #endregion |
| 391 | - | 391 | + |
| 392 | #region 删除金三角设定 | 392 | #region 删除金三角设定 |
| 393 | /// <summary> | 393 | /// <summary> |
| 394 | /// 删除金三角设定 | 394 | /// 删除金三角设定 |
| @@ -400,7 +400,8 @@ namespace NCC.Extend.LqYcsdJsj | @@ -400,7 +400,8 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 400 | var entity = await _db.Queryable<LqYcsdJsjEntity>().FirstAsync(p => p.Id == id); | 400 | var entity = await _db.Queryable<LqYcsdJsjEntity>().FirstAsync(p => p.Id == id); |
| 401 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); | 401 | _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005); |
| 402 | var isOk = await _db.Deleteable<LqYcsdJsjEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); | 402 | var isOk = await _db.Deleteable<LqYcsdJsjEntity>().Where(d => d.Id == id).ExecuteCommandAsync(); |
| 403 | - if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002); | 403 | + if (!(isOk > 0)) |
| 404 | + throw NCCException.Oh(ErrorCode.COM1002); | ||
| 404 | } | 405 | } |
| 405 | #endregion | 406 | #endregion |
| 406 | 407 | ||
| @@ -424,20 +425,33 @@ namespace NCC.Extend.LqYcsdJsj | @@ -424,20 +425,33 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 424 | .WhereIF(!string.IsNullOrEmpty(month), (jsj, jksyj, md) => jsj.Yf == month) | 425 | .WhereIF(!string.IsNullOrEmpty(month), (jsj, jksyj, md) => jsj.Yf == month) |
| 425 | .WhereIF(!string.IsNullOrEmpty(jsjId), (jsj, jksyj, md) => jsj.Id == jsjId) | 426 | .WhereIF(!string.IsNullOrEmpty(jsjId), (jsj, jksyj, md) => jsj.Id == jsjId) |
| 426 | .WhereIF(!string.IsNullOrEmpty(storeId), (jsj, jksyj, md) => jsj.Md == storeId) | 427 | .WhereIF(!string.IsNullOrEmpty(storeId), (jsj, jksyj, md) => jsj.Md == storeId) |
| 427 | - .GroupBy((jsj, jksyj, md) => new { jsj.Id, jsj.Jsj, jsj.Yf, jsj.Md, md.Dm }) | ||
| 428 | - .Select((jsj, jksyj, md) => new | ||
| 429 | - { | ||
| 430 | - jsjId = jsj.Id, | ||
| 431 | - jsjName = jsj.Jsj, | ||
| 432 | - month = jsj.Yf, | ||
| 433 | - storeId = jsj.Md, | ||
| 434 | - storeName = md.Dm, | ||
| 435 | - totalPerformance = SqlFunc.AggregateSum(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 436 | - orderCount = SqlFunc.AggregateCount(jksyj.Id), | ||
| 437 | - avgPerformance = SqlFunc.AggregateAvg(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 438 | - lastOrderDate = SqlFunc.AggregateMax(jksyj.Yjsj), | ||
| 439 | - firstOrderDate = SqlFunc.AggregateMin(jksyj.Yjsj) | ||
| 440 | - }) | 428 | + .GroupBy( |
| 429 | + (jsj, jksyj, md) => | ||
| 430 | + new | ||
| 431 | + { | ||
| 432 | + jsj.Id, | ||
| 433 | + jsj.Jsj, | ||
| 434 | + jsj.Yf, | ||
| 435 | + jsj.Md, | ||
| 436 | + md.Dm, | ||
| 437 | + } | ||
| 438 | + ) | ||
| 439 | + .Select( | ||
| 440 | + (jsj, jksyj, md) => | ||
| 441 | + new | ||
| 442 | + { | ||
| 443 | + jsjId = jsj.Id, | ||
| 444 | + jsjName = jsj.Jsj, | ||
| 445 | + month = jsj.Yf, | ||
| 446 | + storeId = jsj.Md, | ||
| 447 | + storeName = md.Dm, | ||
| 448 | + totalPerformance = SqlFunc.AggregateSum(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 449 | + orderCount = SqlFunc.AggregateCount(jksyj.Id), | ||
| 450 | + avgPerformance = SqlFunc.AggregateAvg(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 451 | + lastOrderDate = SqlFunc.AggregateMax(jksyj.Yjsj), | ||
| 452 | + firstOrderDate = SqlFunc.AggregateMin(jksyj.Yjsj), | ||
| 453 | + } | ||
| 454 | + ) | ||
| 441 | .OrderBy(jsj => jsj.month, OrderByType.Desc) | 455 | .OrderBy(jsj => jsj.month, OrderByType.Desc) |
| 442 | .OrderBy(jsj => jsj.totalPerformance, OrderByType.Desc); | 456 | .OrderBy(jsj => jsj.totalPerformance, OrderByType.Desc); |
| 443 | 457 | ||
| @@ -465,35 +479,53 @@ namespace NCC.Extend.LqYcsdJsj | @@ -465,35 +479,53 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 465 | .Where((jsj, jksyj, md) => jsj.Yf == month) | 479 | .Where((jsj, jksyj, md) => jsj.Yf == month) |
| 466 | .Where((jsj, jksyj, md) => jksyj.Yjsj != null) | 480 | .Where((jsj, jksyj, md) => jksyj.Yjsj != null) |
| 467 | .Where((jsj, jksyj, md) => jksyj.Jksyj != null && jksyj.Jksyj != "" && jksyj.Jksyj != "0") | 481 | .Where((jsj, jksyj, md) => jksyj.Jksyj != null && jksyj.Jksyj != "" && jksyj.Jksyj != "0") |
| 468 | - .GroupBy((jsj, jksyj, md) => new { jsj.Id, jsj.Jsj, jsj.Yf, jsj.Md, md.Dm }) | ||
| 469 | - .Select((jsj, jksyj, md) => new | ||
| 470 | - { | ||
| 471 | - jsjId = jsj.Id, | ||
| 472 | - jsjName = jsj.Jsj, | ||
| 473 | - month = jsj.Yf, | ||
| 474 | - storeId = jsj.Md, | ||
| 475 | - storeName = md.Dm, | ||
| 476 | - totalPerformance = SqlFunc.AggregateSum(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 477 | - orderCount = SqlFunc.AggregateCount(jksyj.Id), | ||
| 478 | - ranking = 0 // 排名将在后续计算 | ||
| 479 | - }) | 482 | + .GroupBy( |
| 483 | + (jsj, jksyj, md) => | ||
| 484 | + new | ||
| 485 | + { | ||
| 486 | + jsj.Id, | ||
| 487 | + jsj.Jsj, | ||
| 488 | + jsj.Yf, | ||
| 489 | + jsj.Md, | ||
| 490 | + md.Dm, | ||
| 491 | + } | ||
| 492 | + ) | ||
| 493 | + .Select( | ||
| 494 | + (jsj, jksyj, md) => | ||
| 495 | + new | ||
| 496 | + { | ||
| 497 | + jsjId = jsj.Id, | ||
| 498 | + jsjName = jsj.Jsj, | ||
| 499 | + month = jsj.Yf, | ||
| 500 | + storeId = jsj.Md, | ||
| 501 | + storeName = md.Dm, | ||
| 502 | + totalPerformance = SqlFunc.AggregateSum(SqlFunc.ToDecimal(jksyj.Jksyj)), | ||
| 503 | + orderCount = SqlFunc.AggregateCount(jksyj.Id), | ||
| 504 | + ranking = 0, // 排名将在后续计算 | ||
| 505 | + } | ||
| 506 | + ) | ||
| 480 | .OrderBy(jsj => jsj.totalPerformance, OrderByType.Desc) | 507 | .OrderBy(jsj => jsj.totalPerformance, OrderByType.Desc) |
| 481 | .Take(topCount); | 508 | .Take(topCount); |
| 482 | 509 | ||
| 483 | var result = await query.ToListAsync(); | 510 | var result = await query.ToListAsync(); |
| 484 | - | 511 | + |
| 485 | // 创建包含排名的结果 | 512 | // 创建包含排名的结果 |
| 486 | - var rankedResult = result.Select((item, index) => new | ||
| 487 | - { | ||
| 488 | - item.jsjId, | ||
| 489 | - item.jsjName, | ||
| 490 | - item.month, | ||
| 491 | - item.storeId, | ||
| 492 | - item.storeName, | ||
| 493 | - item.totalPerformance, | ||
| 494 | - item.orderCount, | ||
| 495 | - ranking = index + 1 | ||
| 496 | - }).ToList(); | 513 | + var rankedResult = result |
| 514 | + .Select( | ||
| 515 | + (item, index) => | ||
| 516 | + new | ||
| 517 | + { | ||
| 518 | + item.jsjId, | ||
| 519 | + item.jsjName, | ||
| 520 | + item.month, | ||
| 521 | + item.storeId, | ||
| 522 | + item.storeName, | ||
| 523 | + item.totalPerformance, | ||
| 524 | + item.orderCount, | ||
| 525 | + ranking = index + 1, | ||
| 526 | + } | ||
| 527 | + ) | ||
| 528 | + .ToList(); | ||
| 497 | 529 | ||
| 498 | return rankedResult; | 530 | return rankedResult; |
| 499 | } | 531 | } |
| @@ -515,9 +547,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -515,9 +547,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 515 | var tAreaName = $"{storeName}T区"; | 547 | var tAreaName = $"{storeName}T区"; |
| 516 | 548 | ||
| 517 | // 检查该门店该月份是否已有T区 | 549 | // 检查该门店该月份是否已有T区 |
| 518 | - var existingTArea = await _db.Queryable<LqYcsdJsjEntity>() | ||
| 519 | - .Where(x => x.Yf == yf && x.Md == mdId && x.Jsj == tAreaName) | ||
| 520 | - .FirstAsync(); | 550 | + var existingTArea = await _db.Queryable<LqYcsdJsjEntity>().Where(x => x.Yf == yf && x.Md == mdId && x.Jsj == tAreaName).FirstAsync(); |
| 521 | 551 | ||
| 522 | if (existingTArea == null) | 552 | if (existingTArea == null) |
| 523 | { | 553 | { |
| @@ -527,7 +557,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -527,7 +557,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 527 | Id = YitIdHelper.NextId().ToString(), | 557 | Id = YitIdHelper.NextId().ToString(), |
| 528 | Yf = yf, | 558 | Yf = yf, |
| 529 | Md = mdId, | 559 | Md = mdId, |
| 530 | - Jsj = tAreaName | 560 | + Jsj = tAreaName, |
| 531 | }; | 561 | }; |
| 532 | 562 | ||
| 533 | await _db.Insertable(tAreaEntity).ExecuteCommandAsync(); | 563 | await _db.Insertable(tAreaEntity).ExecuteCommandAsync(); |
| @@ -547,9 +577,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -547,9 +577,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 547 | var tAreaName = $"{teamName}T区"; | 577 | var tAreaName = $"{teamName}T区"; |
| 548 | 578 | ||
| 549 | // 检查该战队该月份是否已有T区 | 579 | // 检查该战队该月份是否已有T区 |
| 550 | - var existingTArea = await _db.Queryable<LqYcsdJsjEntity>() | ||
| 551 | - .Where(x => x.Yf == yf && x.Md == mdId && x.Jsj == tAreaName) | ||
| 552 | - .FirstAsync(); | 580 | + var existingTArea = await _db.Queryable<LqYcsdJsjEntity>().Where(x => x.Yf == yf && x.Md == mdId && x.Jsj == tAreaName).FirstAsync(); |
| 553 | 581 | ||
| 554 | if (existingTArea == null) | 582 | if (existingTArea == null) |
| 555 | { | 583 | { |
| @@ -559,7 +587,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -559,7 +587,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 559 | Id = YitIdHelper.NextId().ToString(), | 587 | Id = YitIdHelper.NextId().ToString(), |
| 560 | Yf = yf, | 588 | Yf = yf, |
| 561 | Md = mdId, | 589 | Md = mdId, |
| 562 | - Jsj = tAreaName | 590 | + Jsj = tAreaName, |
| 563 | }; | 591 | }; |
| 564 | 592 | ||
| 565 | await _db.Insertable(tAreaEntity).ExecuteCommandAsync(); | 593 | await _db.Insertable(tAreaEntity).ExecuteCommandAsync(); |
| @@ -592,7 +620,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -592,7 +620,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 592 | CreatorTime = DateTime.Now, | 620 | CreatorTime = DateTime.Now, |
| 593 | CreatorUserId = creatorUserId, | 621 | CreatorUserId = creatorUserId, |
| 594 | DeleteMark = 0, | 622 | DeleteMark = 0, |
| 595 | - Month = DateTime.Now.ToString("yyyyMM") | 623 | + Month = DateTime.Now.ToString("yyyyMM"), |
| 596 | }; | 624 | }; |
| 597 | 625 | ||
| 598 | memberEntities.Add(memberEntity); | 626 | memberEntities.Add(memberEntity); |
| @@ -613,10 +641,7 @@ namespace NCC.Extend.LqYcsdJsj | @@ -613,10 +641,7 @@ namespace NCC.Extend.LqYcsdJsj | ||
| 613 | { | 641 | { |
| 614 | try | 642 | try |
| 615 | { | 643 | { |
| 616 | - var storeName = await _db.Queryable<LqMdxxEntity>() | ||
| 617 | - .Where(x => x.Id == mdId) | ||
| 618 | - .Select(x => x.Dm) | ||
| 619 | - .FirstAsync(); | 644 | + var storeName = await _db.Queryable<LqMdxxEntity>().Where(x => x.Id == mdId).Select(x => x.Dm).FirstAsync(); |
| 620 | return string.IsNullOrEmpty(storeName) ? "未知门店" : storeName; | 645 | return string.IsNullOrEmpty(storeName) ? "未知门店" : storeName; |
| 621 | } | 646 | } |
| 622 | catch | 647 | catch |