using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using XYY.Core.Standard.Data.Infrastructure; using XYY.Model.Standard.Enums; using XYY.Model.Standard.Finance; using Dapper; using System.Security.Policy; namespace XYY.Data.Standard.Finance { public interface ILogistics_ExpressSettlementAdjustmentRepository : IBaseRepository { Task>> ExpressSettlementAdjustmentLog(Logistics_ExpressSettlementAdjustmentDto adjustmentDto); } public class Logistics_ExpressSettlementAdjustmentRepository : BaseRepository, ILogistics_ExpressSettlementAdjustmentRepository { public Logistics_ExpressSettlementAdjustmentRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { } public async Task>> ExpressSettlementAdjustmentLog(Logistics_ExpressSettlementAdjustmentDto adjustmentDto) { List> msgs = new List>(); List zones = adjustmentDto.Details.SelectMany(x => x.Zone.Split(",")).ToList(); List details = new List(); string dec = string.Empty; foreach (var item in zones) { string msg = $"分区[{item}],"; var tempdata = adjustmentDto.Details.Where(x => x.Zone.Contains(item)).FirstOrDefault(); string content = $"{tempdata.Mode.GetName()}:{tempdata.Value};"; dec += msg + content; msgs.Add(Tuple.Create(item, msg + content)); Logistics_ExpressSettlementAdjustmentDetail detail = new Logistics_ExpressSettlementAdjustmentDetail() { Zone = item, IsAll =item== "全部"?true:false, Mode = tempdata.Mode, Value = tempdata.Value, }; details.Add(detail); } Logistics_ExpressSettlementAdjustment expressSettlementAdjustment = new Logistics_ExpressSettlementAdjustment() { CustomerId = $",{string.Join(",", adjustmentDto.CustomerId)},", ExpressId = adjustmentDto.ExpressId, AdjTime = DateTime.Now, SettlementAdjustmentContent = dec, }; int Id = (int)(await _unitOfWork.InsertAsync(expressSettlementAdjustment)); details.ForEach(x => x.AdjustmentId = Id); await _unitOfWork.BulkToDBAsync(details); return msgs; } } }