Переглянути джерело

新增商邀费用操作接口

wangh 1 рік тому
батько
коміт
47e66a1561

+ 25 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -1738,7 +1738,7 @@ namespace OASystem.API.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)] 
         public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
         {
             try
@@ -1756,6 +1756,30 @@ namespace OASystem.API.Controllers
                 throw;
             }
         }
+        /// <summary>
+        /// 商邀费用录入操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
+        {
+            try
+            {
+                Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto);
+                if (groupData.Code != 0)
+                { 
+                    return Ok(JsonView(false, groupData.Msg));
+                }
+                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
 
 
         #endregion

+ 4 - 0
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -88,6 +88,10 @@ namespace OASystem.Domain.AutoMappers
             #region 团组增减款项
             CreateMap<DecreasePaymentsOpDto, Grp_DecreasePayments>();
             #endregion
+            #region 商邀费用
+            CreateMap<OpInvitationOfficialActivitiesDto, Grp_InvitationOfficialActivities>();
+            CreateMap<OpInvitationOfficialActivitiesDto,Res_InvitationOfficialActivityData>();
+            #endregion
 
             #endregion
 

+ 3 - 0
OASystem/OASystem.Domain/Dtos/Groups/DecreasePaymentsDto.cs

@@ -29,6 +29,9 @@ namespace OASystem.Domain.Dtos.Groups
         /// 2 修改 
         /// </summary>
         public int Status { get; set; }
+        /// <summary>
+        /// 支付方式
+        /// </summary>
         public int PayDId { get; set; }
         /// <summary>
         /// 费用表示

+ 122 - 0
OASystem/OASystem.Domain/Dtos/Groups/InvitationOfficialActivitiesListDto.cs

@@ -23,4 +23,126 @@ namespace OASystem.Domain.Dtos.Groups
     {
         public int Id { get; set; }
     }
+    /// <summary>
+    /// 操作参数
+    /// </summary>
+    public class OpInvitationOfficialActivitiesDto
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+
+        //-------------------C表参数---------------------------------
+
+        /// <summary>
+        /// 支付方式
+        /// </summary>
+        public int PayDId { get; set; }
+        /// <summary>
+        /// 费用表示
+        /// </summary>
+        public int OrbitalPrivateTransfer { get; set; }
+        /// <summary>
+        /// 收款方
+        /// </summary>
+        public string Payee { get; set; }
+        //---------------------商邀参数--------------------------
+        /// <summary>
+        /// 主键Id
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        /// 团组外键编号
+        /// </summary>
+        public int DiId { get; set; }
+
+        /// <summary>
+        /// 邀请方地区
+        /// </summary>
+        public string InviterArea { get; set; }
+
+        /// <summary>
+        /// 邀请方
+        /// </summary>
+        public string Inviter { get; set; }
+
+        /// <summary>
+        /// 邀请时间
+        /// </summary>
+        public DateTime InviteTime { get; set; }
+
+        /// <summary>
+        /// 附件
+        /// </summary>
+        public string Attachment { get; set; }
+
+        /// <summary>
+        /// 邀请费用
+        /// </summary>
+        public decimal InviteCosts { get; set; }
+
+        /// <summary>
+        /// 币种
+        /// </summary>
+        public int Currency { get; set; }
+
+        /// <summary>
+        /// 快递费用
+        /// </summary>
+        public decimal SendCost { get; set; }
+
+        /// <summary>
+        /// 公务标识
+        /// </summary>
+        public int IsGoOfficaiaBussiness { get; set; }
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+        //-----------------------邀请方资料-----------------------------
+        public int DataId { get; set; }
+        /// <summary>
+        /// 邀请方国家
+        /// </summary>
+        public string Country { get; set; }
+        /// <summary>
+        /// 邀请方名称
+        /// </summary>
+        public string UnitName { get; set; }
+        /// <summary>
+        /// 邀请方地址
+        /// </summary>
+        public string Address { get; set; }
+        /// <summary>
+        /// 联系人
+        /// </summary>
+        public string Contact { get; set; }
+        /// <summary>
+        /// 职务
+        /// </summary>
+        public string Job { get; set; }
+        /// <summary>
+        /// 联系电话
+        /// </summary>
+        public string Tel { get; set; }
+        /// <summary>
+        /// 电子邮箱
+        /// </summary>
+        public string Email { get; set; }
+        /// <summary>
+        /// 其他信息
+        /// </summary>
+        public string OtherInformation { get; set; }
+        /// <summary>
+        /// 传真号码
+        /// </summary>
+        public string Fax { get; set; }
+    }
 }

+ 1 - 0
OASystem/OASystem.Domain/Entities/Groups/Grp_InvitationOfficialActivities.cs

