Explorar o código

添加头等舱价格属性并优化存储库操作

在 `TicketBlackCodeDto.cs` 文件中,`OASystem.Domain.Dtos.Resource` 命名空间下,添加了两个新的属性:`FCPrice`(头等舱全价)和 `FCNowPrice`(头等舱现价)。

在 `TicketBlackCodeRepository.cs` 文件中,`OASystem.Infrastructure.Repositories.Resource` 命名空间下,进行了以下修改:
- 移除了添加操作中对是否存在相同记录的检查,直接插入新的记录。
- 修改操作中增加了对 `FCPrice` 和 `FCNowPrice` 属性的更新。
- 捕获异常时,返回的错误信息中增加了异常的具体消息内容。
yuanrf hai 1 mes
pai
achega
c6429c5939

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

@@ -58,6 +58,18 @@ namespace OASystem.Domain.Dtos.Resource
         ///经济舱单价
         /// </summary>
         public decimal ECPrice { get; set; }
+
+        /// <summary>
+        /// 头等舱全价
+        /// </summary>
+
+        public decimal FCPrice { get; set; }
+
+        /// <summary>
+        /// 头等舱现价
+        /// </summary>
+        public decimal FCNowPrice { get; set; }
+
         /// <summary>
         /// 创建者Id
         /// </summary>

+ 12 - 25
OASystem/OASystem.Infrastructure/Repositories/Resource/TicketBlackCodeRepository.cs

@@ -39,38 +39,25 @@ namespace OASystem.Infrastructure.Repositories.Resource
             {
                 if (dto.Status == 1)//添加
                 {
-                    Air_TicketBlackCode _TicketBlackCode = await _sqlSugar.Queryable<Air_TicketBlackCode>().FirstAsync(a=>a.IsDel==0 && a.BlackCode==dto.BlackCode && a.DiId==dto.DiId);//查询是否存在
-                    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 } };
-                    }
+                    Air_TicketBlackCode air_TicketBlack = _mapper.Map<Air_TicketBlackCode>(dto);
+                    int id = await _sqlSugar.Insertable(air_TicketBlack).ExecuteReturnIdentityAsync();
+                    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,
+                        DiId = dto.DiId,
+                        BlackCode = dto.BlackCode,
+                        Price = dto.Price,
+                        NowPrice = dto.NowPrice,
+                        BCPrice = dto.BCPrice,
+                        ECPrice = dto.ECPrice,
                         CreateUserId = dto.CreateUserId,
                         Remark = dto.Remark,
                         Title = dto.Title,
+                        FCPrice = dto.FCPrice,
+                        FCNowPrice = dto.FCNowPrice
                     });
                     if (!res)
                     {
@@ -85,7 +72,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
             }
             catch (Exception ex)
             {
-                return result = new Result() { Code = -2, Msg = "程序错误!" };
+                return result = new Result() { Code = -2, Msg = $"程序错误!({ex.Message})" };
             }
         }