|
@@ -6,6 +6,7 @@ using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Group;
|
|
|
using OASystem.Infrastructure.Repositories.System;
|
|
|
using Org.BouncyCastle.Utilities.Collections;
|
|
|
+using Serilog;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -22,9 +23,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
private readonly SetDataRepository _setDataRepository;
|
|
|
private readonly UsersRepository _usersRepository;
|
|
|
+ //public readonly Logs _logs;
|
|
|
|
|
|
- public DelegationInfoRepository(SqlSugarClient sqlSugar, SetDataRepository setDataRepository, UsersRepository usersRepository)
|
|
|
- : base(sqlSugar)
|
|
|
+ public DelegationInfoRepository(SqlSugarClient sqlSugar, SetDataRepository setDataRepository, UsersRepository usersRepository)
|
|
|
+ : base(sqlSugar)
|
|
|
{
|
|
|
this._setDataRepository = setDataRepository;
|
|
|
this._usersRepository = usersRepository;
|
|
@@ -37,9 +39,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
/// <returns></returns>
|
|
|
public async Task<Result> GetGroupList(GroupListDto dto)
|
|
|
{
|
|
|
- Result result = new Result() { Code = -2,Msg="未知错误" };
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
|
|
- if (dto.PortType == 1) //web
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) //web
|
|
|
{
|
|
|
string sql = string.Format(@"Select gdi.Id,SalesQuoteNo,TourCode,ssd.Name TeamType,ssd1.Name TeamLev,TeamName,ClientName,
|
|
|
ClientUnit,VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure
|
|
@@ -49,7 +51,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
Left Join Sys_Users su On gdi.JietuanOperator = su.Id
|
|
|
Where gdi.IsDel = 0
|
|
|
Order By VisitDate Desc");
|
|
|
-
|
|
|
+
|
|
|
var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
|
|
|
if (_DelegationList.Count > 0)
|
|
|
{
|
|
@@ -63,13 +65,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 获取接团信息Info
|
|
|
/// </summary>
|
|
@@ -79,15 +79,15 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
|
|
- if (dto.PortType == 1) //web
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) //web
|
|
|
{
|
|
|
string sql = string.Format(@"Select Id,SalesQuoteNo,JietuanOperator,TeamLevSId,TeamDid,TeamName,ClientName,
|
|
|
ClientUnit,VisitCountry,VisitDate,VisitDays,VisitPNumber,TontractTime,
|
|
|
PayDay,PaymentMoney,VisitPurpose,SpecialNeeds,OtherNeeds,CGRWSPBMMC,CGRWSPWH,
|
|
|
ZZSCBMMC,ZZSCSPWH,Remark,TellPhone
|
|
|
- From Grp_DelegationInfo Where Id = {0} And IsDel=0",dto.Id);
|
|
|
+ From Grp_DelegationInfo Where Id = {0} And IsDel = 0", dto.Id);
|
|
|
|
|
|
- var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).ToListAsync();
|
|
|
+ var _DelegationInfo = await _sqlSugar.SqlQueryable<DelegationInfoWebView>(sql).FirstAsync();
|
|
|
if (_DelegationInfo != null)
|
|
|
{
|
|
|
result.Code = 0;
|
|
@@ -110,44 +110,54 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- public async Task<Result> GetGroupEditBasicSource(GroupListDto dto)
|
|
|
+ public async Task<Result> GroupEditBasicSource(GroupListDto dto)
|
|
|
{
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
|
|
- if (dto.PortType == 1) //web
|
|
|
+ try
|
|
|
{
|
|
|
- dynamic? teamTypeData1 = null;
|
|
|
- string teamTypeSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
|
|
|
- var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ; //团组分类 10
|
|
|
- if (teamTypeData.Count > 0)
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) //web
|
|
|
{
|
|
|
- teamTypeData1 = teamTypeData;
|
|
|
- }
|
|
|
+ dynamic? teamTypeData1 = null;
|
|
|
+ string teamTypeSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
|
|
|
+ var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ; //团组分类 10
|
|
|
+ if (teamTypeData.Count > 0)
|
|
|
+ {
|
|
|
+ teamTypeData1 = teamTypeData;
|
|
|
+ }
|
|
|
|
|
|
- dynamic? teamLevData1 = null;
|
|
|
- string teamLevSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
|
|
|
- var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ; //团组等级 56
|
|
|
- if (teamLevData.Count > 0)
|
|
|
- {
|
|
|
- teamLevData1 = teamLevData;
|
|
|
- }
|
|
|
+ dynamic? teamLevData1 = null;
|
|
|
+ string teamLevSql = string.Format(@"Select Id,Name From Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
|
|
|
+ var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ; //团组等级 56
|
|
|
+ if (teamLevData.Count > 0)
|
|
|
+ {
|
|
|
+ teamLevData1 = teamLevData;
|
|
|
+ }
|
|
|
|
|
|
- dynamic? userData1 = null;
|
|
|
- string userSql = string.Format(@"Select Id,CnName From Sys_Users Where IsDel = {0}", 0);
|
|
|
- var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); ;
|
|
|
- if (userData.Count > 0)
|
|
|
- {
|
|
|
- userData1 = userData;
|
|
|
+ dynamic? userData1 = null;
|
|
|
+ string userSql = string.Format(@"Select Id,CnName From Sys_Users Where IsDel = {0}", 0);
|
|
|
+ var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); ;
|
|
|
+ if (userData.Count > 0)
|
|
|
+ {
|
|
|
+ userData1 = userData;
|
|
|
+ }
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "成功!";
|
|
|
+ result.Data = new
|
|
|
+ {
|
|
|
+ teamTypeData = teamTypeData1,
|
|
|
+ teamLevData = teamLevData1,
|
|
|
+ userData = userData1
|
|
|
+ };
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception)
|
|
|
+ {
|
|
|
|
|
|
- result.Code = 0;
|
|
|
- result.Msg = "成功!";
|
|
|
- result.Data = new {
|
|
|
- teamTypeData = teamTypeData1,
|
|
|
- teamLevData = teamLevData1,
|
|
|
- userData = userData1
|
|
|
- };
|
|
|
+ throw;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -161,7 +171,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
|
|
- if (dto.PortType == 1) //web
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) //web
|
|
|
{
|
|
|
Grp_DelegationInfo groupInfo = new Grp_DelegationInfo()
|
|
|
{
|
|
@@ -171,7 +181,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
ClientUnit = dto.ClientUnit,
|
|
|
TeamName = dto.TeamName,
|
|
|
TeamDid = dto.TeamDid,
|
|
|
- VisitDate = dto.VisitDate,
|
|
|
+ VisitDate = Convert.ToDateTime(dto.VisitDate),
|
|
|
VisitCountry = dto.VisitCountry,
|
|
|
VisitPurpose = dto.VisitPurpose,
|
|
|
VisitDays = dto.VisitDays,
|
|
@@ -185,7 +195,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
CGRWSPWH = dto.CGRWSPWH,
|
|
|
ZZSCBMMC = dto.ZZSCBMMC,
|
|
|
ZZSCSPWH = dto.ZZSCSPWH,
|
|
|
- TontractTime = dto.TontractTime,
|
|
|
+ TontractTime = Convert.ToDateTime(dto.TontractTime),
|
|
|
PaymentMoney = dto.PaymentMoney,
|
|
|
PayDay = dto.PayDay
|
|
|
};
|
|
@@ -199,7 +209,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
And TeamName = '{1}'
|
|
|
And ClientName = '{2}'
|
|
|
And ClientUnit ='{3}'
|
|
|
- And VisitDate ='{4}'",dto.SalesQuoteNo,dto.TeamName,dto.ClientName,dto.ClientUnit,dto.VisitDate);
|
|
|
+ And VisitDate ='{4}'", dto.SalesQuoteNo, dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
|
|
|
var selectGroupInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).FirstAsync();
|
|
|
if (selectGroupInfo != null)
|
|
|
{
|
|
@@ -208,13 +218,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
|
|
|
string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
|
|
|
- var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).FirstAsync();
|
|
|
+ var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
|
|
|
|
|
|
string teamCode = "";
|
|
|
while (true)
|
|
|
{
|
|
|
- teamCode = Tools.CommonFun.GetRandomAllStr(6);
|
|
|
-
|
|
|
+ teamCode = Tools.CommonFun.GetRandomStr(6);
|
|
|
+
|
|
|
if (!teamCodeItem.Equals(teamCode))
|
|
|
{
|
|
|
break;
|
|
@@ -249,10 +259,34 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
|
|
|
|
|
|
- }
|
|
|
- else if (dto.Status == 2) //修改
|
|
|
+ } //增加
|
|
|
+ else if (dto.Status == 2) //修改
|
|
|
{
|
|
|
- var updateStatus = await UpdateAsync(a => a.Id == dto.Id,a=> groupInfo);
|
|
|
+ var updateStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo {
|
|
|
+ SalesQuoteNo = dto.SalesQuoteNo,
|
|
|
+ TeamLevSId = dto.TeamLevSId,
|
|
|
+ ClientName = dto.ClientName,
|
|
|
+ ClientUnit = dto.ClientUnit,
|
|
|
+ TeamName = dto.TeamName,
|
|
|
+ TeamDid = dto.TeamDid,
|
|
|
+ VisitDate = Convert.ToDateTime(dto.VisitDate),
|
|
|
+ VisitCountry = dto.VisitCountry,
|
|
|
+ VisitPurpose = dto.VisitPurpose,
|
|
|
+ VisitDays = dto.VisitDays,
|
|
|
+ VisitPNumber = dto.VisitPNumber,
|
|
|
+ SpecialNeeds = dto.SpecialNeeds,
|
|
|
+ OtherNeeds = dto.OtherNeeds,
|
|
|
+ Remark = dto.Remark,
|
|
|
+ JietuanOperator = dto.UserId,
|
|
|
+ TellPhone = dto.TellPhone,
|
|
|
+ CGRWSPBMMC = dto.CGRWSPBMMC,
|
|
|
+ CGRWSPWH = dto.CGRWSPWH,
|
|
|
+ ZZSCBMMC = dto.ZZSCBMMC,
|
|
|
+ ZZSCSPWH = dto.ZZSCSPWH,
|
|
|
+ TontractTime = Convert.ToDateTime(dto.TontractTime),
|
|
|
+ PaymentMoney = dto.PaymentMoney,
|
|
|
+ PayDay = dto.PayDay
|
|
|
+ });
|
|
|
|
|
|
if (updateStatus)
|
|
|
{
|
|
@@ -264,9 +298,119 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
result.Msg = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
+ else if (dto.Status == 3) //删除
|
|
|
+ {
|
|
|
+ var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo {
|
|
|
+ DeleteUserId = dto.UserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ IsDel = 1
|
|
|
+ });
|
|
|
+
|
|
|
+ if (deleteStatus)
|
|
|
+ {
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "删除成功!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result.Msg = "删除失败!";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团组信息操作
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> GroupDel(GroupDelDto dto)
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
+
|
|
|
+ if (dto.PortType == 1 || dto.PortType == 2) //web
|
|
|
+ {
|
|
|
+ var deleteStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
|
|
|
+ {
|
|
|
+ DeleteUserId = dto.UserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ IsDel = 1
|
|
|
+ });
|
|
|
+
|
|
|
+ if (deleteStatus)
|
|
|
+ {
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "删除成功!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result.Msg = "删除失败!";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取销售报价号
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> GetGroupSalesQuoteNo()
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
+
|
|
|
+ string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
|
|
|
+ var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
|
|
|
+
|
|
|
+ string teamCode = "";
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ teamCode = Tools.CommonFun.GetRandomAllStr(6);
|
|
|
+
|
|
|
+ if (!teamCodeItem.Equals(teamCode))
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "成功!";
|
|
|
+ result.Data = teamCode;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团组删除
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> GroupDeleteById()
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
+
|
|
|
+ string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
|
|
|
+ var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
|
|
|
+
|
|
|
+ string teamCode = "";
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ teamCode = Tools.CommonFun.GetRandomAllStr(6);
|
|
|
+
|
|
|
+ if (!teamCodeItem.Equals(teamCode))
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ result.Code = 0;
|
|
|
+ result.Msg = "成功!";
|
|
|
+ result.Data = teamCode;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|