Browse Source

新增机票黑屏代码增删改查相关实体类及方法

wangh 1 year ago
parent
commit
daa1720c19

+ 2 - 1
OASystem/EntitySync/Program.cs

@@ -104,6 +104,7 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Grp_DelegationEnData),
     //typeof(Grp_DelegationEnData),
     //typeof(Grp_EnterExitCost),
     //typeof(Grp_EnterExitCost),
     //typeof(Grp_DayAndCost), 
     //typeof(Grp_DayAndCost), 
-    typeof(Grp_NationalTravelFee)
+    //typeof(Grp_NationalTravelFee)
+    typeof(Air_TicketBlackCode)
 });
 });
 Console.WriteLine("数据库结构同步完成!");
 Console.WriteLine("数据库结构同步完成!");

+ 103 - 1
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -32,12 +32,13 @@ namespace OASystem.API.Controllers
         private readonly OfficialActivitiesRepository _officialActivitiesRep;
         private readonly OfficialActivitiesRepository _officialActivitiesRep;
         private readonly AskDataRepository _askDataRep;
         private readonly AskDataRepository _askDataRep;
         private readonly SqlSugarClient _sqlSugar;
         private readonly SqlSugarClient _sqlSugar;
+        private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
 
 
         public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,
         public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,
             LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
             LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
             HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
             HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
             CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
             CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
-            InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep)
+            InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep, TicketBlackCodeRepository ticketBlackCodeRep)
         {
         {
             _mapper = mapper;
             _mapper = mapper;
             _config = config;
             _config = config;
@@ -54,6 +55,7 @@ namespace OASystem.API.Controllers
             _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
             _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
             _officialActivitiesRep = officialActivitiesRep;
             _officialActivitiesRep = officialActivitiesRep;
             _askDataRep = askDataRep;
             _askDataRep = askDataRep;
+            _ticketBlackCodeRep=ticketBlackCodeRep;
         }
         }
 
 
 
 
@@ -1821,6 +1823,106 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             }
             }
         }
         }
         #endregion
         #endregion
