890 lines
40 KiB
C#
890 lines
40 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using Api.Framework;
|
|
using SqlSugar;
|
|
using Api.Framework.Tools;
|
|
using Api.Framework.Enums;
|
|
using Api.Framework.Model;
|
|
using System.Threading;
|
|
using FLSystem.Events;
|
|
using UI.Framework.Forms;
|
|
using CsharpHttpHelper;
|
|
using DevExpress.XtraEditors;
|
|
using Api.Framework.SDK;
|
|
using Api.Framework.Timers;
|
|
using Api.Framework.Events;
|
|
using CefSharp.DevTools.IndexedDB;
|
|
|
|
namespace FLSystem.Forms
|
|
{
|
|
public partial class cps_order_douyin : DevExpress.XtraEditors.XtraUserControl
|
|
{
|
|
public cps_order_douyin()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public cps_order_douyin(string textedit = "")
|
|
{
|
|
InitializeComponent();
|
|
this.textEdit1.Text = textedit;
|
|
this.comboBoxEdit1.SelectedIndex = string.IsNullOrEmpty(textedit) ? 0 : 5;
|
|
this.dateTimePicker1.Value = DateTime.Parse(DateTime.Today.AddDays(-30).ToString("yyyy-MM-01"));
|
|
this.dateTimePicker2.Value = DateTime.Parse(DateTime.Now.AddDays(30).ToString("yyyy-MM-dd HH:mm:ss"));
|
|
this.gridView1.CustomDrawRowIndicator += gridView1_CustomDrawRowIndicator;
|
|
this.checkBox1.Checked = false;
|
|
|
|
#region 增加所有的机器人账号
|
|
this.comboBoxEdit3.Properties.Items.Clear();
|
|
var weixinBases = Chat.Framework.ChatClient.WXClient.Values.ToList();
|
|
var objList = new List<object>() { "全部平台" };
|
|
foreach (var item in weixinBases)
|
|
{
|
|
objList.Add(item.WeixinHao);
|
|
}
|
|
|
|
var qqBases = Chat.Framework.ChatClient.QQClients.Values;
|
|
foreach (var item in qqBases)
|
|
{
|
|
objList.Add(item.QQ.ToString());
|
|
}
|
|
|
|
this.comboBoxEdit3.Properties.Items.AddRange(objList);
|
|
comboBoxEdit3.SelectedIndex = 0;
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
this.pageControl1.Bind(delegate (int index, int pagesize)
|
|
{
|
|
try
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
List<view_cps_order_douyin> result = null;
|
|
List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
if (this.checkBox1.Checked)
|
|
{
|
|
conModels.Add(new ConditionalModel() { FieldName = "orderTime", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = this.dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") });
|
|
conModels.Add(new ConditionalModel() { FieldName = "orderTime", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = this.dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss") });
|
|
}
|
|
string where = string.Empty;
|
|
string keyword = this.textEdit1.Text.Trim();
|
|
if (!string.IsNullOrEmpty(keyword) || comboBoxEdit1.Text == "未绑定用户")
|
|
{
|
|
switch (this.comboBoxEdit1.Text)
|
|
{
|
|
case "订单编号":
|
|
conModels.Add(new ConditionalModel() { FieldName = "order_id", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "商品编号":
|
|
conModels.Add(new ConditionalModel() { FieldName = "product_id", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "商品标题":
|
|
conModels.Add(new ConditionalModel() { FieldName = "product_name", ConditionalType = ConditionalType.Like, FieldValue = keyword });
|
|
break;
|
|
case "客户编号":
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_userid", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "客户账号":
|
|
var ids = FindMemberIdByKey("username", keyword);
|
|
if (ids != null && ids.Count == 0)
|
|
ids.Add("-1");
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_userid", ConditionalType = ConditionalType.In, FieldValue = string.Join(",", ids) });
|
|
break;
|
|
case "客户昵称":
|
|
ids = FindMemberIdByKey("usernick", keyword);
|
|
if (ids != null && ids.Count == 0)
|
|
ids.Add("-1");
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_userid", ConditionalType = ConditionalType.In, FieldValue = string.Join(",", ids) });
|
|
break;
|
|
case "推广位ID":
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_cpsname", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "联盟账号":
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_cpsname", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "联盟昵称":
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_cpsnick", ConditionalType = ConditionalType.Equal, FieldValue = keyword });
|
|
break;
|
|
case "未绑定用户":
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_userid", ConditionalType = ConditionalType.Equal, FieldValue = "0" });
|
|
break;
|
|
}
|
|
}
|
|
|
|
var status = this.comboBoxEdit2.SelectedIndex == 0 ? SystemOrderStatus.订单未知 : Util.ConvertEnum<SystemOrderStatus>(this.comboBoxEdit2.Text);
|
|
if (status != SystemOrderStatus.订单未知)
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_status", ConditionalType = ConditionalType.Equal, FieldValue = ((int)status).ToString() });
|
|
|
|
if (this.comboBoxEdit3.SelectedIndex != 0)
|
|
conModels.Add(new ConditionalModel() { FieldName = "db_robotname", ConditionalType = ConditionalType.Equal, FieldValue = this.comboBoxEdit3.Text.Trim() });
|
|
|
|
//总记录数
|
|
int totalNumber = 0;
|
|
|
|
result = session.Queryable<fl_order_douyin>()
|
|
.Where(conModels)
|
|
.OrderBy(o => o.pay_time, OrderByType.Desc)
|
|
.Select<view_cps_order_douyin>((o) => new view_cps_order_douyin
|
|
{
|
|
id = o.id,
|
|
db_cpsname = o.db_cpsname,
|
|
db_cpsnick = o.db_cpsnick,
|
|
db_endtime = o.db_endtime,
|
|
db_point = o.db_point,
|
|
db_status = o.db_status,
|
|
db_userpoint = o.db_userpoint,
|
|
robotname = o.db_robotname,
|
|
db_userid = o.db_userid,
|
|
estimated_comission = o.estimated_comission,
|
|
order_id = o.order_id,
|
|
pay_time = o.pay_time,
|
|
product_id = o.product_id,
|
|
product_name = o.product_name,
|
|
total_pay_amount = o.total_pay_amount
|
|
//username = u.username,
|
|
//usernick = u.usernick
|
|
}).ToPageList(index, pagesize, ref totalNumber);
|
|
|
|
if (result.Count != 0)
|
|
{
|
|
#region 附加用户
|
|
var bindUsersList = result.Where(f => f.db_userid != 0).Select(f => f.db_userid.ToString()).ToList();
|
|
var memberData = new List<fl_member_info>();
|
|
if (bindUsersList != null && bindUsersList.Count != 0)
|
|
memberData = session.Queryable<fl_member_info>().Where(new List<IConditionalModel>() { new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.In, FieldValue = string.Join(",", bindUsersList) } }).ToList();
|
|
|
|
int count = 1;
|
|
foreach (var member in memberData)
|
|
{
|
|
count++;
|
|
if (ApiClient.Setting.DbConfig.DatabaseType == DatabaseType.SQLITE && count % 10 == 0)
|
|
Thread.Sleep(50);
|
|
var items = result.Where(f => f.db_userid == member.id).ToList();
|
|
foreach (var item in items)
|
|
{
|
|
item.usernick = member.usernick;
|
|
item.username = member.username;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 附加机器人信息
|
|
var robotList = result.Where(f => !string.IsNullOrWhiteSpace(f.robotname)).GroupBy(f => f.robotname).Select(f => f.Key).ToList();
|
|
var robotData = session.FindRobots().Where(f => robotList.Contains(f.name)).ToList();
|
|
foreach (var robot in robotData)
|
|
{
|
|
var items = result.Where(f => f.robotname == robot.name).ToList();
|
|
foreach (var item in items)
|
|
{
|
|
item.robotnick = robot.nick;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
return new UI.Framework.Controls.PageControl.SerchResult() { Result = result, Total = totalNumber };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseForm.ShowError(ex);
|
|
}
|
|
return null;
|
|
}, this.gridControl1, 50, false, true);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (!this.IsDisposed)
|
|
this.UpdateUI(() =>
|
|
{
|
|
BaseForm.ShowError(ex);
|
|
});
|
|
}
|
|
|
|
MainEvent.CommonEvents += Main_CommonEvents;
|
|
this.Disposed += Control_Disposed;
|
|
}
|
|
|
|
private void Control_Disposed(object sender, EventArgs e)
|
|
{
|
|
MainEvent.CommonEvents -= Main_CommonEvents;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 代理委托更新UI
|
|
/// </summary>
|
|
/// <param name="act"></param>
|
|
protected delegate void DelegateUpdateUI(Action act);
|
|
|
|
/// <summary>
|
|
/// 代理委托更新UI
|
|
/// </summary>
|
|
/// <param name="act"></param>
|
|
protected void UpdateUI(Action act)
|
|
{
|
|
if (!InvokeRequired)
|
|
{
|
|
act.Invoke();
|
|
}
|
|
else
|
|
{
|
|
DelegateUpdateUI delegateUpdateUI = new DelegateUpdateUI(UpdateUI);
|
|
Invoke(delegateUpdateUI, act);
|
|
}
|
|
}
|
|
|
|
|
|
private void Main_CommonEvents(object sender, CommonEvents e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Commons != null && e.Commons.Count != 0)
|
|
{
|
|
if (e.Commons.ContainsKey("cps_type") && e.Commons.ContainsKey("username"))
|
|
{
|
|
var cps_type = (CpsType)int.Parse(e.Commons["cps_type"].ToString());
|
|
if (cps_type == CpsType.抖音联盟)
|
|
{
|
|
textEdit1.Text = e.Commons["username"].ToString();
|
|
comboBoxEdit1.SelectedIndex = 5;
|
|
comboBoxEdit3.SelectedIndex = comboBoxEdit2.SelectedIndex = 0;
|
|
checkBox1.Checked = false;
|
|
pageControl1.GotoPage(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseForm.ShowError(ex);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 条件查询(用户账号/用户昵称),模糊查询,获取用户的id
|
|
/// </summary>
|
|
/// <param name="type">查询的字段</param>
|
|
/// <param name="keyword">模糊的关键词</param>
|
|
/// <returns></returns>
|
|
private List<string> FindMemberIdByKey(string type, string keyword)
|
|
{
|
|
try
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
return session.Find<int>($"select id from fl_member_info where {type} like '%{keyword}%'").Select(f => f.ToString()).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0) e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
|
}
|
|
|
|
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|
{
|
|
switch (e.Column.Caption)
|
|
{
|
|
case "软件状态":
|
|
e.DisplayText = Util.ConvertEnum<SystemOrderStatus>(int.Parse(e.Value.ToString())).ToString();
|
|
break;
|
|
case "一级提成":
|
|
e.DisplayText = HttpExtend.JsonToDictionary(e.Value.ToString().ToLower())["awardone"].ToString();
|
|
break;
|
|
case "二级提成":
|
|
e.DisplayText = HttpExtend.JsonToDictionary(e.Value.ToString().ToLower())["awardtwo"].ToString();
|
|
break;
|
|
case "三级提成":
|
|
{
|
|
var result = HttpExtend.JsonToDictionary(e.Value.ToString().ToLower());
|
|
e.DisplayText = (result != null && result.ContainsKey("awardthree")) ? result["awardthree"].ToString() : "0";
|
|
}
|
|
break;
|
|
case "群负责人提成":
|
|
e.DisplayText = HttpExtend.JsonToDictionary(e.Value.ToString().ToLower())["awardcreate"].ToString();
|
|
break;
|
|
case "创建时间":
|
|
e.DisplayText = HttpExtend.GetDateTime(e.Value.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
|
|
break;
|
|
case "付款金额":
|
|
case "实际总佣金":
|
|
e.DisplayText = (decimal.Parse(e.Value == null ? "0" : e.Value.ToString()) / 100.0m).ToString();
|
|
break;
|
|
|
|
}
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
this.pageControl1.Go(sender, e);
|
|
}
|
|
|
|
private void cps_order_douyin_Load(object sender, EventArgs e)
|
|
{
|
|
simpleButton1_Click(this.simpleButton1, null);
|
|
}
|
|
|
|
public class view_cps_order_douyin
|
|
{
|
|
/// <summary>
|
|
/// id
|
|
/// </summary>
|
|
public long id { get; set; }
|
|
/// <summary>
|
|
/// 创建时间
|
|
/// </summary>
|
|
public long pay_time { get; set; }
|
|
/// <summary>
|
|
/// 订单id
|
|
/// </summary>
|
|
public string order_id { get; set; }
|
|
/// <summary>
|
|
/// 订单状态
|
|
/// </summary>
|
|
public SystemOrderStatus db_status { get; set; }
|
|
/// <summary>
|
|
/// 付款金额
|
|
/// </summary>
|
|
public double total_pay_amount { get; set; }
|
|
/// <summary>
|
|
/// 预计总佣金
|
|
/// </summary>
|
|
public double estimated_comission { get; set; }
|
|
/// <summary>
|
|
/// 积分Json
|
|
/// </summary>
|
|
public string db_point { get; set; }
|
|
/// <summary>
|
|
/// 用户所得
|
|
/// </summary>
|
|
public double db_userpoint { get; set; }
|
|
|
|
private string _robotname;
|
|
/// <summary>
|
|
/// 机器人账号
|
|
/// </summary>
|
|
public string robotname
|
|
{
|
|
get { return _robotname; }
|
|
set { if (string.IsNullOrEmpty(value)) _robotname = string.Empty; else _robotname = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 机器人昵称
|
|
/// </summary>
|
|
public string robotnick { get; set; }
|
|
|
|
private string _username;
|
|
/// <summary>
|
|
/// 用户账号
|
|
/// </summary>
|
|
public string username
|
|
{
|
|
get { return _username; }
|
|
set { if (string.IsNullOrEmpty(value)) _username = string.Empty; else _username = value; }
|
|
}
|
|
|
|
private string _usernick;
|
|
/// <summary>
|
|
/// 用户昵称
|
|
/// </summary>
|
|
public string usernick
|
|
{
|
|
get { return _usernick; }
|
|
set { if (string.IsNullOrEmpty(value)) _usernick = string.Empty; else _usernick = value; }
|
|
}
|
|
public long db_userid { get; set; }
|
|
/// <summary>
|
|
/// 商品标题
|
|
/// </summary>
|
|
public string product_name { get; set; }
|
|
/// <summary>
|
|
/// 商品编码
|
|
/// </summary>
|
|
public string product_id { get; set; }
|
|
/// <summary>
|
|
/// 冻结时间
|
|
/// </summary>
|
|
public DateTime db_endtime { get; set; }
|
|
/// <summary>
|
|
/// 联盟账号
|
|
/// </summary>
|
|
public string db_cpsname { get; set; }
|
|
/// <summary>
|
|
/// 联盟昵称
|
|
/// </summary>
|
|
public string db_cpsnick { get; set; }
|
|
|
|
}
|
|
|
|
private void 绑定用户ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
var db_status = row.db_status;
|
|
|
|
if (db_status == SystemOrderStatus.订单失效 || db_status == SystemOrderStatus.订单结算 || db_status == SystemOrderStatus.全额退款 || db_status == SystemOrderStatus.部分退款)
|
|
throw new Exception("该订单状态为已完结,不允许修改!");
|
|
|
|
var session = ApiClient.GetSession();
|
|
if (row.db_userid != 0)
|
|
{
|
|
var member = session.FindMemberInfoById(row.db_userid);
|
|
if (member != null)
|
|
{
|
|
if (member.bind_order > 0)
|
|
{
|
|
member.bind_order--;
|
|
member = session.UpdateMemberGroup(member);
|
|
}
|
|
}
|
|
}
|
|
|
|
select_member_form select_form = new select_member_form();
|
|
select_form.ShowDialog();
|
|
if (select_form.fl_member_info != null)
|
|
{
|
|
var douyin = session.FindSingle<fl_order_douyin>("id = @id", new { id = row.id });
|
|
if (douyin != null)
|
|
{
|
|
if (douyin.db_robottype == 0) douyin.db_robottype = select_form.fl_member_info.robot_type;
|
|
if (string.IsNullOrWhiteSpace(douyin.db_robotname)) douyin.db_robotname = select_form.fl_member_info.robot_name;
|
|
|
|
var itempoint = session.FindItemPoint(select_form.fl_member_info, Util.ConvertDouble_FenToYuan(douyin.estimated_comission), 1, CpsType.抖音联盟);
|
|
if (itempoint != null)
|
|
{
|
|
douyin.db_point = HttpHelper.ObjectToJson(itempoint);
|
|
douyin.db_userpoint = itempoint.UserPoint;
|
|
}
|
|
|
|
douyin.db_userid = select_form.fl_member_info.id;
|
|
session.SaveOrUpdate(douyin);
|
|
|
|
#region 获取查询时的比例
|
|
var query_item = session.FindSingle<fl_query_hist>("userid=@userid and itemid=@itemid and adzoneid = @adzoneid and crt_time > @time order by id", new { userid = douyin.db_userid, itemid = douyin.product_id, adzoneid = douyin.db_cpsname, time = DateTime.Now.AddHours(-24).ToString("yyyy-MM-dd HH:mm:ss") });
|
|
if (query_item != null && !string.IsNullOrWhiteSpace(query_item.compute_configdic))
|
|
{
|
|
if (douyin.id == 0)
|
|
session.SaveOrUpdate(douyin);
|
|
var queryRatioHist = new fl_query_ratio_hist()
|
|
{
|
|
compute_config = query_item.compute_configdic,
|
|
db_orderid = douyin.id,
|
|
createtime = DateTime.Now,
|
|
cpstype = CpsType.抖音联盟
|
|
};
|
|
session.SaveOrUpdate(queryRatioHist);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
simpleButton1_Click(null, null);
|
|
|
|
//更新显示值
|
|
row.db_userid = select_form.fl_member_info.id;
|
|
row.username = select_form.fl_member_info.username;
|
|
row.usernick = select_form.fl_member_info.usernick;
|
|
row.db_point = douyin.db_point;
|
|
|
|
select_form.fl_member_info.bind_order++;
|
|
|
|
#region 首次付款时间
|
|
try
|
|
{
|
|
var record = session.FindStatisticsRecord(select_form.fl_member_info.id);
|
|
if (record == null)
|
|
{
|
|
record = new fl_statistics_record() { uid = select_form.fl_member_info.id, ex2 = 0, ex4 = HttpExtend.GetTimeStamp(DateTime.Now) };
|
|
session.Saveable(record).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
if (record.ex2 == 0 && record.ex4 == 0)
|
|
{
|
|
record.ex4 = HttpExtend.GetTimeStamp(DateTime.Now);
|
|
session.Saveable(record).ExecuteCommand();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{ }
|
|
#endregion
|
|
|
|
session.UpdateMemberGroup(select_form.fl_member_info);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 解绑ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
var db_status = row.db_status;
|
|
if (db_status == SystemOrderStatus.订单失效 || db_status == SystemOrderStatus.订单结算 || db_status == SystemOrderStatus.全额退款 || db_status == SystemOrderStatus.部分退款)
|
|
throw new Exception("该订单状态为已完结,不允许解绑!");
|
|
|
|
var session = ApiClient.GetSession();
|
|
|
|
if (row.db_userid != 0)
|
|
{
|
|
var member = session.FindMemberInfoById(row.db_userid);
|
|
if (member != null && member.bind_order > 0)
|
|
{
|
|
member.bind_order--;
|
|
member = session.UpdateMemberGroup(member);
|
|
}
|
|
}
|
|
|
|
session.ExcuteSQL("delete from fl_query_hist where itemid = @num_iid", new { num_iid = row.product_id });
|
|
session.ExcuteSQL("update fl_order_douyin set db_userid = @userid where id=@id", new { id = row.id, userid = 0 });
|
|
session.ExcuteSQL("delete from fl_query_ratio_hist where db_orderid=@id", new { id = row.id });
|
|
|
|
//更新显示值
|
|
row.db_userid = 0;
|
|
row.username = string.Empty;
|
|
row.usernick = string.Empty;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
this.pageControl1.GotoPage(1);
|
|
}
|
|
|
|
private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows.Length != 0)
|
|
{
|
|
var info = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
if (XtraMessageBox.Show("您确定要删除选中数据嘛?\r\n" + info.product_name, "友情提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
var session = ApiClient.GetSession();
|
|
session.ExcuteSQL("delete from fl_order_douyin where id=" + info.id);
|
|
}
|
|
this.pageControl1.GotoPage(1);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 冻结延期ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (XtraMessageBox.Show("确定要延长冻结选中订单?", "友情提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
var db_status = row.db_status;
|
|
|
|
if (db_status != SystemOrderStatus.订单冻结)
|
|
throw new Exception($"选中订单:{db_status},不予操作");
|
|
|
|
var session = ApiClient.GetSession();
|
|
var endtime_form = new setting_endtime_form(row.db_endtime);
|
|
endtime_form.ShowDialog();
|
|
if (endtime_form.newtime == DateTime.MinValue) return;
|
|
var douyin = session.FindSingle<fl_order_douyin>("id = @id", new { id = row.id });
|
|
if (endtime_form.newtime != row.db_endtime)
|
|
{
|
|
douyin.db_endtime = endtime_form.newtime;
|
|
session.Updateable(douyin).ExecuteCommand();
|
|
}
|
|
row.db_endtime = endtime_form.newtime;//更新显示值
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 立即结算ToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (XtraMessageBox.Show("确定要结算选中订单?", "友情提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
var db_status = row.db_status;
|
|
|
|
if (db_status == SystemOrderStatus.订单失效 || db_status == SystemOrderStatus.订单创建 || db_status == SystemOrderStatus.订单结算 || db_status == SystemOrderStatus.全额退款 || db_status == SystemOrderStatus.部分退款 || db_status == SystemOrderStatus.订单退款)
|
|
throw new Exception($"选中订单:{db_status},不予操作");
|
|
|
|
var session = ApiClient.GetSession();
|
|
var douyin = session.FindSingle<fl_order_douyin>("order_id = @order_id and product_id = @product_id", new { order_id = row.order_id, product_id = row.product_id });
|
|
if (douyin == null) throw new Exception("数据查询失败,请稍后重试");
|
|
douyin.db_endtime = DateTime.Now;
|
|
douyin.db_status = SystemOrderStatus.订单冻结;
|
|
douyin.order_status = "SETTLE";//改成结算
|
|
douyin.product_detail = "手动处理";
|
|
var task = TimerTask.GetTimer<DownDouyinTimer>() as DownDouyinTimer;
|
|
var notices = new List<OrderNoticeEvent>();
|
|
task.UpdateOrder(douyin, notices, session);
|
|
|
|
var tasks = TimerTask.GetTimer<Update_NoticeQueue>() as Update_NoticeQueue;
|
|
foreach (var item in notices)
|
|
{
|
|
if (item.Member == null) continue;
|
|
var order = item.Order as fl_order_douyin;
|
|
tasks.Add(item);
|
|
}
|
|
//更新显示值
|
|
row.db_status = SystemOrderStatus.订单结算;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 立即失效ToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var result = XtraMessageBox.Show("确定要失效选中订单?", "友情提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
//获取选中数据
|
|
var row = this.gridView1.GetRow(rows[0]) as view_cps_order_douyin;
|
|
var db_status = row.db_status;
|
|
|
|
var session = ApiClient.GetSession();
|
|
var douyin = session.FindSingle<fl_order_douyin>("order_id = @order_id and product_id = @product_id", new { order_id = row.order_id, product_id = row.product_id });
|
|
if (douyin == null) throw new Exception("数据查询失败,请稍后重试");
|
|
|
|
var flag = false;
|
|
var notices = new List<OrderNoticeEvent>();
|
|
if (db_status == SystemOrderStatus.订单结算 || db_status == SystemOrderStatus.部分退款)
|
|
flag = true;
|
|
else if (douyin.IsFinish())
|
|
throw new Exception($"选中订单:{db_status},不予操作");
|
|
|
|
douyin.order_status = "REFUND";
|
|
douyin.product_detail = "手动处理";
|
|
douyin.db_endtime = DateTime.Now;
|
|
douyin.db_status = SystemOrderStatus.订单失效;
|
|
var task = TimerTask.GetTimer<DownDouyinTimer>() as DownDouyinTimer;
|
|
|
|
if (!flag)
|
|
task.UpdateOrder(douyin, notices, session);
|
|
else
|
|
{
|
|
//new OrderHelper().DeductPinDuoOrderPoint(notices, douyin);
|
|
//session.SaveOrUpdate(douyin);
|
|
}
|
|
|
|
var tasks = TimerTask.GetTimer<Update_NoticeQueue>() as Update_NoticeQueue;
|
|
foreach (var item in notices)
|
|
{
|
|
if (item.Member == null) continue;
|
|
var order = item.Order as fl_order_douyin;
|
|
tasks.Add(item);
|
|
}
|
|
//更新显示值
|
|
row.db_status = SystemOrderStatus.订单失效;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 查看用户信息ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
var username = gridView1.GetRowCellValue(rows[0], "username").ToString();//获取列的数据;
|
|
if (!string.IsNullOrWhiteSpace(username))
|
|
{
|
|
var tsmi = sender as ToolStripMenuItem;
|
|
if (tsmi == null) throw new Exception("数据异常");
|
|
|
|
var common = new Dictionary<string, object>();
|
|
common["control_name"] = tsmi.Text;
|
|
common["username"] = username;
|
|
MainEvent.OnEvent(null, new CommonEvents(common));
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
|
|
private void ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
var username = this.gridView1.GetRowCellValue(rows[0], "username").ToString();//获取列的数据
|
|
|
|
var tsmi = sender as ToolStripMenuItem;
|
|
if (tsmi == null) throw new Exception("数据异常");
|
|
|
|
var text = tsmi.Text.Replace("订单", "").Replace("所有", "");
|
|
var cps = (CpsType)Enum.Parse(typeof(CpsType), text);
|
|
|
|
var common = new Dictionary<string, object>();
|
|
common["cps_type"] = (int)cps;
|
|
common["username"] = username;
|
|
MainEvent.OnEvent(null, new CommonEvents(common));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void 积分日志ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
var username = this.gridView1.GetRowCellValue(rows[0], "username").ToString();//获取列的数据
|
|
|
|
var tsmi = sender as ToolStripMenuItem;
|
|
if (tsmi == null) throw new Exception("数据异常");
|
|
var common = new Dictionary<string, object>();
|
|
common["control_name"] = "提现管理";
|
|
common["query_type"] = tsmi.Text;
|
|
common["username"] = username;
|
|
MainEvent.OnEvent(null, new CommonEvents(common));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (comboBoxEdit1.SelectedIndex == 0 || comboBoxEdit1.SelectedIndex == 10)
|
|
{
|
|
this.textEdit1.Enabled = false;
|
|
this.textEdit1.Text = "";
|
|
}
|
|
else this.textEdit1.Enabled = true;
|
|
}
|
|
|
|
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var rows = this.gridView1.GetSelectedRows();
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
this.用户个人信息ToolStripMenuItem.Enabled = this.gridView1.GetRowCellValue(rows[0], "username") != null;
|
|
this.冻结延期ToolStripMenuItem.Enabled = this.gridView1.GetRowCellValue(rows[0], "db_status").ToString() == "订单冻结";
|
|
}
|
|
else
|
|
e.Cancel = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void 重新计算未结算订单ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var db = ApiClient.GetSession();
|
|
var orders = db.Queryable<fl_order_douyin>().Where(f =>
|
|
f.db_userid != 0 && (f.db_status == SystemOrderStatus.订单付款 ||
|
|
f.db_status == SystemOrderStatus.订单冻结 ||
|
|
f.db_status == SystemOrderStatus.订单维权中)).ToList();
|
|
EventClient.OnEvent("", $"抖音需要重新计算的订单数:{orders.Count}");
|
|
|
|
foreach (var order in orders)
|
|
{
|
|
var member = db.FindMemberInfoById(order.db_userid);
|
|
var itempoint = db.FindItemPoint(member,
|
|
Util.ConvertDouble_FenToYuan(order.estimated_comission), 1, CpsType.抖音联盟);
|
|
if (itempoint != null)
|
|
{
|
|
order.db_point = HttpHelper.ObjectToJson(itempoint);
|
|
order.db_userpoint = itempoint.UserPoint;
|
|
|
|
db.SaveOrUpdate(order);
|
|
EventClient.OnEvent("", $"抖音单号:{order.order_id},重新计算完成");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
EventClient.OnEvent("", $"抖音重新计算异常:{ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|