old_flsystem/FLSystem/Forms/member_private_config.cs

439 lines
23 KiB
C#
Raw Normal View History

2022-09-20 03:10:29 +00:00
using Api.Framework;
using Api.Framework.Cps;
using Api.Framework.Enums;
using Api.Framework.Model;
using Api.Framework.SDK;
using Api.Framework.Tools;
using FLSystem.Properties;
using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using UI.Framework.Controls;
using UI.Framework.Forms;
namespace FLSystem.Forms
{
public partial class member_private_config : BaseForm
{
private long uid;
public member_private_config(long uid)
{
InitializeComponent();
this.uid = uid;
var session = ApiClient.GetSession();
var member = session.FindMemberInfoById(uid);
if (member != null)
tbox_member_KeyWord.Text = member.username;
}
private void simpleButton1_Click(object sender, EventArgs e)
{
pageControl1.Go(sender, e);
}
private void member_private_config_Load(object sender, EventArgs e)
{
try
{
pageControl1.Bind((page, size) =>
{
var session = ApiClient.GetSession();
var parm = session.NewParamMap();
parm.setPageParamters(page, size);
var keyword = tbox_member_KeyWord.Text.Replace("'", "''").Trim();
var where = string.IsNullOrWhiteSpace(keyword) ? string.Empty : $" and (mi.username like '%{keyword}%' or mi.usernick like '%{keyword}%' )";
//var result1 = session.FindPage<member_private_config_temp>($"select mi.id as uid,mi.robot_type as robot_type,mi.username as username,mi.usernick as usernick,flag.* from fl_member_info mi left join (select ai1_temp.member_id as member_id,ai1_temp.is_auto_bind,ai1_temp.adzone_name as tb_pid_name,ai2_temp.adzone_name as pdd_pid_name,ai3_temp.adzone_name as jd_pid_name from (select * from fl_adzone_info ai1 where ai1.alliance_id = '{(int)CpsType.阿里妈妈}' and ai1.custom_type = '{Resources.SoftwareType}' and ai1.extend = '淘宝私人pid') ai1_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.多多进宝}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='拼多多私人pid') ai2_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.京东联盟}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='京东私人pid') ai3_temp on ai1_temp.member_id = ai2_temp.member_id and ai3_temp.member_id = ai2_temp.member_id) flag on mi.id = flag.member_id where 1=1 {where}", parm);
/*
var result = session.FindPage<member_private_config_temp>($@"select mi.id as uid,mi.robot_type as robot_type,mi.username as username,mi.usernick as usernick,flag.* from fl_member_info mi left join (select ai1_temp.member_id as member_id,ai1_temp.is_auto_bind,ai1_temp.adzone_name as tb_pid_name,ai2_temp.adzone_name as pdd_pid_name,ai3_temp.adzone_name as jd_pid_name,ai4_temp.adzone_name as wph_pid_name,ai5_temp.adzone_name as dy_pid_name from (select * from fl_adzone_info ai1 where ai1.alliance_id = '{(int)CpsType.阿里妈妈}' and ai1.custom_type = '{Resources.SoftwareType}' and ai1.extend = '淘宝私人pid') ai1_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.多多进宝}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='拼多多私人pid') ai2_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.京东联盟}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='京东私人pid') ai3_temp
INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='pid') ai4_temp
INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='pid') ai5_temp
on ai1_temp.member_id = ai2_temp.member_id and ai3_temp.member_id = ai2_temp.member_id and ai4_temp.member_id = ai2_temp.member_id and ai5_temp.member_id = ai2_temp.member_id) flag on mi.id = flag.member_id where 1=1 {where}", parm);
*/
var result = session.FindPage<member_private_config_temp>($@"select mi.id as uid,mi.robot_type as robot_type,mi.username as username,mi.usernick as usernick,flag.* from fl_member_info mi left join (select ai1_temp.member_id as member_id,ai1_temp.is_auto_bind,ai1_temp.adzone_name as tb_pid_name,ai2_temp.adzone_name as pdd_pid_name,ai3_temp.adzone_name as jd_pid_name,ai4_temp.adzone_name as wph_pid_name from (select * from fl_adzone_info ai1 where ai1.alliance_id = '{(int)CpsType.阿里妈妈}' and ai1.custom_type = '{Resources.SoftwareType}' and ai1.extend = '淘宝私人pid') ai1_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.多多进宝}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='拼多多私人pid') ai2_temp INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.京东联盟}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='京东私人pid') ai3_temp
INNER JOIN (select * from fl_adzone_info ai2 where ai2.alliance_id = '{(int)CpsType.}' and ai2.custom_type = '{Resources.SoftwareType}' and ai2.extend='pid') ai4_temp
on ai1_temp.member_id = ai2_temp.member_id and ai3_temp.member_id = ai2_temp.member_id and ai4_temp.member_id = ai2_temp.member_id) flag on mi.id = flag.member_id where 1=1 {where}", parm);
return new PageControl.SerchResult() { Result = result.DataList, Total = result.Total };
}, gridControl1, 40);
}
catch (Exception ex)
{
ShowError(ex);
}
}
/// <summary>
/// 修改显示内容的事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
try
{
//if ((e.Column.FieldName == "pdd_pid_name" || e.Column.FieldName == "tb_pid_name" || e.Column.FieldName == "jd_pid_name" || e.Column.FieldName == "wph_pid_name" || e.Column.FieldName == "dy_pid_name") && (e.Value == null || string.IsNullOrEmpty(e.Value.ToString()))) e.DisplayText = "双击设置";
if ((e.Column.FieldName == "pdd_pid_name" || e.Column.FieldName == "tb_pid_name" || e.Column.FieldName == "jd_pid_name" || e.Column.FieldName == "wph_pid_name") && (e.Value == null || string.IsNullOrEmpty(e.Value.ToString()))) e.DisplayText = "双击设置";
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
try
{
#region 广
var selectRow = gridView1.GetSelectedRows()[0];
var id = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
//点击数大于2弹出窗体进行推广位的选择
if (e.Clicks >= 2)
{
var session = ApiClient.GetSession();
2023-04-06 01:07:55 +00:00
var strs = new string[] { "淘宝推广位名称", "拼多多推广位名称", "京东推广位名称", "唯品会推广位名称", "抖音推广位名称", "抖客推广位名称" };
2022-09-20 03:10:29 +00:00
//var pidSortRemark = new string[] { "淘宝私人pid", "拼多多私人pid", "京东私人pid" };//pid类别备注,值顺序不能变
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
if (!strs.Contains(e.Column.Caption)) return;
else
{
var pidInfos = session.Queryable<fl_adzone_info>().Where(f => f.member_id == int.Parse(id) && f.custom_type == Resources.SoftwareType).ToList();
if (pidInfos != null && pidInfos.Count == 0)
{
for (int i = 1; i <= pidSortRemark.Length; i++)
{
var adzone = new fl_adzone_info
{
custom_type = Resources.SoftwareType,
extend = pidSortRemark[i - 1],
alliance_id = i,
is_download = false,
member_id = int.Parse(id),
onoff = false,
robot_id = 0,
group_id = string.Empty,
adzone_pid_cps_name = string.Empty,
adzone_pid = string.Empty,
adzone_name = string.Empty
};
session.Saveable(adzone).ExecuteReturnEntity();
pidInfos.Add(adzone);
}
}
fl_adzone_info esbAdzone = null;
object setAdzoneObj = null;
Tuiguangwei setAdzone = null;
if (e.Column.Caption == strs[0])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[0]).FirstOrDefault();
}
else if (e.Column.Caption == strs[1])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[1]).FirstOrDefault();
}
else if (e.Column.Caption == strs[2])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[2]).FirstOrDefault();
}
else if (e.Column.Caption == strs[3])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[3]).FirstOrDefault();
}
else if (e.Column.Caption == strs[4])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[4]).FirstOrDefault();
}
2023-04-06 01:07:55 +00:00
else if (e.Column.Caption == strs[5])
{
setAdzoneObj = CpsClient.SelectTuiguangwei(CpsType.);
if (setAdzoneObj != null)
esbAdzone = pidInfos.Where(f => f.extend == pidSortRemark[5]).FirstOrDefault();
}
2022-09-20 03:10:29 +00:00
if (esbAdzone != null && setAdzoneObj != null)
{
setAdzone = setAdzoneObj as Tuiguangwei;
//var adzone = session.FindAdzoneInfos(true).FirstOrDefault(f => f.member_id != int.Parse(id) && f.adzone_pid == setAdzone.Pid && f.adzone_pid_cps_name == setAdzone.Member.username && f.adzone_name == setAdzone.Name);
//if (adzone != null)
// throw new Exception("该推广位已经被其插件或用户绑定");
esbAdzone.adzone_name = setAdzone.Name;
esbAdzone.adzone_pid = setAdzone.Pid;
esbAdzone.adzone_pid_cps_name = setAdzone.Member.username;
session.SaveOrUpdate(esbAdzone);
}
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
}
#endregion
#region
if (e.Column.FieldName == "is_auto_bind" && e.Clicks == 1)
{
if (!(bool)e.CellValue && MessageBox.Show("该私人推广位是否无条件绑定?", "系统提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
var session = ApiClient.GetSession();
var adzones = session.FindAdzoneInfos().Where(f => f.member_id == int.Parse(id) && f.custom_type == Resources.SoftwareType).ToList();
if (adzones == null || adzones.Count == 0) throw new Exception("请先设置私人推广位");
session.ExcuteSQL("update fl_adzone_info set is_auto_bind = @is_auto_bind where member_id = @member_id", new { is_auto_bind = !adzones[0].is_auto_bind, member_id = int.Parse(id) });
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
#endregion
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void 广ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var uid = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType. && f.member_id == int.Parse(uid) && f.custom_type == Resources.SoftwareType && f.extend == pidSortRemark[0]);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
}
ShowSuccess("执行成功");
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void 广ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var uid = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType. && f.member_id == int.Parse(uid) && f.custom_type == Resources.SoftwareType && f.extend == pidSortRemark[1]);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
}
ShowSuccess("执行成功");
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void 广ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var uid = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType. && f.member_id == int.Parse(uid) && f.custom_type == Resources.SoftwareType && f.extend == pidSortRemark[2]);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
ShowSuccess("执行成功");
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
try
{
var rows = this.gridView1.GetSelectedRows();
if (!(rows != null && rows.Length > 0)) e.Cancel = true;
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void 广ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var uid = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType. && f.member_id == int.Parse(uid) && f.custom_type == Resources.SoftwareType && f.extend == pidSortRemark[3]);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
ShowSuccess("执行成功");
}
catch (Exception ex)
{
ShowError(ex);
}
}
private void 广ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var session = ApiClient.GetSession();
var selectRow = gridView1.GetSelectedRows()[0];
var uid = this.gridView1.GetRowCellValue(selectRow, "uid").ToString();//获取列的数据
var pidSortRemark = Enum.GetNames(typeof(PrivateAdzoneType));//pid类别备注,值顺序不能变
var adzone = session.FindAdzoneInfos().FirstOrDefault(f => f.alliance_id == (int)CpsType. && f.member_id == int.Parse(uid) && f.custom_type == Resources.SoftwareType && f.extend == pidSortRemark[4]);
if (adzone != null)
{
adzone.adzone_name = string.Empty;
adzone.adzone_pid = string.Empty;
adzone.adzone_pid_cps_name = string.Empty;
session.SaveOrUpdate(adzone);
pageControl1.GotoPage(1);
session.FindAdzoneInfos(true);
}
ShowSuccess("执行成功");
}
catch (Exception ex)
{
ShowError(ex);
}
}
}
class member_private_config_temp
{
/// <summary>
/// 用户id (fl_membe_info 表id)
/// </summary>
public long uid { get; set; }
/// <summary>
/// 机器人类型
/// </summary>
public ChatType robot_type { get; set; }
/// <summary>
/// 用户账号
/// </summary>
public string username { get; set; }
/// <summary>
/// 用户昵称
/// </summary>
public string usernick { get; set; }
/// <summary>
/// 淘宝推广位名称
/// </summary>
public string tb_pid_name { get; set; }
/// <summary>
/// 京东推广位名称
/// </summary>
public string jd_pid_name { get; set; }
/// <summary>
/// 拼多多推广位名称
/// </summary>
public string pdd_pid_name { get; set; }
/// <summary>
/// 唯品会推广位名称
/// </summary>
public string wph_pid_name { get; set; }
/// <summary>
/// 抖音推广位名称
/// </summary>
public string dy_pid_name { get; set; }
/// <summary>
/// 个人的积分比例
/// </summary>
public long member_id { get; set; }
/// <summary>
/// 私人推广位是否强制绑定
/// </summary>
public bool is_auto_bind { get; set; }
}
class group_pid_temp
{
/// <summary>
/// 群账号
/// </summary>
public string groupid { get; set; }
/// <summary>
/// 群昵称
/// </summary>
public string extend { get; set; }
/// <summary>
/// 淘宝推广位名称
/// </summary>
public string tb_pid_name { get; set; }
/// <summary>
/// 京东推广位名称
/// </summary>
public string jd_pid_name { get; set; }
/// <summary>
/// 拼多多推广位名称
/// </summary>
public string pdd_pid_name { get; set; }
///// <summary>
///// 个人的积分比例
///// </summary>
//public long member_id { get; set; }
///// <summary>
///// 私人推广位是否强制绑定
///// </summary>
//public bool is_auto_bind { get; set; }
}
}