@@ -63,6 +63,7 @@ namespace OASystem.Domain.Entities.Groups
         /// <summary>
         /// 公务标识
         /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int IsGoOfficaiaBussiness { get; set; }
     }
 }

+ 1 - 4
OASystem/OASystem.Infrastructure/Repositories/Groups/AirTicketResRepository.cs

@@ -465,10 +465,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         PriceDescription = dto.AirTicketResOpData.PriceDescription,
                         Remark = dto.AirTicketResOpData.Remark,
                     });
-                    if (!res)
-                    {
-                        result = new Result() { Code = -1, Msg = "修改失败!" };
-                    }
+                    if (!res){result = new Result() { Code = -1, Msg = "修改失败!" }; }
                     else { result = new Result() { Code = 0, Msg = "修改成功!" }; }
 
                     if (result.Code == 0)

+ 1 - 1
OASystem/OASystem.Infrastructure/Repositories/Groups/DecreasePaymentsRepository.cs

@@ -173,7 +173,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                             //C.RMBPrice = 0.00f;
 
                             //设置该团组的汇率
-                            Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Decrease.DiId && a.IsDel == 0 && a.CTable == 85);
+                            Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Decrease.DiId && a.IsDel == 0 && a.CTable == 98);
                             if (_TeamRate != null)
                             {
                                 if (grp_Decrease.Currency == 49)

+ 298 - 4
OASystem/OASystem.Infrastructure/Repositories/Groups/InvitationOfficialActivitiesRepository.cs

@@ -1,7 +1,10 @@
 using AutoMapper;
+using MathNet.Numerics.Statistics.Mcmc;
+using NPOI.SS.Formula.Functions;
 using OASystem.Domain;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Groups;
 using System;
 using System.Collections.Generic;
@@ -19,7 +22,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             this._mapper = mapper;
         }
-
+        /// <summary>
+        /// 根据商邀费用Id查询C表和商邀资料及费用表
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         public async Task<Result> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "程序错误" };
@@ -27,9 +34,15 @@ namespace OASystem.Infrastructure.Repositories.Groups
             {
                 Grp_InvitationOfficialActivities grp_Invitation = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().First(a => a.Id == dto.Id && a.IsDel == 0);
                 Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0);
+                Res_InvitationOfficialActivityData res_InvitationOfficialActivityData = new Res_InvitationOfficialActivityData();
+                if (grp_Invitation!=null)
+                {
+                    res_InvitationOfficialActivityData = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().First(a =>a.Country==grp_Invitation.InviterArea && a.UnitName==grp_Invitation.Inviter && a.IsDel == 0);
+                }
                 var data = new
                 {
                     _Invitation = grp_Invitation,
+                    _InvitationData = res_InvitationOfficialActivityData,
                     _CreditCard = grp_CreditCard,
                 };
                 result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
@@ -41,7 +54,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
             return result;
         }
-
+        /// <summary>
+        /// 根据团组id查询商邀费用数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         public async Task<Result> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
@@ -54,9 +71,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 }
                 if (!string.IsNullOrWhiteSpace(dto.StartInviteTime) && !string.IsNullOrWhiteSpace(dto.EndInviteTime))
                 {
-                    sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime,dto.EndInviteTime);
+                    sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime, dto.EndInviteTime);
                 }
-                sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}",dto.DiId,0);
+                sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}", dto.DiId, 0);
 
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
@@ -82,5 +99,282 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
             return result;
         }
