|
@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Groups;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.Resource;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
+using OASystem.Domain.ViewModels.Resource;
|
|
|
using OASystem.Infrastructure.Repositories.Resource;
|
|
|
namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
@@ -52,63 +53,113 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
/// <returns></returns>
|
|
|
public async Task<JsonView> List(int portType, int diId)
|
|
|
{
|
|
|
- if (diId < 0) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的DiId参数" };
|
|
|
- if (portType < 1 || portType > 3) return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的portType参数" };
|
|
|
+ if (diId < 0)
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的DiId参数" };
|
|
|
+ if (portType < 1 || portType > 3)
|
|
|
+ return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的portType参数" };
|
|
|
+
|
|
|
+ //防SQL注入
|
|
|
+ string sql = @"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
|
|
|
+ vfi.OBType,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)
|
|
|
+ .AddParameters(new { diId })
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
- string sql = string.Format($@"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
|
|
|
- vfi.OBType,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();
|
|
|
-
|
|
|
- //默认十行 雷怡 2024-26-08 11:26:40
|
|
|
if (data.Count == 0)
|
|
|
{
|
|
|
- var groupInfo = await _groupRep.PostShareGroupInfo(new ShareGroupInfoDto() { PortType = 1, Id = diId });
|
|
|
+ var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .FirstAsync(x => x.IsDel == 0 && x.Id == diId);
|
|
|
|
|
|
- if (groupInfo.Code != 200)
|
|
|
+ if (groupInfo == null)
|
|
|
{
|
|
|
return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "团组信息不存在!" };
|
|
|
}
|
|
|
|
|
|
- var countrys = _groupRep.GroupSplitCountry((groupInfo.Data as Web_ShareGroupInfoView)?.VisitCountry ?? "");
|
|
|
-
|
|
|
- if (countrys.Any())
|
|
|
+ var countrys = _groupRep.GroupSplitCountry(groupInfo.VisitCountry ?? "");
|
|
|
+ if (countrys.Count > 0)
|
|
|
{
|
|
|
- //int dataRow = 0;
|
|
|
- foreach (var country in countrys)
|
|
|
- {
|
|
|
- var countryInfo = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0 && it.VisaCountry.Equals(country)).FirstAsync();
|
|
|
- if (countryInfo != null)
|
|
|
+ var visaFeeCountrys = await _sqlSugar.Queryable<Res_VisaFeeStandard>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.FeeType == 0 && countrys.Contains(x.Country))
|
|
|
+ .Select(x => new VisaFeeStandardInfoView
|
|
|
{
|
|
|
- data.Add(new VisaFeeInfosView()
|
|
|
- {
|
|
|
- IsChecked = 0,
|
|
|
- Country = country,
|
|
|
- VisaFee = countryInfo.VisaPrice,
|
|
|
- OBType = 1,
|
|
|
- AgencyFee = countryInfo.GrandBusinessAgencyFee
|
|
|
- });
|
|
|
+ Id = x.Id,
|
|
|
+ Continent = x.Continent,
|
|
|
+ Country = x.Country,
|
|
|
+ FeeType = x.FeeType,
|
|
|
+ })
|
|
|
+ .ToListAsync();
|
|
|
+
|
|
|
+ if (visaFeeCountrys.Count > 0)
|
|
|
+ {
|
|
|
+ var visaFeeCountryIds = visaFeeCountrys.Select(x => x.Id).ToList();
|
|
|
+ var visaFeeDetails = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
|
|
|
+ .Where(x => x.IsDel == 0 && visaFeeCountryIds.Contains(x.ParentId))
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
- data.Add(new VisaFeeInfosView()
|
|
|
+ // 建立ParentId到Details的字典,避免多次Where查找
|
|
|
+ var detailsDict = visaFeeDetails
|
|
|
+ .GroupBy(x => x.ParentId)
|
|
|
+ .ToDictionary(g => g.Key, g => g.ToList());
|
|
|
+
|
|
|
+ foreach (var countryInfo in visaFeeCountrys)
|
|
|
+ {
|
|
|
+ if (detailsDict.TryGetValue(countryInfo.Id, out var details))
|
|
|
{
|
|
|
- IsChecked = 0,
|
|
|
- Country = country,
|
|
|
- VisaFee = countryInfo.VisaPrice,
|
|
|
- OBType = 2,
|
|
|
- AgencyFee = countryInfo.PettyBusinessAgencyFee
|
|
|
- });
|
|
|
+ // 只做映射,无副作用可省略变量
|
|
|
+ countryInfo.VisaFees = _mapper.Map<List<VisaFeeStandardDetails>>(details);
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ var provCityDatas = await _groupRep.ProvinceCityBasicSource();
|
|
|
+ int provinceId = _groupRep.FindParentIdByChildId(provCityDatas, groupInfo.CityId) ?? 0;
|
|
|
+
|
|
|
+ foreach (var country in countrys)
|
|
|
{
|
|
|
+ var countryInfo = visaFeeCountrys.FirstOrDefault(x => x.Country == country);
|
|
|
+ if (countryInfo != null && countryInfo.VisaFees != null)
|
|
|
+ {
|
|
|
+ //如果未找到对应的城市则默认四川的费用标准
|
|
|
+ var cityVisaFeeInfo = countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == provinceId)
|
|
|
+ ?? countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == 122); // 122 四川省ID
|
|
|
+
|
|
|
+ if (cityVisaFeeInfo != null)
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ //大公务签证费用为0时,使用小公务签证费用
|
|
|
+ VisaFee = cityVisaFeeInfo.LargeVisaPrice == 0.00M
|
|
|
+ ? cityVisaFeeInfo.SmallVisaPrice
|
|
|
+ : cityVisaFeeInfo.LargeVisaPrice,
|
|
|
+ OBType = 1,
|
|
|
+ AgencyFee = cityVisaFeeInfo.LargeAgencyFee
|
|
|
+ });
|
|
|
+
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ //小公务签证费用为0时,使用大公务签证费用
|
|
|
+ VisaFee = cityVisaFeeInfo.SmallVisaPrice == 0.00M
|
|
|
+ ? cityVisaFeeInfo.LargeVisaPrice
|
|
|
+ : cityVisaFeeInfo.SmallVisaPrice,
|
|
|
+ OBType = 2,
|
|
|
+ AgencyFee = cityVisaFeeInfo.SmallAgencyFee
|
|
|
+ });
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 没有费用信息时补空行
|
|
|
data.Add(new VisaFeeInfosView()
|
|
|
{
|
|
|
IsChecked = 0,
|
|
|
Country = country,
|
|
|
OBType = 1,
|
|
|
});
|
|
|
-
|
|
|
data.Add(new VisaFeeInfosView()
|
|
|
{
|
|
|
IsChecked = 0,
|
|
@@ -117,7 +168,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
AddDefaultRows(data, 10);
|
|
|
}
|
|
|
else
|
|
@@ -130,7 +180,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
AddDefaultRows(data, 10);
|
|
|
}
|
|
|
|
|
|
- return new JsonView() { Code = StatusCodes.Status200OK, Data =data, Msg = "请传入有效的DiId参数" };
|
|
|
+ return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "操作成功!" };
|
|
|
}
|
|
|
|
|
|
/// <summary>
|