Browse Source

1、团组操作默认添加/修改收款账单

LEIYI 6 months ago
parent
commit
5a112ad044

+ 128 - 3
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -17,11 +17,13 @@ using OASystem.API.OAMethodLib.JuHeAPI;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Dtos.FileDto;
+using OASystem.Domain.Dtos.Financial;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Financial;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
+using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
 using Quartz.Util;
 using SqlSugar.Extensions;
@@ -89,6 +91,7 @@ namespace OASystem.API.Controllers
         private readonly FeeAuditRepository _feeAuditRep;
 
         private readonly VisaCommissionRepository _visaCommissionRep;
+        private readonly ForeignReceivablesRepository _ffrRep;  //对外收款账单仓库
 
         public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
             TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
@@ -98,7 +101,7 @@ namespace OASystem.API.Controllers
             GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
             TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
             InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
-            ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep)
+            ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep, ForeignReceivablesRepository ffrRep)
         {
             _logger = logger;
             _mapper = mapper;
@@ -140,6 +143,7 @@ namespace OASystem.API.Controllers
             _threeCodeRepository = threeCodeRepository;
             _feeAuditRep = feeAuditRep;
             _visaCommissionRep = visaCommissionRep;
+            _ffrRep = ffrRep;
         }
 
         #region 流程管控
@@ -577,6 +581,18 @@ namespace OASystem.API.Controllers
         {
             try
             {
+                decimal ffrPrice = 0.00M;
+                DateTime? visitDt = null;
+                if (dto.Status == 2)
+                {
+                    var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
+                    if (groupInfo != null)
+                    {
+                        ffrPrice = groupInfo.PaymentMoney;
+                        visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
+                    }
+                }
+
                 var groupData = await _groupRepository.GroupOperation(dto);
                 if (groupData.Code != 0)
                 {
@@ -616,12 +632,60 @@ namespace OASystem.API.Controllers
 
                     //默认创建倒推表
                     await _invertedListRep._Create(dto.UserId, diId);
+
                 }
                 else if (dto.Status == 2)
                 {
                     diId = dto.Id;
                 }
 
+                #region 团组操作默认添加/修改收款账单
+                if (dto.PayDay > 0 && dto.PaymentMoney > 0)
+                {
+                    var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
+                                                 .Where(x => x.IsDel == 0 &&
+                                                              x.Diid == diId &&
+                                                              x.Remark.Equals("预付款")
+                                                              )
+                                                 .WhereIF(ffrPrice > 0 , x => x.ItemSumPrice == ffrPrice)
+                                                 .WhereIF(visitDt != null, x=> x.CreateTime == visitDt)
+                                                 .FirstAsync();
+
+                    ffrInfo.Diid = diId;
+                    ffrInfo.PriceName = dto.ClientUnit;
+                    ffrInfo.Price = dto.PaymentMoney;
+                    ffrInfo.Count = 1;
+                    ffrInfo.Unit = $"元";
+                    ffrInfo.ItemSumPrice = dto.PaymentMoney;
+                    ffrInfo.Rate = 1.0000M;
+                    ffrInfo.Currency = 836;
+                    ffrInfo.AddingWay = 0;
+                    ffrInfo.CreateUserId = dto.UserId;
+                    ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
+                    ffrInfo.Remark = $"预付款";
+
+                    if (ffrInfo == null) //Add
+                    {
+                        await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
+                    }
+                    else //修改
+                    {
+                        await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
+                                       .UpdateColumns(x => new
+                                       {
+                                           x.PriceName,
+                                           x.Price,
+                                           x.ItemSumPrice,
+                                           x.CreateTime,
+                                           x.CreateUserId
+                                       })
+                                       .WhereColumns(x => x.Id)
+                                       .ExecuteCommandAsync();
+                    }
+                }
+
+                #endregion
+
                 return Ok(JsonView(true, "操作成功!", diId));
             }
             catch (Exception ex)
@@ -658,8 +722,20 @@ namespace OASystem.API.Controllers
 
                 #endregion
 
-
                 _sqlSugar.BeginTran();
+
+                decimal ffrPrice = 0.00M;
+                DateTime? visitDt = null;
+                if (dto.Status == 2)
+                {
+                    var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
+                    if (groupInfo != null)
+                    {
+                        ffrPrice = groupInfo.PaymentMoney;
+                        visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
+                    }
+                }
+
                 var _dto = new GroupOperationDto();
                 _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
                 var groupData = await _groupRepository.GroupOperation(_dto);
@@ -698,8 +774,10 @@ namespace OASystem.API.Controllers
                         string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
                         await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
                     }
-                }
 
+                    //默认创建倒推表
+                    await _invertedListRep._Create(dto.UserId, diId);
+                }
 
                 if (dto.Status == 2)
                 {
@@ -719,6 +797,53 @@ namespace OASystem.API.Controllers
                 }
 
 
+                #region 团组操作默认添加/修改收款账单
+                if (dto.PayDay > 0 && dto.PaymentMoney > 0)
+                {
+                    var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
+                                                 .Where(x => x.IsDel == 0 &&
+                                                              x.Diid == diId &&
+                                                              x.Remark.Equals("预付款")
+                                                              )
+                                                 .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
+                                                 .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
+                                                 .FirstAsync();
+
+                    ffrInfo.Diid = diId;
+                    ffrInfo.PriceName = dto.ClientUnit;
+                    ffrInfo.Price = dto.PaymentMoney;
+                    ffrInfo.Count = 1;
+                    ffrInfo.Unit = $"元";
+                    ffrInfo.ItemSumPrice = dto.PaymentMoney;
+                    ffrInfo.Rate = 1.0000M;
+                    ffrInfo.Currency = 836;
+                    ffrInfo.AddingWay = 0;
+                    ffrInfo.CreateUserId = dto.UserId;
+                    ffrInfo.CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay);
+                    ffrInfo.Remark = $"预付款";
+
+                    if (ffrInfo == null) //Add
+                    {
+                        await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
+                    }
+                    else //修改
+                    {
+                        await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
+                                       .UpdateColumns(x => new
+                                       {
+                                           x.PriceName,
+                                           x.Price,
+                                           x.ItemSumPrice,
+                                           x.CreateTime,
+                                           x.CreateUserId
+                                       })
+                                       .WhereColumns(x => x.Id)
+                                       .ExecuteCommandAsync();
+                    }
+                }
+
+                #endregion
+
                 _sqlSugar.CommitTran();
                 return Ok(JsonView(true, "添加成功"));
             }

+ 1 - 1
OASystem/OASystem.Domain/Dtos/Financial/ForForeignReceivablesNewDto.cs

@@ -91,7 +91,7 @@ namespace OASystem.Domain.Dtos.Financial
 
         /// <summary>
         /// 添加方式   
-        /// 0 - 账单页面添加   1 - 预算成本页面添加
+        /// 0 - 账单模块 1 - 成本预算模块 2 - 实际报价
         /// </summary>
         public int AddingWay { get; set; }