314 lines
14 KiB
C#
314 lines
14 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Text;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
using DevExpress.XtraEditors;
|
|||
|
using UI.Framework.Forms;
|
|||
|
using SqlSugar;
|
|||
|
using Api.Framework;
|
|||
|
using Api.Framework.Model;
|
|||
|
using Api.Framework.Enums;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using Grant.Framework;
|
|||
|
using System.Threading;
|
|||
|
using CsharpHttpHelper;
|
|||
|
|
|||
|
namespace FLSystem.Forms
|
|||
|
{
|
|||
|
public partial class member_base_info_form : BaseForm
|
|||
|
{
|
|||
|
private SqlSugarClient session = null;
|
|||
|
long uid = 0;
|
|||
|
fl_member_info member = null;
|
|||
|
|
|||
|
public member_base_info_form(long uid)
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
this.uid = uid;
|
|||
|
session = ApiClient.GetSession();
|
|||
|
}
|
|||
|
private MemberType old_status;
|
|||
|
private void member_base_info_form_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
comboBoxEdit2.Properties.Items.Clear();
|
|||
|
foreach (int v in Enum.GetValues(typeof(MemberType)))
|
|||
|
{
|
|||
|
string strName = Enum.GetName(typeof(MemberType), v);
|
|||
|
comboBoxEdit2.Properties.Items.AddRange(new object[] { strName });
|
|||
|
}
|
|||
|
|
|||
|
comboBoxEdit3.Properties.Items.Clear();
|
|||
|
foreach (int v in Enum.GetValues(typeof(ExchangeType)))
|
|||
|
{
|
|||
|
string strName = Enum.GetName(typeof(ExchangeType), v);
|
|||
|
comboBoxEdit3.Properties.Items.AddRange(new object[] { strName });
|
|||
|
}
|
|||
|
|
|||
|
comboBoxEdit1.Properties.Items.Clear();
|
|||
|
foreach (int v in Enum.GetValues(typeof(SwitchType)))
|
|||
|
{
|
|||
|
string strName = Enum.GetName(typeof(SwitchType), v);
|
|||
|
comboBoxEdit1.Properties.Items.AddRange(new object[] { strName });
|
|||
|
}
|
|||
|
|
|||
|
var groups = session.FindGroups();
|
|||
|
if (groups != null && groups.Count != 0)
|
|||
|
{
|
|||
|
comboBox1.DataSource = groups;
|
|||
|
comboBox1.DisplayMember = "name";
|
|||
|
comboBox1.Tag = groups;
|
|||
|
}
|
|||
|
loadMemberInfo();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
ShowError(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
private CancellationTokenSource tokenSource = new CancellationTokenSource();
|
|||
|
/// <summary>
|
|||
|
/// 加载数据
|
|||
|
/// </summary>
|
|||
|
/// <param name="noAssignment">是否重新赋值可修改的控件数据</param>
|
|||
|
private void loadMemberInfo(bool noAssignment = true)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (uid != 0)
|
|||
|
{
|
|||
|
member = session.FindMemberInfoById(uid);
|
|||
|
if (member == null) throw new Exception("用户数据存在异常");
|
|||
|
old_status = member.status;
|
|||
|
memoEdit1.Text = member.username;
|
|||
|
memoEdit2.Text = member.usernick;
|
|||
|
memoEdit3.Text = member.robot_type.ToString();
|
|||
|
textEdit1.Text = member.inviter_id.ToString();
|
|||
|
if (comboBox1.Tag != null)
|
|||
|
{
|
|||
|
var groups = comboBox1.Tag as List<fl_member_group>;
|
|||
|
var group = groups.FirstOrDefault(f => f.id == member.group_id);
|
|||
|
comboBox1.Text = group != null ? group.name : groups.FirstOrDefault().name;
|
|||
|
}
|
|||
|
|
|||
|
memoEdit11.Text = member.remark;
|
|||
|
|
|||
|
memoEdit5.Text = member.cur_point.ToString("0.00");
|
|||
|
memoEdit7.Text = member.buy_point.ToString("0.00");
|
|||
|
memoEdit6.Text = member.sum_point.ToString("0.00");
|
|||
|
memoEdit8.Text = member.ext_point.ToString("0.00");
|
|||
|
memoEdit9.Text = member.rew_point.ToString("0.00");
|
|||
|
memoEdit10.Text = member.finish_order.ToString();
|
|||
|
dateTimePicker5.Value = member.crt_time;
|
|||
|
dateTimePicker6.Value = member.upd_time;
|
|||
|
dateTimePicker7.Value = (member.blackout_time == DateTime.MinValue ? DateTime.Parse("1900-01-01 00:00:00") : member.blackout_time);
|
|||
|
memoEdit22.Text = member.chat_count.ToString();
|
|||
|
|
|||
|
var dic_t = FindOrderTotalInfo(uid, tokenSource.Token);
|
|||
|
dic_t.ContinueWith(f =>
|
|||
|
{
|
|||
|
var dic = f.Result;
|
|||
|
|
|||
|
this.Invoke(new Action(() =>
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
memoEdit4.Text = (dic == null ? "异常" : dic["count_pay"].ToString("0.00"));//待收货数
|
|||
|
memoEdit19.Text = (dic == null ? "异常" : dic["point_pay"].ToString("0.00"));//未收货金额
|
|||
|
memoEdit21.Text = (dic == null ? "异常" : dic["count_sleep"].ToString("0.00"));//冻结数量
|
|||
|
memoEdit20.Text = (dic == null ? "异常" : dic["point_sleep"].ToString("0.00"));//冻结金额
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
}
|
|||
|
}));
|
|||
|
}, tokenSource.Token);
|
|||
|
|
|||
|
if (noAssignment)
|
|||
|
{
|
|||
|
comboBoxEdit2.SelectedIndex = (int)member.status;
|
|||
|
comboBoxEdit3.SelectedIndex = (int)member.exchange_type;
|
|||
|
comboBoxEdit1.SelectedIndex = (int)member.ignore_group_update;
|
|||
|
memoEdit17.Text = member.identity_name;
|
|||
|
memoEdit18.Text = member.identity_card;
|
|||
|
|
|||
|
memoEdit15.Text = member.alipay_name;
|
|||
|
memoEdit16.Text = member.alipay_num;
|
|||
|
dateTimePicker1.Value = member.ban_exchange_time;
|
|||
|
numericUpDown1.Value = (decimal)member.private_ratio;
|
|||
|
}
|
|||
|
|
|||
|
is_loding = true;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
if (!this.IsDisposed)
|
|||
|
ShowError(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 统计阿里妈妈,京东,拼多多,(付款状态订单合计/冻结状态订单合计/付款和冻结状态订单合计)
|
|||
|
/// </summary>
|
|||
|
/// <param name="tableName">表名</param>
|
|||
|
/// <param name="uid">用户id</param>
|
|||
|
/// <returns></returns>
|
|||
|
private Task<Dictionary<string, decimal>> FindOrderTotalInfo(long uid, CancellationToken Token)
|
|||
|
{
|
|||
|
return Task.Run(() =>
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var result = session.FindTable($"select round(COALESCE(sum(db_userpoint),0) ,2) as sum ,count(id) as count from fl_order_alimama where db_userid = @id and db_status = 1001 UNION ALL select round(COALESCE(sum(db_userpoint), 0), 2) as sum, count(id) as count from fl_order_alimama where db_userid = @id and db_status = 1005 union all select round(COALESCE(sum(db_userpoint),0) ,2) as sum ,count(id) as count from fl_order_jingdong where db_userid = @id and db_status = 1001 UNION ALL select round(COALESCE(sum(db_userpoint), 0), 2) as sum, count(id) as count from fl_order_jingdong where db_userid = @id and db_status = 1005 union all select round(COALESCE(sum(db_userpoint),0) ,2) as sum ,count(id) as count from fl_order_pinduoduo where db_userid = @id and db_status = 1001 UNION ALL select round(COALESCE(sum(db_userpoint), 0), 2) as sum, count(id) as count from fl_order_pinduoduo where db_userid = @id and db_status = 1005", new { id = uid });
|
|||
|
if (result.Rows.Count != 0 && result.Rows.Count == 6)
|
|||
|
{
|
|||
|
var dic = new Dictionary<string, decimal>();
|
|||
|
|
|||
|
var ali_point_sleep = decimal.Parse(result.Rows[0]["sum"].ToString());
|
|||
|
var ali_count_sleep = int.Parse(result.Rows[0]["count"].ToString());
|
|||
|
var ali_point_pay = decimal.Parse(result.Rows[1]["sum"].ToString());
|
|||
|
var ali_count_pay = int.Parse(result.Rows[1]["count"].ToString());
|
|||
|
|
|||
|
var jd_point_sleep = decimal.Parse(result.Rows[2]["sum"].ToString());
|
|||
|
var jd_count_sleep = int.Parse(result.Rows[2]["count"].ToString());
|
|||
|
var jd_point_pay = decimal.Parse(result.Rows[3]["sum"].ToString());
|
|||
|
var jd_count_pay = int.Parse(result.Rows[3]["count"].ToString());
|
|||
|
|
|||
|
var pdd_point_sleep = decimal.Parse(result.Rows[4]["sum"].ToString());
|
|||
|
var pdd_count_sleep = int.Parse(result.Rows[4]["count"].ToString());
|
|||
|
var pdd_point_pay = decimal.Parse(result.Rows[5]["sum"].ToString());
|
|||
|
var pdd_count_pay = int.Parse(result.Rows[5]["count"].ToString());
|
|||
|
|
|||
|
dic.Add("point_sleep", ali_point_sleep + jd_point_sleep + pdd_point_sleep);
|
|||
|
dic.Add("count_sleep", ali_count_sleep + jd_count_sleep + pdd_count_sleep);
|
|||
|
dic.Add("point_pay", ali_point_pay + jd_point_pay + pdd_point_pay);
|
|||
|
dic.Add("count_pay", ali_count_pay + jd_count_pay + pdd_count_pay);
|
|||
|
|
|||
|
return dic;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{ }
|
|||
|
return null;
|
|||
|
}, Token);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
DialogResult dialogResult = DialogResult.No;
|
|||
|
|
|||
|
CsharpHttpHelper.IniHelper Config = new CsharpHttpHelper.IniHelper(HttpExtend.MapFile("系统配置.ini", "Config"));
|
|||
|
var pass = Config.GetValue("帐号信息", "密码2");
|
|||
|
if (!string.IsNullOrWhiteSpace(pass))
|
|||
|
{
|
|||
|
var v = new VerifyPassForm(pass);
|
|||
|
dialogResult = v.ShowDialog();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var verify = new Grant.Framework.VerifyPassForm();
|
|||
|
dialogResult = verify.ShowDialog();
|
|||
|
}
|
|||
|
|
|||
|
if (dialogResult == DialogResult.OK)
|
|||
|
{
|
|||
|
if (uid == 0) throw new Exception("当前窗体数据异常");
|
|||
|
var changepoint = new change_point_form(uid);
|
|||
|
changepoint.ShowDialog();
|
|||
|
loadMemberInfo(false);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
ShowError(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void member_base_info_form_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
memoEdit17.Focus();
|
|||
|
if (is_change && XtraMessageBox.Show("您当前做了修改操作,是否保存?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|||
|
{
|
|||
|
member.status = (MemberType)comboBoxEdit2.SelectedIndex;
|
|||
|
member.exchange_type = (ExchangeType)comboBoxEdit3.SelectedIndex;
|
|||
|
|
|||
|
member.ignore_group_update = (SwitchType)comboBoxEdit1.SelectedIndex;
|
|||
|
member.identity_name = memoEdit17.Text.Trim();
|
|||
|
member.ban_exchange_time = dateTimePicker1.Value;
|
|||
|
member.private_ratio = (double)numericUpDown1.Value;
|
|||
|
member.identity_card = memoEdit18.Text.Trim();
|
|||
|
member.alipay_name = memoEdit15.Text.Trim();
|
|||
|
member.alipay_num = memoEdit16.Text.Trim();
|
|||
|
member.inviter_id = int.Parse(textEdit1.Text);
|
|||
|
if (comboBox1.SelectedValue != null)
|
|||
|
member.group_id = (comboBox1.SelectedValue as fl_member_group).id;
|
|||
|
member.remark = memoEdit11.Text;
|
|||
|
|
|||
|
session.SaveOrUpdate(member);
|
|||
|
session.FindBlacklistMemberInfos(true);//刷新黑名单缓存
|
|||
|
}
|
|||
|
tokenSource.Cancel();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
ShowError(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
private bool is_change = false;
|
|||
|
private bool is_loding = false;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 现在有8个控件可以赋值,如果8个值都没有被修改那么关闭的时候将不提示是否保存提示
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
private void ChangeInput(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (is_loding)
|
|||
|
is_change = true;
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
if (sender is TextEdit)
|
|||
|
{
|
|||
|
var edit = sender as TextEdit;
|
|||
|
if (edit.Name == "textEdit1")
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (edit.Text.Trim() == "0") throw new Exception("无");
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var member = session.FindMemberInfoById(int.Parse(edit.Text.Trim()));
|
|||
|
if (member == null) throw new Exception("数据异常");
|
|||
|
memoEdit14.Text = member.usernick;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
memoEdit14.Text = ex.Message;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{ }
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|