+
+        #region 机票黑屏代码
+        /// <summary>
+        /// 根据团组Id查询黑屏代码列表
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
+        {
+            try
+            {
+                Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeByDiId(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;
+            }
+        }
+        /// <summary>
+        /// 根据黑屏代码数据Id查询信息
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
+        {
+            try
+            {
+                Result groupData = await _ticketBlackCodeRep.QueryTicketBlackCodeById(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;
+            }
+        }
+        /// <summary>
+        /// 黑屏代码操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OpTicketBlackCode(OpTicketBlackCodeDto dto)
+        {
+            try
+            {
+                Result groupData = await _ticketBlackCodeRep.OpTicketBlackCode(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;
+            }
+        }
+
+        /// <summary>
+        /// 删除黑屏代码
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelTicketBlackCode(DelBaseDto dto)
+        {
+            try
+            {
+                var res = await _ticketBlackCodeRep.SoftDeleteByIdAsync<Air_TicketBlackCode>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        #endregion
     }
     }
 
 
 
 

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

@@ -150,6 +150,10 @@ namespace OASystem.Domain.AutoMappers
             #region 请示数据库
             #region 请示数据库
             CreateMap<OpAskDataDto, Res_AskData>();
             CreateMap<OpAskDataDto, Res_AskData>();
             #endregion
             #endregion
+
+            #region 黑屏代码录入
+            CreateMap<OpTicketBlackCodeDto, Air_TicketBlackCode>();
+            #endregion
             #endregion
             #endregion
 
 
             #region Crm
             #region Crm

+ 70 - 0
OASystem/OASystem.Domain/Dtos/Resource/TicketBlackCodeDto.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    public class QueryTicketBlackCodeByDiIdDto
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int DiId { get; set; }
+    }
+    /// <summary>
+    /// 根据黑屏代码Id查询数据
+    /// </summary>
+    public class QueryTicketBlackCodeByIdDto
+    {
+        public int Id{ get; set; }
+
+        public int DiId { get; set; }
+    }
+    public class OpTicketBlackCodeDto
+    {
+        /// <summary>
+        /// 操作状态
+        /// 1 添加 
+        /// 2 修改 
+        /// </summary>
+        public int Status { get; set; }
+        /// <summary>
+        /// 编号
+        /// </summary>
+        public int Id { get; set; }
+        /// <summary>
+        ///  团组Id
+        /// </summary>
+        public int DiId { get; set; }
+        /// <summary>
+        ///   黑屏代码
+        /// </summary>
+        public string BlackCode { get; set; }
+        /// <summary>
+        ///  报价
+        /// <summary>
+        public string Price { get; set; }
+        /// <summary>
+        ///  最新报价
+        /// <summary>
+        public string NowPrice { get; set; }
+        /// <summary>
+        /// 公务舱单价
+        /// </summary>
+        public decimal BCPrice { get; set; }
+        /// <summary>
+        ///经济舱单价
+        /// </summary>
+        public decimal ECPrice { get; set; }
+        /// <summary>
+        /// 创建者Id
+        /// </summary>
+        public int CreateUserId { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Remark { get; set; }
+    }
+}

+ 56 - 0
OASystem/OASystem.Domain/Entities/Resource/Air_TicketBlackCode.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Resource
+{
+    /// <summary>
+    /// 机票黑屏代码
+    /// </summary>
+    [SugarTable("Air_TicketBlackCode")]
+    public class Air_TicketBlackCode:EntityBase
+    {
+        /// <summary>
+        ///  团组Id
+        /// </summary>
+        [SugarColumn(IsNullable =true,ColumnDataType ="int")]
+        public int DiId { get; set; }
+        /// <summary>
+        ///   黑屏代码
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(800)")]
+        public string LeaveCode { get; set; }
+        /// <summary>
+        ///   黑屏代码
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(800)")]
+        public string BlackCode { get; set; }
+        /// <summary>
+        ///   黑屏代码
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(800)")]
+        public string ReturnCode { get; set; }
+        /// <summary>
+        ///  报价
+        /// <summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(300)")]
+        public string Price { get; set; }
+        /// <summary>
+        ///  最新报价
+        /// <summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(300)")]
+        public string NowPrice { get; set; }
+        /// <summary>
+        /// 公务舱单价
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(18,2)")]
+        public decimal BCPrice { get; set; }
+        /// <summary>
+        ///经济舱单价
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(18,2)")]
+        public decimal ECPrice { get; set; }
+    }
+}

+ 14 - 0
OASystem/OASystem.Domain/ViewModels/Resource/TicketBlackCodeView.cs

@@ -0,0 +1,14 @@
+using OASystem.Domain.Entities.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Resource
+{
+    public class TicketBlackCodeView:Air_TicketBlackCode
+    {
+        public string CreateName { get; set; }
+    }
+}

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

@@ -214,7 +214,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
                     }
                 }
                 }
                 //团组成本预算表查询
                 //团组成本预算表查询
-                Grp_GroupCostParameter _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().First(a => a.DiId == dto.DiId);
+                Grp_GroupCostParameter _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().First(a => a.DiId == dto.DiId && a.IsDel==0);
 
 
                 AirGroupCostParameterView _AirgroupCostParameter = _mapper.Map<AirGroupCostParameterView>(_GroupCostParameter);
                 AirGroupCostParameterView _AirgroupCostParameter = _mapper.Map<AirGroupCostParameterView>(_GroupCostParameter);
                 for (int i = 0; i <_AirTicketReservations.Count; i++)
                 for (int i = 0; i <_AirTicketReservations.Count; i++)

+ 171 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/TicketBlackCodeRepository.cs

