1.优化代运营 补偿机制

This commit is contained in:
老道 2023-02-02 15:37:56 +08:00
parent fb296bb61c
commit 26303e1ffb
2 changed files with 379 additions and 331 deletions

View File

@ -51,15 +51,22 @@ namespace ProductClient
//创建配置文件
Config = this.ReadConfig<Config>();
//var thread = TimerTask.NewTimer<MonitorThread>(60) as MonitorThread;
EventClient.DyyNoticeEvent += EventClient_DyyNoticeEvent;
var thread = TimerTask.NewTimer<MonitorThread>(60) as MonitorThread;
//EventClient_DyyNoticeEvent(null, new DyyNoticeEvent()
//{
// //Data = "{\"Id\":\"122522636742819840\",\"TaskId\":\"122522636742819840\",\"IsGoods\":true}"
// Data = "{\"TaskId\":\"142515582485397504\",\"CollectionSourceId\":\"129505086429724672\",\"IsGoods\":true}"
//});
Task.Run(() =>
{
thread.Sleep(1000 * 30);
MonitorThread.GetDyyCircleGoodsLastTask();
});
}
catch (Exception ex)
{

View File

@ -17,6 +17,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Api.Framework.Data.TB;
using Api.Framework.Events;
using static Api.Framework.Tools.TBHelper.TbAnalysis;
namespace ProductClient
@ -31,6 +32,17 @@ namespace ProductClient
try
{
count++;
var node = 5;
var hour = DateTime.Now.Hour;
if (2 <= hour && hour <= 6)
{
node = 30;
}
if (count % node == 0)
{
GetDyyCircleGoodsLastTask();
}
#region web接口检测
//if (count % 5 == 0)
@ -229,6 +241,35 @@ namespace ProductClient
//private static string ZJYUrl = string.Empty;
public static void GetDyyCircleGoodsLastTask()
{
try
{
var taskId = Class1.Config.SignId;
var sourceId = Class1.Config.sourceId;
if (sourceId == null)
{
sourceId = "129505086429724672";
}
// $"{taskId}[分段]{collectionSourceId}"
HttpHelper http = new HttpHelper();
var html = http.GetHtml($"http://goods.api.52cmg.cn/api/WechatMomentsGoods-WechatMoments/GetLastTaskV2", postData: $"SourceId={sourceId}&LastTaskId={taskId}").Html;
//"{\"TaskId\":\"130145086167056384\",\"CollectionSourceId\":\"129505086429724672\",\"IsGoods\":true}"
if (string.IsNullOrWhiteSpace(html))
{
return;
}
EventClient.OnDyyNoticeEvent(null, new DyyNoticeEvent() { Data = html });
}
catch (Exception ex)
{
EventClient.OnEvent("", $"代运营朋友圈 - 补偿:{ex.Message}");
}
}
/// <summary>
/// 阿里妈妈转连接
/// </summary>
@ -315,7 +356,7 @@ namespace ProductClient
/// </summary>
/// <param name="itemInfo"></param>
private string PinDuoDuoConvertLink(string itemUrl, bool appendQrcode, out string compositeQRCode)
{
{
var goods_id = PDDHelper.GetPddGoodsID(itemUrl);
if (string.IsNullOrWhiteSpace(goods_id)) throw new Exception("@解析拼多多商品Id失败,操作终止");
var session = ApiClient.GetSession();
@ -383,14 +424,14 @@ namespace ProductClient
compositeQRCode = string.Empty;
return string.Empty;
}
}
/// <summary>
/// 京东联盟转连接
/// </summary>
/// <param name="itemInfo"></param>
private string JingDongConvertLink(string itemUrl, bool appendQrcode, out string compositeQRCode)
{
/// <summary>
/// 京东联盟转连接
/// </summary>
/// <param name="itemInfo"></param>
private string JingDongConvertLink(string itemUrl, bool appendQrcode, out string compositeQRCode)
{
var itemId = JDHelper.GetJingdongItemId(itemUrl);//匹配京东链接获取京东宝贝ID
if (string.IsNullOrEmpty(itemId)) throw new Exception($"@解析京东商品Id失败{itemUrl}");
@ -523,80 +564,80 @@ private string JingDongConvertLink(string itemUrl, bool appendQrcode, out string
compositeQRCode = string.Empty;
return string.Empty;
}
}
///// <summary>
///// 执行发送任务
///// </summary>
//private void _ExecuteSend(string objectDesc, string comment)
//{
// try
// {
// if (string.IsNullOrWhiteSpace(objectDesc)) return;
// var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == WeixinType.Grpc微信 || f.WeixinType == WeixinType.Hook微信) && f.Status == WxStatus.在线).ToList();
// if (clients.Count != 0)
// {
// foreach (var _item in clients)
// {
// var item = _item;
// //Task.Run(() =>
// //{
// try
// {
// //objectDesc = Regex.Replace(objectDesc, @"videomd5=""(.{32})""", @"videomd5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @"""");
// //objectDesc = Regex.Replace(objectDesc, @"md5=""(.{32})""", @"md5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @"""");
///// <summary>
///// 执行发送任务
///// </summary>
//private void _ExecuteSend(string objectDesc, string comment)
//{
// try
// {
// if (string.IsNullOrWhiteSpace(objectDesc)) return;
// var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == WeixinType.Grpc微信 || f.WeixinType == WeixinType.Hook微信) && f.Status == WxStatus.在线).ToList();
// if (clients.Count != 0)
// {
// foreach (var _item in clients)
// {
// var item = _item;
// //Task.Run(() =>
// //{
// try
// {
// //objectDesc = Regex.Replace(objectDesc, @"videomd5=""(.{32})""", @"videomd5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @"""");
// //objectDesc = Regex.Replace(objectDesc, @"md5=""(.{32})""", @"md5=""" + Util.GetMD5Hash(Guid.NewGuid().ToByteArray()) + @"""");
// objectDesc = objectDesc.Replace("[活动口令]", Class1.Config.actionLink);
// objectDesc = objectDesc.Replace("[活动口令]", Class1.Config.actionLink);
// var json = item.SendCircle(objectDesc);//发送朋友圈的主内容
// if (string.IsNullOrWhiteSpace(json))
// EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发失败");
// else
// EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发成功");
// var json = item.SendCircle(objectDesc);//发送朋友圈的主内容
// if (string.IsNullOrWhiteSpace(json))
// EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发失败");
// else
// EventClient.OnEvent(this, $"【代运营朋友圈】 => {item.WeixinHao},转发成功");
// if (!Class1.Config.isPl)
// {
// var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
// if (reg.Success && !string.IsNullOrWhiteSpace(comment))
// {
// var id = reg.Groups["id"].Value;
// var commentStr = string.Empty;
// if (string.IsNullOrWhiteSpace(Class1.Config.appendComment))
// commentStr = string.Join("[分段]", comment);
// else
// commentStr = string.Join("[分段]", comment, Class1.Config.appendComment);
// if (!string.IsNullOrWhiteSpace(commentStr))
// item.SendCircleComment(item.User.Username, id, commentStr.Replace("[活动口令]", Class1.Config.actionLink));
// }
// }
// }
// catch (Exception ex)
// {
// EventClient.OnEvent(this, $"【代运营朋友圈】 发送异常:{ex.Message} - {ex.StackTrace}");
// }
// //});
// }
// if (!Class1.Config.isPl)
// {
// var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
// if (reg.Success && !string.IsNullOrWhiteSpace(comment))
// {
// var id = reg.Groups["id"].Value;
// var commentStr = string.Empty;
// if (string.IsNullOrWhiteSpace(Class1.Config.appendComment))
// commentStr = string.Join("[分段]", comment);
// else
// commentStr = string.Join("[分段]", comment, Class1.Config.appendComment);
// if (!string.IsNullOrWhiteSpace(commentStr))
// item.SendCircleComment(item.User.Username, id, commentStr.Replace("[活动口令]", Class1.Config.actionLink));
// }
// }
// }
// catch (Exception ex)
// {
// EventClient.OnEvent(this, $"【代运营朋友圈】 发送异常:{ex.Message} - {ex.StackTrace}");
// }
// //});
// }
// if (Class1.Config.Monitor_Interval != 0)
// {
// Class1.Config.LastSendTime = DateTime.Now;
// Util.Save(Class1.Config);
// }
// EventClient.OnEvent(this, $"【代运营朋友圈】 所有账号发送完毕");
// }
// }
// catch (Exception ex)
// {
// EventClient.OnEvent(this, $"【代运营朋友圈】 发送失败:{ex.Message} - {ex.StackTrace}");
// }
//}
// if (Class1.Config.Monitor_Interval != 0)
// {
// Class1.Config.LastSendTime = DateTime.Now;
// Util.Save(Class1.Config);
// }
// EventClient.OnEvent(this, $"【代运营朋友圈】 所有账号发送完毕");
// }
// }
// catch (Exception ex)
// {
// EventClient.OnEvent(this, $"【代运营朋友圈】 发送失败:{ex.Message} - {ex.StackTrace}");
// }
//}
/// <summary>
/// 执行发送任务
/// </summary>
public static void _ExecuteSend(string objectDesc, List<string> comments, bool isGoods, string taskId)
{
/// <summary>
/// 执行发送任务
/// </summary>
public static void _ExecuteSend(string objectDesc, List<string> comments, bool isGoods, string taskId)
{
try
{
if (string.IsNullOrWhiteSpace(objectDesc))
@ -669,7 +710,7 @@ public static void _ExecuteSend(string objectDesc, List<string> comments, bool i
{
EventClient.OnEvent(null, $"【代运营朋友圈】 发送失败:{ex.Message} - {ex.StackTrace}");
}
}
}
}
}