|
@@ -157,6 +157,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
BeginTran();
|
|
|
int id = 0;
|
|
|
var grp_Decrease = _mapper.Map<Grp_DecreasePayments>(dto);
|
|
|
+ var recheck = true;
|
|
|
+
|
|
|
|
|
|
//处理费用总计
|
|
|
if (grp_Decrease.FeeTotal == 0.00M)
|
|
@@ -174,6 +176,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
if (dto.Status == 1)//添加
|
|
|
{
|
|
|
id = await AddAsyncReturnId(grp_Decrease);
|
|
|
+ grp_Decrease.Id = id;
|
|
|
|
|
|
#region C表赋值
|
|
|
|
|
@@ -335,7 +338,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
if (isAuto)
|
|
|
{
|
|
|
- _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
+ var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
.SetColumns(a => new Grp_CreditCardPayment
|
|
|
{
|
|
|
IsAuditGM = 3, //自动审核通过
|
|
@@ -344,21 +347,29 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
})
|
|
|
.Where(a => a.CId == id && a.CTable == 98 && a.DIId == 2590)
|
|
|
.ExecuteCommand();
|
|
|
+ recheck = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 会务成本自动审核处理
|
|
|
+ var hwids = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
|
|
|
+ .Select(x => x.Id)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var groupTypeIsTrue = _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.Id == dto.DiId && x.IsDel == 0)
|
|
|
+ .Any(x => hwids.Contains(x.TeamDid));
|
|
|
|
|
|
- if (false)
|
|
|
+ if (groupTypeIsTrue)
|
|
|
{
|
|
|
var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
|
|
|
.First(x => x.Diid == dto.DiId && x.IsDel == 0);
|
|
|
|
|
|
if (main != null)
|
|
|
{
|
|
|
-
|
|
|
var chiArr = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
|
|
|
.Where(x => x.Diid == dto.DiId && x.ConferenceAffairsCostId == main.Id && x.IsDel == 0)
|
|
|
.ToList();
|
|
@@ -369,40 +380,64 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
if (find != null)
|
|
|
{
|
|
|
|
|
|
+ //检索历史金额
|
|
|
+ var histyPrice = _sqlSugar.Queryable<Grp_DecreasePayments>()
|
|
|
+ .LeftJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 98 && a.CId == x.Id )
|
|
|
+ .Where((x, a) => x.IsDel == 0 && x.PriceName == dto.PriceName && x.Id != grp_Decrease.Id)
|
|
|
+ .Select((x, a) => new
|
|
|
+ {
|
|
|
+ x.FeeTotal,
|
|
|
+ x.Currency,
|
|
|
+ a.DayRate,
|
|
|
+ a.RMBPrice,
|
|
|
+ x.DiId,
|
|
|
+ x.PriceName,
|
|
|
+ x.Price,
|
|
|
+ x.Quantity,
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+
|
|
|
//币种不同情况
|
|
|
- if (find.Currency != dto.Currency)
|
|
|
+ if (true)
|
|
|
{
|
|
|
//币种全转换为人民币
|
|
|
var rate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
|
|
|
if (rate != null)
|
|
|
{
|
|
|
- //dto.Price *= rate.Rate;
|
|
|
grp_Decrease.FeeTotal *= rate.Rate;
|
|
|
}
|
|
|
|
|
|
var ConferenceAffairsCostFeeTotal = 0.00M;
|
|
|
- var ConferenceAffairsCostRate = teamRates.Where(it => it.CurrencyId == find.Currency).FirstOrDefault();
|
|
|
- if (rate != null)
|
|
|
+ ConferenceAffairsCostFeeTotal = find.Count * find.CostPrice * find.Rate;
|
|
|
+
|
|
|
+ var histyPriceValue = histyPrice.Sum(x => x.FeeTotal * x.DayRate);
|
|
|
+ if (ConferenceAffairsCostFeeTotal > histyPriceValue)
|
|
|
{
|
|
|
- //dto.Price *= rate.Rate;
|
|
|
- ConferenceAffairsCostFeeTotal = rate.Rate * find.CostPrice * find.Count;
|
|
|
+ isAuto = ConferenceAffairsCostFeeTotal - histyPriceValue >= grp_Decrease.FeeTotal;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- isAuto = find.CostPrice >= dto.Price && find.Count >= dto.Quantity;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isAuto) { }
|
|
|
+ if (isAuto) {
|
|
|
+
|
|
|
+ var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
+ .SetColumns(a => new Grp_CreditCardPayment
|
|
|
+ {
|
|
|
+ IsAuditGM = 3, //自动审核通过
|
|
|
+ AuditGMOperate = 4,
|
|
|
+ AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ })
|
|
|
+ .Where(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.DIId == grp_Decrease.DiId)
|
|
|
+ .ExecuteCommand();
|
|
|
+ recheck = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
CommitTran();
|
|
|
- var data = new { ccpId = cId, sign = 1, dataId = id };
|
|
|
+ var data = new { ccpId = cId, sign = 1, dataId = id, recheck };
|
|
|
return new JsonView() { Code = 200, Msg = "添加成功!", Data = data };
|
|
|
}
|
|
|
|
|
@@ -559,13 +594,98 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
})
|
|
|
.Where(a => a.CId == dto.Id && a.CTable == 98 && a.DIId == 2590)
|
|
|
.ExecuteCommand();
|
|
|
+ recheck = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 会务成本自动审核处理
|
|
|
+ var hwids = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
|
|
|
+ .Select(x => x.Id)
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ var groupTypeIsTrue = _sqlSugar.Queryable<Grp_DelegationInfo>()
|
|
|
+ .Where(x => x.Id == dto.DiId && x.IsDel == 0)
|
|
|
+ .Any(x => hwids.Contains(x.TeamDid));
|
|
|
+
|
|
|
+ if (groupTypeIsTrue)
|
|
|
+ {
|
|
|
+ var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
|
|
|
+ .First(x => x.Diid == dto.DiId && x.IsDel == 0);
|
|
|
+
|
|
|
+ if (main != null)
|
|
|
+ {
|
|
|
+ var chiArr = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
|
|
|
+ .Where(x => x.Diid == dto.DiId && x.ConferenceAffairsCostId == main.Id && x.IsDel == 0)
|
|
|
+ .ToList();
|
|
|
+ var find = chiArr.FirstOrDefault(x => x.PriceName == dto.PriceName && x.ReviewStatus == 1);
|
|
|
+ var isAuto = false;
|
|
|
+
|
|
|
+ //存在已审的会务成本
|
|
|
+ if (find != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ //检索历史金额
|
|
|
+ var histyPrice = _sqlSugar.Queryable<Grp_DecreasePayments>()
|
|
|
+ .LeftJoin<Grp_CreditCardPayment>((x, a) => a.IsDel == 0 && a.CTable == 98 && a.CId == x.Id)
|
|
|
+ .Where((x, a) => x.IsDel == 0 && x.PriceName == dto.PriceName && x.Id != grp_Decrease.Id)
|
|
|
+ .Select((x, a) => new
|
|
|
+ {
|
|
|
+ x.FeeTotal,
|
|
|
+ x.Currency,
|
|
|
+ a.DayRate,
|
|
|
+ a.RMBPrice,
|
|
|
+ x.DiId,
|
|
|
+ x.PriceName,
|
|
|
+ x.Price,
|
|
|
+ x.Quantity,
|
|
|
+ })
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ if (true)
|
|
|
+ {
|
|
|
+ //币种全转换为人民币
|
|
|
+ var rate = teamRates.Where(it => it.CurrencyId == grp_Decrease.Currency).FirstOrDefault();
|
|
|
+ if (rate != null)
|
|
|
+ {
|
|
|
+ grp_Decrease.FeeTotal *= rate.Rate;
|
|
|
+ }
|
|
|
+
|
|
|
+ var ConferenceAffairsCostFeeTotal = 0.00M;
|
|
|
+ ConferenceAffairsCostFeeTotal = find.Count * find.CostPrice * find.Rate;
|
|
|
+
|
|
|
+ var histyPriceValue = histyPrice.Sum(x => x.FeeTotal * x.DayRate);
|
|
|
+ if (ConferenceAffairsCostFeeTotal > histyPriceValue)
|
|
|
+ {
|
|
|
+ isAuto = ConferenceAffairsCostFeeTotal - histyPriceValue >= grp_Decrease.FeeTotal;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isAuto)
|
|
|
+ {
|
|
|
+
|
|
|
+ var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
+ .SetColumns(a => new Grp_CreditCardPayment
|
|
|
+ {
|
|
|
+ IsAuditGM = 3, //自动审核通过
|
|
|
+ AuditGMOperate = 4,
|
|
|
+ AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ })
|
|
|
+ .Where(a => a.CId == grp_Decrease.Id && a.CTable == 98 && a.DIId == grp_Decrease.DiId)
|
|
|
+ .ExecuteCommand();
|
|
|
+ recheck = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
CommitTran();
|
|
|
|
|
|
- var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2, dataId = grp_Decrease.Id };
|
|
|
+ var data = new { ccpId = grp_CreditCardPayment.Id, sign = 2, dataId = grp_Decrease.Id ,recheck };
|
|
|
|
|
|
return new JsonView() { Code = 200, Msg = "修改成功!", Data = data };
|
|
|
}
|