|
@@ -0,0 +1,163 @@
|
|
|
+using AutoMapper;
|
|
|
+using OASystem.Domain;
|
|
|
+using OASystem.Domain.Dtos.Groups;
|
|
|
+using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Domain.Entities.Resource;
|
|
|
+using OASystem.Domain.ViewModels.Groups;
|
|
|
+using OASystem.Infrastructure.Repositories.Resource;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 团组签证费用详情 info
|
|
|
+ /// 仓储
|
|
|
+ /// </summary>
|
|
|
+ public class VisaFeeInfoRepository:BaseRepository<Grp_VisaFeeInfo,VisaInfoView>
|
|
|
+ {
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private Result _result;
|
|
|
+ private readonly CountryFeeRepository _countryFeeRep;
|
|
|
+
|
|
|
+ public VisaFeeInfoRepository(SqlSugarClient sqlSugar, IMapper mapper, CountryFeeRepository countryFeeRep)
|
|
|
+ : base(sqlSugar)
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ _result = new Result() { Code = -2,Msg = "操作失败!"};
|
|
|
+ _countryFeeRep = countryFeeRep;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Init
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="portType"></param>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> _Init()
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ var data = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+ _result.Code = 0;
|
|
|
+ _result.Data = data;
|
|
|
+ _result.Msg = "操作成功!";
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// List
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="portType"></param>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> _List(int portType, int diId)
|
|
|
+ {
|
|
|
+ if (diId < 0) return _result = new Result() { Code = -1, Msg = "请传入有效的DiId参数" };
|
|
|
+ if (portType < 1 || portType > 3) return _result = new Result() { Code = -1, Msg = "请传入有效的portType参数" };
|
|
|
+
|
|
|
+ string sql = string.Format($@"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
|
|
|
+ vfi.AgencyFee,vfi.OtherFee,vfi.Remark
|
|
|
+ From Grp_VisaFeeInfo vfi
|
|
|
+ Left Join Res_CountryFeeCost cfc On vfi.CountryVisaFeeId = cfc.Id
|
|
|
+ Where vfi.Isdel = 0 And vfi.Diid = {diId}");
|
|
|
+ var data = await _sqlSugar.SqlQueryable<VisaFeeInfosView>(sql).ToListAsync();
|
|
|
+ _result.Code = 0;
|
|
|
+ _result.Data = data;
|
|
|
+ _result.Msg = "操作成功!";
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// List
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="portType"></param>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> _AddAndUpdate(VisaFeeAddAndUpdateDto dto)
|
|
|
+ {
|
|
|
+ if (dto.Status < 1 || dto.Status > 2) return _result = new Result() { Code = -1, Msg = "请传入有效的Status参数" };
|
|
|
+ if (dto.VisaFeeInfos.Count < 1) return _result = new Result() { Code = -1, Msg = "请传入有效的签证费用集合参数" };
|
|
|
+ if (dto.PortType < 1 || dto.PortType > 3) return _result = new Result() { Code = -1, Msg = "请传入有效的portType参数" };
|
|
|
+
|
|
|
+ List<Grp_VisaFeeInfo> visaInfos = new List<Grp_VisaFeeInfo>();
|
|
|
+
|
|
|
+ BeginTran();
|
|
|
+ bool visaFeeUpdate = false;
|
|
|
+ foreach (var item in dto.VisaFeeInfos)
|
|
|
+ {
|
|
|
+ int countryVisaFeeId = 0;
|
|
|
+ var info =await _countryFeeRep._InfoByCountryName(item.Country);
|
|
|
+ if (info == null) //添加
|
|
|
+ {
|
|
|
+ int addId = _sqlSugar.Insertable(
|
|
|
+ new Res_CountryFeeCost()
|
|
|
+ {
|
|
|
+ VisaCountry = item.Country,
|
|
|
+ VisaPrice = item.VisaFee,
|
|
|
+ LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ CreateUserId = dto.OpUserId,
|
|
|
+ }).ExecuteReturnIdentity();
|
|
|
+ if (addId > 0) countryVisaFeeId = addId;
|
|
|
+ }
|
|
|
+ else //修改
|
|
|
+ {
|
|
|
+ countryVisaFeeId = info.Id;
|
|
|
+ if (item.VisaFee != info.VisaPrice) //价格不同的时候执行修改
|
|
|
+ {
|
|
|
+ Res_CountryFeeCost _CountryFeeCost = new Res_CountryFeeCost()
|
|
|
+ {
|
|
|
+ Id = info.Id,
|
|
|
+ VisaPrice = item.VisaFee,
|
|
|
+ LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ };
|
|
|
+ int update = _sqlSugar.Updateable(_CountryFeeCost).UpdateColumns(it => new { it.VisaPrice, it.LastUpdateTime }).WhereColumns(it => it.Id).ExecuteCommand();
|
|
|
+ if (update > 0)
|
|
|
+ {
|
|
|
+ visaFeeUpdate = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ visaInfos.Add(new Grp_VisaFeeInfo()
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ DiId = dto.DiId,
|
|
|
+ IsChecked = item.IsChecked,
|
|
|
+ CountryVisaFeeId = countryVisaFeeId,
|
|
|
+ AgencyFee = item.AgencyFee,
|
|
|
+ OtherFee = item.OtherFee
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (dto.Status == 1) //添加
|
|
|
+ {
|
|
|
+ var add = _sqlSugar.Insertable(visaInfos).ExecuteCommand();
|
|
|
+ if (add > 0)
|
|
|
+ {
|
|
|
+ CommitTran();
|
|
|
+ return new Result() {Code = 0 ,Msg = "操作成功!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (dto.Status == 2) //修改
|
|
|
+ {
|
|
|
+ var update = _sqlSugar.Updateable(visaInfos).IgnoreColumns(it => new { it.CreateUserId,it.CreateTime,it.IsDel }).WhereColumns(it => it.Id).ExecuteCommand();
|
|
|
+ if (update > 0 || visaFeeUpdate)
|
|
|
+ {
|
|
|
+ CommitTran();
|
|
|
+ return new Result() { Code = 0, Msg = "操作成功!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ RollbackTran();
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|