增加下级OEM 查询

This commit is contained in:
chfei committed 2026-11-20 15:50:31 +08:00
1 parent e35de50da8
commit 29197fe637
7 files changed
+633 -2

No files matched your search

+3
View File
@@ -40,6 +40,8 @@ namespace TemuKJD.WXForms.ShopForms
System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("税务申报");
System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("积分充值");
System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("OEM返利明细");
System.Windows.Forms.TreeNode subOemRebateNode = new System.Windows.Forms.TreeNode("下级OEM返利明细");
subOemRebateNode.Name = "下级OEM返利明细";
System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("店铺管理", new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode2,
@@ -48,6 +50,7 @@ namespace TemuKJD.WXForms.ShopForms
treeNode5,
treeNode6,
treeNode12,
subOemRebateNode,
treeNode7,
treeNode8,
treeNode9,
+7 -1
View File
@@ -35,6 +35,7 @@ namespace TemuKJD.WXForms.ShopForms
public Lazy<WXOemPointsTopUpListForm> oemAccountPointsForm = new Lazy<WXOemPointsTopUpListForm>();
public Lazy<WXShopOemWithdrawalForm> oemWithdrawalForm = new Lazy<WXShopOemWithdrawalForm>();
public Lazy<WXShopOemRebateRecordsForm> oemRebateRecordsForm = new Lazy<WXShopOemRebateRecordsForm>();
private readonly Lazy<WXShopSubOemRebateRecordsForm> subOemRebateRecordsForm = new Lazy<WXShopSubOemRebateRecordsForm>();
public WXShopForm()
@@ -62,7 +63,7 @@ namespace TemuKJD.WXForms.ShopForms
public List<string> getHideTreeNodes()
{
List<string> hideNames = new List<string>() { "积分充值", "OEM账号管理", "运费流水明细", "积分流水明细", "OEM提现管理", "OEM返利明细", "店铺地址管理", "评分考核", "子账号管理", "高级运费模板", "运费模板", "素材库管理", "订单金额统计", "工作明细统计", "店铺经营统计1" };
List<string> hideNames = new List<string>() { "积分充值", "OEM账号管理", "运费流水明细", "积分流水明细", "OEM提现管理", "OEM返利明细", "下级OEM返利明细", "店铺地址管理", "评分考核", "子账号管理", "高级运费模板", "运费模板", "素材库管理", "订单金额统计", "工作明细统计", "店铺经营统计1" };
if (BaseClass.SaLevel == 1)
{
@@ -90,6 +91,8 @@ namespace TemuKJD.WXForms.ShopForms
hideNames.Remove("积分流水明细");
hideNames.Remove("OEM提现管理");
hideNames.Remove("OEM返利明细");
if (BaseClass.UserAuthority.Split(',').Contains("下级OEM"))
hideNames.Remove("下级OEM返利明细");
}
foreach (var forbiddenPage in BaseClass.ForbiddenPage.Split(','))
@@ -156,6 +159,9 @@ namespace TemuKJD.WXForms.ShopForms
case "OEM返利明细":
SetForm(oemRebateRecordsForm.Value);
break;
case "下级OEM返利明细":
SetForm(subOemRebateRecordsForm.Value);
break;
}
}));
}).Start();
@@ -0,0 +1,368 @@
namespace TemuKJD.WXForms.ShopForms
{
partial class WXShopSubOemRebateRecordsForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.panel1 = new System.Windows.Forms.Panel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.ucGroupBoxFilter = new TemuKJD.UserComponent.UcGroupBoxEx(this.components);
this.btnSearch = new DevComponents.DotNetBar.PanelEx();
this.dtpEndTime = new System.Windows.Forms.DateTimePicker();
this.lblTo = new System.Windows.Forms.Label();
this.dtpStartTime = new System.Windows.Forms.DateTimePicker();
this.lblDateRange = new System.Windows.Forms.Label();
this.cmbSubOem = new System.Windows.Forms.ComboBox();
this.lblSubOem = new System.Windows.Forms.Label();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.pbLoading = new System.Windows.Forms.PictureBox();
this.dgvRebateRecords = new TemuKJD.UserComponent.DataGridViewEx();
this.colFromOemId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSettleStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colRebate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colCreatedAt = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.colSettledAt = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ucSplitPage1 = new TemuKJD.UserControls.UcSplitPage();
this.statusBar = new TemuKJD.UserControls.StatusBarUserControl();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.ucGroupBoxFilter.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvRebateRecords)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.White;
this.panel1.Controls.Add(this.splitContainer1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(1, 33);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1222, 586);
this.panel1.TabIndex = 0;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.ucGroupBoxFilter);
this.splitContainer1.Panel1.Padding = new System.Windows.Forms.Padding(2);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(1222, 586);
this.splitContainer1.SplitterDistance = 75;
this.splitContainer1.TabIndex = 0;
//
// ucGroupBoxFilter
//
this.ucGroupBoxFilter.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.ucGroupBoxFilter.BorderStyle = TemuKJD.UserComponent.UcGroupBoxEx.GroupBoxBorderStyle.ROUND;
this.ucGroupBoxFilter.Controls.Add(this.btnSearch);
this.ucGroupBoxFilter.Controls.Add(this.dtpEndTime);
this.ucGroupBoxFilter.Controls.Add(this.lblTo);
this.ucGroupBoxFilter.Controls.Add(this.dtpStartTime);
this.ucGroupBoxFilter.Controls.Add(this.lblDateRange);
this.ucGroupBoxFilter.Controls.Add(this.cmbSubOem);
this.ucGroupBoxFilter.Controls.Add(this.lblSubOem);
this.ucGroupBoxFilter.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucGroupBoxFilter.Location = new System.Drawing.Point(2, 2);
this.ucGroupBoxFilter.Name = "ucGroupBoxFilter";
this.ucGroupBoxFilter.Size = new System.Drawing.Size(1218, 71);
this.ucGroupBoxFilter.TabIndex = 0;
this.ucGroupBoxFilter.TabStop = false;
this.ucGroupBoxFilter.Text = "查询条件";
//
// btnSearch
//
this.btnSearch.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnSearch.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSearch.DisabledBackColor = System.Drawing.Color.Empty;
this.btnSearch.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSearch.Location = new System.Drawing.Point(677, 26);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(68, 25);
this.btnSearch.Style.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearch.Style.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearch.Style.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSearch.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.btnSearch.Style.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
this.btnSearch.Style.BorderSide = DevComponents.DotNetBar.eBorderSide.None;
this.btnSearch.Style.ForeColor.Color = System.Drawing.Color.White;
this.btnSearch.Style.GradientAngle = 90;
this.btnSearch.StyleMouseOver.Alignment = System.Drawing.StringAlignment.Center;
this.btnSearch.StyleMouseOver.BackColor1.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearch.StyleMouseOver.BackColor2.Color = System.Drawing.Color.FromArgb(((int)(((byte)(25)))), ((int)(((byte)(102)))), ((int)(((byte)(255)))));
this.btnSearch.TabIndex = 5;
this.btnSearch.Text = "查询";
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
//
// dtpEndTime
//
this.dtpEndTime.CustomFormat = "yyyy-MM-dd";
this.dtpEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpEndTime.Location = new System.Drawing.Point(492, 26);
this.dtpEndTime.Name = "dtpEndTime";
this.dtpEndTime.Size = new System.Drawing.Size(145, 23);
this.dtpEndTime.TabIndex = 4;
//
// lblTo
//
this.lblTo.AutoSize = true;
this.lblTo.Location = new System.Drawing.Point(466, 30);
this.lblTo.Name = "lblTo";
this.lblTo.Size = new System.Drawing.Size(20, 17);
this.lblTo.TabIndex = 3;
this.lblTo.Text = "至";
//
// dtpStartTime
//
this.dtpStartTime.CustomFormat = "yyyy-MM-dd";
this.dtpStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dtpStartTime.Location = new System.Drawing.Point(312, 26);
this.dtpStartTime.Name = "dtpStartTime";
this.dtpStartTime.Size = new System.Drawing.Size(145, 23);
this.dtpStartTime.TabIndex = 2;
//
// lblDateRange
//
this.lblDateRange.AutoSize = true;
this.lblDateRange.Location = new System.Drawing.Point(240, 30);
this.lblDateRange.Name = "lblDateRange";
this.lblDateRange.Size = new System.Drawing.Size(68, 17);
this.lblDateRange.TabIndex = 1;
this.lblDateRange.Text = "日期范围:";
//
// cmbSubOem
//
this.cmbSubOem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbSubOem.FormattingEnabled = true;
this.cmbSubOem.Location = new System.Drawing.Point(83, 26);
this.cmbSubOem.Name = "cmbSubOem";
this.cmbSubOem.Size = new System.Drawing.Size(145, 25);
this.cmbSubOem.TabIndex = 0;
//
// lblSubOem
//
this.lblSubOem.AutoSize = true;
this.lblSubOem.Location = new System.Drawing.Point(12, 30);
this.lblSubOem.Name = "lblSubOem";
this.lblSubOem.Size = new System.Drawing.Size(44, 17);
this.lblSubOem.TabIndex = 0;
this.lblSubOem.Text = "下级OEM";
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.pbLoading);
this.splitContainer2.Panel1.Controls.Add(this.dgvRebateRecords);
this.splitContainer2.Panel1.Padding = new System.Windows.Forms.Padding(4, 0, 4, 0);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.ucSplitPage1);
this.splitContainer2.Panel2.Controls.Add(this.statusBar);
this.splitContainer2.Size = new System.Drawing.Size(1222, 507);
this.splitContainer2.SplitterDistance = 478;
this.splitContainer2.TabIndex = 0;
//
// pbLoading
//
this.pbLoading.Anchor = System.Windows.Forms.AnchorStyles.None;
this.pbLoading.Image = global::TemuKJD.Properties.Resources.loading_blue;
this.pbLoading.Location = new System.Drawing.Point(586, 214);
this.pbLoading.Name = "pbLoading";
this.pbLoading.Size = new System.Drawing.Size(50, 50);
this.pbLoading.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pbLoading.TabIndex = 1;
this.pbLoading.TabStop = false;
this.pbLoading.Visible = false;
//
// dgvRebateRecords
//
this.dgvRebateRecords.AllowUserToAddRows = false;
this.dgvRebateRecords.AllowUserToDeleteRows = false;
dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dgvRebateRecords.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
this.dgvRebateRecords.AutoRowNumber = true;
this.dgvRebateRecords.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dgvRebateRecords.BackgroundColor = System.Drawing.Color.White;
this.dgvRebateRecords.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.dgvRebateRecords.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
this.dgvRebateRecords.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvRebateRecords.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.colFromOemId,
this.colRebate,
this.colSettleStatus,
this.colCreatedAt,
this.colSettledAt});
this.dgvRebateRecords.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvRebateRecords.Location = new System.Drawing.Point(4, 0);
this.dgvRebateRecords.MultiSelectCheckBox = false;
this.dgvRebateRecords.Name = "dgvRebateRecords";
this.dgvRebateRecords.ReadOnly = true;
this.dgvRebateRecords.RowTemplate.Height = 28;
this.dgvRebateRecords.ShowCellErrors = false;
this.dgvRebateRecords.Size = new System.Drawing.Size(1214, 478);
this.dgvRebateRecords.TabIndex = 0;
//
// colFromOemId
//
this.colFromOemId.FillWeight = 30F;
this.colFromOemId.HeaderText = "下级OEM ID";
this.colFromOemId.Name = "colFromOemId";
this.colFromOemId.ReadOnly = true;
//
// colSettleStatus
//
this.colSettleStatus.FillWeight = 24F;
this.colSettleStatus.HeaderText = "结算状态";
this.colSettleStatus.Name = "colSettleStatus";
this.colSettleStatus.ReadOnly = true;
//
// colRebate
//
dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(140)))), ((int)(((byte)(0)))));
this.colRebate.DefaultCellStyle = dataGridViewCellStyle3;
this.colRebate.FillWeight = 24F;
this.colRebate.HeaderText = "返利金额(元)";
this.colRebate.Name = "colRebate";
this.colRebate.ReadOnly = true;
//
// colCreatedAt
//
this.colCreatedAt.FillWeight = 32F;
this.colCreatedAt.HeaderText = "创建时间";
this.colCreatedAt.Name = "colCreatedAt";
this.colCreatedAt.ReadOnly = true;
this.colSettledAt.FillWeight = 32F;
this.colSettledAt.HeaderText = "结算时间";
this.colSettledAt.Name = "colSettledAt";
this.colSettledAt.ReadOnly = true;
//
// ucSplitPage1
//
this.ucSplitPage1.CurrentPage = 1;
this.ucSplitPage1.Dock = System.Windows.Forms.DockStyle.Right;
this.ucSplitPage1.IsShowPageSize = false;
this.ucSplitPage1.IsShowTotalCount = true;
this.ucSplitPage1.Location = new System.Drawing.Point(833, 0);
this.ucSplitPage1.Margin = new System.Windows.Forms.Padding(0);
this.ucSplitPage1.Name = "ucSplitPage1";
this.ucSplitPage1.PageSize = 20;
this.ucSplitPage1.Size = new System.Drawing.Size(389, 25);
this.ucSplitPage1.TabIndex = 1;
this.ucSplitPage1.TotalCount = ((long)(0));
this.ucSplitPage1.TotalPage = 1;
this.ucSplitPage1.PageChange += new System.Action<object>(this.ucSplitPage1_PageChange);
//
// statusBar
//
this.statusBar.BackColor = System.Drawing.Color.White;
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
this.statusBar.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.statusBar.Location = new System.Drawing.Point(0, 0);
this.statusBar.Margin = new System.Windows.Forms.Padding(0);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(1222, 25);
this.statusBar.TabIndex = 0;
//
// WXShopSubOemRebateRecordsForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1224, 620);
this.Controls.Add(this.panel1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.KeyPreview = true;
this.Name = "WXShopSubOemRebateRecordsForm";
this.Text = "下级OEM返利明细";
this.TitleText = "下级OEM返利明细";
this.VisibleChanged += new System.EventHandler(this.WXShopSubOemRebateRecordsForm_VisibleChanged);
this.Controls.SetChildIndex(this.panel1, 0);
this.panel1.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ucGroupBoxFilter.ResumeLayout(false);
this.ucGroupBoxFilter.PerformLayout();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pbLoading)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvRebateRecords)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.SplitContainer splitContainer1;
private TemuKJD.UserComponent.UcGroupBoxEx ucGroupBoxFilter;
private System.Windows.Forms.Label lblSubOem;
private System.Windows.Forms.ComboBox cmbSubOem;
private System.Windows.Forms.Label lblDateRange;
private System.Windows.Forms.DateTimePicker dtpStartTime;
private System.Windows.Forms.Label lblTo;
private System.Windows.Forms.DateTimePicker dtpEndTime;
private DevComponents.DotNetBar.PanelEx btnSearch;
private System.Windows.Forms.SplitContainer splitContainer2;
private TemuKJD.UserComponent.DataGridViewEx dgvRebateRecords;
private System.Windows.Forms.PictureBox pbLoading;
private TemuKJD.UserControls.UcSplitPage ucSplitPage1;
private TemuKJD.UserControls.StatusBarUserControl statusBar;
private System.Windows.Forms.DataGridViewTextBoxColumn colFromOemId;
private System.Windows.Forms.DataGridViewTextBoxColumn colSettleStatus;
private System.Windows.Forms.DataGridViewTextBoxColumn colRebate;
private System.Windows.Forms.DataGridViewTextBoxColumn colCreatedAt;
private System.Windows.Forms.DataGridViewTextBoxColumn colSettledAt;
}
}
@@ -0,0 +1,235 @@
using AllBase;
using AllBase.Model.Result;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.BaseForms;
using Work;
namespace TemuKJD.WXForms.ShopForms
{
public partial class WXShopSubOemRebateRecordsForm : BaseGeneralForm
{
private const int MaxPageIndex = 1000;
private readonly BindingList<SubOemRebateRecord> records = new BindingList<SubOemRebateRecord>();
private bool subOemsLoaded;
private bool loading;
public WXShopSubOemRebateRecordsForm()
{
InitializeComponent();
dtpStartTime.Value = DateTime.Today.AddMonths(-3);
dtpEndTime.Value = DateTime.Today;
dgvRebateRecords.AutoGenerateColumns = false;
colFromOemId.DataPropertyName = nameof(SubOemRebateRecord.FromOemId);
colRebate.DataPropertyName = nameof(SubOemRebateRecord.Amount);
colSettleStatus.DataPropertyName = nameof(SubOemRebateRecord.SettleStatus);
colCreatedAt.DataPropertyName = nameof(SubOemRebateRecord.CreatedAt);
colSettledAt.DataPropertyName = nameof(SubOemRebateRecord.SettledAt);
colCreatedAt.DefaultCellStyle.Format = "yyyy-MM-dd HH:mm:ss";
colSettledAt.DefaultCellStyle.Format = colCreatedAt.DefaultCellStyle.Format;
colRebate.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvRebateRecords.CellFormatting += DgvRebateRecords_CellFormatting;
dgvRebateRecords.DataSource = records;
cmbSubOem.DisplayMember = nameof(SubOem.DisplayName);
cmbSubOem.ValueMember = nameof(SubOem.OemId);
cmbSubOem.SelectedIndexChanged += FilterChanged;
dtpStartTime.ValueChanged += FilterChanged;
dtpEndTime.ValueChanged += FilterChanged;
ucSplitPage1.Enabled = false;
}
private void DgvRebateRecords_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.ColumnIndex == colRebate.Index && e.Value is long amount)
{
e.Value = (amount / 100m).ToString("F2");
e.FormattingApplied = true;
if (amount < 0)
e.CellStyle.ForeColor = Color.Crimson;
}
else if (e.ColumnIndex == colSettleStatus.Index && e.Value is int status)
{
e.Value = status == 0 ? "未结算" : status == 1 ? "已结算" : status.ToString();
e.FormattingApplied = true;
}
}
private void FilterChanged(object sender, EventArgs e)
{
ucSplitPage1.Enabled = false;
records.Clear();
ucSplitPage1.TotalCount = 0;
ucSplitPage1.TotalPage = 1;
ucSplitPage1.CurrentPage = 1;
if (subOemsLoaded)
statusBar.lblTaskStatus.Text = "筛选条件已修改,请点击查询";
}
private async void WXShopSubOemRebateRecordsForm_VisibleChanged(object sender, EventArgs e)
{
if (Visible && !subOemsLoaded)
await LoadSubOems();
}
private async Task LoadSubOems()
{
if (loading)
return;
SetLoading(true);
try
{
var subOems = await Request<List<SubOem>>("user/get_sub_oems", null);
if (IsDisposed)
return;
cmbSubOem.DataSource = subOems;
subOemsLoaded = true;
statusBar.lblTaskStatus.Text = subOems.Count == 0 ? "没有直属下级OEM" : "请选择下级OEM和日期范围";
}
catch (Exception ex)
{
ShowRequestError("下级OEM列表获取失败,可点击查询重试", ex);
}
finally
{
SetLoading(false);
}
}
private async void btnSearch_Click(object sender, EventArgs e)
{
if (!subOemsLoaded)
{
await LoadSubOems();
return;
}
if (!(cmbSubOem.SelectedValue is string oemId) || string.IsNullOrWhiteSpace(oemId))
{
BaseMsgForm.ShowError("请选择下级OEM!");
return;
}
if (dtpStartTime.Value.Date > dtpEndTime.Value.Date)
{
BaseMsgForm.ShowError("开始日期不能大于结束日期!");
return;
}
ucSplitPage1.Enabled = false;
ucSplitPage1.CurrentPage = 1;
await LoadRebateRecords(oemId);
}
private async void ucSplitPage1_PageChange(object obj)
{
if (ucSplitPage1.Enabled && cmbSubOem.SelectedValue is string oemId)
await LoadRebateRecords(oemId);
}
private async Task LoadRebateRecords(string oemId)
{
SetLoading(true);
try
{
var page = await Request<PageData<SubOemRebateRecord>>("oem/get_sub_oem_rebate_records", new
{
oemId,
startTime = dtpStartTime.Value.Date.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture),
endTime = dtpEndTime.Value.Date.AddHours(23).AddMinutes(59).AddSeconds(59)
.ToString("yyyy-MM-dd'T'HH:mm:ss", CultureInfo.InvariantCulture),
pageIndex = ucSplitPage1.CurrentPage,
pageSize = ucSplitPage1.PageSize
});
if (IsDisposed)
return;
records.Clear();
page.List?.ForEach(records.Add);
ucSplitPage1.TotalCount = page.Total;
ucSplitPage1.TotalPage = Math.Max(1, Math.Min(MaxPageIndex, page.TotalPages));
ucSplitPage1.Enabled = true;
statusBar.lblTaskStatus.Text = "返利明细查询完毕";
}
catch (Exception ex)
{
if (IsDisposed)
return;
records.Clear();
ucSplitPage1.TotalCount = 0;
ucSplitPage1.TotalPage = 1;
ucSplitPage1.CurrentPage = 1;
ShowRequestError("返利明细获取失败", ex);
}
finally
{
SetLoading(false);
}
}
private void SetLoading(bool value)
{
loading = value;
if (IsDisposed)
return;
if (value)
ucSplitPage1.Enabled = false;
ucGroupBoxFilter.Enabled = !value;
pbLoading.Visible = value;
}
private void ShowRequestError(string message, Exception exception)
{
if (IsDisposed)
return;
statusBar.lblTaskStatus.Text = message;
BaseMsgForm.ShowError(message + ":" + exception.Message);
}
private static async Task<T> Request<T>(string path, object parameters) where T : class
{
string url = BaseClass.BuildWXObjString(path);
string json = await GetHtml.PostJsonAsync(url, UserLogin.GetSignPostData(parameters));
if (string.IsNullOrWhiteSpace(json))
throw new InvalidOperationException("接口未返回数据");
var result = JsonConvert.DeserializeObject<Result<T>>(json);
if (result == null)
throw new InvalidOperationException("接口未返回数据");
if (result.Code != 200)
throw new InvalidOperationException(string.IsNullOrWhiteSpace(result.Msg)
? $"业务状态码 {result.Code}"
: result.Msg);
return result.Data ?? throw new InvalidOperationException("响应缺少数据");
}
private class SubOem
{
public string OemId { get; set; }
public string OemName { get; set; }
public string DisplayName => string.IsNullOrWhiteSpace(OemName) ? OemId : $"{OemName} ({OemId})";
}
private class SubOemRebateRecord
{
public string FromOemId { get; set; }
public long Amount { get; set; }
public int SettleStatus { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? SettledAt { get; set; }
}
}
}