123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- using AutoMapper;
- using MySqlX.XDevAPI.Common;
- using OASystem.Domain;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- using OASystem.Infrastructure.Repositories.System;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Result = OASystem.Domain.Result;
- namespace OASystem.Infrastructure.Repositories.Groups
- {
- /// <summary>
- /// 酒店询价 仓储
- /// </summary>
- public class HotelInquiryRepository:BaseRepository<Grp_HotelInquiry,HotelInquiryView>
- {
- private readonly IMapper _mapper;
- private readonly SetDataRepository _setDataRep;
- /// <summary>
- /// Init
- /// </summary>
- /// <param name="sqlSugar"></param>
- public HotelInquiryRepository(SqlSugarClient sqlSugar, IMapper mapper, SetDataRepository setDataRep)
- : base(sqlSugar)
- {
- _mapper = mapper;
- _setDataRep = setDataRep;
- }
- /// <summary>
- /// 酒店询价
- /// 初始化数据
- /// </summary>
- /// <returns></returns>
- public async Task<Result> _Init()
- {
- var currDataResult = await _setDataRep.GetSetDataBySTId(_setDataRep, 66);
- dynamic currDatas = null;
- if (currDataResult.Code == 0) currDatas = currDataResult.Data;
- var data = new {
- CurrData = currDatas
- };
- return new Result() { Code = 0 ,Msg="操作成功!",Data = data };
- }
- /// <summary>
- /// 酒店询价
- /// Page 列表
- /// </summary>
- /// <param name="portType"></param>
- /// <param name="DiId"></param>
- /// <returns></returns>
- public async Task<Result> _PageItem(int pageIndex,int pageSize, int portType, int diId)
- {
- if (portType < 1 || portType > 3) return new Result() { Code = -1, Msg = MsgTips.Port};
- if (diId < 1) return new Result() { Code = -1, Msg = MsgTips.DiId };
- if (pageIndex < 1) return new Result() { Code = -1, Msg = MsgTips.PageIndex };
- if (pageIndex < 1) return new Result() { Code = -1, Msg = MsgTips.PageSize };
- string sql = string.Format(@$"SELECT
- hi.Id,
- hi.DiId,
- hi.City,
- hi.[Name],
- hi.[SelectDt],
- hi.CheckInDate,
- hi.CheckOutDate,
- hi.SinglePrice,
- hi.SingleQuantity,
- sd1.[Name] AS SingleCurrency,
- hi.DoublePrice,
- hi.DoubleQuantity,
- sd2.[Name] AS DoubleCurrency,
- hi.SuitePrice,
- hi.SuiteQuantity,
- sd3.[Name] AS SuiteCurrency,
- hi.OtherPrice,
- hi.OtherQuantity,
- sd4.[Name] AS OtherCurrency,
- hi.Remark,
- u.CnName AS CreateUserName,
- hi.CreateTime
- FROM
- Grp_HotelInquiry hi
- WITH
- (NoLock)
- LEFT JOIN Sys_Users u
- WITH
- (NoLock) ON hi.CreateUserId = u.Id
- LEFT JOIN Sys_SetData sd1
- WITH
- (NoLock) ON hi.SingleCurrency = sd1.Id
- LEFT JOIN Sys_SetData sd2
- WITH
- (NoLock) ON hi.DoubleCurrency = sd2.Id
- LEFT JOIN Sys_SetData sd3
- WITH
- (NoLock) ON hi.SuiteCurrency = sd3.Id
- LEFT JOIN Sys_SetData sd4
- WITH
- (NoLock) ON hi.OtherCurrency = sd4.Id
- WHERE
- hi.Isdel = 0
- AND hi.DiId = {diId}");
- if (portType == 1 || portType == 2 || portType == 3)
- {
- RefAsync<int> total = 0;
- var eqquiryDatas = await _sqlSugar.SqlQueryable<HotelInquiryItemView>(sql).OrderBy(it => it.checkInDate).ToPageListAsync(pageIndex, pageSize, total);
- return new Result() { Code = 0, Msg = MsgTips.Succeed, Data = new PageDataViewBase { Data = eqquiryDatas, Total = total } };
- }
- return new Result() { Code = -1, Msg = MsgTips.Fail };
- }
-
- /// <summary>
- /// info
- /// </summary>
- /// <param name="portType"></param>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<Result> _Info(int portType, int id)
- {
- if (portType < 1 || portType > 3) return new Result() { Code = -1, Msg = MsgTips.Port };
- if (id < 1 ) return new Result() { Code = -1, Msg = MsgTips.Id };
- var info = await _sqlSugar.Queryable<Grp_HotelInquiry>()
- .Where(it => it.IsDel == 0 && it.Id == id)
- .Select(it =>
- new {
- it.Id,
- it.DiId,
- it.City,
- it.Name,
- it.Address,
- it.SelectDt,
- it.CheckInDate,
- it.CheckOutDate,
- it.SinglePrice,
- it.SingleQuantity,
- it.SingleCurrency,
- it.DoublePrice,
- it.DoubleQuantity,
- it.DoubleCurrency,
- it.SuitePrice,
- it.SuiteQuantity,
- it.SuiteCurrency,
- it.OtherPrice,
- it.OtherQuantity,
- it.OtherCurrency,
- it.Remark,
- })
- .FirstAsync();
- return new Result() { Code = 0, Msg = MsgTips.Succeed,Data = info };
- }
- /// <summary>
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- public async Task<Result> _AddOrEdit(HotelInquiryAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.DiId < 1) return new Result() { Code = -1, Msg = MsgTips.DiId };
- if (_dto.Status < 1 || _dto.Status > 2) return new Result() { Code = -1, Msg = MsgTips.Status };
- #endregion
- Grp_HotelInquiry _HotelInquiry = _mapper.Map<Grp_HotelInquiry>(_dto);
- if (_dto.Status == 1)
- {
- var add = await _sqlSugar.Insertable(_HotelInquiry).ExecuteReturnIdentityAsync();
- if (add > 0 ) return new Result() { Code = 0, Msg = MsgTips.Succeed };
- }
- else if (_dto.Status == 2)
- {
- var update = await _sqlSugar.Updateable(_HotelInquiry)
- .IgnoreColumns(it =>
- new
- {
- it.CreateUserId,
- it.CreateTime,
- it.DeleteUserId,
- it.DeleteTime,
- it.IsDel
- })
- .WhereColumns(it =>
- new
- {
- it.Id
- })
- .ExecuteCommandAsync();
- if (update > 0) return new Result() { Code = 0, Msg = MsgTips.Succeed };
- }
- return new Result() { Code = -1, Msg = MsgTips.Fail };
- }
- /// <summary>
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- public async Task<Result> _Del(int id,int userId)
- {
- #region 参数验证
- if (id < 1) return new Result() { Code = -1, Msg = MsgTips.Id };
- if (userId < 0) return new Result() { Code = -1, Msg = MsgTips.UserId };
- #endregion
- var del = await SoftDeleteByIdAsync<Grp_HotelInquiry>(id.ToString(), userId);
- if (del) return new Result() { Code = 0, Msg = MsgTips.Succeed };
- return new Result() { Code = -1, Msg = MsgTips.Fail };
- }
- }
- }
|