|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
@ -26,54 +25,54 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
mailService = new(provider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 渲染模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="docType">单据类型</param>
|
|
|
|
|
/// <param name="bsId">业务ID</param>
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<string>> RenderTemplateAsync(DocumentType docType, long bsId, BusinessType businessType)
|
|
|
|
|
{
|
|
|
|
|
var taskMail = await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
.Where(x => x.DocumentType == docType).OrderByDescending(x => x.CreateTime).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (taskMail == null)
|
|
|
|
|
return DataResult<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
if (string.IsNullOrEmpty(taskMail.Content))
|
|
|
|
|
return DataResult<string>.Success(taskMail.Content);
|
|
|
|
|
|
|
|
|
|
var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport);
|
|
|
|
|
if (model.Primary == null)
|
|
|
|
|
return DataResult<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
|
|
|
|
|
string content = await MailGenerator.RenderTemplateAsync(taskMail.Content, model);
|
|
|
|
|
return DataResult<string>.Success(content);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取邮件内容
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="docType">单据类型</param>
|
|
|
|
|
/// <param name="templateName">邮件模板名称</param>
|
|
|
|
|
/// <param name="customerNO">委托编号</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<Tuple<string, string>>> GetMailContentAsync(string customerNO, DocumentType docType, string? templateName = null)
|
|
|
|
|
{
|
|
|
|
|
var taskMail = await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
.Where(x => x.DocumentType == docType || x.Name == templateName).OrderByDescending(x => x.CreateTime).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (taskMail == null)
|
|
|
|
|
return DataResult<Tuple<string, string>>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
|
|
|
|
|
var bsId = await TenantDb.Queryable<SeaExport>().Where(x => x.CustomerNo.Contains(customerNO)).Select(x => x.Id).FirstAsync();
|
|
|
|
|
var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport);
|
|
|
|
|
|
|
|
|
|
string title = await MailGenerator.RenderTemplateAsync(taskMail.Title, model);
|
|
|
|
|
string content = await MailGenerator.RenderTemplateAsync(taskMail.Content, model);
|
|
|
|
|
|
|
|
|
|
return DataResult<Tuple<string, string>>.Success(new Tuple<string, string>(title, content));
|
|
|
|
|
}
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 渲染模板
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="docType">单据类型</param>
|
|
|
|
|
///// <param name="bsId">业务ID</param>
|
|
|
|
|
///// <param name="businessType">业务类型</param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//public async Task<DataResult<string>> RenderTemplateAsync(DocumentType docType, long bsId, BusinessType businessType)
|
|
|
|
|
//{
|
|
|
|
|
// var taskMail = await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
// .Where(x => x.DocumentType == docType).OrderByDescending(x => x.CreateTime).FirstAsync();
|
|
|
|
|
|
|
|
|
|
// if (taskMail == null)
|
|
|
|
|
// return DataResult<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
// if (string.IsNullOrEmpty(taskMail.Content))
|
|
|
|
|
// return DataResult<string>.Success(taskMail.Content);
|
|
|
|
|
|
|
|
|
|
// var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport);
|
|
|
|
|
// if (model.Primary == null)
|
|
|
|
|
// return DataResult<string>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
|
|
|
|
|
// string content = await BizMailGenerator.RenderTemplateAsync(taskMail.Content, model);
|
|
|
|
|
// return DataResult<string>.Success(content);
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// 获取邮件内容
|
|
|
|
|
///// </summary>
|
|
|
|
|
///// <param name="docType">单据类型</param>
|
|
|
|
|
///// <param name="templateName">邮件模板名称</param>
|
|
|
|
|
///// <param name="customerNO">委托编号</param>
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
//public async Task<DataResult<Tuple<string, string>>> GetMailContentAsync(string customerNO, DocumentType docType, string? templateName = null)
|
|
|
|
|
//{
|
|
|
|
|
// var taskMail = await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
// .Where(x => x.DocumentType == docType || x.Name == templateName).OrderByDescending(x => x.CreateTime).FirstAsync();
|
|
|
|
|
|
|
|
|
|
// if (taskMail == null)
|
|
|
|
|
// return DataResult<Tuple<string, string>>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
|
|
|
|
|
// var bsId = await TenantDb.Queryable<SeaExport>().Where(x => x.CustomerNo.Contains(customerNO)).Select(x => x.Id).FirstAsync();
|
|
|
|
|
// var model = await mailService.GetTemplateModelAsync(actionService.Value, bsId, BusinessType.OceanShippingExport);
|
|
|
|
|
|
|
|
|
|
// string title = await BizMailGenerator.RenderTemplateAsync(taskMail.Title, model);
|
|
|
|
|
// string content = await BizMailGenerator.RenderTemplateAsync(taskMail.Content, model);
|
|
|
|
|
|
|
|
|
|
// return DataResult<Tuple<string, string>>.Success(new Tuple<string, string>(title, content));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取分页列表
|
|
|
|
|