2022-09-20 03:10:29 +00:00
|
|
|
|
using Api.Framework;
|
|
|
|
|
using Api.Framework.Cps;
|
|
|
|
|
using Api.Framework.Enums;
|
|
|
|
|
using Api.Framework.Events;
|
|
|
|
|
using Api.Framework.Model;
|
|
|
|
|
using Api.Framework.SDK;
|
|
|
|
|
using Api.Framework.Timers;
|
|
|
|
|
using DevExpress.XtraBars;
|
|
|
|
|
using DevExpress.XtraEditors;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using UI.Framework.Controls;
|
|
|
|
|
using UI.Framework.Forms;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using static Api.Framework.Cps.AlimamaApi;
|
|
|
|
|
using FLSystem.Properties;
|
|
|
|
|
using Api.Framework.Tools;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
namespace FLSystem.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class cps_manage_control : DevExpress.XtraEditors.XtraUserControl
|
|
|
|
|
{
|
|
|
|
|
public cps_manage_control()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
var StartDy = Util.AppConfig_GetValue("StartDy");
|
|
|
|
|
if (StartDy == "1")
|
|
|
|
|
barButtonItem43.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0) e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
|
|
|
}
|
|
|
|
|
private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var m = e.Row as Api.Framework.Model.fl_cps_member;
|
|
|
|
|
// m.online
|
|
|
|
|
if (e.Column.Caption == "图标")
|
|
|
|
|
{
|
|
|
|
|
switch (m.cpstype)
|
|
|
|
|
{
|
|
|
|
|
case CpsType.京东联盟:
|
|
|
|
|
e.Value = Properties.Resources.京东_20;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.多多进宝:
|
|
|
|
|
e.Value = Properties.Resources.拼多多_20;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.唯品联盟:
|
|
|
|
|
e.Value = Properties.Resources.唯品会12;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.阿里妈妈:
|
|
|
|
|
e.Value = Properties.Resources.淘宝_20;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.抖音联盟:
|
|
|
|
|
e.Value = Properties.Resources.抖音;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.苏宁易购:
|
|
|
|
|
e.Value = Properties.Resources.苏宁小;
|
|
|
|
|
break;
|
|
|
|
|
case CpsType.快手联盟:
|
|
|
|
|
e.Value = Properties.Resources.快手登录;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
e.Value = Properties.Resources.淘宝_20;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Column.Caption == "接口类型")
|
|
|
|
|
e.Value = "联盟授权";
|
|
|
|
|
else if (e.Column.Caption == "状态")
|
|
|
|
|
{
|
|
|
|
|
if (m.cpstype == CpsType.唯品联盟)
|
|
|
|
|
e.Value = m.is_valid ? "在线" : "离线";
|
|
|
|
|
else
|
|
|
|
|
e.Value = m.online ? "在线" : "离线";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cps_manage_control_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.gridControl1.DataSource = CpsClient.Members;
|
|
|
|
|
EventClient.MethodEvent += EventClient_MethodEvent;
|
|
|
|
|
this.Disposed += Cps_manage_control_Disposed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cps_manage_control_Disposed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EventClient.MethodEvent -= EventClient_MethodEvent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EventClient_MethodEvent(object sender, MethodType e)
|
|
|
|
|
{
|
|
|
|
|
if (e == MethodType.刷新联盟)
|
|
|
|
|
{
|
|
|
|
|
this.gridControl1.DataSource = null;
|
|
|
|
|
CpsClient.RefreshCps();
|
|
|
|
|
this.gridControl1.DataSource = CpsClient.Members;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
EventClient.OnEvent(this, MethodType.刷新联盟);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void gridControl1_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Right) popupMenu1.ShowPopup(Control.MousePosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void popupMenu1_Popup(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
barSubItem4.Enabled = false;
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
this.barButtonItem17.Enabled = barButtonItem16.Enabled = this.barSubItem1.Enabled = r.Length != 0;
|
|
|
|
|
if (r.Length == 0) return;
|
|
|
|
|
var row = gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
if (row == null) return;
|
|
|
|
|
barButtonItem37.Enabled = barSubItem4.Enabled = (row.cpstype == CpsType.阿里妈妈);
|
|
|
|
|
|
|
|
|
|
barButtonItem45.Enabled = row.cpstype == CpsType.抖音联盟;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步订单操作
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="start_time">同步订单开始时间</param>
|
|
|
|
|
private void sync_order(DateTime start_time, bool is_all = false)
|
|
|
|
|
{
|
|
|
|
|
DialogResult ok = DialogResult.No;
|
|
|
|
|
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
if (row == null) return;
|
|
|
|
|
|
|
|
|
|
if (is_all)
|
|
|
|
|
{
|
|
|
|
|
ok = XtraMessageBox.Show($"您确定要刷新所有【{row.cpstype}】联盟订单吗?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (row.is_download == SwitchType.关闭)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError($@"联盟:{row.username}({row.usernick})
|
|
|
|
|
同步状态:禁止
|
|
|
|
|
注:联盟列表选中账号右击开启,即可同步");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok = XtraMessageBox.Show($"您确定要启动线程同步【{row.username}({row.usernick})】的订单吗?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
Task.Factory.StartNew(delegate
|
|
|
|
|
{
|
|
|
|
|
string cpsStr = $"【{row.cpstype.ToString()}】账号:{row.username}({row.usernick})";
|
|
|
|
|
if (!is_all)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownAlimamaTimer>() as DownAlimamaTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
row.is_valid = true;
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.多多进宝)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownPinduoduoTimer>() as DownPinduoduoTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.京东联盟)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownJingdongTimer>() as DownJingdongTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.唯品联盟)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownWeipinhuiTimer>() as DownWeipinhuiTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.抖音联盟)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownDouyinTimer>() as DownDouyinTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.苏宁易购)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownSuningTimer>() as DownSuningTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.快手联盟)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownKuaiShouTimer>() as DownKuaiShouTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(new List<fl_cps_member>() { row }, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowSuccessAutoClose($"{cpsStr},同步完成!", 20000);
|
|
|
|
|
}));
|
|
|
|
|
EventClient.OnEvent(null, $"{cpsStr},手动同步完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 不下载通知
|
|
|
|
|
var cpss_down = CpsClient.Members.Where(f => f.cpstype == row.cpstype && f.is_download == SwitchType.开启).ToList();
|
|
|
|
|
var cpss_undown = CpsClient.Members.Where(f => f.cpstype == row.cpstype && f.is_download == SwitchType.关闭).ToList();
|
|
|
|
|
if (cpss_undown != null && cpss_undown.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder strb = new StringBuilder($@"{row.cpstype}联盟:
|
|
|
|
|
");
|
|
|
|
|
foreach (var cps in cpss_undown)
|
|
|
|
|
{
|
|
|
|
|
strb.AppendLine($"{cps.username} ({cps.usernick})");
|
|
|
|
|
}
|
|
|
|
|
strb.AppendLine(@"
|
|
|
|
|
同步状态:禁止
|
|
|
|
|
注:联盟列表选中账号右击开启, 即可同步");
|
|
|
|
|
EventClient.OnEvent(this, strb.ToString());
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownAlimamaTimer>() as DownAlimamaTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.多多进宝)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownPinduoduoTimer>() as DownPinduoduoTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.京东联盟)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownJingdongTimer>() as DownJingdongTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.唯品联盟)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownWeipinhuiTimer>() as DownWeipinhuiTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.抖音联盟)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownDouyinTimer>() as DownDouyinTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.苏宁易购)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownSuningTimer>() as DownSuningTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (row.cpstype == CpsType.快手联盟)
|
|
|
|
|
{
|
|
|
|
|
if (cpss_down != null && cpss_down.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownKuaiShouTimer>() as DownKuaiShouTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
timer.UpdateOrder(cpss_down, start_time, DateTime.Now);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowSuccessAutoClose($"{cpsStr},同步完成!", 20000);
|
|
|
|
|
}));
|
|
|
|
|
EventClient.OnEvent(null, $"{cpsStr},手动同步完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-7));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddMonths(-1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-90));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
if (r.Length == 0) return;
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
var result = XtraMessageBox.Show($"您确定要删除【{row.username}({row.usernick})】账号吗?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
this.gridView1.DeleteRow(r[0]);
|
|
|
|
|
CpsClient.Members.Remove(row);
|
|
|
|
|
var session = ApiClient.GetSession();
|
|
|
|
|
session.Delete(row);
|
|
|
|
|
EventClient.OnEvent(this, MethodType.刷新联盟);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.阿里妈妈);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.多多进宝);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem10_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.京东联盟);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem42_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.唯品联盟);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem43_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.抖音联盟);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex.Message, "抖音异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem44_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoginCps(CpsType.苏宁易购);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem46_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//TODO 快手
|
2022-09-26 09:04:23 +00:00
|
|
|
|
//return;
|
2022-09-20 03:10:29 +00:00
|
|
|
|
LoginCps(CpsType.快手联盟);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fl_cps_member LoginCps(CpsType type)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var member = CpsClient.Login(type);
|
|
|
|
|
if (member != null)
|
|
|
|
|
{
|
|
|
|
|
CpsClient.RefreshCps();
|
|
|
|
|
EventClient.OnEvent(null, MethodType.刷新联盟);
|
|
|
|
|
}
|
|
|
|
|
return member;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-7), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddMonths(-1), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem15_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-90), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem16_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
if (row != null)
|
|
|
|
|
{
|
|
|
|
|
row.abnormal_tip = (row.abnormal_tip == SwitchType.开启) ? SwitchType.关闭 : SwitchType.开启;
|
|
|
|
|
var session = ApiClient.GetSession();
|
|
|
|
|
session.SaveOrUpdate(row);
|
|
|
|
|
EventClient.OnEvent(this, MethodType.刷新联盟);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem17_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
if (row != null)
|
|
|
|
|
{
|
|
|
|
|
row.is_download = (row.is_download == SwitchType.开启) ? SwitchType.关闭 : SwitchType.开启;
|
|
|
|
|
var session = ApiClient.GetSession();
|
|
|
|
|
session.SaveOrUpdate(row);
|
|
|
|
|
EventClient.OnEvent(this, MethodType.刷新联盟);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (sender is BarManager)
|
|
|
|
|
{
|
|
|
|
|
var tag = e.Item.Tag.ToString();
|
|
|
|
|
//var button = sender as BarManager;
|
|
|
|
|
//var tag = button.Tag;
|
|
|
|
|
AlimamaOrderStatus status = AlimamaOrderStatus.全部订单;
|
|
|
|
|
|
|
|
|
|
if (e.Item.Caption == "付款订单")
|
|
|
|
|
status = AlimamaOrderStatus.订单付款;
|
|
|
|
|
else if (e.Item.Caption == "结算订单")
|
|
|
|
|
status = AlimamaOrderStatus.订单结算;
|
|
|
|
|
else if (e.Item.Caption == "失效订单")
|
|
|
|
|
status = AlimamaOrderStatus.订单失效;
|
|
|
|
|
if (status != AlimamaOrderStatus.全部订单)
|
|
|
|
|
{
|
|
|
|
|
sync_appoint_alimama_order(status, DateTime.Now.AddDays(-int.Parse(tag)));
|
|
|
|
|
}
|
|
|
|
|
else if (e.Item.Caption == "维权订单")
|
|
|
|
|
{
|
|
|
|
|
sync_appoint_alimama_refund_order(DateTime.Now.AddDays(-int.Parse(tag)));
|
|
|
|
|
//XtraMessageBox.Show("开发中!", "温馨提示", MessageBoxButtons.OK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步指定类型阿里妈妈订单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="start_time"></param>
|
|
|
|
|
/// <param name="is_all"></param>
|
|
|
|
|
private void sync_appoint_alimama_order(AlimamaOrderStatus status, DateTime start_time, bool is_all = false)
|
|
|
|
|
{
|
|
|
|
|
DialogResult ok = DialogResult.No;
|
|
|
|
|
|
|
|
|
|
fl_cps_member row = null;
|
|
|
|
|
if (is_all) ok = XtraMessageBox.Show($"您确定要刷新所有联盟订单吗?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
|
|
|
|
|
if (row != null && row.is_download == SwitchType.关闭)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError($@"联盟:{row.username}({row.usernick})
|
|
|
|
|
同步状态:禁止
|
|
|
|
|
注:联盟列表选中账号右击开启,即可同步");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ok = XtraMessageBox.Show($"您确定要启动线程同步【{row.username}({row.usernick})】的{status.ToString().Replace("订单", "")}订单吗?", "请选择", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
Task.Factory.StartNew(delegate
|
|
|
|
|
{
|
|
|
|
|
if (!is_all)
|
|
|
|
|
{
|
|
|
|
|
string cpsStr = $"【{row.cpstype.ToString()}】账号:{row.username}({row.usernick})";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownAlimamaTimer>() as DownAlimamaTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
row.is_valid = true;
|
|
|
|
|
timer.UpdateOrder(new fl_cps_member[] { row }, start_time, DateTime.Now, status);
|
|
|
|
|
}
|
|
|
|
|
//else if (row.cpstype == CpsType.多多进宝)
|
|
|
|
|
//{
|
|
|
|
|
// var timer = TimerTask.GetTimer<DownPinduoduoTimer>() as DownPinduoduoTimer;
|
|
|
|
|
// if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
// timer.UpdateOrder(row, start_time, DateTime.Now);
|
|
|
|
|
//}
|
|
|
|
|
//else if (row.cpstype == CpsType.京东联盟)
|
|
|
|
|
//{
|
|
|
|
|
// var timer = TimerTask.GetTimer<DownJingdongTimer>() as DownJingdongTimer;
|
|
|
|
|
// if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
// timer.UpdateOrder(row, start_time);
|
|
|
|
|
//}
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowSuccessAutoClose($"{cpsStr},同步完成!", 20000);
|
|
|
|
|
}));
|
|
|
|
|
EventClient.OnEvent(null, $"{cpsStr},手动同步完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
// {
|
|
|
|
|
// var timer = TimerTask.GetTimer<DownAlimamaTimer>() as DownAlimamaTimer;
|
|
|
|
|
// if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
// timer.UpdateOrder(row, start_time, DateTime.Now);
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else if (row.cpstype == CpsType.多多进宝)
|
|
|
|
|
// {
|
|
|
|
|
// var timer = TimerTask.GetTimer<DownPinduoduoTimer>() as DownPinduoduoTimer;
|
|
|
|
|
// if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
// timer.UpdateOrder(row, start_time, DateTime.Now);
|
|
|
|
|
// }
|
|
|
|
|
// else if (row.cpstype == CpsType.京东联盟)
|
|
|
|
|
// {
|
|
|
|
|
// var timer = TimerTask.GetTimer<DownJingdongTimer>() as DownJingdongTimer;
|
|
|
|
|
// if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
// timer.UpdateOrder(row, start_time);
|
|
|
|
|
// }
|
|
|
|
|
// if (!this.IsDisposed)
|
|
|
|
|
// {
|
|
|
|
|
// this.Invoke(new Action(delegate
|
|
|
|
|
// {
|
|
|
|
|
// BaseForm.ShowSuccess("同步完成!");
|
|
|
|
|
// }));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// catch (Exception ex)
|
|
|
|
|
// {
|
|
|
|
|
// if (!this.IsDisposed)
|
|
|
|
|
// {
|
|
|
|
|
// this.Invoke(new Action(delegate
|
|
|
|
|
// {
|
|
|
|
|
// BaseForm.ShowError(ex);
|
|
|
|
|
// }));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 在同步的维权阿里妈妈名称
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<string> syncAlimamaRefundNames = new List<string>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 手动同步维权订单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="status"></param>
|
|
|
|
|
/// <param name="start_time"></param>
|
|
|
|
|
/// <param name="is_all"></param>
|
|
|
|
|
private void sync_appoint_alimama_refund_order(DateTime start_time, bool is_all = false)
|
|
|
|
|
{
|
|
|
|
|
fl_cps_member row = null;
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
|
|
|
|
|
if (row != null && row.is_download == SwitchType.关闭)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowErrorAutoClose($@"联盟:{row.username}({row.usernick})
|
|
|
|
|
同步状态:禁止
|
|
|
|
|
注:联盟列表选中账号右击开启,即可同步");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (row != null && row.online == false)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowErrorAutoClose($@"联盟:{row.username}({row.usernick})
|
|
|
|
|
阿里妈妈状态:离线
|
|
|
|
|
注:重新扫码登录阿里妈妈账号即可");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (syncAlimamaRefundNames.Contains(row.username))
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowErrorAutoClose($@"联盟:{row.username}({row.usernick})
|
|
|
|
|
正在同步维权订单~请耐心等待");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task.Factory.StartNew(delegate
|
|
|
|
|
{
|
|
|
|
|
if (!is_all)
|
|
|
|
|
{
|
|
|
|
|
syncAlimamaRefundNames.Add(row.username);
|
|
|
|
|
string cpsStr = $"【{row.cpstype.ToString()}】账号:{row.username}({row.usernick})";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
{
|
|
|
|
|
var timer = TimerTask.GetTimer<DownAlimamaTimer>() as DownAlimamaTimer;
|
|
|
|
|
if (timer.IsRunning) throw new Exception("系统繁忙,请稍后再同步!");
|
|
|
|
|
var api = timer.GetAlimamaApi(row);
|
|
|
|
|
if (api != null)
|
|
|
|
|
timer.UpdateOrder(api, start_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowSuccessAutoClose($"{cpsStr},同步完成!", 20000);
|
|
|
|
|
}));
|
|
|
|
|
EventClient.OnEvent(null, $"{cpsStr},手动同步完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (syncAlimamaRefundNames.Contains(row.username))
|
|
|
|
|
syncAlimamaRefundNames.Remove(row.username);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem37_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
if (row.cpstype == CpsType.阿里妈妈)
|
|
|
|
|
{
|
|
|
|
|
var tljform = new tlj_form(row.usernick, row.username);
|
|
|
|
|
tljform.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new Action(delegate
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem38_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-1), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem39_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-7), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem40_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddMonths(-1), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem41_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sync_order(DateTime.Now.AddDays(-90), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void barButtonItem45_ItemClick(object sender, ItemClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var r = this.gridView1.GetSelectedRows();
|
|
|
|
|
if (r.Length == 0) return;
|
|
|
|
|
var row = this.gridView1.GetRow(r[0]) as fl_cps_member;
|
|
|
|
|
|
|
|
|
|
var json = JsonConvert.SerializeObject(row);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(json))
|
|
|
|
|
{
|
|
|
|
|
var date = Util.EncryptDES(json);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetDataObject(date);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("登录码复制失败,请稍后再试");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseForm.ShowSuccessAutoClose("相同登陆码复制成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new Exception("复制登录码异常");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.ShowError(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|