1074 lines
50 KiB
C#
1074 lines
50 KiB
C#
using AllBase;
|
||
using AllBase.Helper;
|
||
using AllBase.Model.Result;
|
||
using NaiBa.Util.Extension;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net.Http;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using TemuKJD.Extension;
|
||
using TemuKJD.BaseForms;
|
||
using TemuKJD.ToolForms;
|
||
using Work;
|
||
using TemuKJD.BLL;
|
||
using System.Text.RegularExpressions;
|
||
using TemuKJD.PDDForms.ProductSelectForms;
|
||
using TemuKJD.WXForms.ShopForms;
|
||
using AllBase.Model.Result.PDDResult;
|
||
using AllBase.Model.Param.WXParam;
|
||
using AllBase.Model.Result.WXResult;
|
||
using Newtonsoft.Json;
|
||
using NaiBa.Util;
|
||
using AllBase.Model.Config;
|
||
|
||
namespace TemuKJD.WXForms.ProductForms
|
||
{
|
||
public partial class WXProdNoCheckEditAddressForm : BaseForm
|
||
{
|
||
int PageBegin = 1;
|
||
int PageEnd = 999;
|
||
string PreType = "";
|
||
string OnSaleStatus = "在售";
|
||
|
||
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
|
||
public bool IsLoadComplate { get; set; } = false;
|
||
|
||
bool isInit = false;
|
||
CheckBox chkSelectAll = null;
|
||
ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||
public NaiBa.Util.ConcurrentList<TemuDBProductSelect> lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
|
||
NaiBa.Util.ConcurrentList<AddPriceRule> lstAddPriceRule = new NaiBa.Util.ConcurrentList<AddPriceRule>();
|
||
AddPriceRule defaultAddPriceRule = null;
|
||
WXUploadRule wxUploadRule = null;
|
||
//public Dictionary<string, List<string>> dicCheckedShopIdList = new Dictionary<string, List<string>>();
|
||
public Dictionary<string, bool> dicCheckedShopId = new Dictionary<string, bool>();
|
||
public Dictionary<string, WxShopUploadInfo> dicShopUpload = new Dictionary<string, WxShopUploadInfo>();
|
||
public WXProdNoCheckEditAddressForm()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void UserSelectDbProductForm_Load(object sender, EventArgs e)
|
||
{
|
||
this.splitContainer1.Dock = DockStyle.Fill;
|
||
|
||
lstWXShopTokenInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
|
||
if (lstWXShopTokenInfo == null)
|
||
lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||
|
||
lstTemuDBProductSelect = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<TemuDBProductSelect>>("wx_db_prod_upload_list");
|
||
if (lstTemuDBProductSelect == null)
|
||
lstTemuDBProductSelect = new NaiBa.Util.ConcurrentList<TemuDBProductSelect>();
|
||
|
||
lstAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<AddPriceRule>>("wx_add_price_rules");
|
||
if (lstAddPriceRule == null)
|
||
{
|
||
lstAddPriceRule = new NaiBa.Util.ConcurrentList<AddPriceRule>();
|
||
lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 0, LessThanPrice = 10, AddPriceTimes = 2, AddMorePrice = 10, SinglePriceAdd = 1 });
|
||
lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 10, LessThanPrice = 20, AddPriceTimes = 2, AddMorePrice = 10, SinglePriceAdd = 1 });
|
||
lstAddPriceRule.Add(new AddPriceRule() { MoreThanPrice = 20, LessThanPrice = 999, AddPriceTimes = 2, AddMorePrice = 10, SinglePriceAdd = 1 });
|
||
}
|
||
|
||
dicCheckedShopId = NaiBa.Util.Helper.ConfigHelper.LoadConfig<Dictionary<string, bool>>("wx_checked_shop_dic");
|
||
if (dicCheckedShopId == null)
|
||
dicCheckedShopId = new Dictionary<string, bool>();
|
||
|
||
defaultAddPriceRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig<AddPriceRule>("wx_default_add_price_rule");
|
||
if (defaultAddPriceRule == null)
|
||
{
|
||
defaultAddPriceRule = new AddPriceRule() { AddPriceTimes = 1.3m, AddMorePrice = 1, SinglePriceAdd = 1 };
|
||
}
|
||
|
||
wxUploadRule = NaiBa.Util.Helper.ConfigHelper.LoadConfig<WXUploadRule>("wx_upload_rule");
|
||
if (wxUploadRule == null)
|
||
wxUploadRule = new WXUploadRule();
|
||
|
||
chkSelectAll = dgvShop.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false);
|
||
dgvShop.Columns["colSelect"].HeaderText = "";
|
||
//chkSelectAll.Width = chkSelectAll.Height = 13;
|
||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||
//chkSelectAll.Checked = true;
|
||
|
||
this.dgvSelectProduct.AddSelectorColumn("colCheck");
|
||
|
||
dgvSelectProduct.AddImgColumn("colProductSkcPic", "colImgUrl");
|
||
dgvSelectProduct.AddImgColumn("colSkuFakeImg", "colSkuFakeImgUrl");
|
||
|
||
dgvSelectProduct.Columns["colSkuFakeImg"].Visible = false;
|
||
|
||
dtpStartTime.Value = DateTime.Now.Date.AddMonths(-1);
|
||
|
||
//#if DEBUG
|
||
if (BaseClass.SaLevel == 1)
|
||
{
|
||
//txtIdFilter.Visible = true;
|
||
//txtExtCodeFilter.Visible = true;
|
||
//lblIdFilter.Visible = true;
|
||
//lblExtCodeFilter.Visible = true;
|
||
}
|
||
//#endif
|
||
IsLoadComplate = true;
|
||
}
|
||
|
||
private void btnRefreshAuthor_Click(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
if (!chkSelectAll.Checked)
|
||
{
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
row.Cells["colSelect"].Value = false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//var list = GlobalConfig.ShopLoginList.Where(s => s.LoginStatus == "登录成功").Select(ss => ss.ShopId);
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
//if (list.Any(l => l == row.Cells["colShopId"]?.Value?.ToString()))
|
||
if (row.Visible == true)
|
||
row.Cells["colSelect"].Value = true;
|
||
}
|
||
}
|
||
|
||
foreach (var r in dgvShop.Rows.Cast<DataGridViewRow>())
|
||
{
|
||
dicCheckedShopId[r.Cells["colShopId"].Value.ParseToString()] = r.Cells["colSelect"].Value.ParseToBool();
|
||
}
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_checked_shop_dic", dicCheckedShopId);
|
||
}
|
||
|
||
private void btnRefreshShop_Click(object sender, EventArgs e)
|
||
{
|
||
pbLoadingShop.Visible = true;
|
||
RefreshShopLogin();
|
||
pbLoadingShop.Visible = false;
|
||
}
|
||
|
||
private void UserSelectDbProductForm_VisibleChanged(object sender, EventArgs e)
|
||
{
|
||
if (Visible == true)
|
||
{
|
||
RefreshShopLogin();
|
||
|
||
if (!isInit)
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||
{
|
||
//if (shop.LoginStatus == "登录成功")
|
||
//{
|
||
// var rst = WXNoCheckEdit.scanProductPreview(shop);
|
||
// if (!rst.Contains("\"code\":0") && !rst.Contains("\"success\":true"))
|
||
// {
|
||
// WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
|
||
// }
|
||
//}
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
isInit = true;
|
||
}
|
||
}
|
||
|
||
private void RefreshShopLogin()
|
||
{
|
||
// 店铺Id
|
||
var selectIds = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||
// 获取被删除的店铺
|
||
List<DataGridViewRow> dgvRowList = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||
=> !GlobalConfig.ShopLoginList.Any(s => s.ShopId == row.Cells["colShopId"]?.Value?.ToString())).ToList();
|
||
// 更新被删除的店铺列表
|
||
foreach (var row in dgvRowList)
|
||
{
|
||
dgvShop.Rows.Remove(row);
|
||
}
|
||
// 绑定其他店铺(含新导入的店铺)
|
||
foreach (ShopLoginInfo shopEntity in GlobalConfig.ShopLoginList)
|
||
{
|
||
if (!string.IsNullOrEmpty(shopEntity.ShopId))
|
||
BindShop(shopEntity, selectIds);
|
||
}
|
||
cmbFilterShopNotes.Items.Clear();
|
||
foreach (var note in GlobalConfig.ShopLoginList.Select(s => s.Notes).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||
{
|
||
cmbFilterShopNotes.Items.Add(note);
|
||
}
|
||
cmbFilterShopGroup.Items.Clear();
|
||
foreach (var note in GlobalConfig.ShopLoginList.Select(s => s.GroupName).Where(s => !s.IsNullOrEmpty()).Distinct())
|
||
{
|
||
cmbFilterShopGroup.Items.Add(note);
|
||
}
|
||
}
|
||
|
||
private void BindShop(ShopLoginInfo shopEntity, List<string> selectShopId = null, string msg = "")
|
||
{
|
||
if (shopEntity == null)
|
||
return;
|
||
if (shopEntity.is_point_shop_expire)
|
||
return;
|
||
if (selectShopId == null)
|
||
selectShopId = new List<string>();
|
||
|
||
bool canUse = shopEntity.LoginStatus == "登录成功";
|
||
//canUse = true; // 内部库不需要校验登录状态
|
||
var row = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colShopId").ParseToString() == shopEntity.ShopId);
|
||
var day = DateTime.Now.ToString("yyyyMMdd").ParseToInt();
|
||
if (row == null)
|
||
{
|
||
this.dgvShop.Rows.Add(
|
||
//!isInit || (selectShopId.Contains(shopEntity.ShopId) && canUse),
|
||
dicCheckedShopId.Keys.Contains(shopEntity.ShopId) && dicCheckedShopId[shopEntity.ShopId] == true,
|
||
shopEntity.LoginName,
|
||
shopEntity.ShopId,
|
||
shopEntity.ShopAccount,
|
||
shopEntity.Notes,
|
||
shopEntity.GroupName,
|
||
"选择商品",
|
||
canUse ? "在线" : "掉线",
|
||
GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期",
|
||
canUse,
|
||
dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].DicDayUploadCount.ContainsKey(day) ?
|
||
dicShopUpload[shopEntity.ShopId].DicDayUploadCount[day] : 0,
|
||
dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].OnSaleRefreshDay == DateTime.Now.ToString("yyyyMMdd").ParseToInt() ?
|
||
dicShopUpload[shopEntity.ShopId].OnSaleCount : 0,
|
||
shopEntity.AddProductRemaining,
|
||
msg
|
||
);
|
||
}
|
||
else
|
||
{
|
||
row.Cells["colSelect"].Value = !isInit || (selectShopId.Contains(shopEntity.ShopId) && canUse);
|
||
row.Cells["colShopLoginName"].Value = shopEntity.LoginName;
|
||
row.Cells["colShopName"].Value = shopEntity.ShopAccount;
|
||
row.Cells["colShopNotes"].Value = shopEntity.Notes;
|
||
row.Cells["colGroup"].Value = shopEntity.GroupName;
|
||
row.Cells["colLoginStatus"].Value = canUse ? "在线" : "掉线";
|
||
row.Cells["colLoginStatus"].Style.ForeColor = canUse ? Color.Green : Color.Red;
|
||
row.Cells["colCanUse"].Value = canUse;
|
||
row.Cells["colApi"].Value = GlobalConfig.lstWxShopAuthInfo.FirstOrDefault(sa => sa.ShopId == shopEntity.ShopId)?.ExpiresTime > DateTime.Now.AddMinutes(5) ? "可用" : "过期";
|
||
row.Cells["colRemaining"].Value = shopEntity.AddProductRemaining;
|
||
row.Cells["colUploadCount"].Value = dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].DicDayUploadCount.ContainsKey(day) ?
|
||
dicShopUpload[shopEntity.ShopId].DicDayUploadCount[day] : 0;
|
||
row.Cells["colOnSaleNum"].Value = dicShopUpload.ContainsKey(shopEntity.ShopId) && dicShopUpload[shopEntity.ShopId].OnSaleRefreshDay == DateTime.Now.ToString("yyyyMMdd").ParseToInt() ?
|
||
dicShopUpload[shopEntity.ShopId].OnSaleCount : 0;
|
||
row.Cells["colMessage"].Value = msg;
|
||
}
|
||
|
||
displayAuthStatus(shopEntity);
|
||
}
|
||
|
||
void displayAuthStatus(ShopLoginInfo shop)
|
||
{
|
||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopId"].Value.ParseToString() == shop?.ShopId);
|
||
foreach (var row in rows)
|
||
{
|
||
bool canUse = row.Cells["colLoginStatus"].Value.ParseToString() == "在线";
|
||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Blue : Color.Red;
|
||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Blue : Color.Red;
|
||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightBlue : Color.OrangeRed;
|
||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkBlue : Color.DarkRed;
|
||
canUse = row.Cells["colApi"].Value.ParseToString() == "可用";
|
||
(row.Cells["colApi"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Blue : Color.Red;
|
||
(row.Cells["colApi"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Blue : Color.Red;
|
||
(row.Cells["colApi"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightBlue : Color.OrangeRed;
|
||
(row.Cells["colApi"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkBlue : Color.DarkRed;
|
||
}
|
||
}
|
||
|
||
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||
return;
|
||
string headerText = dgvShop.Columns[e.ColumnIndex].HeaderText;
|
||
string columnName = dgvShop.Columns[e.ColumnIndex].Name;
|
||
string shopId = dgvShop.Rows[e.RowIndex].Cells["colShopId"].Value.ParseToString();
|
||
string shopAccount = dgvShop.Rows[e.RowIndex].Cells["colShopName"].Value.ToString();
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId.ToString());
|
||
var row = dgvShop.Rows[e.RowIndex];
|
||
switch (columnName)
|
||
{
|
||
case "colSelect":
|
||
//if (row.Cells["colCanUse"].Value.ParseToBool())
|
||
{
|
||
row.Cells["colSelect"].Value = !row.Cells["colSelect"].Value.ParseToBool();
|
||
|
||
chkSelectAll.CheckedChanged -= chkSelectAll_CheckedChanged;
|
||
if (dgvShop.Rows.Cast<DataGridViewRow>().All(r => r.Cells["colSelect"].Value.ParseToBool()))
|
||
chkSelectAll.Checked = true;
|
||
else
|
||
chkSelectAll.Checked = false;
|
||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||
}
|
||
//else
|
||
{
|
||
//BaseMsgForm.ShowInfo("店铺未登录!");
|
||
}
|
||
|
||
dicCheckedShopId[row.Cells["colShopId"].Value.ParseToString()] = row.Cells["colSelect"].Value.ParseToBool();
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_checked_shop_dic", dicCheckedShopId);
|
||
break;
|
||
case "colLoginStatus":
|
||
{
|
||
if (WXShopListForm.Instance == null)
|
||
WXShopListForm.Instance = new WXShopListForm();
|
||
WXShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
//shopLoginForm.prodUserSelectForm = this;
|
||
if (shop.LoginStatus != "登录成功")
|
||
{
|
||
shopLoginForm.openType = EnumOpenType.login;
|
||
shopLoginForm.ShowDialog();
|
||
RefreshShopLogin();
|
||
}
|
||
else
|
||
{
|
||
shopLoginForm.openType = EnumOpenType.manage;
|
||
shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
shopLoginForm.Show();
|
||
}
|
||
}
|
||
break;
|
||
case "colApi":
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
shopLoginForm.openType = EnumOpenType.manage;
|
||
shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/servicemarket/detail?serviceId=3984039898079707139";
|
||
shopLoginForm.Show();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void btnSearch_Click(object sender, EventArgs e)
|
||
{
|
||
var lstShopId = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||
if (lstShopId.Count == 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("请选择店铺!");
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void dgvSelectProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||
return;
|
||
string headerText = dgvSelectProduct.Columns[e.ColumnIndex].HeaderText;
|
||
var dbId = dgvSelectProduct.Rows[e.RowIndex].Cells["colSelectId"].Value.ParseToString();
|
||
var dbProduct = lstTemuDBProductSelect.FirstOrDefault(p => p.id.ToString() == dbId);
|
||
var shopId = dgvSelectProduct.Rows[e.RowIndex].Cells["colSupplierId"].Value.ParseToString();
|
||
var draftId = dgvSelectProduct.Rows[e.RowIndex].Cells["colDraftId"].Value.ParseToString();
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||
|
||
switch (headerText)
|
||
{
|
||
case "删除":
|
||
break;
|
||
case "登录":
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
//shopLoginForm.prodUserSelectForm = this;
|
||
shopLoginForm.openType = EnumOpenType.login;
|
||
shopLoginForm.ShowDialog();
|
||
RefreshShopLogin();
|
||
}
|
||
break;
|
||
case "进店":
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||
if (shop.LoginStatus == "登录成功")
|
||
{
|
||
shopLoginForm.openType = EnumOpenType.manage;
|
||
shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home";
|
||
shopLoginForm.Show();
|
||
}
|
||
else
|
||
{
|
||
shopLoginForm.openType = EnumOpenType.login;
|
||
shopLoginForm.ShowDialog();
|
||
RefreshShopLogin();
|
||
}
|
||
}
|
||
break;
|
||
case "上传商品Id":
|
||
//if (!string.IsNullOrEmpty(draftId) && shop != null)
|
||
//{
|
||
// ShopLoginForm shopLoginForm = new ShopLoginForm(shop);
|
||
// shopLoginForm.InitUrl = "https://seller.kuajingmaihuo.com/goods/product-create/product-edit?productDraftId=" +
|
||
// draftId + "&from=productDraftList";
|
||
// shopLoginForm.openType = EnumOpenType.manage;
|
||
// shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
// shopLoginForm.ShowDialog();
|
||
//}
|
||
break;
|
||
case "图片":
|
||
{
|
||
ShowImgForm imgFrom = new ShowImgForm(dgvSelectProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString());
|
||
imgFrom.ShowDialog();
|
||
break;
|
||
}
|
||
case "SKU替换图":
|
||
{
|
||
ShowImgForm imgFrom = new ShowImgForm(dgvSelectProduct.Rows[e.RowIndex].Cells["colSkuFakeImgUrl"].Value.ParseToString());
|
||
imgFrom.ShowDialog();
|
||
break;
|
||
}
|
||
case "":
|
||
dgvSelectProduct.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvSelectProduct.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
private void btnSetPreSale_Click(object sender, EventArgs e)
|
||
{
|
||
var rowLst = dgvSelectProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colCheck"].Value.ParseToBool() == true).ToList();
|
||
if (rowLst.Count <= 0)
|
||
{
|
||
BaseMsgForm.ShowError("请勾选需要操作的商品!");
|
||
return;
|
||
}
|
||
|
||
this.pbLoading.Visible = true;
|
||
this.btnSetPreSale.Enabled = false;
|
||
cancellationTokenSource = new CancellationTokenSource();
|
||
Task.Run(() =>
|
||
{
|
||
SetProdAddress(rowLst);
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.statusBar.lblTaskStatus.Text = "商品设置完毕";
|
||
BaseMsgForm.ShowInfo("商品设置完毕");
|
||
this.pbLoading.Visible = false;
|
||
this.btnSetPreSale.Enabled = true;
|
||
}));
|
||
}, cancellationTokenSource.Token);
|
||
|
||
}
|
||
|
||
void SetProdAddress(List<DataGridViewRow> rowLst)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.pbLoading.Visible = true;
|
||
this.statusBar.lblTaskStatus.Text = "正在设置" + "...".Substring(0, DateTime.Now.Second % 4);
|
||
this.statusBar.pgbTaskProgress.Maximum = dgvSelectProduct.Rows.Count;
|
||
this.statusBar.UpdateProgressBar(0);
|
||
}));
|
||
|
||
foreach (var row in rowLst)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = "";
|
||
}));
|
||
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
break;
|
||
|
||
var prodId = row.Cells["colDraftId"].Value.ParseToString();
|
||
var shopId = row.Cells["colSupplierId"].Value.ParseToString();
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||
if (shop == null)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = "店铺不存在";
|
||
}));
|
||
continue;
|
||
}
|
||
if (shop.LoginStatus != "登录成功")
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = "店铺掉线";
|
||
}));
|
||
continue;
|
||
}
|
||
//shop = new ShopLoginInfo();
|
||
var getEditProdRst = WXUpload.getEditProductV2(shop, prodId);
|
||
Thread.Sleep(Randomx.GetId(50, 100));
|
||
if (getEditProdRst.Contains("biz magic invalid"))
|
||
{
|
||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||
}
|
||
if (!getEditProdRst.Contains("\"success\":true"))
|
||
{
|
||
var errmsg = BaseRegex.GetStringJson(ref getEditProdRst, "msg");
|
||
if (string.IsNullOrWhiteSpace(errmsg))
|
||
errmsg = getEditProdRst;
|
||
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = errmsg;
|
||
}));
|
||
continue;
|
||
}
|
||
|
||
string productJson = "";
|
||
try
|
||
{
|
||
string addressId = "";
|
||
string setAddressRst = WXProdNoCheckEditHelper.SetShanghaiReturnOrderAddress(shop);
|
||
if (setAddressRst.Contains("\"success\":true"))
|
||
{
|
||
addressId = WXProdNoCheckEditHelper.dicShopAddressId[shop.ShopId];
|
||
}
|
||
else
|
||
{
|
||
var errmsg = BaseRegex.GetStringJson(ref setAddressRst, "msg");
|
||
if (string.IsNullOrWhiteSpace(errmsg))
|
||
errmsg = setAddressRst;
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = errmsg;
|
||
}));
|
||
continue;
|
||
}
|
||
|
||
// 收件人:百家姓随机
|
||
// 手机号:13024622251(马老师手机号)
|
||
// 上海市普陀区真如镇街道真北路2653弄Z区zt
|
||
// 获取免审编辑回传数据
|
||
JObject jObjTmp = JsonHelper.JObjectParse(getEditProdRst);
|
||
//jObjTmp["product"]["deliverInfo"]["skuDeliverInfo"]["fullPaymentPresaleDeliveryTime"] = chkPreSale.Checked ? txtPreDays.Text.Trim().ParseToInt() : 0;
|
||
//jObjTmp["product"]["deliverInfo"]["deliverType"] = chkPreSale.Checked ? 1 : 0;
|
||
//jObjTmp["product"]["info"]["presaleTag"] = chkPreSale.Checked ? 1 : 0;
|
||
//jObjTmp["product"]["info"]["presaleTagType"] = chkPreSale.Checked ? 1 : 0;
|
||
jObjTmp["product"]["info"]["afterSaleInfo"]["afterSaleAddressId"] = addressId;
|
||
productJson = JsonHelper.SerializeObject(jObjTmp);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = ex.Message;
|
||
}));
|
||
continue;
|
||
}
|
||
|
||
DateTime tickTime = DateTime.Now.AddSeconds(0 - Randomx.GetId(10, 30));
|
||
int time1 = BaseClass.DateTimeToTimestampSeconds(tickTime) - Randomx.GetId(80, 150);
|
||
int time2 = BaseClass.DateTimeToTimestampSeconds(tickTime);
|
||
|
||
// 提交免审修改(实际生效接口)
|
||
var listingAuditFreeRst = WXUpload.listingAuditFree(shop, productJson, prodId, time1, time2);
|
||
System.Threading.Thread.Sleep(Randomx.GetId(100, 500));
|
||
if (!listingAuditFreeRst.Contains("\"code\":0"))
|
||
{
|
||
var errmsg = BaseRegex.GetStringJson(ref listingAuditFreeRst, "msg");
|
||
if (string.IsNullOrWhiteSpace(errmsg))
|
||
errmsg = listingAuditFreeRst;
|
||
if (errmsg.Contains("9401083"))
|
||
errmsg = "店铺处罚中禁止操作";
|
||
|
||
if (getEditProdRst.Contains("biz magic invalid"))
|
||
{
|
||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = "店铺掉线";
|
||
}));
|
||
continue;
|
||
}
|
||
|
||
if (chkFailDownProd.Checked)
|
||
{
|
||
int saleCount = 99999999;
|
||
if (chkNotDownCount.Checked)
|
||
{
|
||
Invoke(new Action(() => { saleCount = txtNotDownCount.Text.Trim().ParseToInt(); }));
|
||
}
|
||
|
||
if (chkNotDownCount.Checked && row.Cells["colSoldNum"].Value.ParseToInt() >= saleCount)
|
||
{
|
||
errmsg += " 退货地址设置失败 销量大于" + saleCount + ",不下架";
|
||
}
|
||
else
|
||
{
|
||
var downProd = WXProdNoCheckEditHelper.DownProd(shop, prodId);
|
||
System.Threading.Thread.Sleep(Randomx.GetId(50, 100));
|
||
if (downProd.Contains("\"code\":0"))
|
||
{
|
||
errmsg += " 退货地址设置失败 已下架";
|
||
}
|
||
else
|
||
errmsg += " 退货地址设置失败 下架失败";
|
||
}
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = errmsg;
|
||
}));
|
||
continue;
|
||
}
|
||
if (listingAuditFreeRst.Contains("\"code\":0"))
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colOpResult"].Value = "设置成功";
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private void btnStop_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.cancellationTokenSource != null)
|
||
this.cancellationTokenSource.Cancel();
|
||
}
|
||
|
||
private void btnSearchProd_Click(object sender, EventArgs e)
|
||
{
|
||
var shopIdLst = dgvShop.Rows.Cast<DataGridViewRow>().Where(row
|
||
=> row.Cells["colSelect"]?.Value.ParseToBool() == true).Select(r => r.Cells["colShopId"]?.Value.ToString()).ToList();
|
||
if (shopIdLst.Count <= 0)
|
||
{
|
||
BaseMsgForm.ShowError("未勾选上传店铺!");
|
||
return;
|
||
}
|
||
btnSearchProd.Enabled = false;
|
||
pbLoading.Visible = true;
|
||
cancellationTokenSource = new CancellationTokenSource();
|
||
dgvSelectProduct.Rows.Clear();
|
||
Task.Run(() =>
|
||
{
|
||
GetProduct(shopIdLst);
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.statusBar.lblTaskStatus.Text = "商品查询完毕";
|
||
BaseMsgForm.ShowInfo("商品查询完毕");
|
||
pbLoading.Visible = false;
|
||
btnSearchProd.Enabled = true;
|
||
}));
|
||
}, cancellationTokenSource.Token);
|
||
}
|
||
|
||
void GetProduct(List<string> shopIdLst)
|
||
{
|
||
List<ShopLoginInfo> shopLst = GlobalConfig.ShopLoginList.Where(s => shopIdLst.Contains(s.ShopId)).ToList();
|
||
foreach (var shop in shopLst)
|
||
{
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
break;
|
||
|
||
if (shop.LoginStatus != "登录成功")
|
||
{
|
||
continue;
|
||
}
|
||
|
||
int page = PageBegin - 1;
|
||
int totalPage = 1;
|
||
int pageSize = 50;
|
||
string nextKey = "";
|
||
while (page < totalPage && page < PageEnd)
|
||
{
|
||
page++;
|
||
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
break;
|
||
|
||
string getProdOnSaleRst = "";
|
||
int onSaleStatusCode = -1;
|
||
if (OnSaleStatus == "在售")
|
||
onSaleStatusCode = 5;
|
||
else if (OnSaleStatus == "下架")
|
||
onSaleStatusCode = 11;
|
||
else if (OnSaleStatus == "审核待处理")
|
||
onSaleStatusCode = 3;
|
||
else if (OnSaleStatus == "草稿箱")
|
||
onSaleStatusCode = 1;
|
||
else if (OnSaleStatus == "回收站")
|
||
onSaleStatusCode = 6;
|
||
|
||
if (string.IsNullOrEmpty(PreType))
|
||
getProdOnSaleRst = WXProdNoCheckEditHelper.scanProductPreview(shop, page, nextKey, pageSize, onSaleStatusCode);
|
||
else
|
||
getProdOnSaleRst = WXProdNoCheckEditHelper.searchProduct(shop, page, PreType == "预售" ? 1 : 0, pageSize, onSaleStatusCode);
|
||
Thread.Sleep(Randomx.GetId(50, 100));
|
||
if (!getProdOnSaleRst.Contains("\"success\":true"))
|
||
{
|
||
var error = BaseRegex.GetStringJson(ref getProdOnSaleRst, "msg");
|
||
if (string.IsNullOrEmpty(error))
|
||
error = getProdOnSaleRst;
|
||
|
||
WXShopListForm.Instance.CheckShopLogin(new ShopLoginInfo[] { shop }, false);
|
||
if (shop.LoginStatus != "登录成功")
|
||
{
|
||
Invoke(new Action(() => { BindShop(shop, shopIdLst, "店铺掉线"); }));
|
||
}
|
||
|
||
var shopRow = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
|
||
Invoke(new Action(() =>
|
||
{
|
||
if (shopRow != null)
|
||
{
|
||
shopRow.Cells["colMessage"].Value = error;
|
||
}
|
||
}));
|
||
break;
|
||
}
|
||
|
||
try
|
||
{
|
||
var prodObjs = JsonHelper.JObjectParse(getProdOnSaleRst);
|
||
if (page == 1 || 1 == 1)
|
||
{
|
||
var totalNum = prodObjs["totalNum"].ParseToInt();
|
||
totalPage = Math.Ceiling(1m * totalNum / pageSize).ParseToInt();
|
||
}
|
||
nextKey = prodObjs["nextKey"].ParseToString();
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.pbLoading.Visible = true;
|
||
this.statusBar.lblTaskStatus.Text = "正在查询店铺:" + shop.ShopAccount + " " + page + "/" + Math.Min(PageEnd, totalPage);
|
||
//this.statusBar.pgbTaskProgress.Maximum = lstTemuDBProductSelect.Count;
|
||
//this.statusBar.UpdateProgressBar(0);
|
||
}));
|
||
bool istTimeOver = false;
|
||
List<Task> tList = new List<Task>();
|
||
foreach (JObject prod in prodObjs["productList"])
|
||
{
|
||
string StatusStr = "";
|
||
int rowIndex = 0;
|
||
var pStr = JsonHelper.SerializeObject(prod);
|
||
var editTime = BaseClass.StampToDateTime(prod["editTime"].ParseToInt());
|
||
if (chkProdTime.Checked && editTime < dtpStartTime.Value)
|
||
{
|
||
istTimeOver = true;
|
||
break;
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
decimal? minPrice = prod["skuList"]?.Min(sk => sk["price"].ParseToDecimal() / 100);
|
||
decimal? maxPrice = prod["skuList"]?.Max(sk => sk["price"].ParseToDecimal() / 100);
|
||
var prodId = prod["productId"].ParseToString();
|
||
if (dgvSelectProduct.Rows.Cast<DataGridViewRow>().Any(r => r.Cells["colDraftId"].ParseToString() == prodId))
|
||
{
|
||
}
|
||
StatusStr = "其他";
|
||
if (prod["status"].ParseToInt() == 5)
|
||
StatusStr = "在售";
|
||
if (prod["status"].ParseToInt() == 11)
|
||
StatusStr = "下架";
|
||
if (prod["status"].ParseToInt() == 0)
|
||
{
|
||
StatusStr = "草稿箱";
|
||
if (prod["editStatus"].ParseToInt() == 3)
|
||
StatusStr = "审核待处理";
|
||
}
|
||
if (prod["status"].ParseToInt() == 6)
|
||
StatusStr = "回收站";
|
||
var Limit1 = pStr.Contains("同款/高度相似商品") ? "\r\n上架相似品" : "";
|
||
//var Limit2 = BaseRegex.GetStringJson(ref pStr, "secondLevelLabelName").ParseToString().Length > 0 ? "\r\n命中低风险规则上架" : "";
|
||
var Limit2 = BaseRegex.GetStringJson(ref pStr, "secondLevelLabelName").ParseToString().Length > 0 ? "\r\n低风险规则上架" : "";
|
||
StatusStr += Limit1 + Limit2;
|
||
|
||
rowIndex = this.dgvSelectProduct.Rows.Add(
|
||
false,
|
||
"",
|
||
shop.ShopId,
|
||
shop.ShopAccount,
|
||
"登录",
|
||
"进店",
|
||
"",
|
||
"",
|
||
prod["productId"].ParseToString(),
|
||
prod["headImg"].ParseToString(),
|
||
DataGridViewExtension.defaultBitmap,
|
||
"", // 替换图地址
|
||
null, // 替换图
|
||
prod["title"].ParseToString(), // 用户端显示商品原名
|
||
"", // 推广短链
|
||
(prod["recommendCategory"].IsJTokenNullOrEmpty() || prod["recommendCategory"]["categoryNames"].IsJTokenNullOrEmpty()) ?
|
||
"" : string.Join(" >> ", prod["recommendCategory"]["categoryNames"].Select(s => s.ParseToString())), // 类目名称
|
||
prod["spuCode"].ParseToString(),
|
||
prod["skuList"].ParseToString(),
|
||
//prod["price"].ParseToDecimal() * 0.01m,
|
||
"" + minPrice + " - " + maxPrice,
|
||
prod["soldNum"].ParseToInt(),
|
||
StatusStr,
|
||
prod["presaleTag"].ParseToInt() == 1 ? "[预售]" : "",
|
||
"", // 备注
|
||
"",
|
||
"删除",
|
||
editTime.ToString("yy-MM-dd HH:mm"),
|
||
"");
|
||
|
||
dgvSelectProduct.Rows[rowIndex].Height = 60;
|
||
Color color = Color.Red;
|
||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "在售")
|
||
color = Color.Blue;
|
||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "下架")
|
||
color = Color.Purple;
|
||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "草稿箱")
|
||
color = Color.DarkOrange;
|
||
if (dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Value.ParseToString() == "回收站")
|
||
color = Color.Gray;
|
||
dgvSelectProduct.Rows[rowIndex].Cells["colMsg"].Style.ForeColor = color;
|
||
dgvSelectProduct.Rows[rowIndex].Cells["colPreSale"].Style.ForeColor = dgvSelectProduct.Rows[rowIndex].Cells["colPreSale"].Value.ParseToString().Contains("预售") ? Color.Green : Color.Blue;
|
||
}));
|
||
}
|
||
while (tList.Count > 0)
|
||
{
|
||
Thread.Sleep(200);
|
||
tList.RemoveAll(ta => ta.IsFaulted || ta.IsCanceled || ta.IsCompleted);
|
||
}
|
||
if (istTimeOver)
|
||
break;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnClearDgv_Click(object sender, EventArgs e)
|
||
{
|
||
var rows = this.dgvSelectProduct.Rows.Cast<DataGridViewRow>().ToList(); //Cast后Rows做foreach循环时仍会夹花跳过,所以要ToList转一个新的数组。
|
||
foreach (var row in rows)
|
||
{
|
||
if (row.Cells["colCheck"].Value.ParseToBool() == true)
|
||
{
|
||
//var draft_id = row.Cells["colDraftId"].Value.ParseToString();
|
||
//upload_draft_product_lst.RemoveAll(p => p.draft_id == draft_id);
|
||
|
||
this.dgvSelectProduct.Rows.Remove(row);
|
||
}
|
||
}
|
||
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_select_upload_draft_products", upload_draft_product_lst);
|
||
}
|
||
|
||
private void btnClearSearch_Click(object sender, EventArgs e)
|
||
{
|
||
chkProdTime.Checked = false;
|
||
dtpStartTime.Value = DateTime.Now.AddMonths(-1);
|
||
cmbPreType.Text = "";
|
||
cmbOnSaleStatus.Text = "在售";
|
||
}
|
||
|
||
private void btnFilterShop_Click(object sender, EventArgs e)
|
||
{
|
||
string notes = cmbFilterShopNotes.Text.Trim().Trim(';');
|
||
if (notes == "全部")
|
||
notes = "";
|
||
List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
string group = cmbFilterShopGroup.Text.Trim().Trim(';');
|
||
if (group == "全部")
|
||
group = "";
|
||
List<string> groupLst = group.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (!row.Cells["colShopName"].Value.ParseToString().Contains(txtFilterShopName.Text.Trim()))
|
||
{
|
||
row.Visible = false;
|
||
row.Cells["colSelect"].Value = false;
|
||
continue;
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(notes) && !notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString()))
|
||
{
|
||
row.Visible = false;
|
||
row.Cells["colSelect"].Value = false;
|
||
continue;
|
||
}
|
||
if (!string.IsNullOrWhiteSpace(group) && !groupLst.Contains(row.Cells["colGroup"].Value.ParseToString()))
|
||
{
|
||
row.Visible = false;
|
||
row.Cells["colSelect"].Value = false;
|
||
continue;
|
||
}
|
||
row.Visible = true;
|
||
}
|
||
}
|
||
|
||
private void btnEmptyShop_Click(object sender, EventArgs e)
|
||
{
|
||
txtFilterShopName.Text = "";
|
||
cmbFilterShopNotes.Text = "全部";
|
||
cmbFilterShopGroup.Text = "全部";
|
||
btnFilterShop_Click(null, null);
|
||
}
|
||
|
||
private void btnReverse_Click(object sender, EventArgs e)
|
||
{
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (row.Visible == true)
|
||
row.Cells["colSelect"].Value = !row.Cells["colSelect"].Value.ParseToBool();
|
||
}
|
||
}
|
||
|
||
private void btnAddSelect_Click(object sender, EventArgs e)
|
||
{
|
||
string notes = cmbFilterShopNotes.Text.Trim().Trim(';');
|
||
if (notes == "全部")
|
||
notes = "";
|
||
List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
string group = cmbFilterShopGroup.Text.Trim().Trim(';');
|
||
if (group == "全部")
|
||
group = "";
|
||
List<string> groupLst = group.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (row.Visible == false)
|
||
continue;
|
||
|
||
if (!row.Cells["colShopName"].Value.ParseToString().Contains(txtFilterShopName.Text.Trim()))
|
||
continue;
|
||
if (!string.IsNullOrWhiteSpace(notes) && !notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString()))
|
||
continue;
|
||
if (!string.IsNullOrWhiteSpace(group) && !groupLst.Contains(row.Cells["colGroup"].Value.ParseToString()))
|
||
continue;
|
||
|
||
row.Cells["colSelect"].Value = true;
|
||
}
|
||
}
|
||
|
||
private void btnAddUnSelect_Click(object sender, EventArgs e)
|
||
{
|
||
string notes = cmbFilterShopNotes.Text.Trim().Trim(';');
|
||
if (notes == "全部")
|
||
notes = "";
|
||
List<string> notesLst = notes.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
string group = cmbFilterShopGroup.Text.Trim().Trim(';');
|
||
if (group == "全部")
|
||
group = "";
|
||
List<string> groupLst = group.Split(new string[] { ";", ";", ",", "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (row.Visible == false)
|
||
continue;
|
||
|
||
if (!row.Cells["colShopName"].Value.ParseToString().Contains(txtFilterShopName.Text.Trim()))
|
||
continue;
|
||
if (!string.IsNullOrWhiteSpace(notes) && !notesLst.Contains(row.Cells["colShopNotes"].Value.ParseToString()))
|
||
continue;
|
||
if (!string.IsNullOrWhiteSpace(group) && !groupLst.Contains(row.Cells["colGroup"].Value.ParseToString()))
|
||
continue;
|
||
|
||
row.Cells["colSelect"].Value = false;
|
||
}
|
||
}
|
||
|
||
private void btnSelectOnline_Click(object sender, EventArgs e)
|
||
{
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (row.Visible == true)
|
||
{
|
||
if (row.Cells["colLoginStatus"].Value.ParseToString() == "在线")
|
||
{
|
||
row.Cells["colSelect"].Value = true;
|
||
}
|
||
else
|
||
{
|
||
row.Cells["colSelect"].Value = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnSelectOffline_Click(object sender, EventArgs e)
|
||
{
|
||
foreach (DataGridViewRow row in dgvShop.Rows)
|
||
{
|
||
if (row.Visible == true)
|
||
{
|
||
if (row.Cells["colLoginStatus"].Value.ParseToString() != "在线")
|
||
{
|
||
row.Cells["colSelect"].Value = true;
|
||
}
|
||
else
|
||
{
|
||
row.Cells["colSelect"].Value = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void txtPageEnd_TextChanged(object sender, EventArgs e)
|
||
{
|
||
PageEnd = txtPageEnd.Text.ParseToInt();
|
||
}
|
||
|
||
private void cmbPreType_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
PreType = cmbPreType.Text.Trim();
|
||
}
|
||
|
||
private void cmbOnSaleStatus_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void cmbOnSaleStatus_TextChanged(object sender, EventArgs e)
|
||
{
|
||
OnSaleStatus = cmbOnSaleStatus.Text;
|
||
}
|
||
|
||
private void chkProdTime_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnFilter_Click(object sender, EventArgs e)
|
||
{
|
||
foreach(DataGridViewRow row in dgvSelectProduct.Rows)
|
||
{
|
||
if (!txtFilterProductId.Text.IsNullOrEmpty() && !("," + txtFilterProductId.Text + ",").Contains( row.Cells["colDraftId"].Value.ParseToString()))
|
||
{
|
||
row.Cells["colCheck"].Value = false;
|
||
row.Visible = false;
|
||
}
|
||
else if (!txtFilterProductName.Text.IsNullOrEmpty() && !("," + txtFilterProductName.Text + ",").Contains(row.Cells["colProductName"].Value.ParseToString()) &&
|
||
!row.Cells["colProductName"].Value.ParseToString().Contains(txtFilterProductName.Text))
|
||
{
|
||
row.Cells["colCheck"].Value = false;
|
||
row.Visible = false;
|
||
}
|
||
else
|
||
{
|
||
row.Visible = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnClearFilter_Click(object sender, EventArgs e)
|
||
{
|
||
txtFilterProductName.Text = txtFilterProductId.Text = "";
|
||
}
|
||
}
|
||
}
|