Commit 3efab4b7 authored by 吴春's avatar 吴春

1

parent d12c7ed5
......@@ -58,6 +58,8 @@ namespace REBORN.Common.EMail
_configs.TryGetValue(name, out var config);
return config;
}
}
/// <summary>
......@@ -89,15 +91,34 @@ namespace REBORN.Common.EMail
/// 邮箱发送者账号
/// </summary>
public string MailFromAccount { get; set; }
/// <summary>
/// 邮箱发送者密码
/// </summary>
public string MailPassword { get; set; }
/// <summary>
/// 邮箱接收人信息
/// </summary>
public MailboxAddress From { get; set; }
}
/// <summary>
/// 邮箱配置实体
/// </summary>
public class MailConfig_Extend : MailConfig
{
/// <summary>
/// 发件人名称
/// </summary>
public string Title { get; set; }
/// <summary>
/// 发件人集团
/// </summary>
public int RB_Group_id { get; set; }
}
}
......@@ -21,14 +21,15 @@ namespace REBORN.Common.EMail
/// <summary>
/// 创建Email帮助类
/// </summary>
public static EMailHelper Instance {
get
public static EMailHelper Instance
{
get
{
if (_instance == null)
if (_instance == null)
{
lock (locker)
lock (locker)
{
if (_instance == null)
if (_instance == null)
{
_instance = new EMailHelper();
}
......@@ -41,7 +42,7 @@ namespace REBORN.Common.EMail
/// <summary>
/// 构造函数
/// </summary>
public EMailHelper()
public EMailHelper()
{
RegistConfig();
}
......@@ -69,6 +70,28 @@ namespace REBORN.Common.EMail
From = new MailboxAddress("Travel Design产品团队", "service@viitto.com")
};
EMailConfigManager.Instance.AddOrUpdateConfig("pptist", pptistConfig);
var mailConfig = Config.GetAppSetting("MailConfig");
if (!string.IsNullOrWhiteSpace(mailConfig))
{
var mailConfigList = JsonHelper.DeserializeObject<List<MailConfig_Extend>>(mailConfig);
if (mailConfigList != null && mailConfigList.Any())
{
foreach (var item in mailConfigList)
{
var HuaTuConfig = new MailConfig
{
Port = 465,
Host = "smtp.exmail.qq.com",
MailFromAccount = item.MailFromAccount,
MailPassword = item.MailPassword,
UseSsl = true,
From = new MailboxAddress(item.Title, item.MailFromAccount)
};
EMailConfigManager.Instance.AddOrUpdateConfig(item.RB_Group_id.ToString(), pptistConfig);
}
}
}
}
/// <summary>
......@@ -78,14 +101,16 @@ namespace REBORN.Common.EMail
/// <param name="subject"></param>
/// <param name="message"></param>
/// <param name="provideName"></param>
public void SendEmail(Dictionary<string,string> tos, string subject, string message,string provideName = "default")
public void SendEmail(Dictionary<string, string> tos, string subject, string message, string provideName = "default")
{
var emailMessage = new MimeMessage();
var config = EMailConfigManager.Instance.GetConfig(provideName);
if (config == null || string.IsNullOrWhiteSpace(config.MailFromAccount) || string.IsNullOrWhiteSpace(config.MailPassword)) {
return;
}
emailMessage.From.Add(config.From);
foreach (var to in tos)
emailMessage.To.Add(new MailAddress(to.Key,to.Value));
emailMessage.To.Add(new MailAddress(to.Key, to.Value));
emailMessage.Subject = subject;
var alternative = new Multipart("alternative");
if (config.IsHtml)
......@@ -122,10 +147,166 @@ namespace REBORN.Common.EMail
}
catch (Exception ex)
{
LogHelper.Error("邮件发送失败:"+ex.Message,ex);
LogHelper.Error("邮件发送失败:" + ex.Message, ex);
}
}
}
/// <summary>
/// 生成邮轮新订单提醒信息
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public string CreateMessage(Dictionary<string, string> dic)
{
// 创建字典并填充数据
//Dictionary<string, string> dic = new Dictionary<string, string>();
//dic.Add("订单类型", "签证产品");
//dic.Add("订单来源", "ERP");
//dic.Add("订单编号", "73802");
//dic.Add("团队信息", "12306251003A(29128)");
//dic.Add("产品名称", "10.3-10.8 刘毅2人北京-新加坡 自由行6日");
//dic.Add("订单人数", "2人");
//dic.Add("销售人员", "刘毅");
// 生成HTML字符串
return $@"
<!DOCTYPE html>
<html lang=""zh-CN"">
<head>
<meta charset=""UTF-8"">
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
<title>订单信息</title>
<style>
* {{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Microsoft YaHei', sans-serif;
}}
body {{
background-color: #f5f7f9;
padding: 20px;
color: #333;
}}
.container {{
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 10px;
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
overflow: hidden;
}}
.header {{
background: linear-gradient(135deg, #3498db, #2c3e50);
color: white;
padding: 20px;
text-align: center;
font-size: 24px;
font-weight: bold;
}}
.order-info {{
padding: 25px;
}}
.info-row {{
display: flex;
border-bottom: 1px solid #eee;
padding: 15px 0;
}}
.info-label {{
width: 120px;
font-weight: bold;
color: #2c3e50;
}}
.info-value {{
flex: 1;
color: #34495e;
}}
.footer {{
text-align: center;
padding: 20px;
color: #7f8c8d;
font-size: 14px;
}}
@media (max-width: 600px) {{
.info-row {{
flex-direction: column;
}}
.info-label {{
width: 100%;
margin-bottom: 5px;
}}
}}
</style>
</head>
<body>
<div class=""container"">
<div class=""header"">
订单信息
</div>
<div class=""order-info"">
{string.Join("", dic.Select(kv => $@"
<div class=""info-row"">
<div class=""info-label"">{kv.Key}:</div>
<div class=""info-value"">{kv.Value}</div>
</div>"))}
</div>
</div>
</body>
</html>";
//<div class=""footer"">
// 系统自动生成 | 订单信息仅供参考
//</div>
}
/// <summary>
/// 发邮件
/// </summary>
/// <param name="tos"></param>
/// <param name="subject"></param>
/// <param name="message"></param>
/// <param name="provideName"></param>
public void SendEmail_YL(Dictionary<string, string> tos, string subject, string message, string provideName = "default")
{
var emailMessage = new MimeMessage();
var config = EMailConfigManager.Instance.GetConfig(provideName);
emailMessage.From.Add(config.From);
foreach (var to in tos)
emailMessage.To.Add(new MailAddress(to.Key, to.Value));
emailMessage.Subject = subject;
var alternative = new Multipart("alternative");
if (config.IsHtml)
alternative.Add(new TextPart("html") { Text = message });
else
alternative.Add(new TextPart("plain") { Text = message });
emailMessage.Body = alternative;
using (var client = new SmtpClient())
{
try
{
client.Connect(config.Host, config.Port);// SecureSocketOptions.None
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(config.MailFromAccount, config.MailPassword);
client.Send(emailMessage);
client.Disconnect(true);
}
catch (Exception ex)
{
LogHelper.Error("邮件发送失败:" + ex.Message, ex);
}
}
}
}
/// <summary>
......
using REBORN.Model.Entity;
using REBORN.Common.EMail;
using REBORN.Common.Enum.Dmc;
using REBORN.Common.Plugin;
using REBORN.Common;
using REBORN.Model.Entity;
using REBORN.Repository;
using REBORN.Repository.Commons;
using System;
......@@ -81,7 +85,7 @@ namespace REBORN.Module.ConfigModule
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{
{ nameof(RB_MessagePushConfig.UpdateBy),model.UpdateBy},
{ nameof(RB_MessagePushConfig.UpdateTime),DateTime.Now},
};
......@@ -108,7 +112,7 @@ namespace REBORN.Module.ConfigModule
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool DelMessagePushConfig(int id,int updateBy)
public bool DelMessagePushConfig(int id, int updateBy)
{
bool flag = false;
if (id > 0)
......@@ -129,5 +133,65 @@ namespace REBORN.Module.ConfigModule
return flag;
}
/// <summary>
/// 消息推送信息
/// </summary>
/// <param name="RB_Group_id"></param>
/// <param name="dic"></param>
/// <param name="mSendType"></param>
public void MessagePushSend(int RB_Group_id, Dictionary<string, string> dic, MessagePushSendType mSendType)
{
var mpcList = GetList(new RB_MessagePushConfig { RB_Group_Id = RB_Group_id });
if (mpcList != null && mpcList.Any())
{
foreach (var mpcModel in mpcList)
{
int sendType = (int)mSendType;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType ?? "");
if (!string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
{//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
}
catch (Exception ex)
{
LogHelper.Error("企业微信消息推送失败", ex);
}
}
if (!string.IsNullOrWhiteSpace(mpcModel?.EmailRecipients ?? "") && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && (mpcModel?.EmailEnabled ?? 0) == 1)
{//新增订单,推送消息
try
{
List<string> emailRecipientsList = new List<string>();
var revices = new Dictionary<string, string>();
if (!string.IsNullOrWhiteSpace(mpcModel.EmailRecipients))
{
try
{
emailRecipientsList = mpcModel.EmailRecipients.Split(',').ToList();
foreach (var item in emailRecipientsList)
{
revices.Add(item.Split('@')?[0], item);
}
}
catch (Exception ex)
{
}
}
EMailHelper.Instance.SendEmail(revices, "新订单推送", (EMailHelper.Instance.CreateMessage(dic)), RB_Group_id.ToString());
}
catch (Exception ex)
{
LogHelper.Error("邮件消息推送失败", ex);
}
}
}
}
}
}
}
......@@ -15,6 +15,7 @@ using REBORN.Model.Extend;
using REBORN.Model.Extend.Dmc;
using REBORN.Model.Extend.Finance;
using REBORN.Model.Extend.Sell;
using REBORN.Module.ConfigModule;
using REBORN.Module.DMCModule;
using REBORN.Repository;
using REBORN.Repository.Commons;
......@@ -35,7 +36,10 @@ namespace REBORN.Module.SellModule
/// </summary>
public class CustomerOrderModule
{
private readonly RB_MessagePushConfigRepository messagePushConfigRepository = new RB_MessagePushConfigRepository();
/// <summary>
/// 消息推送处理类
/// </summary>
private MessagePushConfigModule messagePushConfigModule = new MessagePushConfigModule();
/// <summary>
/// 其它单项服务合同
/// </summary>
......@@ -1173,32 +1177,19 @@ namespace REBORN.Module.SellModule
#region 推送企微机器人消息
var mpcModel = messagePushConfigRepository.GetList(new RB_MessagePushConfig { SendType = "1", RB_Group_Id = demodel.GroupId })?.FirstOrDefault() ?? new RB_MessagePushConfig();
int sendType = (int)MessagePushSendType.NewOrder;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType??"");
if (userInfo.SimpleEasy == 1 && sendTypeList != null && (sendTypeList.Any(x => x == sendType))&& !string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
if (userInfo.SimpleEasy == 1)
{
string jdName = hotel?.Name;
if (demodel.GroupId == 2)
{
Dictionary<string, string> dic = new Dictionary<string, string>
{
{ "订单类型", "酒店产品" },
{ "订单编号", demodel.OrderNo.ToString() },
{ "产品名称", jdName },
{ "销售人员", userInfo.emName }
};
//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
}
catch (Exception ex)
Dictionary<string, string> dic = new Dictionary<string, string>
{
LogHelper.Error("企业微信消息推送失败", ex);
}
}
{ "订单类型", "酒店产品" },
{ "订单编号", demodel.OrderNo.ToString() },
{ "产品名称", jdName },
{ "销售人员", userInfo.emName }
};
//新增订单,推送消息
messagePushConfigModule.MessagePushSend(userInfo.RB_Group_id, dic, MessagePushSendType.NewOrder);
}
#endregion
}
......@@ -3621,11 +3612,8 @@ namespace REBORN.Module.SellModule
#region 推送企微机器人消息
// var dictModel = dictvalueRepository.GetList(new RB_Dictvalue_Extend() { RB_Group_id = demodel.GroupId, DictKey = "Client_OrderPush_Url" }).FirstOrDefault();
var mpcModel = messagePushConfigRepository.GetList(new RB_MessagePushConfig { SendType = "1", RB_Group_Id = demodel.GroupId })?.FirstOrDefault() ?? new RB_MessagePushConfig();
int sendType = (int)MessagePushSendType.NewOrder;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType??"");
if (userInfo.SimpleEasy == 1 && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && !string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
if (userInfo.SimpleEasy == 1 )
{
string jdName = ticketCouponsRepository.GetEntity(demodel.CouponsId)?.Name ?? "";
......@@ -3640,13 +3628,13 @@ namespace REBORN.Module.SellModule
//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
//新增订单,推送消息
messagePushConfigModule.MessagePushSend(userInfo.RB_Group_id, dic, MessagePushSendType.NewOrder);
}
catch (Exception ex)
{
LogHelper.Error("企业微信消息推送失败", ex);
LogHelper.Error("推送机器人消息失败", ex);
}
}
#endregion
}
......@@ -5317,13 +5305,9 @@ namespace REBORN.Module.SellModule
LogId = 0,
LogContent = userInfo.emName + "新增订单"
});
var mpcModel = messagePushConfigRepository.GetList(new RB_MessagePushConfig { SendType = "1", RB_Group_Id = demodel.GroupId })?.FirstOrDefault() ?? new RB_MessagePushConfig();
int sendType = (int)MessagePushSendType.NewOrder;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType ?? "");
if (userInfo.SimpleEasy == 1 && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && !string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
if (userInfo.SimpleEasy == 1 )
{
// string jdName = ticketCouponsRepository.GetEntity(demodel.CouponsId)?.Name ?? "";
//新增订单,推送消息
Dictionary<string, string> dic = new Dictionary<string, string>
{
......@@ -5332,10 +5316,10 @@ namespace REBORN.Module.SellModule
{ "出发时间", StringHelper.FormatDate(demodel.DepartTime) },
{ "销售人员", userInfo.emName }
};
//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
//新增订单,推送消息
messagePushConfigModule.MessagePushSend(userInfo.RB_Group_id, dic, MessagePushSendType.NewOrder);
}
catch (Exception ex)
{
......
......@@ -14,6 +14,7 @@ using REBORN.CacheManager.User;
using REBORN.Common;
using REBORN.Common.API;
using REBORN.Common.Data;
using REBORN.Common.EMail;
using REBORN.Common.Enum;
using REBORN.Common.Enum.Dmc;
using REBORN.Common.Enum.Sell;
......@@ -64,7 +65,10 @@ namespace REBORN.Module.SellModule
/// </summary>
public partial class SellOrderModule
{
private readonly RB_MessagePushConfigRepository messagePushConfigRepository = new RB_MessagePushConfigRepository();
/// <summary>
/// 消息推送处理类
/// </summary>
private MessagePushConfigModule messagePushConfigModule = new MessagePushConfigModule();
/// <summary>
/// 供应商仓储类
/// </summary>
......@@ -6756,12 +6760,13 @@ namespace REBORN.Module.SellModule
#endregion
orderRepository.DBSession.Commit();
coupon_AllotRepository.DBSession.Commit();
//自动更新候补订单
updaeTravelOrderWaitingRepository.UpdateOrderWaitingRepository(tmodel, null);
var mpcModel = messagePushConfigRepository.GetList(new RB_MessagePushConfig { SendType = "1" ,RB_Group_Id= dmodel .RB_Group_Id})?.FirstOrDefault() ?? new RB_MessagePushConfig();
int sendType = (int)MessagePushSendType.NewOrder;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType ?? "");
if (isAddorder && userInfo.SimpleEasy == 1 && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && !string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
if (userInfo.SimpleEasy == 0)
{
//自动更新候补订单
updaeTravelOrderWaitingRepository.UpdateOrderWaitingRepository(tmodel, null);
}
if (isAddorder && userInfo.SimpleEasy == 1)
{
//推送消息到企业微信
//新增订单,推送消息
......@@ -6779,7 +6784,8 @@ namespace REBORN.Module.SellModule
}
}
var priceExtModel = GetTravelInfoExt(dmodel?.TCID ?? 0);
if (!string.IsNullOrWhiteSpace(teamTypeName)) {
if (!string.IsNullOrWhiteSpace(teamTypeName))
{
dic.Add("订单类型", teamTypeName);
}
string orderSourceStr = dmodel?.OrderSource?.ToName();
......@@ -6793,16 +6799,9 @@ namespace REBORN.Module.SellModule
dic.Add("订单人数", (dmodel?.GuestNum ?? 0).ToString() + "人");
dic.Add("销售人员", userInfo.emName);
//新增订单,推送消息
//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
}
catch (Exception ex)
{
LogHelper.Error("企业微信消息推送失败", ex);
}
messagePushConfigModule.MessagePushSend(userInfo.RB_Group_id, dic, MessagePushSendType.NewOrder);
}
return "";
}
else
......@@ -7270,5 +7270,6 @@ LEFT JOIN {(Config.IsOnline ? "uat_reborn_user" : "reborn_user")}.rb_employee e
#endregion
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ using REBORN.Repository.Sell;
using System.Collections;
using System.Web.UI.WebControls.WebParts;
using REBORN.Module.ConfigModule;
using REBORN.Common.EMail;
namespace REBORN.Services.DMCService
{
......@@ -5272,20 +5273,7 @@ namespace REBORN.Services.DMCService
}
else if (userInfo.SimpleEasy == 1)
{
var mpcModel = messagePushConfigModule.GetList(new RB_MessagePushConfig { SendType = "1", RB_Group_Id = userInfo.RB_Group_id })?.FirstOrDefault() ?? new RB_MessagePushConfig();
int sendType = (int)MessagePushSendType.NewOrder;
var sendTypeList = StringHelper.StringToListInt(mpcModel?.SendType ?? "");
if (!string.IsNullOrWhiteSpace(mpcModel?.WeChatBotWebhookUrl ?? "") && sendTypeList != null && (sendTypeList.Any(x => x == sendType)) && (mpcModel?.WeChatBotEnabled ?? 0) == 1)
{//新增订单,推送消息
try
{
Common.Plugin.QYWorkHelper.NewOrderMessagePush(dic, mpcModel?.WeChatBotWebhookUrl);
}
catch (Exception ex)
{
LogHelper.Error("企业微信消息推送失败", ex);
}
}
messagePushConfigModule.MessagePushSend(userInfo.RB_Group_id, dic, MessagePushSendType.NewOrder);
}
}
if (flag)
......
......@@ -537,4 +537,8 @@
<add key="NoShowScenicIdID" value="自由活动,启程,回程" />
<!--集团默认国家信息-->
<add key="DefaultCountry" value='[{"ID":2,"RB_Group_id":"2","ParentID":1},{"ID":9835,"RB_Group_id":"81","ParentID":2941}]'/>
<!--画途邮箱基础信息开始-->
<add key="MailConfig" value='[{"MailFromAccount":"service@viitto.com","MailPassword":"bSL7FkkFCBsU3omk","Title":"Travel Design产品团队","RB_Group_id":"2"}]'/>
<!--画途邮箱基础信息结束-->
</appSettings>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment