831 lines
64 KiB
C#
831 lines
64 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.Enums;
|
|||
|
using Api.Framework.Model;
|
|||
|
using Api.Framework.SDK;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using Chat.Framework;
|
|||
|
using SqlSugar;
|
|||
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Text.RegularExpressions;
|
|||
|
using Api.Framework.Data.TB;
|
|||
|
using Weixin.TBCirclePromotion.Entitys;
|
|||
|
using Weixin.TBCirclePromotion.Properties;
|
|||
|
using static Api.Framework.Tools.TBHelper;
|
|||
|
using static Weixin.TBCirclePromotion.Enums;
|
|||
|
|
|||
|
namespace Weixin.TBCirclePromotion
|
|||
|
{
|
|||
|
public class SendCircleFriendThread : TimerTask
|
|||
|
{
|
|||
|
AnalyzeGoods analyzegoods = new AnalyzeGoods();
|
|||
|
TbAnalysis tbAnalysis = new TbAnalysis();
|
|||
|
AnalyzeGoods analyzeGoods = new AnalyzeGoods();
|
|||
|
StringBuilder strb = new StringBuilder();
|
|||
|
bool isSend = false;
|
|||
|
bool isSendTime = false;//这里是用来判断是否在任务时间段里面,如果满足这会赋值为true
|
|||
|
//private static DateTime RecordSendTime = DateTime.MinValue;
|
|||
|
SqlSugarClient session = ApiClient.GetSession();
|
|||
|
private static object objLock = new object();
|
|||
|
|
|||
|
public override void Run(object state, bool timedOut)
|
|||
|
{
|
|||
|
#region 好单库
|
|||
|
|
|||
|
#region 定时清空采集的数据
|
|||
|
if (!string.IsNullOrWhiteSpace(Class1.Config.HDK_AutoClearTaskTimes))
|
|||
|
{
|
|||
|
if (Class1.Config.HDK_Auto_IsClear == SwitchType.开启)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (DateTime.Now.AddSeconds(-3).ToString("HHmm") == DateTime.Parse(Class1.Config.HDK_AutoClearTaskTimes).ToString("HHmm"))
|
|||
|
{
|
|||
|
session.ExcuteSQL("Delete from fl_plugin_tbcirclepromotion_goodsinfos", new { });
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
EventClient.OnEvent(this, "定时清理异常" + ex.Message + "-" + ex.StackTrace);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
isSendTime = false;
|
|||
|
var now = DateTime.Now;
|
|||
|
for (int i = 0; i < Class1.Config.HDK_SendTaskTimes.Length; i++)
|
|||
|
{
|
|||
|
if (!string.IsNullOrWhiteSpace(Class1.Config.HDK_SendTaskTimes[i]))
|
|||
|
{
|
|||
|
var times = Class1.Config.HDK_SendTaskTimes[i].Trim().Split('-');
|
|||
|
if (times.Length == 2)
|
|||
|
{
|
|||
|
var begin = DateTime.Parse(times[0].Trim());
|
|||
|
var end = DateTime.Parse(times[1].Trim());
|
|||
|
if (begin <= now && now <= end)
|
|||
|
{
|
|||
|
isSendTime = true;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (!isSendTime) return;
|
|||
|
if ((DateTime.Now - Class1.Config.HDK_RecordSendTime).TotalMinutes < Class1.Config.HDK_Interval_Circle) return;
|
|||
|
var sb = new StringBuilder();
|
|||
|
try
|
|||
|
{
|
|||
|
lock (objLock)
|
|||
|
{
|
|||
|
//删除N天前的数据
|
|||
|
session.ExcuteSQL("Delete from fl_plugin_tbcirclepromotion_goodsinfos where cur_time <= @time", new { time = DateTime.Today.AddDays(-3) });
|
|||
|
isSend = false;
|
|||
|
#region 采集数据
|
|||
|
if (Class1.Config.HDK_Switch == SwitchType.开启)
|
|||
|
{
|
|||
|
var num = session.Find<fl_plugin_tbcirclepromotion_goodsinfos>("select * from fl_plugin_tbcirclepromotion_goodsinfos where state = @state", new { state = StateType.未推广 }).Count();
|
|||
|
if (num <= Class1.Config.HDK_GatherTouchNum) analyzeGoods.GatherFactory();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
var goods_infos_temp = new List<fl_plugin_tbcirclepromotion_goodsinfos>();
|
|||
|
#region 发送多产品模式
|
|||
|
if (Class1.Config.HDK_SendMode == SendModeType.多产品)
|
|||
|
{
|
|||
|
//EventClient.OnEvent(this, $"【淘宝发单】5555");
|
|||
|
var goods_infos = session.Find<fl_plugin_tbcirclepromotion_goodsinfos>($"select * from fl_plugin_tbcirclepromotion_goodsinfos where state = 1 order by cur_time desc limit {(Class1.Config.HDK_Multi_SendGoodsImageNum <= 0 ? 1 : Class1.Config.HDK_Multi_SendGoodsImageNum)}");
|
|||
|
|
|||
|
if (goods_infos != null && goods_infos.Count != 0)
|
|||
|
{
|
|||
|
var clients = Chat.Framework.ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Grpc微信 || f.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Hook微信) && f.Status == Chat.Framework.WXSdk.WxStatus.在线);
|
|||
|
foreach (var item in clients)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var robot_info = session.FindRobots().FirstOrDefault(f => f.name == item.WeixinHao && f.type == ChatType.微信);
|
|||
|
if (robot_info != null)
|
|||
|
{
|
|||
|
var tb_circle_promotion_temp = session.FindTBCirclePromotions().Where(f => f.onoff).ToList();
|
|||
|
if (tb_circle_promotion_temp != null)
|
|||
|
{
|
|||
|
if (tb_circle_promotion_temp.FirstOrDefault(f => f.name == robot_info.name) != null) continue;
|
|||
|
}
|
|||
|
|
|||
|
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType.阿里妈妈 && f.custom_type == Resources.SoftwareType && f.robot_id == robot_info.id);
|
|||
|
if (adzone != null)
|
|||
|
{
|
|||
|
var member = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.阿里妈妈 && f.username == adzone.adzone_pid_cps_name);
|
|||
|
if (member != null)
|
|||
|
{
|
|||
|
var api = CpsClient.CreateAlimamaRequest(member);
|
|||
|
if (api == null) { continue; }
|
|||
|
strb.Length = 0;
|
|||
|
|
|||
|
strb.AppendLine(Class1.Config.HDK_Multi_ContentCircle);
|
|||
|
int count = 0;
|
|||
|
int _count = goods_infos.Count;
|
|||
|
for (int i = 0; i < _count; i++)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
goods_infos_temp.Add(goods_infos[i]);
|
|||
|
var goodsinfo = goods_infos[i];
|
|||
|
count = 0;
|
|||
|
Next:
|
|||
|
var result = analyzegoods.FindGoodsInfoToGoodsId(goodsinfo.goods_id, adzone.adzone_pid_cps_name, adzone.adzone_pid, goodsinfo.goods_quan);//获取到自己返利链接等信息
|
|||
|
if (result == null)
|
|||
|
{
|
|||
|
count++;
|
|||
|
if (count <= 7 && goods_infos_temp.Count < goods_infos.Count)
|
|||
|
{
|
|||
|
goodsinfo = session.FindSingle<fl_plugin_tbcirclepromotion_goodsinfos>("select * from fl_plugin_tbcirclepromotion_goodsinfos where state = @state order by cur_time desc", new { state = StateType.未推广 });
|
|||
|
goods_infos_temp.Add(goodsinfo);
|
|||
|
goto Next;
|
|||
|
}
|
|||
|
else
|
|||
|
continue;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var tklInfo = tbAnalysis.FindTKL(result.shopping_url, api);
|
|||
|
if (tklInfo == null)
|
|||
|
continue; //生成淘口令失败
|
|||
|
|
|||
|
//var shortUrl = tbAnalysis.FindShortUrlBySrcUrl(result.shopping_url, api);
|
|||
|
|
|||
|
var short_url = api.ComposeTbClick(result.goods_id, result.goods_thumbnail_url, tklInfo.tkl, tklInfo.isoUrl, ApiClient.Setting.SystemConfig.ZjyComposeType == ComposeType.有推荐商品, (int)DwzType.快站短网址, isCircleZjy: true);//短连接
|
|||
|
var cprice = ((decimal)result.normal_price - (decimal)result.coupon_discount).ToString();//券后价
|
|||
|
var goods_desc = string.IsNullOrWhiteSpace(Class1.Config.HDK_Multi_GoodsDesc) ? result.goods_desc : Class1.Config.HDK_Multi_GoodsDesc
|
|||
|
.Replace("[商品标题]", result.goods_name)
|
|||
|
.Replace("[商品描述]", goodsinfo.goods_desc)
|
|||
|
.Replace("[已售数量]", result.sold_quantity.ToString())
|
|||
|
.Replace("[店铺名称]", result.mall_name)
|
|||
|
.Replace("[优惠券金额]", result.coupon_discount.ToString())
|
|||
|
.Replace("[优惠券数量]", result.coupon_remain_quantity.ToString())
|
|||
|
.Replace("[商品单价]", result.normal_price.ToString())
|
|||
|
.Replace("[券后价]", cprice)
|
|||
|
.Replace("[劵后价]", cprice)
|
|||
|
.Replace("[购买地址]", short_url);// result.shopping_url);
|
|||
|
var image = ApiClient.GetQRImage(result.goods_name, result.normal_price.ToString(), result.coupon_discount.ToString(), cprice, result.goods_thumbnail_url, short_url, Class1.Config.HDK_Model, CpsType.阿里妈妈, string.IsNullOrWhiteSpace(Class1.Config.HDK_Single_GoodsQRCodePicDesc) ? goodsinfo.goods_desc : Class1.Config.HDK_Single_GoodsQRCodePicDesc); //合成附带二维码等信息的宝贝图片
|
|||
|
strb.Append($"[图片={image}]");
|
|||
|
}
|
|||
|
}
|
|||
|
catch
|
|||
|
{ }
|
|||
|
}
|
|||
|
var json = item.SendCircle(strb.ToString());
|
|||
|
if (!string.IsNullOrWhiteSpace(Class1.Config.HDK_Multi_AdditionalComment))
|
|||
|
{
|
|||
|
var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
|
|||
|
if (reg.Success)
|
|||
|
item.SendCircleComment(item.User.Username, reg.Groups["id"].Value, Class1.Config.HDK_Multi_AdditionalComment);
|
|||
|
}
|
|||
|
if (string.IsNullOrWhiteSpace(json))
|
|||
|
EventClient.OnEvent(this, $"【淘宝发单】多({clients.Count()}):{item.WeixinHao},发单失败");
|
|||
|
else
|
|||
|
EventClient.OnEvent(this, $"【淘宝发单】多({clients.Count()}):{item.WeixinHao},发单成功");
|
|||
|
isSend = true;//认定发送过了...
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
EventClient.OnEvent(this, $"淘宝推广 - 多产品:{item.WeixinHao},朋友圈推广失败,{ex.Message}");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 发送单品【多图】模式
|
|||
|
else
|
|||
|
{
|
|||
|
//获取一个宝贝
|
|||
|
var goods_info = session.FindSingle<fl_plugin_tbcirclepromotion_goodsinfos>("select * from fl_plugin_tbcirclepromotion_goodsinfos where state = @state order by id desc", new { state = StateType.未推广 });
|
|||
|
//.Where(f => f.state == StateType.未推广).OrderBy(f => f.cur_time, OrderByType.Desc).First();
|
|||
|
if (goods_info != null)
|
|||
|
{
|
|||
|
var html = string.Empty;
|
|||
|
var shopIcon = string.Empty;
|
|||
|
var QRCodeUrl = string.Empty;//获取其中一张图片用于合成二维码
|
|||
|
var Content = string.Empty;//内容
|
|||
|
sb.AppendLine($"a");
|
|||
|
|
|||
|
#region 获取商品图片
|
|||
|
var memberTmp = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.阿里妈妈);
|
|||
|
if (memberTmp != null)
|
|||
|
{
|
|||
|
var api = CpsClient.CreateAlimamaRequest(memberTmp);
|
|||
|
if (api == null) { return; }
|
|||
|
|
|||
|
GetItemInfosData itemInfo = null;
|
|||
|
try
|
|||
|
{
|
|||
|
sb.AppendLine($"b = " + goods_info.goods_id);
|
|||
|
//objData = api.SendTaobao("taobao.tbk.item.info.get", new { num_iids = goods_info.goods_id });
|
|||
|
itemInfo = api.GetItemInfo(goods_info.goods_id, "2");
|
|||
|
}
|
|||
|
catch
|
|||
|
{ }
|
|||
|
|
|||
|
if (itemInfo != null && itemInfo.n_tbk_item != null && itemInfo.n_tbk_item.Count > 0)
|
|||
|
{
|
|||
|
var tbk_item = itemInfo.n_tbk_item[0];
|
|||
|
if (tbk_item.small_images != null && tbk_item.small_images.@string.Count > 0)
|
|||
|
{
|
|||
|
foreach (string _small_image in tbk_item.small_images.@string)
|
|||
|
{
|
|||
|
string small_image = _small_image;
|
|||
|
if (string.IsNullOrEmpty(shopIcon)) shopIcon = small_image;
|
|||
|
if (Class1.Config.HDK_Single_IsQRCodePic == SwitchType.开启 && string.IsNullOrWhiteSpace(QRCodeUrl))
|
|||
|
QRCodeUrl = small_image;
|
|||
|
|
|||
|
Content += $"[图片={small_image}]";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
sb.AppendLine($"d");
|
|||
|
if (string.IsNullOrWhiteSpace(Content))
|
|||
|
{
|
|||
|
session.Deleteable(goods_info).ExecuteCommand();
|
|||
|
return;
|
|||
|
}
|
|||
|
sb.AppendLine($"e");
|
|||
|
var clients = ChatClient.WXClient.Values.ToList().Where(f => (f.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Grpc微信 || f.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Hook微信) && f.Status == Chat.Framework.WXSdk.WxStatus.在线);
|
|||
|
foreach (var item in clients)
|
|||
|
{
|
|||
|
sb.AppendLine($"{item.WeixinHao}");
|
|||
|
try
|
|||
|
{
|
|||
|
var robot_info = session.FindRobots().FirstOrDefault(f => f.name == item.WeixinHao && f.type == ChatType.微信);
|
|||
|
if (robot_info != null)
|
|||
|
{
|
|||
|
var tb_circle_promotion_temp = session.FindTBCirclePromotions().Where(f => f.onoff);
|
|||
|
if (tb_circle_promotion_temp != null)
|
|||
|
{
|
|||
|
sb.AppendLine($"A");
|
|||
|
if (tb_circle_promotion_temp.FirstOrDefault(f => f.name == robot_info.name) != null) continue;
|
|||
|
}
|
|||
|
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType.阿里妈妈 && f.custom_type == Resources.SoftwareType && f.robot_id == robot_info.id);
|
|||
|
if (adzone != null)
|
|||
|
{
|
|||
|
sb.AppendLine($"B");
|
|||
|
var member = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.阿里妈妈 && f.username == adzone.adzone_pid_cps_name);
|
|||
|
|
|||
|
if (member != null)
|
|||
|
{
|
|||
|
sb.AppendLine($"C");
|
|||
|
var api = CpsClient.CreateAlimamaRequest(member);
|
|||
|
if (api == null) { continue; }
|
|||
|
strb.Length = 0;
|
|||
|
strb.Append(Content);
|
|||
|
//获取的预览图不为空
|
|||
|
if (strb.Length != 0)
|
|||
|
{
|
|||
|
sb.AppendLine($"D");
|
|||
|
//朋友圈评语
|
|||
|
var goodsInfo = analyzegoods.FindGoodsInfoToGoodsId(goods_info.goods_id, adzone.adzone_pid_cps_name, adzone.adzone_pid, goods_info.goods_quan);//获取到自己返利链接等信息
|
|||
|
if (goodsInfo != null)
|
|||
|
{
|
|||
|
sb.AppendLine($"E");
|
|||
|
var tklInfo = tbAnalysis.FindTKL(goodsInfo.shopping_url, api);
|
|||
|
if (tklInfo == null)
|
|||
|
continue; //生成淘口令失败
|
|||
|
|
|||
|
//var shortUrl = tbAnalysis.FindShortUrlBySrcUrl(goodsInfo.shopping_url, api);
|
|||
|
var short_url = api.ComposeTbClick(goodsInfo.goods_id, goodsInfo.goods_thumbnail_url, tklInfo.tkl, tklInfo.isoUrl, ApiClient.Setting.SystemConfig.ZjyComposeType == ComposeType.有推荐商品, (int)DwzType.快站短网址, isCircleZjy: true);//短连接
|
|||
|
var cprice = ((decimal)goodsInfo.normal_price - (decimal)goodsInfo.coupon_discount).ToString();//券后价
|
|||
|
|
|||
|
strb.Append(Class1.Config.HDK_Single_ContentCircle
|
|||
|
.Replace("[商品标题]", goods_info.goods_name)
|
|||
|
.Replace("[优惠券金额]", goods_info.coupon_discount.ToString())
|
|||
|
.Replace("[券后价]", ((decimal)goods_info.normal_price - (decimal)goods_info.coupon_discount).ToString())
|
|||
|
.Replace("[劵后价]", ((decimal)goods_info.normal_price - (decimal)goods_info.coupon_discount).ToString())
|
|||
|
.Replace("[商品描述]", goods_info.goods_desc)
|
|||
|
.Replace("[已售数量]", goods_info.sold_quantity.ToString())
|
|||
|
.Replace("[店铺名称]", goods_info.mall_name)
|
|||
|
.Replace("[商品单价]", goods_info.normal_price.ToString())
|
|||
|
.Replace("[购买地址]", short_url)
|
|||
|
.Replace("[淘口令]", tklInfo.tkl)
|
|||
|
);
|
|||
|
////朋友圈评语
|
|||
|
//var goodsInfo = analyzegoods.FindGoodsInfoToGoodsId(goods_info.goods_id, adzone.adzone_pid_cps_name, adzone.adzone_pid, goods_info.goods_quan);//获取到自己返利链接等信息
|
|||
|
//if (goodsInfo != null)
|
|||
|
//{
|
|||
|
// var tkl = tbAnalysis.FindTKL(goodsInfo.shopping_url, goodsInfo.goods_name, goodsInfo.goods_thumbnail_url, api);
|
|||
|
// if (string.IsNullOrEmpty(tkl)) { continue; }//生成淘口令失败
|
|||
|
|
|||
|
// var shortUrl = tbAnalysis.FindShortUrlBySrcUrl(goodsInfo.shopping_url, api);
|
|||
|
// var short_url = api.ComposeTbClick(goodsInfo.goods_id, goodsInfo.goods_thumbnail_url, tkl, shortUrl, true, (int)DwzType.快站短网址);//短连接
|
|||
|
// var cprice = ((decimal)goodsInfo.normal_price - (decimal)goodsInfo.coupon_discount).ToString();//券后价
|
|||
|
|
|||
|
//合成二维码图片
|
|||
|
if (!string.IsNullOrEmpty(QRCodeUrl))
|
|||
|
{
|
|||
|
sb.AppendLine($"F");
|
|||
|
var QRCodeimage = ApiClient.GetQRImage(goodsInfo.goods_name, goodsInfo.normal_price.ToString(), goodsInfo.coupon_discount.ToString(), cprice, QRCodeUrl, short_url, Class1.Config.HDK_Model, CpsType.阿里妈妈, string.IsNullOrWhiteSpace(Class1.Config.HDK_Single_GoodsQRCodePicDesc) ? goods_info.goods_desc : Class1.Config.HDK_Single_GoodsQRCodePicDesc); //合成附带二维码等信息的宝贝图片
|
|||
|
strb.Append($"[图片={QRCodeimage}]");
|
|||
|
}
|
|||
|
if (Class1.Config.HDK_Single_IsSynthCoupon == SwitchType.开启)
|
|||
|
{
|
|||
|
sb.AppendLine($"G");
|
|||
|
#region 获取头像
|
|||
|
if (string.IsNullOrEmpty(shopIcon) || goodsInfo.mall_name == "天猫超市")
|
|||
|
shopIcon = "https://ss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1659832877.jpg";
|
|||
|
#endregion
|
|||
|
|
|||
|
if (!File.Exists(Tools.PosterPathImgUrl))
|
|||
|
Tools.GetBaseIco();
|
|||
|
//合成优惠券图片
|
|||
|
var shopimage_temp = Util.MapFile(Guid.NewGuid().ToString() + ".jpg", "Cache\\Image");
|
|||
|
try
|
|||
|
{
|
|||
|
FileTools.DownloadImage(shopIcon, shopimage_temp);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
FileTools.DownloadImage("https://ss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1659832877.jpg", shopimage_temp);
|
|||
|
}
|
|||
|
|
|||
|
var shopimage = Tools.ReadImageFile(shopimage_temp);
|
|||
|
shopimage = Tools.getnew(shopimage, 150, 150);
|
|||
|
|
|||
|
var goodsImage_temp = Util.MapFile(Guid.NewGuid().ToString() + ".jpg", "Cache\\Image");
|
|||
|
FileTools.DownloadImage(goodsInfo.goods_thumbnail_url, goodsImage_temp);
|
|||
|
var goodsImage = Tools.ReadImageFile(goodsImage_temp);
|
|||
|
goodsImage = Tools.getnew(goodsImage, 150, 150);
|
|||
|
|
|||
|
strb.Append($"[图片={ApiClient.GetCouponImage2(Tools.PosterPathImgUrl2, goodsInfo.mall_name, shopimage, goodsInfo.goods_name, goodsInfo.normal_price.ToString(), goodsInfo.coupon_discount.ToString(), goodsImage, $"{DateTime.Today.ToString("yyyy.MM.dd")} - {DateTime.Today.AddMonths(1).ToString("yyyy.MM.dd")}", goodsInfo.sold_quantity.ToString())}]");
|
|||
|
}
|
|||
|
sb.AppendLine($"H");
|
|||
|
//淘口令的前/后符号有没有设置.有设置将替换掉
|
|||
|
var tkl = new TBHelper.TbAnalysis().ReplaceTklModifier(tklInfo.tkl);
|
|||
|
var comment = Class1.Config.HDK_Single_AdditionalComment
|
|||
|
.Replace("[商品标题]", goodsInfo.goods_name)
|
|||
|
//.Replace("[商品描述]", goodsInfo.goods_desc)
|
|||
|
.Replace("[已售数量]", goodsInfo.sold_quantity.ToString())
|
|||
|
.Replace("[店铺名称]", goodsInfo.mall_name)
|
|||
|
.Replace("[优惠券金额]", goodsInfo.coupon_discount.ToString())
|
|||
|
.Replace("[优惠券数量]", goodsInfo.coupon_remain_quantity.ToString())
|
|||
|
.Replace("[商品单价]", goodsInfo.normal_price.ToString())
|
|||
|
.Replace("[券后价]", cprice)
|
|||
|
.Replace("[劵后价]", cprice)
|
|||
|
.Replace("[购买地址]", short_url)
|
|||
|
.Replace("[淘口令]", tkl);//评语内容
|
|||
|
goods_infos_temp.Add(goods_info);
|
|||
|
var json = item.SendCircle(strb.ToString().Replace("[购买地址]", short_url));
|
|||
|
if (!string.IsNullOrWhiteSpace(Class1.Config.HDK_Single_AdditionalComment))
|
|||
|
{
|
|||
|
sb.AppendLine($"I");
|
|||
|
var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
|
|||
|
if (reg.Success)
|
|||
|
item.SendCircleComment(item.User.Username, reg.Groups["id"].Value, comment);
|
|||
|
}
|
|||
|
if (string.IsNullOrWhiteSpace(json))
|
|||
|
EventClient.OnEvent(this, $"【淘宝发单】单({clients.Count()}):{item.WeixinHao},发单失败");
|
|||
|
else
|
|||
|
EventClient.OnEvent(this, $"【淘宝发单】单({clients.Count()}):{item.WeixinHao},发单成功");
|
|||
|
|
|||
|
isSend = true;//认定发送过了...
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
EventClient.OnEvent(this, $"淘宝推广 - 单产品:{item.WeixinHao},朋友圈推广失败,{ex.Message} - {ex.StackTrace}");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
if (isSend)
|
|||
|
{
|
|||
|
//RecordSendTime = DateTime.Now;
|
|||
|
for (int i = 0; i < goods_infos_temp.Count; i++)
|
|||
|
{
|
|||
|
session.ExcuteSQL("update fl_plugin_tbcirclepromotion_goodsinfos set state = @state where id = @id", new { state = Enums.StateType.已推广, id = goods_infos_temp[i].id });
|
|||
|
}
|
|||
|
Class1.Config.HDK_RecordSendTime = DateTime.Now;
|
|||
|
|
|||
|
Util.Save(Class1.Config);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
//EventClient.OnEvent(this, $"淘宝推广:{ex.Message},{ex.StackTrace}");
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
//EventClient.OnEvent(this, $"【淘宝发单】({sb.ToString()})");
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 大淘客 xxx
|
|||
|
|
|||
|
//#region 定时清空采集的数据
|
|||
|
//if (!string.IsNullOrWhiteSpace(Class1.Config.AutoClearTaskTimes))
|
|||
|
//{
|
|||
|
// if (Class1.Config.Auto_IsClear == SwitchType.开启)
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// if (DateTime.Now.AddSeconds(-3).ToString("HHmm") == DateTime.Parse(Class1.Config.AutoClearTaskTimes).ToString("HHmm"))
|
|||
|
// {
|
|||
|
// session.ExcuteSQL("Delete from fl_plugin_tbcirclepromotion_goodsinfos", new { });
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// EventClient.OnEvent(this, "定时清理异常" + ex.Message + "-" + ex.StackTrace);
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
//#endregion
|
|||
|
|
|||
|
//isSendTime = false;
|
|||
|
//var now = DateTime.Now;
|
|||
|
//for (int i = 0; i < Class1.Config.SendTaskTimes.Length; i++)
|
|||
|
//{
|
|||
|
// if (!string.IsNullOrWhiteSpace(Class1.Config.SendTaskTimes[i]))
|
|||
|
// {
|
|||
|
// var times = Class1.Config.SendTaskTimes[i].Trim().Split('-');
|
|||
|
// if (times.Length == 2)
|
|||
|
// {
|
|||
|
// var begin = DateTime.Parse(times[0].Trim());
|
|||
|
// var end = DateTime.Parse(times[1].Trim());
|
|||
|
// if (begin <= now && now <= end)
|
|||
|
// {
|
|||
|
// isSendTime = true;
|
|||
|
// break;
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
//if (!isSendTime) return;
|
|||
|
|
|||
|
//if ((DateTime.Now - Class1.Config.RecordSendTime).TotalMinutes < Class1.Config.Interval_Circle) return;
|
|||
|
|
|||
|
//try
|
|||
|
//{
|
|||
|
|
|||
|
// lock (objLock)
|
|||
|
// {
|
|||
|
// //删除N天前的数据
|
|||
|
// session.ExcuteSQL("Delete from fl_plugin_tbcirclepromotion_goodsinfos where cur_time <= @time", new { time = DateTime.Today.AddDays(-3) });
|
|||
|
// isSend = false;
|
|||
|
|
|||
|
// #region 采集数据
|
|||
|
// if (Class1.Config.Switch == SwitchType.开启)
|
|||
|
// {
|
|||
|
// var num = session.Queryable<fl_plugin_tbcirclepromotion_goodsinfos>().Count(f => f.state == StateType.未推广);
|
|||
|
// if (num <= Class1.Config.GatherTouchNum) analyzeGoods.GatherFactory();
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// var goods_infos_temp = new List<fl_plugin_tbcirclepromotion_goodsinfos>();
|
|||
|
// #region 发送多产品模式
|
|||
|
// if (Class1.Config.SendMode == SendModeType.多产品)
|
|||
|
// {
|
|||
|
// //var goods_infos = session.Find<fl_plugin_tbcirclepromotion_goodsinfos>($"select * from fl_plugin_tbcirclepromotion_goodsinfos where state = 1 order by cur_time desc limit {(Class1.Config.Multi_SendGoodsImageNum <= 0 ? 1 : Class1.Config.Multi_SendGoodsImageNum)}");
|
|||
|
|
|||
|
// var goods_infos = session.Queryable<fl_plugin_tbcirclepromotion_goodsinfos>().Where(f => f.state == StateType.未推广).OrderBy(f => f.cur_time, OrderByType.Desc).ToPageList(1, (Class1.Config.Multi_SendGoodsImageNum <= 0 ? 1 : Class1.Config.Multi_SendGoodsImageNum));
|
|||
|
|
|||
|
// if (goods_infos != null && goods_infos.Count != 0)
|
|||
|
// {
|
|||
|
// var clients = Chat.Framework.ChatClient.WXClient.Values;
|
|||
|
// foreach (var item in clients)
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// if (item.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Grpc微信 && item.Status == Chat.Framework.WXSdk.WxStatus.在线)
|
|||
|
// {
|
|||
|
// var robot_info = session.FindRobotInfo(item.WeixinHao, ChatType.微信);
|
|||
|
// if (robot_info != null)
|
|||
|
// {
|
|||
|
// var tb_circle_promotion_temp = session.FindTBCirclePromotions().Where(f => f.onoff).ToList();
|
|||
|
// if (tb_circle_promotion_temp != null)
|
|||
|
// {
|
|||
|
// if (tb_circle_promotion_temp.FirstOrDefault(f => f.name == robot_info.name) != null) continue;
|
|||
|
// }
|
|||
|
|
|||
|
// var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType.阿里妈妈 && f.custom_type == Resources.SoftwareType && f.robot_id == robot_info.id);
|
|||
|
// if (adzone != null)
|
|||
|
// {
|
|||
|
// var member = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.阿里妈妈 && f.username == adzone.adzone_pid_cps_name);
|
|||
|
// if (member != null)
|
|||
|
// {
|
|||
|
// var api = CpsClient.CreateAlimamaRequest(member);
|
|||
|
// if (api == null) { continue; }
|
|||
|
// strb.Length = 0;
|
|||
|
|
|||
|
// strb.AppendLine(Class1.Config.Multi_ContentCircle);
|
|||
|
// int count = 0;
|
|||
|
// for (int i = 0; i < goods_infos.Count; i++)
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// goods_infos_temp.Add(goods_infos[i]);
|
|||
|
// var goodsinfo = goods_infos[i];
|
|||
|
// count = 0;
|
|||
|
// Next:
|
|||
|
// //var result = analyzegoods.FindGoodsInfoToGoodsId(goodsinfo.goods_id, GoodsSourceType.对象, adzone.adzone_pid_cps_name, adzone.adzone_pid);//获取到自己返利链接等信息
|
|||
|
// var result = analyzegoods.FindGoodsInfoToGoodsId(goodsinfo.goods_id, adzone.adzone_pid_cps_name, adzone.adzone_pid, goodsinfo.goods_quan);//获取到自己返利链接等信息
|
|||
|
// if (result == null)
|
|||
|
// {
|
|||
|
// count++;
|
|||
|
// if (count <= 7 && goods_infos_temp.Count < goods_infos.Count)
|
|||
|
// {
|
|||
|
// goodsinfo = session.Queryable<fl_plugin_tbcirclepromotion_goodsinfos>().Where(f => f.state == StateType.未推广).OrderBy(f => f.cur_time, OrderByType.Desc).First();
|
|||
|
// goods_infos_temp.Add(goodsinfo);
|
|||
|
// goto Next;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// continue;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// var shortUrl = tbAnalysis.FindShortUrlBySrcUrl(result.shopping_url, api);
|
|||
|
// if (string.IsNullOrEmpty(shortUrl)) { continue; }//生成短连接失败
|
|||
|
// var tkl = tbAnalysis.FindTKL(shortUrl, result.goods_name, result.goods_thumbnail_url, api);
|
|||
|
// if (string.IsNullOrEmpty(tkl)) { continue; }//生成淘口令失败
|
|||
|
// var short_url = ApiClient.ShortURL(api.ComposeTbClick(result.goods_id, result.goods_thumbnail_url, tkl, result.shopping_url), DwzType.新浪短网址).Result;//短连接
|
|||
|
// var cprice = ((decimal)result.normal_price - (decimal)result.coupon_discount).ToString();//券后价
|
|||
|
// var goods_desc = string.IsNullOrWhiteSpace(Class1.Config.Multi_GoodsDesc) ? result.goods_desc : Class1.Config.Multi_GoodsDesc
|
|||
|
// .Replace("[商品标题]", result.goods_name)
|
|||
|
// .Replace("[商品描述]", result.goods_desc)
|
|||
|
// .Replace("[已售数量]", result.sold_quantity.ToString())
|
|||
|
// .Replace("[店铺名称]", result.mall_name)
|
|||
|
// .Replace("[优惠券金额]", result.coupon_discount.ToString())
|
|||
|
// .Replace("[优惠券数量]", result.coupon_remain_quantity.ToString())
|
|||
|
// .Replace("[商品单价]", result.normal_price.ToString())
|
|||
|
// .Replace("[券后价]", cprice)
|
|||
|
// .Replace("[劵后价]", cprice)
|
|||
|
// .Replace("[购买地址]", short_url);// result.shopping_url);
|
|||
|
// var image = ApiClient.GetQRImage(result.goods_name, result.normal_price.ToString(), result.coupon_discount.ToString(), cprice, result.goods_thumbnail_url, short_url, Class1.Config.Model, CpsType.阿里妈妈, Class1.Config.Single_GoodsQRCodePicDesc); //合成附带二维码等信息的宝贝图片
|
|||
|
// strb.Append($"[图片={image}]");
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch
|
|||
|
// { }
|
|||
|
// }
|
|||
|
// var json = item.SendCircle(strb.ToString());
|
|||
|
// if (!string.IsNullOrWhiteSpace(Class1.Config.Multi_AdditionalComment))
|
|||
|
// {
|
|||
|
// var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
|
|||
|
// if (reg.Success)
|
|||
|
// item.SendCircleComment(item.User.Username, reg.Groups["id"].Value, Class1.Config.Multi_AdditionalComment);
|
|||
|
// }
|
|||
|
// isSend = true;//认定发送过了...
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// EventClient.OnEvent(this, $"淘宝推广 - 多产品:{item.WeixinHao},朋友圈推广失败,{ex.Message}");
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// #region 发送单品【多图】模式
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //获取一个宝贝
|
|||
|
// var goods_info = session.Queryable<fl_plugin_tbcirclepromotion_goodsinfos>().Where(f => f.state == StateType.未推广).OrderBy(f => f.cur_time, OrderByType.Desc).First();
|
|||
|
// if (goods_info != null)
|
|||
|
// {
|
|||
|
// var clients = Chat.Framework.ChatClient.WXClient.Values;
|
|||
|
// foreach (var item in clients)
|
|||
|
// {
|
|||
|
// try
|
|||
|
// {
|
|||
|
// if (item.WeixinType == Chat.Framework.WXSdk.Implement.WeixinType.Grpc微信 && item.Status == Chat.Framework.WXSdk.WxStatus.在线)
|
|||
|
// {
|
|||
|
// var robot_info = session.FindRobotInfo(item.WeixinHao, ChatType.微信);
|
|||
|
// if (robot_info != null)
|
|||
|
// {
|
|||
|
// var tb_circle_promotion_temp = session.FindTBCirclePromotions().Where(f => f.onoff);
|
|||
|
// if (tb_circle_promotion_temp != null)
|
|||
|
// {
|
|||
|
// if (tb_circle_promotion_temp.FirstOrDefault(f => f.name == robot_info.name) != null) continue;
|
|||
|
// }
|
|||
|
|
|||
|
// var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType.阿里妈妈 && f.custom_type == Resources.SoftwareType && f.robot_id == robot_info.id);
|
|||
|
// if (adzone != null)
|
|||
|
// {
|
|||
|
// var member = CpsClient.Members.FirstOrDefault(f => f.cpstype == CpsType.阿里妈妈 && f.username == adzone.adzone_pid_cps_name);
|
|||
|
|
|||
|
// if (member != null)
|
|||
|
// {
|
|||
|
// var api = CpsClient.CreateAlimamaRequest(member);
|
|||
|
// if (api == null) { continue; }
|
|||
|
// int num = 0;
|
|||
|
// Next:
|
|||
|
// HttpItem httpItem = new HttpItem()
|
|||
|
// {
|
|||
|
// URL = @"https://item.taobao.com/item.htm?id=" + goods_info.goods_id,//宝贝的链接
|
|||
|
// Method = "get",
|
|||
|
// IsToLower = false,
|
|||
|
// Timeout = 10000,
|
|||
|
// ReadWriteTimeout = 10000,
|
|||
|
// Allowautoredirect = true,
|
|||
|
// UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",
|
|||
|
// ContentType = "application/x-www-form-urlencoded"
|
|||
|
// };
|
|||
|
// HttpHelper http = new HttpHelper();
|
|||
|
// var result = http.GetHtml(httpItem);
|
|||
|
|
|||
|
// if (result != null && result.Html == "操作超时" && num <= 3)
|
|||
|
// {
|
|||
|
// num++;
|
|||
|
// goto Next;
|
|||
|
// }
|
|||
|
// var regs = Regex.Matches(result.Html, @"<a href=""#""><img ([^=]+?)=""(?<商品预览图>.+?.jpg)_([^""]*?)""");
|
|||
|
|
|||
|
// if (regs.Count != 0)
|
|||
|
// {
|
|||
|
// strb.Length = 0;
|
|||
|
// //var previewPicUrls = new List<string>();//保存商品预览图
|
|||
|
// var shopIcon = string.Empty;
|
|||
|
// var QRCodeUrl = string.Empty;//获取其中一张图片用于合成二维码
|
|||
|
// for (int i = 0; i < regs.Count; i++)
|
|||
|
// {
|
|||
|
// var previewPic = regs[i].Groups["商品预览图"].Value;
|
|||
|
// if (!previewPic.StartsWith("http"))
|
|||
|
// {
|
|||
|
// previewPic = $"http:{previewPic}";
|
|||
|
// if (string.IsNullOrEmpty(shopIcon)) shopIcon = previewPic;
|
|||
|
// }
|
|||
|
// if (Class1.Config.Single_IsQRCodePic == SwitchType.开启 && i == (regs.Count - 1))
|
|||
|
// QRCodeUrl = previewPic;
|
|||
|
// else
|
|||
|
// strb.Append($"[图片={previewPic}]");
|
|||
|
// }
|
|||
|
// //获取的预览图不为空
|
|||
|
// if (strb.Length != 0)
|
|||
|
// {
|
|||
|
// strb.Append(Class1.Config.Single_ContentCircle
|
|||
|
// .Replace("[商品标题]", goods_info.goods_name)
|
|||
|
// .Replace("[优惠券金额]", goods_info.coupon_discount.ToString())
|
|||
|
// .Replace("[券后价]", ((decimal)goods_info.normal_price - (decimal)goods_info.coupon_discount).ToString())
|
|||
|
// .Replace("[劵后价]", ((decimal)goods_info.normal_price - (decimal)goods_info.coupon_discount).ToString())
|
|||
|
// .Replace("[商品描述]", goods_info.goods_desc)
|
|||
|
// .Replace("[已售数量]", goods_info.sold_quantity.ToString())
|
|||
|
// .Replace("[店铺名称]", goods_info.mall_name)
|
|||
|
// .Replace("[商品单价]", goods_info.normal_price.ToString()));
|
|||
|
// //朋友圈评语
|
|||
|
// //var goodsInfo = analyzegoods.FindGoodsInfoToGoodsId(goods_info.goods_id, GoodsSourceType.对象, adzone.adzone_pid_cps_name, adzone.adzone_pid);//获取到自己返利链接等信息
|
|||
|
// var goodsInfo = analyzegoods.FindGoodsInfoToGoodsId(goods_info.goods_id, adzone.adzone_pid_cps_name, adzone.adzone_pid, goods_info.goods_quan);//获取到自己返利链接等信息
|
|||
|
// if (goodsInfo != null)
|
|||
|
// {
|
|||
|
// var shortUrl = tbAnalysis.FindShortUrlBySrcUrl(goodsInfo.shopping_url, api);
|
|||
|
// if (string.IsNullOrEmpty(shortUrl)) { continue; }//生成短连接失败
|
|||
|
// var tkl = tbAnalysis.FindTKL(shortUrl, goodsInfo.goods_name, goodsInfo.goods_thumbnail_url, api);
|
|||
|
// if (string.IsNullOrEmpty(tkl)) { continue; }//生成淘口令失败
|
|||
|
// var short_url = ApiClient.ShortURL(api.ComposeTbClick(goodsInfo.goods_id, goodsInfo.goods_thumbnail_url, tkl, goodsInfo.shopping_url), DwzType.新浪短网址).Result;//短连接
|
|||
|
// var cprice = ((decimal)goodsInfo.normal_price - (decimal)goodsInfo.coupon_discount).ToString();//券后价
|
|||
|
// //合成二维码图片
|
|||
|
// if (!string.IsNullOrEmpty(QRCodeUrl))
|
|||
|
// {
|
|||
|
// var QRCodeimage = ApiClient.GetQRImage(goodsInfo.goods_name, goodsInfo.normal_price.ToString(), goodsInfo.coupon_discount.ToString(), cprice, QRCodeUrl, short_url, Class1.Config.Model, CpsType.阿里妈妈, Class1.Config.Single_GoodsQRCodePicDesc); //合成附带二维码等信息的宝贝图片
|
|||
|
// strb.Append($"[图片={QRCodeimage}]");
|
|||
|
// }
|
|||
|
// if (Class1.Config.Single_IsSynthCoupon == SwitchType.开启)
|
|||
|
// {
|
|||
|
// #region 获取头像
|
|||
|
// // B
|
|||
|
// //var shopIcon = string.Empty;
|
|||
|
// //var objDate = api.SendTaobao("taobao.tbk.item.info.get", new { num_iids = goods_info.goods_id });
|
|||
|
// //if (objDate != null && objDate.Count != 0)
|
|||
|
// //{
|
|||
|
// // var tbk_temp_info = ((objDate["n_tbk_item"]) as ArrayList)[0];
|
|||
|
// // var tbk_item = tbk_temp_info as Dictionary<string, object>;
|
|||
|
// // //商品主图
|
|||
|
// // shopIcon = tbk_item["pict_url"].ToString();
|
|||
|
// //}
|
|||
|
// if (string.IsNullOrEmpty(shopIcon) || goodsInfo.mall_name == "天猫超市")
|
|||
|
// shopIcon = "https://ss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1659832877.jpg";
|
|||
|
// #endregion
|
|||
|
|
|||
|
// if (!File.Exists(Tools.PosterPathImgUrl))
|
|||
|
// Tools.GetBaseIco();
|
|||
|
// //strb.Append($"[图片={ApiClient.GetCouponImage(Tools.PosterPathImgUrl, goodsInfo.mall_name, shopIcon, goodsInfo.coupon_discount.ToString(), $"{DateTime.Today.ToString("yyyy.MM.dd")} - {DateTime.Today.AddMonths(1).ToString("yyyy.MM.dd")}")}]");
|
|||
|
// //合成优惠券图片
|
|||
|
// var shopimage_temp = Util.MapFile(Guid.NewGuid().ToString() + ".jpg", "Cache\\Image");
|
|||
|
// try
|
|||
|
// {
|
|||
|
// Tools.DownloadImage(shopIcon, shopimage_temp);
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// Tools.DownloadImage("https://ss2.bdstatic.com/8_V1bjqh_Q23odCf/pacific/1659832877.jpg", shopimage_temp);
|
|||
|
// }
|
|||
|
|
|||
|
// var shopimage = Tools.ReadImageFile(shopimage_temp);
|
|||
|
// shopimage = Tools.getnew(shopimage, 150, 150);
|
|||
|
|
|||
|
// var goodsImage_temp = Util.MapFile(Guid.NewGuid().ToString() + ".jpg", "Cache\\Image");
|
|||
|
// Tools.DownloadImage(goodsInfo.goods_thumbnail_url, goodsImage_temp);
|
|||
|
// var goodsImage = Tools.ReadImageFile(goodsImage_temp);
|
|||
|
// goodsImage = Tools.getnew(goodsImage, 150, 150);
|
|||
|
|
|||
|
// strb.Append($"[图片={ApiClient.GetCouponImage2(Tools.PosterPathImgUrl2, goodsInfo.mall_name, shopimage, goodsInfo.goods_name, goodsInfo.normal_price.ToString(), goodsInfo.coupon_discount.ToString(), goodsImage, $"{DateTime.Today.ToString("yyyy.MM.dd")} - {DateTime.Today.AddMonths(1).ToString("yyyy.MM.dd")}", goodsInfo.sold_quantity.ToString())}]");
|
|||
|
// }
|
|||
|
|
|||
|
// Random rd = new Random();
|
|||
|
// if (!string.IsNullOrWhiteSpace(ApiClient.Setting.SystemConfig.TklStr_First))
|
|||
|
// {
|
|||
|
// var fh = ApiClient.Setting.SystemConfig.TklStr_First.Split('|');//符号
|
|||
|
// tkl = fh[rd.Next(0, fh.Length)] + tkl.Substring(1, tkl.Length - 1);
|
|||
|
// }
|
|||
|
|
|||
|
// if (!string.IsNullOrWhiteSpace(ApiClient.Setting.SystemConfig.TKLStr_End))
|
|||
|
// {
|
|||
|
// var fh = ApiClient.Setting.SystemConfig.TKLStr_End.Split('|');//符号
|
|||
|
// tkl = tkl.Substring(0, tkl.Length - 1) + fh[rd.Next(0, fh.Length)];
|
|||
|
// }
|
|||
|
|
|||
|
// var comment = Class1.Config.Single_AdditionalComment
|
|||
|
// .Replace("[商品标题]", goodsInfo.goods_name)
|
|||
|
// //.Replace("[商品描述]", goodsInfo.goods_desc)
|
|||
|
// .Replace("[已售数量]", goodsInfo.sold_quantity.ToString())
|
|||
|
// .Replace("[店铺名称]", goodsInfo.mall_name)
|
|||
|
// .Replace("[优惠券金额]", goodsInfo.coupon_discount.ToString())
|
|||
|
// .Replace("[优惠券数量]", goodsInfo.coupon_remain_quantity.ToString())
|
|||
|
// .Replace("[商品单价]", goodsInfo.normal_price.ToString())
|
|||
|
// .Replace("[券后价]", cprice)
|
|||
|
// .Replace("[劵后价]", cprice)
|
|||
|
// .Replace("[购买地址]", short_url)
|
|||
|
// .Replace("[淘口令]", tkl);//评语内容
|
|||
|
|
|||
|
// goods_infos_temp.Add(goods_info);
|
|||
|
|
|||
|
// var json = item.SendCircle(strb.ToString().Replace("[购买地址]", short_url));
|
|||
|
// //EventClient.OnEvent(this,$"发送成功:{json}");
|
|||
|
// if (!string.IsNullOrWhiteSpace(Class1.Config.Single_AdditionalComment))
|
|||
|
// {
|
|||
|
// var reg = Regex.Match(json.Replace("<![CDATA[", "").Replace("]]>", ""), @"<id>(?<id>\d{15,})</id>");//获取返回的朋友圈id
|
|||
|
// if (reg.Success)
|
|||
|
// item.SendCircleComment(item.User.Username, reg.Groups["id"].Value, comment);
|
|||
|
// }
|
|||
|
// isSend = true;//认定发送过了...
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// catch (Exception ex)
|
|||
|
// {
|
|||
|
// EventClient.OnEvent(this, $"淘宝推广 - 单产品:{item.WeixinHao},朋友圈推广失败,{ex.Message} - {ex.StackTrace}");
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// if (isSend)
|
|||
|
// {
|
|||
|
// //RecordSendTime = DateTime.Now;
|
|||
|
// for (int i = 0; i < goods_infos_temp.Count; i++)
|
|||
|
// {
|
|||
|
// //goods_infos_temp[i].state = Enums.StateType.已推广;
|
|||
|
// //session.Updateable(goods_infos_temp[i]).ExecuteCommand();
|
|||
|
// session.ExcuteSQL("update fl_plugin_tbcirclepromotion_goodsinfos set state = @state where id = @id", new { state = Enums.StateType.已推广, id = goods_infos_temp[i].id });
|
|||
|
// }
|
|||
|
// Class1.Config.RecordSendTime = DateTime.Now;
|
|||
|
|
|||
|
// Api.Framework.Tools.Util.Save(Class1.Config);
|
|||
|
// }
|
|||
|
|
|||
|
// }
|
|||
|
|
|||
|
//}
|
|||
|
//catch (Exception ex)
|
|||
|
//{
|
|||
|
// EventClient.OnEvent(this, $"淘宝推广:{ex.Message},{ex.StackTrace}");
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|