|
|
|
@ -6,6 +6,7 @@ using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Dtos.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Interface.TaskInteraction;
|
|
|
|
|
using DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor;
|
|
|
|
|
using DS.WMS.Core.Op.Method.TaskInteraction.ActionExecutor.Booking;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
@ -54,6 +55,74 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
|
|
|
|
|
return await compiledTemplate.RunAsync(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据业务ID和类型获取模板所需数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="actionManager"></param>
|
|
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static async Task<MailTemplateModel> GetTemplateModelAsync(IActionManagerService actionManager,
|
|
|
|
|
long bsId, BusinessType? businessType = null)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(actionManager, nameof(actionManager));
|
|
|
|
|
|
|
|
|
|
MailTemplateModel model = new()
|
|
|
|
|
{
|
|
|
|
|
BusinessId = bsId,
|
|
|
|
|
BusinessType = businessType.GetValueOrDefault(),
|
|
|
|
|
Primary = await actionManager.GetBusinessDataAsync(bsId, businessType.GetValueOrDefault())
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (model.Primary == null)
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
|
|
IDictionary<string, object>? dic = model.Primary as IDictionary<string, object>;
|
|
|
|
|
if (dic == null)
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
|
|
List<Tuple<long, string>> list = [];
|
|
|
|
|
if (dic.TryGetValue(nameof(SeaExport.SaleId), out object? sale))
|
|
|
|
|
list.Add(new Tuple<long, string>((long)sale, nameof(sale)));
|
|
|
|
|
|
|
|
|
|
if (dic.TryGetValue(nameof(SeaExport.OperatorId), out object? op))
|
|
|
|
|
list.Add(new Tuple<long, string>((long)op, nameof(op)));
|
|
|
|
|
|
|
|
|
|
if (dic.TryGetValue(nameof(SeaExport.CustomerService), out object? cs))
|
|
|
|
|
list.Add(new Tuple<long, string>((long)cs, nameof(cs)));
|
|
|
|
|
|
|
|
|
|
if (dic.TryGetValue(nameof(SeaExport.Doc), out object? doc))
|
|
|
|
|
list.Add(new Tuple<long, string>((long)doc, nameof(doc)));
|
|
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var ids = list.Select(x => x.Item1).ToArray();
|
|
|
|
|
var userList = await actionManager.GetUserQueryable(ids).Select(x => new Contact
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
Email = x.Email,
|
|
|
|
|
EnName = x.UserEnName,
|
|
|
|
|
Name = x.UserEnName,
|
|
|
|
|
Mobile = x.Phone,
|
|
|
|
|
//QQ = x
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
long saleId = list.Find(x => x.Item2 == nameof(sale))!.Item1;
|
|
|
|
|
model.Sales = userList.Find(x => x.Id == saleId);
|
|
|
|
|
|
|
|
|
|
long opId = list.Find(x => x.Item2 == nameof(op))!.Item1;
|
|
|
|
|
model.Operator = userList.Find(x => x.Id == opId);
|
|
|
|
|
|
|
|
|
|
long csId = list.Find(x => x.Item2 == nameof(cs))!.Item1;
|
|
|
|
|
model.CustomerService = userList.Find(x => x.Id == csId);
|
|
|
|
|
|
|
|
|
|
long docId = list.Find(x => x.Item2 == nameof(doc))!.Item1;
|
|
|
|
|
model.Document = userList.Find(x => x.Id == docId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据配置发送邮件
|
|
|
|
|
/// </summary>
|
|
|
|
|