|
@@ -22,13 +22,15 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
private readonly IMapper _mapper;
|
|
|
private Result _result;
|
|
|
private readonly CountryFeeRepository _countryFeeRep;
|
|
|
+ private readonly DelegationInfoRepository _groupRep;
|
|
|
|
|
|
- public VisaFeeInfoRepository(SqlSugarClient sqlSugar, IMapper mapper, CountryFeeRepository countryFeeRep)
|
|
|
+ public VisaFeeInfoRepository(SqlSugarClient sqlSugar, IMapper mapper, CountryFeeRepository countryFeeRep, DelegationInfoRepository groupRep)
|
|
|
: base(sqlSugar)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
|
_result = new Result() { Code = -2,Msg = "操作失败!"};
|
|
|
_countryFeeRep = countryFeeRep;
|
|
|
+ _groupRep = groupRep;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -40,8 +42,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
public async Task<Result> _Init()
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
var data = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
_result.Code = 0;
|
|
|
_result.Data = data;
|
|
@@ -62,11 +62,105 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
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}");
|
|
|
+ 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();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (data.Count == 0)
|
|
|
+ {
|
|
|
+ var groupInfo = await _groupRep.PostShareGroupInfo(new ShareGroupInfoDto() { PortType = 1, Id = diId });
|
|
|
+ List<string> countrys = new List<string>();
|
|
|
+ if (groupInfo.Code == 0)
|
|
|
+ {
|
|
|
+ countrys = _groupRep.GroupSplitCountry((groupInfo.Data as Web_ShareGroupInfoView)?.VisitCountry ?? "");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (countrys.Count > 0)
|
|
|
+ {
|
|
|
+ int dataRow = 0;
|
|
|
+
|
|
|
+ foreach (var country in countrys)
|
|
|
+ {
|
|
|
+ var countryInfo = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0 && it.VisaCountry.Equals(country)).First();
|
|
|
+ if (countryInfo != null)
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ VisaFee = countryInfo.VisaPrice,
|
|
|
+ OBType = 1,
|
|
|
+ AgencyFee = countryInfo.GrandBusinessAgencyFee
|
|
|
+ });
|
|
|
+
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ VisaFee = countryInfo.VisaPrice,
|
|
|
+ OBType = 2,
|
|
|
+ AgencyFee = countryInfo.PettyBusinessAgencyFee
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ OBType = 1,
|
|
|
+ });
|
|
|
+
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ IsChecked = 0,
|
|
|
+ Country = country,
|
|
|
+ OBType = 2,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (data.Count < 10)
|
|
|
+ {
|
|
|
+ int defaultRow = 10 - data.Count;
|
|
|
+ for (int i = 0; i < defaultRow; i++)
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ Id = 0,
|
|
|
+ OBType = 1
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (int i = 0; i < 10; i++)
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ Id = 0,
|
|
|
+ OBType = 1
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (data.Count <= 10)
|
|
|
+ {
|
|
|
+ int defaultRow = 10 - data.Count;
|
|
|
+ for (int i = 0; i < defaultRow; i++)
|
|
|
+ {
|
|
|
+ data.Add(new VisaFeeInfosView()
|
|
|
+ {
|
|
|
+ Id = 0,
|
|
|
+ OBType = 1
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
_result.Code = 0;
|
|
|
_result.Data = data;
|
|
|
_result.Msg = "操作成功!";
|
|
@@ -88,17 +182,32 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
BeginTran();
|
|
|
bool visaFeeUpdate = false;
|
|
|
- foreach (var item in dto.VisaFeeInfos)
|
|
|
+
|
|
|
+ var countrys = dto.VisaFeeInfos.GroupBy(x => x.Country);
|
|
|
+
|
|
|
+ foreach (var country in countrys)
|
|
|
{
|
|
|
int countryVisaFeeId = 0;
|
|
|
- var info =await _countryFeeRep._InfoByCountryName(item.Country);
|
|
|
+ decimal _grandBusinessAgencyFee = 0;
|
|
|
+ decimal _pettyBusinessAgencyFee = 0;
|
|
|
+ decimal _visaFee = 0;
|
|
|
+ foreach (var item in country.ToList())
|
|
|
+ {
|
|
|
+ _visaFee = item.VisaFee;
|
|
|
+ if (item.OBType == 1) _grandBusinessAgencyFee = item.AgencyFee;
|
|
|
+ else if (item.OBType == 2) _pettyBusinessAgencyFee = item.AgencyFee;
|
|
|
+ }
|
|
|
+
|
|
|
+ var info = await _countryFeeRep._InfoByCountryName(country.Key);
|
|
|
if (info == null)
|
|
|
{
|
|
|
int addId = _sqlSugar.Insertable(
|
|
|
new Res_CountryFeeCost()
|
|
|
{
|
|
|
- VisaCountry = item.Country,
|
|
|
- VisaPrice = item.VisaFee,
|
|
|
+ VisaCountry = country.Key,
|
|
|
+ VisaPrice = _visaFee,
|
|
|
+ GrandBusinessAgencyFee = _grandBusinessAgencyFee,
|
|
|
+ PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
|
|
|
LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
CreateUserId = dto.OpUserId,
|
|
|
}).ExecuteReturnIdentity();
|
|
@@ -107,12 +216,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
else
|
|
|
{
|
|
|
countryVisaFeeId = info.Id;
|
|
|
- if (item.VisaFee != info.VisaPrice)
|
|
|
+ if (_visaFee != info.VisaPrice)
|
|
|
{
|
|
|
Res_CountryFeeCost _CountryFeeCost = new Res_CountryFeeCost()
|
|
|
{
|
|
|
Id = info.Id,
|
|
|
- VisaPrice = item.VisaFee,
|
|
|
+ VisaPrice = _visaFee,
|
|
|
+ GrandBusinessAgencyFee = _grandBusinessAgencyFee,
|
|
|
+ PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
|
|
|
LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
};
|
|
|
int update1 = _sqlSugar.Updateable(_CountryFeeCost).UpdateColumns(it => new { it.VisaPrice, it.LastUpdateTime }).WhereColumns(it => it.Id).ExecuteCommand();
|
|
@@ -120,21 +231,25 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
visaFeeUpdate = true;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- visaInfos.Add(new Grp_VisaFeeInfo()
|
|
|
+ foreach (var item in country.ToList())
|
|
|
{
|
|
|
- Id = item.Id,
|
|
|
- DiId = dto.DiId,
|
|
|
- IsChecked = item.IsChecked,
|
|
|
- CountryVisaFeeId = countryVisaFeeId,
|
|
|
- AgencyFee = item.AgencyFee,
|
|
|
- OtherFee = item.OtherFee
|
|
|
- });
|
|
|
+ visaInfos.Add(new Grp_VisaFeeInfo()
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ DiId = dto.DiId,
|
|
|
+ IsChecked = item.IsChecked,
|
|
|
+ CountryVisaFeeId = countryVisaFeeId,
|
|
|
+ OBType = item.OBType,
|
|
|
+ AgencyFee = item.AgencyFee,
|
|
|
+ OtherFee = item.OtherFee
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
var update = _sqlSugar.Updateable<Grp_VisaFeeInfo>().SetColumns(it => new Grp_VisaFeeInfo()
|
|
|
{
|
|
@@ -172,32 +287,59 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
List<dynamic> datas = new List<dynamic>();
|
|
|
string remark = "";
|
|
|
decimal feeTotal = 0.00M;
|
|
|
- foreach (var item in visaData)
|
|
|
+
|
|
|
+ visaData = visaData.Where(it => it.IsChecked == 1).ToList();
|
|
|
+ var visaData1 = visaData.GroupBy(it => it.CountryVisaFeeId);
|
|
|
+
|
|
|
+ foreach (var kvp in visaData1)
|
|
|
{
|
|
|
- if (item.IsChecked == 1)
|
|
|
+ var countryData = visaCountryDatas.Find(it => it.Id == kvp.Key);
|
|
|
+ decimal _otherFee = kvp.FirstOrDefault()?.OtherFee ?? 0;
|
|
|
+ decimal _visaFee = Convert.ToDecimal(countryData?.VisaPrice ?? 0.00M);
|
|
|
+ decimal visaFeeTotal = _visaFee + _otherFee;
|
|
|
+ decimal _agencyFee = 0;
|
|
|
+ decimal _GrandBusinessAgencyFee = 0;
|
|
|
+ decimal _PettyBusinessAgencyFee = 0;
|
|
|
+
|
|
|
+ string remark1 = $"签证费:{_visaFee.ToString("#0.00")}元、";
|
|
|
+ foreach (var item in kvp.ToList())
|
|
|
{
|
|
|
- var countryData = visaCountryDatas.Find(it => it.Id == item.CountryVisaFeeId);
|
|
|
+ if (item.OBType == 1)
|
|
|
+ {
|
|
|
+ if (item.AgencyFee > 0)
|
|
|
+ {
|
|
|
+ remark1 += $@"大公务代办费:{item.AgencyFee.ToString("#0.00")}元、";
|
|
|
+ _agencyFee += item.AgencyFee;
|
|
|
+ _GrandBusinessAgencyFee = item.AgencyFee;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (item.OBType == 1)
|
|
|
+ {
|
|
|
+ if (item.AgencyFee > 0)
|
|
|
+ {
|
|
|
+ remark1 += $@"小公务代办费:{item.AgencyFee.ToString("#0.00")}元、";
|
|
|
+ _agencyFee += item.AgencyFee;
|
|
|
+ _PettyBusinessAgencyFee = item.AgencyFee;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- decimal visaFeeTotal = Convert.ToDecimal( countryData?.VisaPrice ?? 0.00M) + item.AgencyFee + item.OtherFee;
|
|
|
- remark += $@"{countryData?.VisaCountry ?? ""}:签证总费用:{visaFeeTotal}元/人 其中(";
|
|
|
- if (countryData?.VisaPrice > 0) remark += $@"签证费用:{countryData?.VisaPrice.ToString("#0.00")}元、";
|
|
|
- if (item.AgencyFee > 0) remark += $@"代办费:{item.AgencyFee.ToString("#0.00")}元、";
|
|
|
- if (item.OtherFee > 0) remark += $@"其他费用:{item.OtherFee.ToString("#0.00")}元";
|
|
|
+ if (_otherFee > 0) remark1 += $@"其他费用:{_otherFee.ToString("#0.00")}元";
|
|
|
|
|
|
- if (visaFeeTotal > 0) remark = remark.Substring(0,remark.Length -1);
|
|
|
+ visaFeeTotal += (_GrandBusinessAgencyFee + _PettyBusinessAgencyFee);
|
|
|
+ remark += $@"{countryData?.VisaCountry ?? ""}:签证总费用:{visaFeeTotal}元/人 其中({remark1});";
|
|
|
|
|
|
- remark += ");";
|
|
|
- feeTotal += visaFeeTotal;
|
|
|
- datas.Add(new
|
|
|
- {
|
|
|
- Country = countryData?.VisaCountry ?? "",
|
|
|
- visaFeeTotal = visaFeeTotal,
|
|
|
- VisaFee = countryData?.VisaPrice ?? 0.00M,
|
|
|
- item.AgencyFee,
|
|
|
- item.OtherFee
|
|
|
+ feeTotal += visaFeeTotal;
|
|
|
|
|
|
- });
|
|
|
- }
|
|
|
+ datas.Add(new
|
|
|
+ {
|
|
|
+ Country = countryData?.VisaCountry ?? "",
|
|
|
+ visaFeeTotal = visaFeeTotal,
|
|
|
+ VisaFee = countryData?.VisaPrice ?? 0.00M,
|
|
|
+ GrandBusinessAgencyFee = _GrandBusinessAgencyFee,
|
|
|
+ PettyBusinessAgencyFee = _PettyBusinessAgencyFee,
|
|
|
+ OtherFee = _otherFee
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
_result.Code = 0;
|