@@ -0,0 +1,171 @@
+using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Resource;
+using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Groups;
+using OASystem.Domain.ViewModels.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.Resource
+{
+    public class TicketBlackCodeRepository : BaseRepository<Air_TicketBlackCode, TicketBlackCodeView>
+    {
+        private readonly IMapper _mapper;
+        public TicketBlackCodeRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        {
+            _mapper = mapper;
+        }
+
+        /// <summary>
+        /// 黑屏代码操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<Result> OpTicketBlackCode(OpTicketBlackCodeDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                if (dto.Status == 1)//添加
+                {
+                   
+                    Air_TicketBlackCode _TicketBlackCode = await _sqlSugar.Queryable<Air_TicketBlackCode>().FirstAsync(a=>a.IsDel==0 && a.BlackCode==dto.BlackCode);//查询是否存在
+                    if (_TicketBlackCode != null)
+                    {
+                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+
+                    }
+                    else//不存在,可添加
+                    {
+
+                        Air_TicketBlackCode air_TicketBlack = _mapper.Map<Air_TicketBlackCode>(dto);
+                        int id = await _sqlSugar.Insertable(air_TicketBlack).ExecuteReturnIdentityAsync();
+                        if (id == 0)
+                        {
+                            return result = new Result() { Code = -1, Msg = "添加失败!" };
+
+                        }
+                        return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
+                    }
+                }
+                else if (dto.Status == 2)//修改
+                {
+                    bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Air_TicketBlackCode
+                    {
+                        DiId=dto.DiId,
+                        BlackCode=dto.BlackCode,
+                        Price=dto.Price,
+                        NowPrice=dto.NowPrice,
+                        BCPrice=dto.BCPrice,
+                        ECPrice=dto.ECPrice,
+                        CreateUserId = dto.CreateUserId,
+                        Remark = dto.Remark,
+                    });
+                    if (!res)
+                    {
+                        return result = new Result() { Code = -1, Msg = "修改失败!" };
+                    }
+                    return result = new Result() { Code = 0, Msg = "修改成功!", Data = new { Id = dto.Id } };
+                }
+                else
+                {
+                    return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                }
+            }
+            catch (Exception ex)
+            {
+                return result = new Result() { Code = -2, Msg = "程序错误!" };
+            }
+        }
+
+        public async Task<Result> QueryTicketBlackCodeByDiId(QueryTicketBlackCodeByDiIdDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                string sqlWhere = string.Empty;
+
+                sqlWhere += string.Format(@" And a.IsDel={0} And a.DiId={1}", 0, dto.DiId);
+                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
+                {
+                    Regex r = new Regex("And");
+                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
+                }
+
+                string sql = string.Format(@"select *,(select CnName from Sys_Users where id=a.CreateUserId) as CreateName from Air_TicketBlackCode a  {0}", sqlWhere);
+                List<TicketBlackCodeView> _TicketBlackCodes = await _sqlSugar.SqlQueryable<TicketBlackCodeView>(sql).ToListAsync();
+                Grp_DelegationInfo _DelegationInfo=await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(a=>a.IsDel==0 && a.Id==dto.DiId);
+                if (_TicketBlackCodes.Count!=0)
+                {
+                    return result = new Result()
+                    {
+                        Code = 0,
+                        Msg = "查询成功",
+                        Data = new
+                        {
+                            TicketBlackCodes= _TicketBlackCodes,
+                            DelegationInfo= _DelegationInfo
+                        },
+                    };
+                }
+                else
+                {
+                    return result = new Result()
+                    {
+                        Code = 0,
+                        Msg = "暂无数据",
+                        Data = new
+                        {
+                            TicketBlackCodes = _TicketBlackCodes,
+                            DelegationInfo = _DelegationInfo
+                        },
+                    };
+                }
+            }
+            catch (Exception)
+            {
+                return result;
+                throw;
+            }
+        }
+
+        public async Task<Result> QueryTicketBlackCodeById(QueryTicketBlackCodeByIdDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                //查询成本和团组信息
+                Grp_GroupCostParameter _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().First(a => a.DiId == dto.DiId && a.IsDel==0);//团组成本
+                AirGroupCostParameterView _AirgroupCostParameter = _mapper.Map<AirGroupCostParameterView>(_GroupCostParameter);
+                Grp_DelegationInfo _DelegationInfo=_sqlSugar.Queryable<Grp_DelegationInfo>().First(a=>a.Id == dto.DiId && a.IsDel==0);//团组信息
+                Air_TicketBlackCode _TicketBlackCode=new Air_TicketBlackCode();
+                if (dto.Id!=0 && !string.IsNullOrWhiteSpace(dto.Id.ToString()))
+                {
+                    _TicketBlackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(a => a.IsDel==0 && a.Id==dto.Id);
+                }
+                return result = new Result()
+                {
+                    Code = 0,
+                    Msg = "查询成功!",
+                    Data = new
+                    {
+                        GroupCostParameter = _AirgroupCostParameter,
+                        DelegationInfo = _DelegationInfo,
+                        TicketBlackCode = _TicketBlackCode
+                    },
+                };
+            }
+            catch (Exception)
+            {
+                return result;
+                throw;
+            }
+        }
+    }
+}