You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

114 lines
4.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using Sog.Log;
using ProtoCSStruct;
namespace Rank
{
public static class MailSender
{
public static void SendNewMailToPlayer(long uid, int mailId, string rewardId, int param1=0, int param2 =0, int param3=0)
{
var desc = MailDescMgr.Instance.GetConfig(mailId);
DBMail mail = new DBMail();
mail.Uid = uid;
mail.MailConfId = mailId;
mail.MailType = (int)MailType.None;
mail.SendTime = RankServerUtils.GetTimeSecond();
mail.ExpirationTime = RankServerUtils.GetTimeSecond() + desc.expireTime * 24 * 3600;
mail.Param1 = param1;
mail.Param2 = param2;
mail.Param3 = param3;
if (!string.IsNullOrEmpty(rewardId))
{
mail.AddReward.SetString(rewardId);
}
MailSender.SendNewMailToPlayer(uid, ref mail);
}
/// <summary>
/// 邮件发送需要回应,保证不出错
/// </summary>
/// <param name="clientOpUid">客户端发起的时候填写</param>
/// <param name="mail"></param>
public static void SendNewMailToPlayer(long clientOpUid, ref DBMail mail)
{
SendMailOpReqToDB(clientOpUid, MailOpType.Insert, ref mail);
}
/// <summary>
/// 邮件发送需要回应,保证不出错
/// </summary>
/// <param name="clientOpUid">客户端发起的时候填写</param>
/// <param name="opType"></param>
/// <param name="mail"></param>
/// <param name="notifyclient"></param>
internal static void SendMailOpReqToDB(long clientOpUid, MailOpType opType, ref DBMail mail)
{
TraceLog.UserDebug(clientOpUid,"MailSender.SendMailOpReqToDB clientOpUid {0} opType {1} ", clientOpUid, opType);
SSMailOpReq mailOpReq = new SSMailOpReq();
mailOpReq.OpType = (int)opType;
mailOpReq.ClientOpUid = 0; //0 默认通知game
mailOpReq.AckGameServerID = RankServerUtils.GetApp().ServerID;
mailOpReq.UniqueID = WaitAckStructRequestSender.Instance.GeneratorUniqueID();
if(opType == MailOpType.Insert)
{
mail.InsertUniqueID = mailOpReq.UniqueID;
}
mailOpReq.Mail = mail;
uint mailServerID = RankServerUtils.GetPacketSender().GetMailServerID();
WaitAckStructRequestSender.Instance.BeginSendNeedResend(mailOpReq.UniqueID, mailServerID
, (int)SSGameMsgID.MailOpReq
, ref mailOpReq
, clientOpUid);
CommBillLogUtils.LogMailOpBegin(clientOpUid, ref mail, (int)opType);
}
public static void SendNewMailToPlayerNoCheck(long clientOpUid, ref DBMail mail)
{
SendMailOpReqToDBNoCheck(clientOpUid, MailOpType.Insert, ref mail);
}
/// <summary>
/// 邮件发送,允许发送失败,失败就算了
/// </summary>
/// <param name="clientOpUid">客户端发起的时候填写</param>
/// <param name="opType"></param>
/// <param name="mail"></param>
/// <param name="notifyclient"></param>
private static void SendMailOpReqToDBNoCheck(long clientOpUid, MailOpType opType, ref DBMail mail)
{
TraceLog.UserDebug(clientOpUid, "MailSender.SendMailOpReqToDBNoCheck clientOpUid {0} opType {1} ", clientOpUid, opType);
SSMailOpReq mailOpReq = new SSMailOpReq();
mailOpReq.OpType = (int)opType;
mailOpReq.ClientOpUid = 0; //0 默认
mailOpReq.AckGameServerID = RankServerUtils.GetApp().ServerID;
mailOpReq.UniqueID = WaitAckStructRequestSender.Instance.GeneratorUniqueID();
if (opType == MailOpType.Insert)
{
mail.InsertUniqueID = mailOpReq.UniqueID;
}
mailOpReq.Mail = mail;
RankServerUtils.GetPacketSender().SendToMailServer((int)SSGameMsgID.MailOpReq, ref mailOpReq, clientOpUid);
CommBillLogUtils.LogMailOpBegin(clientOpUid, ref mail, (int)opType);
}
}
}