848 lines
48 KiB
C#
848 lines
48 KiB
C#
using Api.Framework;
|
||
using Api.Framework.Enums;
|
||
using Api.Framework.Events;
|
||
using Api.Framework.Model;
|
||
using Api.Framework.SDK;
|
||
using Api.Framework.Tools;
|
||
using Chat.Framework;
|
||
using Chat.Framework.WXSdk;
|
||
using Chat.Framework.WXSdk.Implement;
|
||
using CsharpHttpHelper;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Linq;
|
||
using System.Threading;
|
||
using TBRebate.Entitys;
|
||
using TBRebate.Properties;
|
||
using TBRebate.Uses;
|
||
using static Api.Framework.Cps.AlimamaApi;
|
||
using static TBRebate.Enums;
|
||
|
||
namespace TBRebate
|
||
{
|
||
public class Class1 : Plugin
|
||
{
|
||
public Class1()
|
||
{
|
||
this.Logo = Resources.淘宝;
|
||
this.Name = Resources.PluginName;
|
||
this.Note = Resources.PluginNote;
|
||
}
|
||
|
||
#region 自定义变量
|
||
public static Config Config;
|
||
private MainForm mainForm = null;
|
||
#endregion
|
||
|
||
public override void Start()
|
||
{
|
||
try
|
||
{
|
||
var session = ApiClient.GetSession();
|
||
#region 判断表是否存在,不存在创建表
|
||
if (session.TableExist<fl_plugin_tbrebate_tbtgw>())
|
||
{
|
||
var tbtgws = session.Find<fl_plugin_tbrebate_tbtgw>("select * from fl_plugin_tbrebate_tbtgw").ToList();
|
||
if (tbtgws != null)
|
||
{
|
||
foreach (var item in tbtgws)
|
||
{
|
||
//插入主推广位数据
|
||
session.Insertable(new fl_adzone_info()
|
||
{
|
||
adzone_name = item.pid_chief_name, //推广位名称
|
||
adzone_pid = item.pid_chief, //推广位pid
|
||
adzone_pid_cps_name = item.pid_chief_cps_name, //推广位cps名称
|
||
alliance_id = (int)CpsType.阿里妈妈, //联盟id
|
||
robot_id = item.robot_id, //机器人id
|
||
group_id = string.Empty, //群id
|
||
is_download = false, //不下载
|
||
member_id = 0, //私人id
|
||
onoff = item.onoff, //不禁用
|
||
custom_type = Resources.SoftwareType, //自定义类型
|
||
extend = "chief"
|
||
}).ExecuteCommand();
|
||
//插入副推广位数据
|
||
session.Insertable(new fl_adzone_info()
|
||
{
|
||
adzone_name = item.pid_deputy_name, //推广位名称
|
||
adzone_pid = item.pid_deputy, //推广位pid
|
||
adzone_pid_cps_name = item.pid_deputy_cps_name, //推广位cps名称
|
||
alliance_id = (int)CpsType.阿里妈妈, //联盟id
|
||
robot_id = item.robot_id, //机器人id
|
||
group_id = string.Empty, //群id
|
||
is_download = false, //不下载
|
||
member_id = 0, //私人id
|
||
onoff = item.onoff, //不禁用
|
||
custom_type = Resources.SoftwareType, //自定义类型
|
||
extend = "deputy"
|
||
}).ExecuteCommand();
|
||
}
|
||
}
|
||
session.DropTable<fl_plugin_tbrebate_tbtgw>();
|
||
}
|
||
if (!session.TableExist<fl_plugin_tbrebate_ignoreids>())
|
||
{
|
||
session.CreateTable<fl_plugin_tbrebate_ignoreids>();
|
||
session.AddIndex<fl_plugin_tbrebate_ignoreids>("itemid");//增加索引.
|
||
session.AddIndex<fl_plugin_tbrebate_ignoreids>("losetime");//增加索引.
|
||
}
|
||
#endregion
|
||
|
||
//创建配置文件
|
||
Config = this.ReadConfig<Config>();
|
||
|
||
SDK.ReciveIMEvent += SDK_ReciveIMEvent;
|
||
SDK.OrderNoticeEvent += SDK_OrderNoticeEvent;
|
||
SDK.WebRequestEvent += SDK_WebRequestEvent;
|
||
InitIgnoreidsCache();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog(ex.Message);
|
||
}
|
||
}
|
||
|
||
private void SDK_WebRequestEvent(object sender, WebRequestEvents e)
|
||
{
|
||
try
|
||
{
|
||
#region
|
||
if (e.Param.ContainsKey("method"))//方法名称
|
||
{
|
||
var method = e.Param["method"].ToLower();
|
||
switch (method)
|
||
{
|
||
case "tbitem":
|
||
{
|
||
var resultJson = string.Empty;
|
||
try
|
||
{
|
||
if (!e.Param.ContainsKey("ids")) throw new Exception("缺少参数ids");
|
||
var ids = e.Param["ids"].ToString();
|
||
if (!string.IsNullOrWhiteSpace(ids))
|
||
{
|
||
var idList = ids.Replace(",", ",").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
|
||
if (idList.Count != 0)
|
||
{
|
||
InitIgnoreidsCache(idList);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
e.Send(ex.Message, 100);
|
||
return;
|
||
}
|
||
e.Send("请求成功", 200);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog("淘宝返利web接收数据异常:" + ex.Message);
|
||
}
|
||
}
|
||
|
||
public static List<fl_plugin_tbrebate_ignoreids> ignoreidsCache = new List<fl_plugin_tbrebate_ignoreids>();
|
||
|
||
private void InitIgnoreidsCache(List<string> idList = null)
|
||
{
|
||
var nowTime = HttpExtend.GetTimeStamp(DateTime.Now);
|
||
|
||
var session = ApiClient.GetSession();
|
||
var temps = new List<fl_plugin_tbrebate_ignoreids>();
|
||
var ignoreids = session.Find<fl_plugin_tbrebate_ignoreids>("select * from fl_plugin_tbrebate_ignoreids");
|
||
if (ignoreids != null && ignoreids.Count != 0)
|
||
{
|
||
temps = ignoreids.Where(f => f.losetime < nowTime).ToList();
|
||
if (temps != null && temps.Count != 0)
|
||
session.Deleteable(temps).ExecuteCommand();
|
||
temps = ignoreids.Where(f => f.losetime >= nowTime).ToList();
|
||
}
|
||
if (idList != null)
|
||
{
|
||
foreach (var itemid in idList)
|
||
{
|
||
var temp = temps.FirstOrDefault(f => f.itemid == itemid);
|
||
if (temp == null)
|
||
session.Insertable(new fl_plugin_tbrebate_ignoreids() { itemid = itemid, losetime = HttpExtend.GetTimeStamp(DateTime.Now.AddDays(2)) }).ExecuteCommand();
|
||
else
|
||
{
|
||
temp.losetime = HttpExtend.GetTimeStamp(DateTime.Now.AddDays(2));
|
||
session.Updateable(temp).ExecuteCommand();
|
||
}
|
||
}
|
||
}
|
||
ignoreidsCache = session.Find<fl_plugin_tbrebate_ignoreids>("select * from fl_plugin_tbrebate_ignoreids");
|
||
}
|
||
|
||
public override void ShowForm()
|
||
{
|
||
try
|
||
{
|
||
if (mainForm == null || mainForm.IsDisposed)
|
||
{
|
||
mainForm = new MainForm();
|
||
mainForm.Show();
|
||
}
|
||
mainForm.TopMost = true;
|
||
mainForm.TopMost = false;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog(ex.Message);
|
||
}
|
||
}
|
||
|
||
public override void Stop()
|
||
{
|
||
try
|
||
{
|
||
SessionExt.Clear();
|
||
if (mainForm != null)
|
||
{
|
||
mainForm.CloseForm();
|
||
mainForm = null;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog(ex.Message);
|
||
}
|
||
}
|
||
|
||
public void SDK_OrderNoticeEvent(object sender, OrderNoticeEvent e)
|
||
{
|
||
try
|
||
{
|
||
if (e.ChatType == CpsType.阿里妈妈)
|
||
{
|
||
//this.OnLog("淘宝订单:" + HttpHelper.ObjectToJson(e));
|
||
var session = ApiClient.GetSession();
|
||
//订单信息
|
||
var order_tb = e.Order as fl_order_alimama;
|
||
|
||
if (order_tb == null) return;
|
||
|
||
if (e.Member != null)
|
||
{
|
||
//是否黑名单
|
||
if (ApiClient.IsBlackFlMemberInfo(e.Member))
|
||
{
|
||
return;
|
||
}
|
||
|
||
#region 订单变化通知消息
|
||
var robot_info = session.FindRobotInfo(e.Member.robot_name.Trim(), e.Member.robot_type);
|
||
if (robot_info != null)
|
||
{
|
||
var mess = string.Empty;
|
||
var point = HttpHelper.JsonToObject<ItemPoint>(order_tb.db_point) as ItemPoint;
|
||
#region 下单用户订单检测(防撸)
|
||
if (e.Customer == null)
|
||
{
|
||
var prevent_theft_cache = session.FindSingle<fl_prevent_theft_cache>("select * from fl_prevent_theft_cache where order_id = @order_id", new { order_id = order_tb.trade_id });//防止上级多次触发
|
||
if (prevent_theft_cache == null)
|
||
{
|
||
var isHint = false;
|
||
if (!string.IsNullOrWhiteSpace(order_tb.seller_id) && e.Member.status != MemberType.白名单)
|
||
{
|
||
#region 同一店铺多次购买(同一商品)
|
||
if (Class1.Config.AShop_SameCommodity_Switch)
|
||
{
|
||
var frequency = session.Find<fl_order_alimama>("select * from fl_order_alimama where db_userid = @db_userid and num_iid = @num_iid", new { db_userid = order_tb.db_userid, num_iid = order_tb.num_iid }).Count;//获取同价店铺同一件商品购买的次数
|
||
if (Class1.Config.AShop_SameCommodity_Number <= frequency)
|
||
{
|
||
if (Class1.Config.AShop_SameCommodity_OperateType == OperateType.拉入黑名单)
|
||
{
|
||
if (!session.TemporaryBypassedBlack(e.Member))
|
||
{
|
||
e.Member.status = MemberType.黑名单; //拉入黑名单
|
||
session.SaveOrUpdate(e.Member);
|
||
session.FindBlacklistMemberInfos(true);//刷新黑名单缓存
|
||
|
||
ApiClient.SendMessage(robot_info, e.Member.username, new VariateReplace().CommonReplace(Config.Blocked_RestrictTip, order_tb, e.Member, point), order_tb.msg_groupid);
|
||
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户拉黑
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
拉黑原因:用户购买同一商品{frequency}次", Config.notice_robotname);
|
||
e.Cancel = true;
|
||
|
||
{
|
||
prevent_theft_cache = new fl_prevent_theft_cache();
|
||
prevent_theft_cache.operate_type = Class1.Config.AShop_SameCommodity_OperateType;
|
||
prevent_theft_cache.member_id = e.Member.id;
|
||
prevent_theft_cache.item_id = order_tb.num_iid;
|
||
prevent_theft_cache.mall_id = order_tb.seller_id;
|
||
prevent_theft_cache.order_id = order_tb.trade_id;
|
||
prevent_theft_cache.cps_type = CpsType.阿里妈妈;
|
||
session.Insertable(prevent_theft_cache).ExecuteCommand();
|
||
}
|
||
|
||
if (Config.AShop_SameCommodity_UserTop)
|
||
{
|
||
if (robot_info.type == ChatType.微信)
|
||
{
|
||
var wx = ChatClient.WXClient.Values.FirstOrDefault(f => f.WeixinHao == robot_info.name /*&& f.WeixinType == WeixinType.Grpc微信*/);
|
||
if (wx != null)
|
||
{
|
||
//var ipad = wx as WXClientImpl_IPAD;
|
||
//if (ipad != null)
|
||
// ipad.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
wx.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
}
|
||
}
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
else if (Class1.Config.AShop_SameCommodity_OperateType == OperateType.通知钉钉群)
|
||
{
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户警告
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
警告原因:用户购买同一商品{frequency}次", Config.notice_robotname);
|
||
isHint = true;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 同一店铺多次购买(不同商品)
|
||
if (!isHint && Class1.Config.AShop_DifferentCommodity_Switch)
|
||
{
|
||
var frequency = session.Find<fl_order_alimama>("select * from fl_order_alimama where db_userid = @db_userid and seller_id = @seller_id", new { db_userid = order_tb.db_userid, seller_id = order_tb.seller_id }).Count;
|
||
if (Class1.Config.AShop_DifferentCommodity_Number <= frequency)
|
||
{
|
||
if (Class1.Config.AShop_DifferentCommodity_OperateType == OperateType.拉入黑名单)
|
||
{
|
||
if (!session.TemporaryBypassedBlack(e.Member))
|
||
{
|
||
e.Member.status = MemberType.黑名单; //拉入黑名单
|
||
session.SaveOrUpdate(e.Member);
|
||
session.FindBlacklistMemberInfos(true);//刷新黑名单缓存
|
||
|
||
ApiClient.SendMessage(robot_info, e.Member.username, new VariateReplace().CommonReplace(Config.Blocked_RestrictTip, order_tb, e.Member, point), order_tb.msg_groupid);
|
||
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户拉黑
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
拉黑原因:用户在同家店铺购买{frequency}次", Config.notice_robotname);
|
||
e.Cancel = true;
|
||
|
||
{
|
||
prevent_theft_cache = new fl_prevent_theft_cache();
|
||
prevent_theft_cache.operate_type = Class1.Config.AShop_DifferentCommodity_OperateType;
|
||
prevent_theft_cache.member_id = e.Member.id;
|
||
prevent_theft_cache.item_id = order_tb.num_iid;
|
||
prevent_theft_cache.mall_id = order_tb.seller_id;
|
||
prevent_theft_cache.order_id = order_tb.trade_id;
|
||
prevent_theft_cache.cps_type = CpsType.阿里妈妈;
|
||
session.Insertable(prevent_theft_cache).ExecuteCommand();
|
||
}
|
||
|
||
if (Config.AShop_DifferentCommodity_UserTop)
|
||
{
|
||
if (robot_info.type == ChatType.微信)
|
||
{
|
||
var wx = ChatClient.WXClient.Values.FirstOrDefault(f => f.WeixinHao == robot_info.name /*&& f.WeixinType == WeixinType.Grpc微信*/);
|
||
if (wx != null)
|
||
{
|
||
//var ipad = wx as WXClientImpl_IPAD;
|
||
//if (ipad != null)
|
||
// ipad.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
wx.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
}
|
||
}
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
else if (Class1.Config.AShop_DifferentCommodity_OperateType == OperateType.通知钉钉群)
|
||
{
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户警告
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
警告原因:用户在同家店铺购买{frequency}次", Config.notice_robotname);
|
||
isHint = true;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
#region 收货时间验证时长
|
||
if (!isHint && Class1.Config.ReceivingTimeCheck_Switch && order_tb.tk_status == (int)AlimamaOrderStatus.订单结算 && e.Member.status != MemberType.白名单)
|
||
{
|
||
if (order_tb.earning_time != DateTime.MinValue)
|
||
{
|
||
var timeLag = (int)Math.Floor((order_tb.earning_time - order_tb.create_time).TotalHours);
|
||
if (timeLag <= Class1.Config.ReceivingTimeCheck_Hour)
|
||
{
|
||
if (Class1.Config.ReceivingTimeCheck_OperateType == OperateType.拉入黑名单)
|
||
{
|
||
if (!session.TemporaryBypassedBlack(e.Member))
|
||
{
|
||
e.Member.status = MemberType.黑名单; //拉入黑名单
|
||
session.SaveOrUpdate(e.Member);
|
||
session.FindBlacklistMemberInfos(true);//刷新黑名单缓存
|
||
|
||
ApiClient.SendMessage(robot_info, e.Member.username, new VariateReplace().CommonReplace(Config.Blocked_RestrictTip, order_tb, e.Member, point), order_tb.msg_groupid);
|
||
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户拉黑
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
拉黑原因:订单收货时间间隔{timeLag}小时", Config.notice_robotname);
|
||
e.Cancel = true;
|
||
{
|
||
prevent_theft_cache = new fl_prevent_theft_cache();
|
||
prevent_theft_cache.operate_type = Class1.Config.ReceivingTimeCheck_OperateType;
|
||
prevent_theft_cache.member_id = e.Member.id;
|
||
prevent_theft_cache.item_id = order_tb.num_iid;
|
||
prevent_theft_cache.mall_id = order_tb.seller_id;
|
||
prevent_theft_cache.order_id = order_tb.trade_id;
|
||
prevent_theft_cache.cps_type = CpsType.阿里妈妈;
|
||
session.Insertable(prevent_theft_cache).ExecuteCommand();
|
||
}
|
||
|
||
if (Config.ReceivingTimeCheck_UserTop)
|
||
{
|
||
if (robot_info.type == ChatType.微信)
|
||
{
|
||
var wx = ChatClient.WXClient.Values.FirstOrDefault(f => f.WeixinHao == robot_info.name /*&& f.WeixinType == WeixinType.Grpc微信*/);
|
||
if (wx != null)
|
||
{
|
||
//var ipad = wx as WXClientImpl_IPAD;
|
||
//if (ipad != null)
|
||
//ipad.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
wx.EditContacts(e.Member.username, EditContactsType.置顶, e.Member.usernick);
|
||
}
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
else if (Class1.Config.ReceivingTimeCheck_OperateType == OperateType.通知钉钉群)
|
||
{
|
||
ApiClient.SendNoticeMessage($@"嫌疑用户警告
|
||
————
|
||
事件类型:订单检测
|
||
微信账号:{robot_info.name}
|
||
微信昵称:{robot_info.nick}
|
||
客户账号:{e.Member.username}
|
||
客户昵称:{e.Member.usernick}
|
||
警告原因:订单收货时间间隔{timeLag}小时", Config.notice_robotname);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
switch (e.OrderNoticeType)
|
||
{
|
||
case OrderNoticeType.客户订单:
|
||
{
|
||
if (Config.UserOrderChangeSwitch == SwitchType.开启 && !ApiClient.Setting.SystemConfig.message_warning_switch)
|
||
{
|
||
#region 淘礼金订单只提示 付款/结算
|
||
var is_tlj = session.CheckIsTljOrder(order_tb.adzone_id);
|
||
#endregion
|
||
|
||
if (!is_tlj)
|
||
mess = _GetOrderStateMess(order_tb.db_status, SettleType.未结算提示, order_tb, e.Member, point);
|
||
else
|
||
{
|
||
if (order_tb.db_status == SystemOrderStatus.订单付款)
|
||
mess = Config.TljPaymentTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单结算)
|
||
mess = Config.TljSettlementTip;
|
||
else//淘礼金其他订单状态不给用户提示
|
||
return;
|
||
mess = new VariateReplace().CommonReplace(mess, order_tb, e.Member, point);
|
||
}
|
||
if (!string.IsNullOrEmpty(e.Member.username) && !string.IsNullOrEmpty(mess))
|
||
ApiClient.SendMessage(robot_info, e.Member.username, mess, order_tb.msg_groupid);
|
||
}
|
||
}
|
||
return;
|
||
case OrderNoticeType.一级提成:
|
||
if (Config.AgentReceivedCommissionSwitch == SwitchType.开启)
|
||
{
|
||
if (e.Customer != null && point.AwardOne != 0)
|
||
{
|
||
if (order_tb.db_status == SystemOrderStatus.订单维权中)
|
||
mess = Config.ClientOrderRefund_OneLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单付款)
|
||
mess = Config.OrderPaymentInform_OneLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单失效)
|
||
mess = Config.OrderCountermandInform_OneLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单结算)
|
||
mess = Config.OrderSettlement_OneLevelTip;
|
||
}
|
||
}
|
||
break;
|
||
case OrderNoticeType.二级提成:
|
||
if (Config.AgentReceivedCommissionSwitch == SwitchType.开启)
|
||
{
|
||
if (e.Customer != null)
|
||
{
|
||
if (order_tb.db_status == SystemOrderStatus.订单维权中)
|
||
mess = Config.ClientOrderRefund_TwoLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单付款)
|
||
mess = Config.OrderPaymentInform_TwoLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单失效)
|
||
mess = Config.OrderCountermandInform_TwoLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单结算)
|
||
mess = Config.OrderSettlement_TwoLevelTip;
|
||
}
|
||
}
|
||
break;
|
||
case OrderNoticeType.三级提成:
|
||
if (Config.AgentReceivedCommissionSwitch == SwitchType.开启)
|
||
{
|
||
if (e.Customer != null)
|
||
{
|
||
if (order_tb.db_status == SystemOrderStatus.订单维权中)
|
||
mess = Config.ClientOrderRefund_ThreeLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单付款)
|
||
mess = Config.OrderPaymentInform_ThreeLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单失效)
|
||
mess = Config.OrderCountermandInform_ThreeLevelTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单结算)
|
||
mess = Config.OrderSettlement_ThreeLevelTip;
|
||
}
|
||
}
|
||
break;
|
||
case OrderNoticeType.群主分成:
|
||
if (Config.PrincipalReceivedCommissionSwitch == SwitchType.开启)
|
||
{
|
||
if (e.Customer != null)
|
||
{
|
||
if (order_tb.db_status == SystemOrderStatus.订单维权中)
|
||
mess = Config.ClientOrderRefund_LeaderTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单付款)
|
||
mess = Config.OrderPaymentInform_LeaderTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单失效)
|
||
mess = Config.OrderCountermandInform_LeaderTip;
|
||
else if (order_tb.db_status == SystemOrderStatus.订单结算)
|
||
mess = Config.OrderSettlement_LeaderTip;
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
if (!ApiClient.Setting.SystemConfig.message_warning_switch && !string.IsNullOrEmpty(e.Member.username) && !string.IsNullOrWhiteSpace(mess))
|
||
ApiClient.SendMessage(robot_info, e.Member.username, new VariateReplace().CommonReplace(mess, order_tb, e.Member, point).Replace("[下级昵称]", e.Customer.realnick ?? ""));
|
||
}
|
||
#endregion
|
||
}
|
||
else
|
||
{
|
||
#region 多人查询通知消息
|
||
var querys = session.Find<queryhist_temp>("select robot_name,type,userid from fl_query_hist where itemid=@itemid and adzoneid = @adzoneid and userid > 0 and crt_time>@time and is_multiple=@is_multiple group by userid,type,robot_name", new { itemid = order_tb.num_iid, adzoneid = order_tb.adzone_id, time = DateTime.Now.AddHours(-24).ToString("yyyy-MM-dd HH:mm:ss"), is_multiple = false });
|
||
if (querys.Count > 0)
|
||
{
|
||
for (int i = 0; i < querys.Count; i++)
|
||
{
|
||
try
|
||
{
|
||
if (querys[i].type != CpsType.阿里妈妈) continue;
|
||
//未绑定的数量
|
||
var unbound_count = int.Parse(session.FindTable($"select count(id) as num from fl_order_alimama where trade_parent_id = @trade_parent_id and db_userid != 0", new { trade_parent_id = order_tb.trade_parent_id }).Rows[0]["num"].ToString());
|
||
if (unbound_count != 0) break;//已经被绑定直接停止
|
||
|
||
var queryhist_temp = querys[i];
|
||
var userid = queryhist_temp.userid;
|
||
var robot_name = queryhist_temp.robot_name;
|
||
var robot_info = session.Find<fl_robot_info>("select * from fl_robot_info where name = @name", new { name = robot_name }).FirstOrDefault();//机器人类型应该是没有的,直接通过机器人name查询机器人信息
|
||
if (robot_info != null)
|
||
{
|
||
Thread.Sleep(5000);
|
||
var wxbase = Chat.Framework.ChatClient.WXClient.Values.ToList().FirstOrDefault(f => f.WeixinHao == robot_name);
|
||
if (wxbase != null /*&& wxbase.WeixinType == WeixinType.Grpc微信*/ && wxbase.Status == WxStatus.在线)
|
||
{
|
||
var member = session.FindMemberInfoById(userid);
|
||
if (member != null)
|
||
{
|
||
ApiClient.SendMessage(robot_info, member.username, Config.LotUserQueryBindTip.Replace("[商品标题]", order_tb.item_title));
|
||
|
||
//session.ExcuteSQL("update fl_query_hist set userid = @newuserid where itemid = @itemid and adzoneid = @adzoneid and robot_name = @robotname and userid = @userid", new { newuserid = (i - querys.Count + 1), itemid = order_tb.num_iid, adzoneid = order_tb.adzone_id, robotname = robot_name, userid = member.id });
|
||
session.ExcuteSQL("update fl_query_hist set is_multiple = @is_multiple where itemid = @itemid and adzoneid = @adzoneid and robot_name = @robotname and userid = @userid", new { is_multiple = true, itemid = order_tb.num_iid, adzoneid = order_tb.adzone_id, robotname = robot_name, userid = member.id });
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{ }
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog(ex.Message);
|
||
}
|
||
}
|
||
|
||
private void SDK_ReciveIMEvent(object sender, ReciveIMEvent e)
|
||
{
|
||
try
|
||
{
|
||
//if (e.Message == "1")
|
||
//{
|
||
// string url = ApiClient.SendWechatPay(new { robot_nick = e.RobotNick, robot_name = e.RobotName, username = e.Username, usernick = e.NickName }, "测试", 0.3, out var ispaid, out var appinfo);
|
||
|
||
// Console.WriteLine(url);
|
||
//}
|
||
|
||
//return;
|
||
|
||
//var hook = sender as WXClientImpl_HOOK;
|
||
//var ss = hook.AutoAuthMiniAPPLogin("wxa918198f16869201");
|
||
|
||
//return;
|
||
|
||
// var sss = @"<TimelineObject>
|
||
// <id><![CDATA[13817912067015979088]]></id>
|
||
// <username><![CDATA[wxid_fy2obibqhy5w22]]></username>
|
||
// <createTime><![CDATA[1647223480]]></createTime>
|
||
// <contentDescShowType>0</contentDescShowType>
|
||
// <contentDescScene>0</contentDescScene>
|
||
// <private><![CDATA[0]]></private>
|
||
// <contentDesc><![CDATA[润本高端货,低价贱卖!!
|
||
//润本?婴儿驱蚊喷雾2瓶,💰12.9
|
||
|
||
//德国进口MERCK原液!!
|
||
|
||
//驱蚊 除螨,喷一下,防蚊5.7小时!]]></contentDesc>
|
||
// <contentattr><![CDATA[0]]></contentattr>
|
||
// <sourceUserName>
|
||
// </sourceUserName>
|
||
// <sourceNickName>
|
||
// </sourceNickName>
|
||
// <statisticsData>
|
||
// </statisticsData>
|
||
// <weappInfo>
|
||
// <appUserName>
|
||
// </appUserName>
|
||
// <pagePath>
|
||
// </pagePath>
|
||
// <version><![CDATA[0]]></version>
|
||
// <debugMode><![CDATA[0]]></debugMode>
|
||
// <shareActionId>
|
||
// </shareActionId>
|
||
// <isGame><![CDATA[0]]></isGame>
|
||
// <messageExtraData>
|
||
// </messageExtraData>
|
||
// <subType><![CDATA[0]]></subType>
|
||
// <preloadResources>
|
||
// </preloadResources>
|
||
// </weappInfo>
|
||
// <canvasInfoXml>
|
||
// </canvasInfoXml>
|
||
// <ContentObject>
|
||
// <contentStyle><![CDATA[1]]></contentStyle>
|
||
// <contentSubStyle><![CDATA[0]]></contentSubStyle>
|
||
// <title>
|
||
// </title>
|
||
// <description>
|
||
// </description>
|
||
// <contentUrl>
|
||
// </contentUrl>
|
||
// <mediaList>
|
||
// <media>
|
||
// <id><![CDATA[13817912067592433749]]></id>
|
||
// <type><![CDATA[2]]></type>
|
||
// <title>
|
||
// </title>
|
||
// <description>
|
||
// </description>
|
||
// <private><![CDATA[0]]></private>
|
||
// <url type='1' md5='4e09fc59d71e99ab7d7bef5fcf56e0b4'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4RwR3kyUJ3YGLZcN7ptPkBfRPVZo3pia5zvceelgppXZE/0]]></url>
|
||
// <thumb type='1'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4RwR3kyUJ3YGLZcN7ptPkBfRPVZo3pia5zvceelgppXZE/150]]></thumb>
|
||
// <videoDuration><![CDATA[0.0]]></videoDuration>
|
||
// <size totalSize='47021.0' width='800.0' height='800.0'>
|
||
// </size>
|
||
// </media>
|
||
// <media>
|
||
// <id><![CDATA[13817912067647483958]]></id>
|
||
// <type><![CDATA[2]]></type>
|
||
// <title>
|
||
// </title>
|
||
// <description>
|
||
// </description>
|
||
// <private><![CDATA[0]]></private>
|
||
// <url type='1' md5='4e09fc59d71e99ab7d7bef5fcf56e0b4'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4TkeucIzqZvoN597MUicoU5ichJMesCAiavJhRKFS19ibx64/0]]></url>
|
||
// <thumb type='1'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4TkeucIzqZvoN597MUicoU5ichJMesCAiavJhRKFS19ibx64/150]]></thumb>
|
||
// <videoDuration><![CDATA[0.0]]></videoDuration>
|
||
// <size totalSize='77928.0' width='1080.0' height='1080.0'>
|
||
// </size>
|
||
// </media>
|
||
// <media>
|
||
// <id><![CDATA[13817912067697029194]]></id>
|
||
// <type><![CDATA[2]]></type>
|
||
// <title>
|
||
// </title>
|
||
// <description>
|
||
// </description>
|
||
// <private><![CDATA[0]]></private>
|
||
// <url type='1' md5='4e09fc59d71e99ab7d7bef5fcf56e0b4'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4gdsX4xty1mRiaayS6HKz01W3dv34R5WNicvkVud7Kt2iaE/0]]></url>
|
||
// <thumb type='1'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI4gdsX4xty1mRiaayS6HKz01W3dv34R5WNicvkVud7Kt2iaE/150]]></thumb>
|
||
// <videoDuration><![CDATA[0.0]]></videoDuration>
|
||
// <size totalSize='112068.0' width='960.0' height='1280.0'>
|
||
// </size>
|
||
// </media>
|
||
// <media>
|
||
// <id><![CDATA[13817912067756077114]]></id>
|
||
// <type><![CDATA[2]]></type>
|
||
// <title>
|
||
// </title>
|
||
// <description>
|
||
// </description>
|
||
// <private><![CDATA[0]]></private>
|
||
// <url type='1' md5='4e09fc59d71e99ab7d7bef5fcf56e0b4'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI45kax0OSO6mIYcNIn2Rr2BvwfZcMpuWzm6kSJHPxLrzU/0]]></url>
|
||
// <thumb type='1'><![CDATA[http://shmmsns.qpic.cn/mmsns/0aFfd9Cz1NicS6H185dNticJ4v7dpIvLI45kax0OSO6mIYcNIn2Rr2BvwfZcMpuWzm6kSJHPxLrzU/150]]></thumb>
|
||
// <videoDuration><![CDATA[0.0]]></videoDuration>
|
||
// <size totalSize='76871.0' width='1080.0' height='1440.0'>
|
||
// </size>
|
||
// </media>
|
||
// <media><id>15034863132013047048</id><type>2</type><title></title><description></description><private>0</private><url type='1'>[图片=C:\Users\Administrator\Desktop\秒单客-返利机器人\Cache\image\637828491427180612.jpg]</url><thumb type='1'>[图片=D:\其他\图片s\timg.jpg]</thumb><size height='800.0' width='800.0' totalSize='0'></size></media></mediaList>
|
||
// </ContentObject>
|
||
// <actionInfo>
|
||
// <appMsg>
|
||
// <mediaTagName>
|
||
// </mediaTagName>
|
||
// <messageExt>
|
||
// </messageExt>
|
||
// <messageAction>
|
||
// </messageAction>
|
||
// </appMsg>
|
||
// </actionInfo>
|
||
// <appInfo>
|
||
// <id>
|
||
// </id>
|
||
// </appInfo>
|
||
|
||
// <publicUserName>
|
||
// </publicUserName>
|
||
// <streamvideo>
|
||
// <streamvideourl>
|
||
// </streamvideourl>
|
||
// <streamvideothumburl>
|
||
// </streamvideothumburl>
|
||
// <streamvideoweburl>
|
||
// </streamvideoweburl>
|
||
// </streamvideo>
|
||
//</TimelineObject>";
|
||
|
||
// var wx = sender as WXClientImpl_HOOK;
|
||
// wx.SendCircle(sss);
|
||
|
||
// return;
|
||
|
||
|
||
//过滤表情xml和卡片xml
|
||
if ((e.Message.Contains(@"<appmsg appid=") || e.Message.Contains(@"<msg><emoji") || e.Message.StartsWith("[声音=")) && !e.Message.Contains(@"点击链接,再选择浏览器咑閞")) return;
|
||
if (!OrderHelper.IsCurrentCpsMess(e.Message, CpsType.阿里妈妈)) return;
|
||
var session = ApiClient.GetSession();
|
||
var _member = e.GetMemberinfo();
|
||
|
||
var mOper = new MessageOperation(sender, e, this);
|
||
|
||
//手动发送订单号绑定
|
||
if (mOper.BindOrderId()) return;
|
||
|
||
|
||
|
||
//var stopWatch = new Stopwatch();
|
||
//stopWatch.Start();
|
||
var flag = mOper.AnalyseFanLi();
|
||
//stopWatch.Stop();
|
||
//this.OnLog($"用时间 {e.NickName}({e.Username}) => {e.Message} => " + stopWatch.Elapsed.TotalSeconds.ToString("0.0000"));
|
||
//返利消息判断
|
||
if (flag) return;
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.OnLog($"淘宝返利插件异常.:{ex.Message} - {ex.StackTrace}");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 订单状态 提示语替换
|
||
/// </summary>
|
||
/// <param name="order"></param>
|
||
/// <param name="objs"></param>
|
||
/// <returns></returns>
|
||
public static string _GetOrderStateMess(SystemOrderStatus order, SettleType settle, params object[] objs)
|
||
{
|
||
var mess = string.Empty;
|
||
switch (order)
|
||
{
|
||
case SystemOrderStatus.订单付款:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderPaymentTip, objs);
|
||
break;
|
||
case SystemOrderStatus.订单失效:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderFailureTip, objs);
|
||
break;
|
||
case SystemOrderStatus.订单维权中:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderRefundTip, objs);
|
||
break;
|
||
case SystemOrderStatus.订单结算:
|
||
mess = new VariateReplace().CommonReplace(settle == SettleType.未结算提示 ? Config.OrderSettlementTip : Config.OrderAlreadySettlementTip, objs);
|
||
break;
|
||
case SystemOrderStatus.订单冻结:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderFreezeTip, objs);
|
||
break;
|
||
case SystemOrderStatus.全额退款:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderFrozen_AllTip, objs);
|
||
break;
|
||
case SystemOrderStatus.部分退款:
|
||
mess = new VariateReplace().CommonReplace(Config.OrderFrozen_PartTip, objs);
|
||
break;
|
||
}
|
||
return mess;
|
||
}
|
||
|
||
}
|
||
}
|