|
@@ -1,17 +1,29 @@
|
|
|
-using OASystem.Domain;
|
|
|
+using Microsoft.AspNetCore.Mvc.TagHelpers;
|
|
|
+using OASystem.API.OAMethodLib.JuHeAPI;
|
|
|
+using OASystem.Domain;
|
|
|
+using OASystem.Domain.Entities.District;
|
|
|
+using OASystem.Domain.Entities.Financial;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.PersonnelModule;
|
|
|
using OASystem.Domain.Entities.System;
|
|
|
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
|
|
|
using OASystem.Domain.ViewModels.PersonnelModule;
|
|
|
using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
|
using System.Security.Claims;
|
|
|
|
|
|
namespace OASystem.API.OAMethodLib
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
public static class GeneralMethod
|
|
|
{
|
|
|
+ //团组信息
|
|
|
+ private readonly static DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
|
|
|
+ private readonly static TeamRateRepository _teamRateRep = AutofacIocManager.Instance.GetService<TeamRateRepository>();
|
|
|
+ private readonly static IJuHeApiService _juHeApiService = AutofacIocManager.Instance.GetService<IJuHeApiService>();
|
|
|
+ private readonly static SetDataRepository _setDataRep = AutofacIocManager.Instance.GetService<SetDataRepository>();
|
|
|
|
|
|
#region 消息
|
|
|
|
|
@@ -131,8 +143,6 @@ namespace OASystem.API.OAMethodLib
|
|
|
#endregion
|
|
|
|
|
|
#region 用户页面操作功能 权限
|
|
|
- //团组信息
|
|
|
- private readonly static DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// 用户页面操作功能(可使用)
|
|
@@ -232,5 +242,172 @@ namespace OASystem.API.OAMethodLib
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 团组相关
|
|
|
+
|
|
|
+ #region 建团按国家默认添加汇率 / 默认权限分配
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团组汇率
|
|
|
+ /// 建团时 添加基础汇率 CNY
|
|
|
+ /// 按国家 添加 默认币种
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<Result> PostGroupRateAddInit(int userId, int diId)
|
|
|
+ {
|
|
|
+
|
|
|
+ Result result = new() { Code = -2 };
|
|
|
+
|
|
|
+ if (userId < 0)
|
|
|
+ {
|
|
|
+ result.Msg = string.Format(@"请传入正确的userId");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (diId < 0)
|
|
|
+ {
|
|
|
+ result.Msg = string.Format(@"请传入正确的DiId");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //美元(USD):1.0000|欧元(EUR):1.0000|墨西哥比索(MXN):1.0000
|
|
|
+ string CNYInit = string.Format(@"人名币(CNY):1.0000");
|
|
|
+
|
|
|
+ var gropInfo = await _dirRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where( it => it.IsDel == 0 && it.Id == diId).FirstAsync();
|
|
|
+ if (gropInfo != null)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(gropInfo.VisitCountry))
|
|
|
+ {
|
|
|
+ var countryCueencyCodes = await _setDataRep.GetSetDataBySTId(_setDataRep, 66);
|
|
|
+
|
|
|
+ string countrys = gropInfo.VisitCountry;
|
|
|
+ string[] countryItems = new string[] { };
|
|
|
+ if (countrys.Contains("|"))
|
|
|
+ {
|
|
|
+ countryItems = countrys.Split('|');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ countryItems = new string[] { countrys };
|
|
|
+ }
|
|
|
+
|
|
|
+ var countryInfos = await _dirRep._sqlSugar.Queryable<Dis_Country>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+
|
|
|
+ List<string> currencyCodes = new List<string>();
|
|
|
+ if (countryItems.Length > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in countryItems)
|
|
|
+ {
|
|
|
+ Dis_Country country = new Dis_Country();
|
|
|
+ country = countryInfos.Where(it => it.CnShortName.Equals(item)).FirstOrDefault();
|
|
|
+ if (country != null)
|
|
|
+ {
|
|
|
+ if (!item.Equals("中国"))
|
|
|
+ {
|
|
|
+ currencyCodes.Add(country.CurrencyCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currencyCodes.Count > 0)
|
|
|
+ {
|
|
|
+ List<ExchangeRateModel> exchangeRateModels = await _juHeApiService.PostItemRateAsync(currencyCodes.ToArray());
|
|
|
+ if (exchangeRateModels.Count > 0)
|
|
|
+ {
|
|
|
+ var codes = await _dirRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.IsDel == 0).ToListAsync();
|
|
|
+ for (int i = 0; i < exchangeRateModels.Count; i++)
|
|
|
+ {
|
|
|
+ string currencyName = exchangeRateModels[i].Name;
|
|
|
+ string code = "";
|
|
|
+ var currencyData = codes.Where(it => it.IsDel == 0 && it.Remark == currencyName).FirstOrDefault();
|
|
|
+ if (currencyData != null) {
|
|
|
+ code = currencyData.Name;
|
|
|
+ CNYInit += string.Format(@"|{0}({1}):{2}", exchangeRateModels[i].Name, code, exchangeRateModels[i].MSellPri);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Grp_TeamRate> grp_TeamRates = new List<Grp_TeamRate>()
|
|
|
+ {
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 76,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //76 酒店预订
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 77,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //77 行程
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 79,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //79 车/导游地接
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 80,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //80 签证
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 82,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //82 团组客户保险
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 85,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //85 机票预订
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 98,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //98 其他款项
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 285,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //285 收款退还
|
|
|
+ new Grp_TeamRate(){ DiId = diId,CTable = 751,Remark = CNYInit,CreateUserId = userId, IsDel = 0 }, //751 酒店早餐
|
|
|
+ };
|
|
|
+
|
|
|
+ var res = _teamRateRep._sqlSugar.Insertable(grp_TeamRates).ExecuteCommand();
|
|
|
+ if (res < 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ result.Msg = string.Format(@"添加失败!");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = string.Format(@"操作成功!");
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团组汇率
|
|
|
+ /// 建团时 默认按照岗位分配权限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userId"></param>
|
|
|
+ /// <param name="diId"></param>
|
|
|
+ /// <param name="companyId"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<Result> PostGroupAuthAddInit(int userId, int diId, int companyId = 2)
|
|
|
+ {
|
|
|
+
|
|
|
+ Result result = new() { Code = -2 };
|
|
|
+
|
|
|
+ if (userId < 0)
|
|
|
+ {
|
|
|
+ result.Msg = string.Format(@"请传入正确的userId");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (companyId < 0)
|
|
|
+ {
|
|
|
+ result.Msg = string.Format(@"请传入正确的companyId");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (diId < 0)
|
|
|
+ {
|
|
|
+ result.Msg = string.Format(@"请传入正确的DiId");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ //var depData = await _teamRateRep._sqlSugar.Queryable<Sys_Department>().Where(it => it.IsDel == 0 && it.CompanyId == companyId && it.DepName.Equals("国交部")).FirstAsync();
|
|
|
+ //if (depData != null)
|
|
|
+ //{
|
|
|
+ // var userData = await _teamRateRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.CompanyId == companyId && it.DepId == depData.Id).ToListAsync();
|
|
|
+
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = string.Format(@"操作成功!");
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|