+        /// <summary>
+        /// 商邀费用操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        public async Task<Result> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "程序错误!" };
+            BeginTran();
+            try
+            {
+                int id = 0;
+                Grp_InvitationOfficialActivities grp_Invitation = _mapper.Map<Grp_InvitationOfficialActivities>(dto);
+                if (dto.Status == 1)//添加
+                {
+                    string selectSql = string.Format(@"select * from Grp_InvitationOfficialActivities where InviterArea='{0}' and Inviter='{1}' and DiId={2} and IsDel={3}"
+                                                    , dto.InviterArea, dto.Inviter, dto.DiId, 0);
+                    var _InvitationOfficialActivities = await _sqlSugar.SqlQueryable<Grp_InvitationOfficialActivities>(selectSql).FirstAsync();//查询是否存在
+                    if (_InvitationOfficialActivities != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该客户已存在,请勿重复添加!" };
+                    }
+                    else
+                    {
+                        id = await AddAsyncReturnId(grp_Invitation);
+                        if (id != 0)//修改或添加商邀资料
+                        {
+                            Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
+                            res_InvitationData.Remark = "";
+                            int DataID = 0;
+                            if (dto.DataId == 0)
+                            {
+                                DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
+                                if (DataID != 0)
+                                {
+                                    result = new Result() { Code = 0, Msg = "添加成功!" };
+                                }
+                                else
+                                {
+                                    RollbackTran();
+                                    result = new Result() { Code = -1, Msg = "添加失败!" };
+                                }
+                            }
+                            else
+                            {
+                                res_InvitationData.Id = dto.DataId;
+                                DataID = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>().Where(b => b.Id == res_InvitationData.Id).SetColumns(b => new Res_InvitationOfficialActivityData
+                                {
+                                    Country = res_InvitationData.Country,
+                                    UnitName = res_InvitationData.UnitName,
+                                    Address = res_InvitationData.Address,
+                                    Contact = res_InvitationData.Contact,
+                                    Job = res_InvitationData.Job,
+                                    Tel = res_InvitationData.Tel,
+                                    Email = res_InvitationData.Email,
+                                    OtherInformation = res_InvitationData.OtherInformation,
+                                    Fax = res_InvitationData.Fax
+                                }).ExecuteCommandAsync();
+                            }
+                            if (DataID != 0)//添加C表
+                            {
+                                Grp_CreditCardPayment C = new Grp_CreditCardPayment();
+                                C.PayDId = dto.PayDId;
+                                C.ConsumptionPatterns = "";
+                                C.ConsumptionDate = new DateTime();
+                                C.CTDId = 0;
+                                C.BankNo = "";
+                                C.CardholderName = "";
+                                C.PayMoney = dto.InviteCosts + dto.SendCost;
+                                C.PaymentCurrency = dto.Currency;
+                                //当天汇率
+                                //if (!string.IsNullOrEmpty(hfRate.Value))
+                                //    C.DayRate = hfRate.Value;
+                                //else
+                                //C.DayRate = "";
+                                C.CompanyBankNo = "";
+                                C.OtherBankName = "";
+                                C.OtherSideNo = "";
+                                C.OtherSideName = "";
+                                C.Remark = "";
+                                C.CreateUserId = dto.CreateUserId;
+                                C.MFOperator = "";
+                                C.MFOperatorDate = new DateTime();
+                                C.IsAuditDM = 0;
+                                C.AuditDMOperate = 0;
+                                C.AuditDMDate = new DateTime();
+                                C.IsAuditMF = 0;
+                                C.AuditMFOperate = 0;
+                                C.AuditMFDate = new DateTime();
+                                C.IsAuditGM = 0;
+                                C.AuditGMOperate = 21;
+                                C.AuditGMDate = new DateTime();
+                                C.IsPay = 0;
+                                C.DIId = dto.DiId;
+                                C.CId = id;
+                                C.CTable = 81;
+                                C.PayPercentage = 0;
+                                C.PayThenMoney = 0;
+                                C.PayPercentageOld = 0;
+                                C.PayThenMoneyOld = 0;
+                                C.UpdateDate = new DateTime();
+                                C.Payee = dto.Payee;
+                                C.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
+                                C.ExceedBudget = 0;
+                                //C.RMBPrice = 0.00f;
+
+                                //设置该团组的汇率
+                                Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 81);
+                                if (_TeamRate != null)
+                                {
+                                    if (dto.Currency == 49)
+                                    {
+                                        C.DayRate = _TeamRate.RateU;
+                                        C.RMBPrice = C.PayMoney * Convert.ToDecimal(_TeamRate.RateU);
+                                        //ccp.PayMoney = ccp.PayMoney * float.Parse(tr.RateU); 
+                                    }
+                                    else if (dto.Currency == 51)
+                                    {
+                                        C.DayRate = _TeamRate.RateE;
+                                        C.RMBPrice = C.PayMoney * Convert.ToDecimal(_TeamRate.RateE);
+                                        //ccp.PayMoney = ccp.PayMoney * float.Parse(tr.RateE); 
+                                    }
+                                    else
+                                    {
+                                        C.DayRate = "1";
+                                        C.RMBPrice = C.PayMoney;
+                                    }
+                                }
+                                else
+                                {
+                                    C.DayRate = "1";
+                                    C.RMBPrice = C.PayMoney;
+                                }
+                                int cId = await _sqlSugar.Insertable(C).ExecuteReturnIdentityAsync();
+                                if (cId != 0)
+                                {
+                                    result = new Result() { Code = 0, Msg = "添加成功!" };
+                                }
+                                else
+                                {
+                                    RollbackTran();
+                                    result = new Result() { Code = -1, Msg = "添加失败!" };
+                                }
+                            }
+                        }
+                    }
+                }
+                else//修改
+                {
+                    bool res = await UpdateAsync(a => a.Id == grp_Invitation.Id, a => new Grp_InvitationOfficialActivities
+                    {
+                        DiId = dto.DiId,
+                        InviterArea = dto.InviterArea,
+                        Inviter = dto.Inviter,
+                        InviteTime = dto.InviteTime,
+                        Attachment = dto.Attachment,
+                        InviteCosts = dto.InviteCosts,
+                        Currency = dto.Currency,
+                        SendCost = dto.SendCost,
+                        IsGoOfficaiaBussiness = dto.IsGoOfficaiaBussiness,
+                        Remark = dto.Remark,
+                    });
+                    if (res)
+                    {
+                        Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
+                        res_InvitationData.Remark = "";
+                        int DataID = 0;
+                        if (dto.DataId == 0)///添加或修改商邀资料
+                        {
+                            DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
+                            if (DataID != 0)
+                            {
+                                result = new Result() { Code = 0, Msg = "添加成功!" };
+                            }
+                            else
+                            {
+                                RollbackTran();
+                                result = new Result() { Code = -1, Msg = "添加失败!" };
+                            }
+                        }
+                        else
+                        {
+                            res_InvitationData.Id = dto.DataId;
+                            DataID = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>().Where(b => b.Id == res_InvitationData.Id).SetColumns(b => new Res_InvitationOfficialActivityData
+                            {
+                                Country = res_InvitationData.Country,
+                                UnitName = res_InvitationData.UnitName,
+                                Address = res_InvitationData.Address,
+                                Contact = res_InvitationData.Contact,
+                                Job = res_InvitationData.Job,
+                                Tel = res_InvitationData.Tel,
+                                Email = res_InvitationData.Email,
+                                OtherInformation = res_InvitationData.OtherInformation,
+                                Fax = res_InvitationData.Fax
+                            }).ExecuteCommandAsync();
+                        }
+                        if (DataID != 0)//修改C表
+                        {
+                            Grp_CreditCardPayment grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId ==grp_Invitation.Id && a.IsDel == 0);
+                            if (grp_CreditCardPayment != null)
+                            {
+                                grp_CreditCardPayment.PayMoney = dto.InviteCosts + dto.SendCost;
+                                Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == grp_Invitation.DiId && a.IsDel == 0 && a.CTable == 81);
+                                if (_TeamRate != null)
+                                {
+
+                                    if (grp_Invitation.Currency == 49)
+                                    {
+                                        grp_CreditCardPayment.DayRate = _TeamRate.RateU;
+                                        grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney * Convert.ToDecimal(_TeamRate.RateU);
+                                        //ccp.PayMoney = ccp.PayMoney * float.Parse(tr.RateU); 
+                                    }
+                                    else if (grp_Invitation.Currency == 51)
+                                    {
+                                        grp_CreditCardPayment.DayRate = _TeamRate.RateE;
+                                        grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney * Convert.ToDecimal(_TeamRate.RateE);
+                                        //ccp.PayMoney = ccp.PayMoney * float.Parse(tr.RateE); 
+                                    }
+                                    else
+                                    {
+                                        grp_CreditCardPayment.DayRate = "1";
+                                        grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney;
+                                    }
+                                }
+                                else
+                                {
+                                    grp_CreditCardPayment.DayRate = "1";
+                                    grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney;
+                                }
+                                int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.Id == grp_CreditCardPayment.Id).SetColumns(a => new Grp_CreditCardPayment
+                                {
+                                    PayDId = dto.PayDId,
+                                    PayMoney = grp_CreditCardPayment.PayMoney,
+                                    PaymentCurrency = grp_Invitation.Currency,
+                                    Payee = dto.Payee,
+                                    OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
+                                    DayRate = grp_CreditCardPayment.DayRate,
+                                    RMBPrice = grp_CreditCardPayment.RMBPrice,
+
+                                }).ExecuteCommandAsync();
+                                if (CTable != 0)
+                                {
+                                    result = new Result() { Code = 0, Msg = "修改成功!" };
+                                }
+                                else
+                                {
+                                    result = new Result() { Code = -1, Msg = "修改失败!" };
+                                    RollbackTran();
+                                }
+                            }
+                            else
+                            {
+                                RollbackTran();
+                                result = new Result() { Code = -1, Msg = "修改失败!" };
+                            }
+                        }
+                        else
+                        {
+                            RollbackTran();
+                            result = new Result() { Code = -1, Msg = "修改失败!" };
+                        }
+                    }
+                    else
+                    {
+                        RollbackTran();
+                        result = new Result() { Code = -1, Msg = "修改失败!" };
+                    }
+                }
+                CommitTran();
+            }
+            catch (Exception ex)
+            {
+                result = new Result() { Code = -2, Msg = "程序错误!" };
+                throw;
+            }
+            return result;
+        }
     }
 }