VisaFeeInfoRepository.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos.Groups;
  4. using OASystem.Domain.Entities.Groups;
  5. using OASystem.Domain.Entities.Resource;
  6. using OASystem.Domain.ViewModels.Groups;
  7. using OASystem.Domain.ViewModels.Resource;
  8. using OASystem.Infrastructure.Repositories.Resource;
  9. namespace OASystem.Infrastructure.Repositories.Groups
  10. {
  11. /// <summary>
  12. /// 团组签证费用详情 info
  13. /// 仓储
  14. /// </summary>
  15. public class VisaFeeInfoRepository : BaseRepository<Grp_VisaFeeInfo, VisaInfoView>
  16. {
  17. private readonly IMapper _mapper;
  18. private Result _result;
  19. private readonly CountryFeeRepository _countryFeeRep;
  20. private readonly DelegationInfoRepository _groupRep;
  21. public VisaFeeInfoRepository(SqlSugarClient sqlSugar, IMapper mapper, CountryFeeRepository countryFeeRep, DelegationInfoRepository groupRep)
  22. : base(sqlSugar)
  23. {
  24. _mapper = mapper;
  25. _result = new Result() { Code = -2, Msg = "操作失败!" };
  26. _countryFeeRep = countryFeeRep;
  27. _groupRep = groupRep;
  28. }
  29. /// <summary>
  30. /// Init
  31. /// </summary>
  32. /// <param name="portType"></param>
  33. /// <param name="diId"></param>
  34. /// <returns></returns>
  35. public async Task<Result> Init()
  36. {
  37. var data = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => it.IsDel == 0).ToListAsync();
  38. _result.Code = 0;
  39. _result.Data = data;
  40. _result.Msg = "操作成功!";
  41. return _result;
  42. }
  43. /// <summary>
  44. /// List
  45. /// </summary>
  46. /// <param name="portType"></param>
  47. /// <param name="diId"></param>
  48. /// <returns></returns>
  49. public async Task<JsonView> List(int portType, int diId)
  50. {
  51. if (diId < 0)
  52. return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的DiId参数" };
  53. if (portType < 1 || portType > 3)
  54. return new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "请传入有效的portType参数" };
  55. //防SQL注入
  56. string sql = @"Select vfi.Id,vfi.IsChecked,cfc.VisaCountry AS Country,cfc.VisaPrice As VisaFee,
  57. vfi.OBType,vfi.AgencyFee,vfi.OtherFee,vfi.Remark
  58. From Grp_VisaFeeInfo vfi
  59. Left Join Res_CountryFeeCost cfc On vfi.CountryVisaFeeId = cfc.Id
  60. Where vfi.Isdel = 0 And vfi.Diid = @diId";
  61. var data = await _sqlSugar.SqlQueryable<VisaFeeInfosView>(sql)
  62. .AddParameters(new { diId })
  63. .ToListAsync();
  64. if (data.Count == 0)
  65. {
  66. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  67. .FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  68. if (groupInfo == null)
  69. return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "团组信息不存在!" };
  70. var countrys = _groupRep.GroupSplitCountry(groupInfo.VisitCountry ?? "");
  71. if (countrys.Count > 0)
  72. {
  73. var visaFeeCountrys = await _sqlSugar.Queryable<Res_VisaFeeStandard>()
  74. .Where(x => x.IsDel == 0 && x.FeeType == 0 && countrys.Contains(x.Country))
  75. .Select(x => new VisaFeeStandardInfoView
  76. {
  77. Id = x.Id,
  78. Continent = x.Continent,
  79. Country = x.Country,
  80. FeeType = x.FeeType,
  81. })
  82. .ToListAsync();
  83. if (visaFeeCountrys.Count > 0)
  84. {
  85. var visaFeeCountryIds = visaFeeCountrys.Select(x => x.Id).ToList();
  86. var visaFeeDetails = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  87. .Where(x => x.IsDel == 0 && visaFeeCountryIds.Contains(x.ParentId))
  88. .ToListAsync();
  89. // 建立ParentId到Details的字典,避免多次Where查找
  90. var detailsDict = visaFeeDetails
  91. .GroupBy(x => x.ParentId)
  92. .ToDictionary(g => g.Key, g => g.ToList());
  93. foreach (var countryInfo in visaFeeCountrys)
  94. {
  95. if (detailsDict.TryGetValue(countryInfo.Id, out var details))
  96. {
  97. // 只做映射,无副作用可省略变量
  98. countryInfo.VisaFees = _mapper.Map<List<VisaFeeStandardDetails>>(details);
  99. }
  100. }
  101. var provCityDatas = await _groupRep.ProvinceCityBasicSource();
  102. int provinceId = _groupRep.FindParentIdByChildId(provCityDatas, groupInfo.CityId) ?? 0;
  103. foreach (var country in countrys)
  104. {
  105. var countryInfo = visaFeeCountrys.FirstOrDefault(x => x.Country == country);
  106. if (countryInfo != null && countryInfo.VisaFees != null)
  107. {
  108. //如果未找到对应的城市则默认四川的费用标准
  109. var cityVisaFeeInfo = countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == provinceId)
  110. ?? countryInfo.VisaFees.FirstOrDefault(x => x.ProvinceId == 122); // 122 四川省ID
  111. if (cityVisaFeeInfo != null)
  112. {
  113. data.Add(new VisaFeeInfosView()
  114. {
  115. IsChecked = 0,
  116. Country = country,
  117. //大公务签证费用为0时,使用小公务签证费用
  118. VisaFee = cityVisaFeeInfo.LargeVisaPrice == 0.00M
  119. ? cityVisaFeeInfo.SmallVisaPrice
  120. : cityVisaFeeInfo.LargeVisaPrice,
  121. OBType = 1,
  122. AgencyFee = cityVisaFeeInfo.LargeAgencyFee
  123. });
  124. data.Add(new VisaFeeInfosView()
  125. {
  126. IsChecked = 0,
  127. Country = country,
  128. //小公务签证费用为0时,使用大公务签证费用
  129. VisaFee = cityVisaFeeInfo.SmallVisaPrice == 0.00M
  130. ? cityVisaFeeInfo.LargeVisaPrice
  131. : cityVisaFeeInfo.SmallVisaPrice,
  132. OBType = 2,
  133. AgencyFee = cityVisaFeeInfo.SmallAgencyFee
  134. });
  135. continue;
  136. }
  137. }
  138. // 没有费用信息时补空行
  139. data.Add(new VisaFeeInfosView()
  140. {
  141. IsChecked = 0,
  142. Country = country,
  143. OBType = 1,
  144. });
  145. data.Add(new VisaFeeInfosView()
  146. {
  147. IsChecked = 0,
  148. Country = country,
  149. OBType = 2,
  150. });
  151. }
  152. }
  153. AddDefaultRows(data, 10);
  154. }
  155. else
  156. {
  157. AddDefaultRows(data, 10);
  158. }
  159. }
  160. else if (data.Count <= 10)
  161. {
  162. AddDefaultRows(data, 10);
  163. }
  164. return new JsonView() { Code = StatusCodes.Status200OK, Data = data, Msg = "操作成功!" };
  165. }
  166. /// <summary>
  167. /// 补齐默认行
  168. /// </summary>
  169. /// <param name="list"></param>
  170. /// <param name="totalRows"></param>
  171. private static void AddDefaultRows(List<VisaFeeInfosView> list, int totalRows)
  172. {
  173. int defaultRow = totalRows - list.Count;
  174. for (int i = 0; i < defaultRow; i++)
  175. {
  176. list.Add(new VisaFeeInfosView { Id = 0, OBType = 1 });
  177. }
  178. }
  179. /// <summary>
  180. /// List
  181. /// </summary>
  182. /// <param name="dto"></param>
  183. /// <returns></returns>
  184. public async Task<Result> Update(VisaFeeAddAndUpdateDto dto)
  185. {
  186. if (dto.VisaFeeInfos.Count < 1) return _result = new Result() { Code = -1, Msg = "请传入有效的签证费用集合参数" };
  187. if (dto.PortType < 1 || dto.PortType > 3) return _result = new Result() { Code = -1, Msg = "请传入有效的portType参数" };
  188. var visaInfos = new List<Grp_VisaFeeInfo>();
  189. BeginTran();
  190. //bool visaFeeUpdate = false;
  191. var countrys = dto.VisaFeeInfos.GroupBy(x => x.Country);
  192. foreach (var country in countrys)
  193. {
  194. int countryVisaFeeId = 0;
  195. decimal _grandBusinessAgencyFee = 0;
  196. decimal _pettyBusinessAgencyFee = 0;
  197. decimal _visaFee = 0;
  198. foreach (var item in country.ToList())
  199. {
  200. _visaFee = item.VisaFee;
  201. if (item.OBType == 1) _grandBusinessAgencyFee = item.AgencyFee;
  202. else if (item.OBType == 2) _pettyBusinessAgencyFee = item.AgencyFee;
  203. }
  204. var info = await _countryFeeRep.InfoByCountryName(country.Key);
  205. if (info == null) //添加
  206. {
  207. int addId = _sqlSugar.Insertable(
  208. new Res_CountryFeeCost()
  209. {
  210. VisaCountry = country.Key,
  211. VisaPrice = _visaFee,
  212. GrandBusinessAgencyFee = _grandBusinessAgencyFee,
  213. PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
  214. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  215. CreateUserId = dto.OpUserId,
  216. }).ExecuteReturnIdentity();
  217. if (addId > 0) countryVisaFeeId = addId;
  218. }
  219. else //修改
  220. {
  221. countryVisaFeeId = info.Id;
  222. if (_visaFee != info.VisaPrice) //价格不同的时候执行修改
  223. {
  224. var _CountryFeeCost = new Res_CountryFeeCost()
  225. {
  226. Id = info.Id,
  227. VisaPrice = _visaFee,
  228. GrandBusinessAgencyFee = _grandBusinessAgencyFee,
  229. PettyBusinessAgencyFee = _pettyBusinessAgencyFee,
  230. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  231. };
  232. int update1 = _sqlSugar.Updateable(_CountryFeeCost).UpdateColumns(it => new { it.VisaPrice, it.LastUpdateTime }).WhereColumns(it => it.Id).ExecuteCommand();
  233. //if (update1 > 0)
  234. //{
  235. // visaFeeUpdate = true;
  236. //}
  237. }
  238. }
  239. foreach (var item in country.ToList())
  240. {
  241. visaInfos.Add(new Grp_VisaFeeInfo()
  242. {
  243. Id = item.Id,
  244. DiId = dto.DiId,
  245. IsChecked = item.IsChecked,
  246. CountryVisaFeeId = countryVisaFeeId,
  247. OBType = item.OBType,
  248. AgencyFee = item.AgencyFee,
  249. OtherFee = item.OtherFee
  250. });
  251. }
  252. }
  253. //执行删除
  254. var update = _sqlSugar.Updateable<Grp_VisaFeeInfo>().SetColumns(it => new Grp_VisaFeeInfo()
  255. {
  256. DeleteUserId = dto.OpUserId,
  257. DeleteTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
  258. IsDel = 1
  259. }).Where(it => it.DiId == dto.DiId).ExecuteCommand();
  260. var add = _sqlSugar.Insertable(visaInfos).ExecuteCommand();
  261. if (add > 0)
  262. {
  263. CommitTran();
  264. return new Result() { Code = 0, Msg = "操作成功!" };
  265. }
  266. RollbackTran();
  267. return _result;
  268. }
  269. /// <summary>
  270. /// 根据Country和城市Id获取签证费用标准详情
  271. /// </summary>
  272. /// <param name="countrys">国家名称</param>
  273. /// <param name="cityId">城市Id</param>
  274. /// <returns></returns>
  275. public async Task<List<VisaFeeStandardDetailsView>> VisaInfoByCountryAndCityId(List<string> countrys, int cityId)
  276. {
  277. if (countrys == null || countrys.Count == 0 || cityId < 1)
  278. return new List<VisaFeeStandardDetailsView>();
  279. var countryIds = await _sqlSugar.Queryable<Res_VisaFeeStandard>()
  280. .Where(it => it.IsDel == 0 && countrys.Contains(it.Country))
  281. .Select(it => it.Id)
  282. .ToListAsync();
  283. if (countryIds.Count == 0)
  284. return new List<VisaFeeStandardDetailsView>();
  285. var visaFeeStandardDetails = await _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  286. .LeftJoin<Res_VisaFeeStandard>((x, y) => x.ProvinceId == y.Id)
  287. .LeftJoin<Sys_Cities>((x, y, z) => x.ProvinceId == z.Id && (z.Level == 1 || z.Level == 4))
  288. .Where((x, y, z) => x.IsDel == 0 && countryIds.Contains(x.ParentId))
  289. .Select((x, y, z) => new VisaFeeStandardDetailsView
  290. {
  291. Id = x.Id,
  292. ParentId = x.ParentId,
  293. CountryName = y.Country,
  294. ProvinceId = x.ProvinceId,
  295. ProvinceName = z.Name_CN,
  296. VisaAddress = x.VisaAddress,
  297. IsVisaOnArrival = x.IsVisaOnArrival,
  298. IsElectronicSign = x.IsElectronicSign,
  299. VisaTime = x.VisaTime,
  300. IsVisaExemptionLarge = x.IsVisaExemptionLarge,
  301. LargeVisaPrice = x.LargeVisaPrice,
  302. LargeAgencyFee = x.LargeAgencyFee,
  303. IsVisaExemptionSmall = x.IsVisaExemptionSmall,
  304. SmallVisaPrice = x.SmallVisaPrice,
  305. SmallAgencyFee = x.SmallAgencyFee,
  306. NormExtFee = x.NormExtFee,
  307. UrgExtFee = x.UrgExtFee,
  308. IsUrgent = x.IsUrgent,
  309. UrgentTime = x.UrgentTime,
  310. UrgentPrice = x.UrgentPrice,
  311. UrgentPriceDesc = x.UrgentPriceDesc,
  312. Remark = x.Remark,
  313. })
  314. .ToListAsync();
  315. // 默认四川省ID
  316. const int defaultProvinceId = 122;
  317. var visaFeeInfoDefaultList = visaFeeStandardDetails.Where(it => it.ProvinceId == defaultProvinceId).ToList();
  318. var provCityDatas = await _groupRep.ProvinceCityBasicSource();
  319. int provinceId = _groupRep.FindParentIdByChildId(provCityDatas, cityId) ?? 0;
  320. if (provinceId == defaultProvinceId)
  321. return visaFeeInfoDefaultList;
  322. // 其他省份优先返回对应省份数据,否则用四川数据
  323. //其他省份单项信息为空或者费用为0时,使用四川的签证费用信息
  324. var visaInfosGroup = visaFeeStandardDetails.GroupBy(x => x.ParentId);
  325. var resultList = new List<VisaFeeStandardDetailsView>();
  326. var VisaInfoOtherProvs = new List<VisaFeeStandardDetailsView>();
  327. foreach (var group in visaInfosGroup)
  328. {
  329. var scInfo = group.FirstOrDefault(x => x.ProvinceId == defaultProvinceId);
  330. var provInfo = group.FirstOrDefault(x => x.ProvinceId == provinceId);
  331. if (provInfo != null)
  332. {
  333. //送签地址
  334. if (!string.IsNullOrEmpty(provInfo.VisaAddress)) scInfo.VisaAddress = provInfo.VisaAddress;
  335. //签证时间(工作日)
  336. if (!string.IsNullOrEmpty(provInfo.VisaTime)) scInfo.VisaTime = provInfo.VisaTime;
  337. //是否免签(大公务)
  338. if (provInfo.IsVisaExemptionLarge) scInfo.IsVisaExemptionLarge = true;
  339. //签证费用(大公务)
  340. if (provInfo.LargeVisaPrice > 0.00M) scInfo.LargeVisaPrice = provInfo.LargeVisaPrice;
  341. //代办费(大公务)
  342. if (provInfo.LargeAgencyFee > 0.00M) scInfo.LargeAgencyFee = provInfo.LargeAgencyFee;
  343. //是否免签(小公务)
  344. if (provInfo.IsVisaExemptionSmall) scInfo.IsVisaExemptionSmall = true;
  345. //签证费用(小公务)
  346. if (provInfo.SmallVisaPrice > 0.00M) scInfo.SmallVisaPrice = provInfo.SmallVisaPrice;
  347. //代办费(小公务)
  348. if (provInfo.SmallAgencyFee > 0.00M) scInfo.SmallAgencyFee = provInfo.SmallAgencyFee;
  349. //外办费用(普通)
  350. if (provInfo.NormExtFee > 0.00M) scInfo.NormExtFee = provInfo.NormExtFee;
  351. //外办费用(加急)
  352. if (provInfo.UrgExtFee > 0.00M) scInfo.UrgExtFee = provInfo.UrgExtFee;
  353. //签证是否加急
  354. if (provInfo.IsUrgent) scInfo.IsUrgent = true;
  355. //加急费用
  356. if (provInfo.UrgentPrice > 0.00M) scInfo.UrgentPrice = provInfo.UrgentPrice;
  357. //加急费用描述
  358. if (!string.IsNullOrEmpty(provInfo.UrgentPriceDesc)) scInfo.UrgentPriceDesc = provInfo.UrgentPriceDesc;
  359. //备注
  360. if (!string.IsNullOrEmpty(provInfo.Remark)) scInfo.Remark = provInfo.Remark;
  361. resultList.Add(scInfo);
  362. }
  363. }
  364. return resultList;
  365. }
  366. /// <summary>
  367. /// 出入境费用签证费用提示
  368. /// </summary>
  369. /// <param name="diId"></param>
  370. /// <returns></returns>
  371. public async Task<Result> EnterExitCostVisaTips(int diId)
  372. {
  373. if (diId < 1) return _result = new Result() { Code = -1, Msg = "请传入有效的DiId参数" };
  374. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  375. .FirstAsync(it => it.IsDel == 0 && it.Id == diId);
  376. if (groupInfo == null)
  377. return _result = new Result() { Code = -1, Msg = "团组信息不存在!" };
  378. var visaData = await _sqlSugar.Queryable<Grp_VisaFeeInfo>()
  379. .Where(it => it.IsDel == 0 && it.DiId == diId)
  380. .ToListAsync();
  381. var visaFeeIds = visaData.Select(x => x.Id).ToList();
  382. var visaCountryNames = await _sqlSugar.Queryable<Res_CountryFeeCost>()
  383. .Where(it => visaFeeIds.Contains(it.Id))
  384. .Select(it => it.VisaCountry)
  385. .ToListAsync();
  386. var visaCountryDatas = await VisaInfoByCountryAndCityId(visaCountryNames, groupInfo.CityId);
  387. //if (visaCountryDatas.Count == 0)
  388. // return _result = new Result() { Code = -1, Msg = "签证费用信息不存在!" };
  389. var datas = new List<dynamic>();
  390. string remark = "";
  391. decimal feeTotal = 0.00M;
  392. visaData = visaData.Where(it => it.IsChecked == 1).ToList();
  393. var visaData1 = visaData.GroupBy(it => it.CountryVisaFeeId);
  394. //费用报价系数
  395. decimal priceCoeff = 1.00M;
  396. foreach (var kvp in visaData1)
  397. {
  398. var countryData = visaCountryDatas.Find(it => it.Id == kvp.Key);
  399. decimal _otherFee = kvp.FirstOrDefault()?.OtherFee * priceCoeff ?? 0;
  400. decimal _visaFee = 0.00M;
  401. decimal visaFeeTotal = 0.00M;
  402. decimal _agencyFee = 0.00M;
  403. decimal _GrandBusinessAgencyFee = 0.00M;
  404. decimal _PettyBusinessAgencyFee = 0.00M;
  405. string remark1 = "";
  406. foreach (var item in kvp.ToList())
  407. {
  408. if (item.OBType == 1)
  409. {
  410. _visaFee = Convert.ToDecimal(countryData?.LargeVisaPrice ?? 0.00M) * priceCoeff;
  411. remark1 = $"签证费:{_visaFee:#0.00}元、";
  412. if (item.AgencyFee > 0)
  413. {
  414. remark1 += $@"大公务代办费:{item.AgencyFee:#0.00}元、";
  415. _agencyFee += item.AgencyFee;
  416. _GrandBusinessAgencyFee = item.AgencyFee * priceCoeff;
  417. }
  418. }
  419. else if (item.OBType == 2)
  420. {
  421. _visaFee = Convert.ToDecimal(countryData?.SmallVisaPrice ?? 0.00M) * priceCoeff;
  422. remark1 = $"签证费:{_visaFee:#0.00}元、";
  423. if (item.AgencyFee > 0)
  424. {
  425. remark1 += $@"小公务代办费:{item.AgencyFee:#0.00}元、";
  426. _agencyFee += item.AgencyFee;
  427. _PettyBusinessAgencyFee = item.AgencyFee * priceCoeff;
  428. }
  429. }
  430. //_visaFee += _otherFee;
  431. }
  432. if (remark1.Length > 0) remark1 = remark1.Substring(0, remark1.Length - 1);
  433. if (_otherFee > 0) remark1 += $@"其他费用:{_otherFee:#0.00}元";
  434. visaFeeTotal += (_GrandBusinessAgencyFee + _PettyBusinessAgencyFee);
  435. remark += $@"{countryData?.CountryName ?? ""}:签证总费用:{visaFeeTotal}元/人 其中({remark1});";
  436. feeTotal += visaFeeTotal;
  437. datas.Add(new
  438. {
  439. Country = countryData?.CountryName ?? "",
  440. visaFeeTotal,
  441. VisaFee = _visaFee,
  442. GrandBusinessAgencyFee = _GrandBusinessAgencyFee,
  443. PettyBusinessAgencyFee = _PettyBusinessAgencyFee,
  444. OtherFee = _otherFee
  445. });
  446. }
  447. _result.Code = 0;
  448. _result.Data = new
  449. {
  450. feeTotal,
  451. data = datas,
  452. remark
  453. };
  454. return _result;
  455. }
  456. /// <summary>
  457. /// 出入境费用草稿签证费用提示
  458. /// </summary>
  459. /// <param name="portType"></param>
  460. /// <param name="diId"></param>
  461. /// <returns></returns>
  462. public async Task<(decimal, string)> EnterExitCostDraftVisaTips(string[] countrys)
  463. {
  464. var visaCountryDatas = await _sqlSugar.Queryable<Res_CountryFeeCost>().Where(it => countrys.Contains(it.VisaCountry)).ToListAsync();
  465. string remark = "";
  466. decimal feeTotal = 0.00M;
  467. //费用报价系数
  468. decimal priceCoeff = 1.00M;
  469. foreach (var kvp in visaCountryDatas)
  470. {
  471. var countryName = kvp?.VisaCountry ?? "";
  472. //免签
  473. if (kvp.IsVisaExemption == 0)
  474. {
  475. remark += $@"{countryName}:免签;";
  476. continue;
  477. }
  478. decimal visaFee = Convert.ToDecimal(kvp?.VisaPrice ?? 0.00M) * priceCoeff;
  479. decimal gbAgencyFee = kvp.GrandBusinessAgencyFee;
  480. decimal pbAgencyFee = kvp.PettyBusinessAgencyFee;
  481. string remark1 = $"签证费:{visaFee:#0.00}元、";
  482. if (gbAgencyFee > 0.00M)
  483. {
  484. remark1 += $@"大公务代办费:{gbAgencyFee:#0.00}元、";
  485. gbAgencyFee *= priceCoeff;
  486. }
  487. if (pbAgencyFee > 0.00M)
  488. {
  489. remark1 += $@"小公务代办费:{pbAgencyFee:#0.00}元、";
  490. pbAgencyFee *= priceCoeff;
  491. }
  492. if (remark1.Length > 0) remark1 = remark1.Substring(0, remark1.Length - 1);
  493. decimal visaFeeTotal = visaFee + gbAgencyFee + pbAgencyFee;
  494. remark += $@"{countryName}:签证总费用:{visaFeeTotal}元/人 其中({remark1});";
  495. feeTotal += visaFeeTotal;
  496. }
  497. return (feeTotal, remark);
  498. }
  499. }
  500. }