123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Abp.Collections.Extensions;
- using Hotline.Snapshot;
- using Mapster;
- using Newtonsoft.Json.Linq;
- using SnapshotWinFormsApp.Application.Dtos;
- using SnapshotWinFormsApp.Application.Interfaces;
- using SnapshotWinFormsApp.Entities.NewHotline;
- using SnapshotWinFormsApp.Entities.OldHotline;
- using SnapshotWinFormsApp.Repository;
- using SnapshotWinFormsApp.Repository.Interfaces;
- using SqlSugar;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Linq.Dynamic.Core.Tokenizer;
- using System.Text;
- using System.Threading.Tasks;
- namespace SnapshotWinFormsApp.Application;
- [Description("邀请码记录")]
- public class InviteLogApplication : ImportApplicationBase<SSP_InviteLogEntity, InviteCodeRecord, OldInviteLogEntity>, IImportApplication
- {
- private readonly ITargetRepository<InviteCode> _newInviteCodeRepo;
- private readonly ITargetRepository<Citizen> _userInfoRepo;
- private readonly ITargetRepository<ThirdAccount> _thirdAccountRepo;
- private IList<InviteCode> invities;
- private IList<ThirdAccount> thirdAccounts;
- public IList<InviteCodeRecord> InviteCodeRecords;
- public InviteLogApplication(CreateInstanceInDto inDto) : base(inDto)
- {
- _newInviteCodeRepo = new TargetRepository<InviteCode>(inDto);
- _thirdAccountRepo = new TargetRepository<ThirdAccount>(inDto);
- invities = _newInviteCodeRepo.GetAll();
- thirdAccounts = _thirdAccountRepo.GetAll();
- InviteCodeRecords = _targetRepo.GetAll();
- }
- public override ISugarQueryable<OldInviteLogEntity> GetSourceList(string key = "")
- {
- return _sourceRepo.Queryable()
- .LeftJoin<SSP_InviteEntity>((log, invite) => log.SSPI_CodeID == invite.Id)
- .LeftJoin<WeChatUserEntity>((log, invite, user) => user.WUR_Openid == log.SSPI_Openid)
- .Select((log, invite, user) => new OldInviteLogEntity
- {
- Id = log.Id,
- Name = user.WUR_WebUserName,
- OrgName = invite.SIC_BMName,
- InviteCode = log.SSPI_Code,
- WXOpenId = log.SSPI_Openid,
- PhoneNumber = user.WUR_PhoneNum,
- CreationTime = log.SSPI_AddTime
- });
- }
- public override async Task<bool> HasOldDataAsync(OldInviteLogEntity item, CancellationToken token)
- {
- return InviteCodeRecords.Any(m => m.OldId == item.Id);
- }
- public override async Task<InviteCodeRecord> GetTargetAsync(OldInviteLogEntity source, CancellationToken token)
- {
- var target = source.Adapt<InviteCodeRecord>();
- target.OrgId = invities.FirstOrDefault(m => m.OrgName == source.OrgName)?.Id ?? string.Empty;
- return await Task.FromResult(target);
- }
- }
|