1备货管理提交备货单 2修复店铺登录第一次记录的cookie错误问题
This commit is contained in:
1 parent
862ad088f5
commit
9fe9fa2610
8 files changed
+2056
-769
No files matched your search
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AllBase.Model.Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统待创建备货单
|
||||
/// </summary>
|
||||
public class StockInfo
|
||||
{
|
||||
/// <summary>
|
||||
@@ -44,5 +47,222 @@ namespace AllBase.Model.Result
|
||||
/// skc图片
|
||||
/// </summary>
|
||||
public string productSkcPicture { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否取消待创建备货单
|
||||
/// </summary>
|
||||
public bool isCancel { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 待备货商品信息
|
||||
/// </summary>
|
||||
public class SubOrderInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 卖家店铺id
|
||||
/// </summary>
|
||||
public long supplierId { get; set; }
|
||||
/// <summary>
|
||||
/// 卖家店铺名称
|
||||
/// </summary>
|
||||
public string supplierName { get; set; }
|
||||
/// <summary>
|
||||
/// 商品名
|
||||
/// </summary>
|
||||
public string productName { get; set; }
|
||||
/// <summary>
|
||||
/// 商品Id
|
||||
/// </summary>
|
||||
public long productId { get; set; }
|
||||
/// <summary>
|
||||
/// 商品Skc
|
||||
/// </summary>
|
||||
public long productSkcId { get; set; }
|
||||
/// <summary>
|
||||
/// skc图片
|
||||
/// </summary>
|
||||
public string productSkcPicture { get; set; }
|
||||
/// <summary>
|
||||
/// sku列表信息
|
||||
/// </summary>
|
||||
public List<SkuQuantityInfo> skuQuantityDetailList { get; set; } = new List<SkuQuantityInfo>();
|
||||
/// <summary>
|
||||
/// sku总计
|
||||
/// </summary>
|
||||
public SkuQuantityInfo skuQuantityTotalInfo { get; set; }
|
||||
/// <summary>
|
||||
/// 备货仓组Id列表
|
||||
/// </summary>
|
||||
public List<long> warehouseGroupIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要备货
|
||||
/// </summary>
|
||||
public bool needStockUp { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 临时存储已创建备货单信息
|
||||
/// </summary>
|
||||
public bool isStockUp { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sku数量信息
|
||||
/// </summary>
|
||||
public class SkuQuantityInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// sku编号
|
||||
/// </summary>
|
||||
public long? productSkuId { get; set; }
|
||||
/// <summary>
|
||||
/// sku名称
|
||||
/// </summary>
|
||||
public string className { get; set; }
|
||||
/// <summary>
|
||||
/// 备货仓组
|
||||
/// </summary>
|
||||
public string warehouseGroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 累计加购数量
|
||||
/// </summary>
|
||||
public int? inCardNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 近7日加购数量
|
||||
/// </summary>
|
||||
public int? inCartNumber7d { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日销量
|
||||
/// </summary>
|
||||
public int? todaySaleVolume { get; set; }
|
||||
/// <summary>
|
||||
/// 近七日销量
|
||||
/// </summary>
|
||||
public int? lastSevenDaysSaleVolume { get; set; }
|
||||
/// <summary>
|
||||
/// 近30天销量
|
||||
/// </summary>
|
||||
public int? lastThirtyDaysSaleVolume { get; set; }
|
||||
/// <summary>
|
||||
/// 申报价格 CNY 分
|
||||
/// </summary>
|
||||
public int? supplierPrice { get; set; }
|
||||
///// <summary>
|
||||
///// 仓内可用库存
|
||||
///// </summary>
|
||||
//public int? salesInventoryNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 建议备货引导(为true无需备货?)
|
||||
/// </summary>
|
||||
public bool? showStockGuide { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 建议备货数量
|
||||
/// </summary>
|
||||
public int? adviceQuantity { get; set; }
|
||||
|
||||
public InventoryNumInfo inventoryNumInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 拟备货数量,=0不备货
|
||||
/// </summary>
|
||||
public int wantStockUpBound { get; set; } = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 备货相关库存数量
|
||||
/// </summary>
|
||||
public class InventoryNumInfo
|
||||
{
|
||||
public int? waitOnShelfNum {get;set;}
|
||||
public int? arrivalDelayNum { get; set; }
|
||||
/// <summary>
|
||||
/// 已创建备货单待发货库存
|
||||
/// </summary>
|
||||
public int? waitDeliveryInventoryNum { get; set; }
|
||||
public int? salesInventoryNum { get; set; }
|
||||
public int? deliveryDelayNum { get; set; }
|
||||
/// <summary>
|
||||
/// 仓内可用库存
|
||||
/// </summary>
|
||||
public int? warehouseInventoryNum { get; set; }
|
||||
public int? expectedOccupiedInventoryNum { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库预占用库存
|
||||
/// </summary>
|
||||
public int? normalLockNumber { get; set; }
|
||||
public int? waitApproveInventoryNum { get; set; }
|
||||
public int? waitQcNum { get; set; }
|
||||
public int? unavailableWarehouseInventoryNum { get; set; }
|
||||
public int? waitInStock { get; set; }
|
||||
/// <summary>
|
||||
/// 已发货库存
|
||||
/// </summary>
|
||||
public int? waitReceiveNum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备货商品基础信息
|
||||
/// </summary>
|
||||
public class stockBaseInfo
|
||||
{
|
||||
public string productName { get; set; }
|
||||
public string catName { get; set; }
|
||||
public string productSkcId { get; set; }
|
||||
public string productSkcPicture { get; set; }
|
||||
public long supplierId { get; set; }
|
||||
public string supplierName { get; set; }
|
||||
public bool punishVmiUrgencyOrder { get; set; }
|
||||
public string purchaseConfig { get; set; }
|
||||
public List<purchaseConfigDetail> purchaseConfigDetailList { get; set; } = new List<purchaseConfigDetail>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 配货sku配置详情
|
||||
/// </summary>
|
||||
public class purchaseConfigDetail
|
||||
{
|
||||
public bool isReducePricePass { get; set; }
|
||||
public bool isVerifyPrice { get; set; }
|
||||
/// <summary>
|
||||
/// 价格单位 CNY
|
||||
/// </summary>
|
||||
public string currencyType { get; set; }
|
||||
/// <summary>
|
||||
/// sku价格 2800 分
|
||||
/// </summary>
|
||||
public int supplierPrice { get; set; }
|
||||
/// <summary>
|
||||
/// sku名称 12color gel pens
|
||||
/// </summary>
|
||||
public string className { get; set; }
|
||||
public long productSkuId { get; set; }
|
||||
public int? exceptQuantity { get; set; }
|
||||
public int? applyQuantity { get; set; }
|
||||
public int? lastSevenDaysSaleVolume { get; set; }
|
||||
public int? availableSaleDays { get; set; }
|
||||
public int? stockOut { get; set; }
|
||||
public int? urgencyPurchaseNum { get; set; }
|
||||
public int? auditLowerBound { get; set; }
|
||||
public int? auditUpperBound { get; set; }
|
||||
/// <summary>
|
||||
/// 备货量上限
|
||||
/// </summary>
|
||||
public int? applyUpperBound { get; set; }
|
||||
/// <summary>
|
||||
/// 备货量下限
|
||||
/// </summary>
|
||||
public int? applyLowerBound { get; set; }
|
||||
public int? exceptQuantityWhenApply { get; set; }
|
||||
public int? addPurchaseNumBound { get; set; }
|
||||
/// <summary>
|
||||
/// 备货逻辑 "0 + 0"
|
||||
/// </summary>
|
||||
public string purchaseConfig { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -120,17 +120,19 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
{
|
||||
foreach (var cookie in cookieList)
|
||||
{
|
||||
//if (cookies.Contains(cookie.Name + "=" + cookie.Value))
|
||||
// continue;
|
||||
//SUB_PASS_ID要用domain是seller.kuajingmaihuo.com才是能登录店铺后台的
|
||||
if (cookie.Name == "SUB_PASS_ID" && cookie.Domain != "seller.kuajingmaihuo.com")
|
||||
continue;
|
||||
|
||||
cookies += cookie.Name + "=" + cookie.Value + "; ";
|
||||
}
|
||||
cookies = cookies.Trim().TrimEnd(';');
|
||||
}
|
||||
shop.Cookies = cookies;
|
||||
|
||||
if (!string.IsNullOrEmpty(cookies)
|
||||
&& lstShopCompany.Any(c => c.LoginName == shop.LoginName))
|
||||
{
|
||||
shop.Cookies = cookies;
|
||||
var lstShopCompanyCopy = lstShopCompany.ToList();
|
||||
lstShopCompanyCopy = lstShopCompanyCopy.Where(l => l.LoginName == shop.LoginName).ToList();
|
||||
|
||||
@@ -280,7 +282,7 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(20);
|
||||
Thread.Sleep(25);
|
||||
cefWebBrowser.Load(shopMainUrl);
|
||||
|
||||
if (openType != EnumOpenType.login)
|
||||
@@ -288,8 +290,10 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
if (cefWebBrowser.IsLoading)
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(1000,1500));
|
||||
|
||||
//设置 local storage
|
||||
//if (GlobalConfig.dicLocalStorage != null)
|
||||
@@ -371,6 +375,8 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
var jArr = jObj["result"]?["companyList"]?[0]?["malInfoList"] as JArray;
|
||||
if (jArr == null)
|
||||
jArr = new JArray();
|
||||
|
||||
Thread.Sleep(500);
|
||||
foreach (var productObj in jArr)
|
||||
{
|
||||
var prod = JsonHelper.SerializeObject(productObj);
|
||||
|
||||
+53
-51
@@ -33,6 +33,9 @@
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.splitContainer5 = new System.Windows.Forms.SplitContainer();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.btnRefresh = new TemuKJD.UserControls.ButtonEx();
|
||||
this.btnCancel = new TemuKJD.UserControls.ButtonEx();
|
||||
this.btnOpUser = new TemuKJD.UserControls.ButtonEx();
|
||||
this.label30 = new System.Windows.Forms.Label();
|
||||
this.label31 = new System.Windows.Forms.Label();
|
||||
this.repasstextBox = new System.Windows.Forms.TextBox();
|
||||
@@ -49,9 +52,6 @@
|
||||
this.label39 = new System.Windows.Forms.Label();
|
||||
this.nametextBox = new System.Windows.Forms.TextBox();
|
||||
this.label40 = new System.Windows.Forms.Label();
|
||||
this.btnRefresh = new TemuKJD.UserControls.ButtonEx();
|
||||
this.btnCancel = new TemuKJD.UserControls.ButtonEx();
|
||||
this.btnOpUser = new TemuKJD.UserControls.ButtonEx();
|
||||
this.dgvUser = new TemuKJD.UserComponent.DataGridViewEx();
|
||||
this.UserIdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.UserNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@@ -118,6 +118,53 @@
|
||||
this.label1.TabIndex = 37;
|
||||
this.label1.Text = "编辑时,密码为空表示不更改原密码。";
|
||||
//
|
||||
// btnRefresh
|
||||
//
|
||||
this.btnRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRefresh.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnRefresh.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnRefresh.ForeColor = System.Drawing.Color.White;
|
||||
this.btnRefresh.Location = new System.Drawing.Point(267, 5);
|
||||
this.btnRefresh.Name = "btnRefresh";
|
||||
this.btnRefresh.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnRefresh.TabIndex = 36;
|
||||
this.btnRefresh.Text = "刷新列表";
|
||||
this.btnRefresh.UseVisualStyleBackColor = false;
|
||||
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnCancel.ForeColor = System.Drawing.Color.White;
|
||||
this.btnCancel.Location = new System.Drawing.Point(59, 328);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnCancel.TabIndex = 35;
|
||||
this.btnCancel.Text = "取消编辑";
|
||||
this.btnCancel.UseVisualStyleBackColor = false;
|
||||
this.btnCancel.Visible = false;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnOpUser
|
||||
//
|
||||
this.btnOpUser.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnOpUser.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnOpUser.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnOpUser.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnOpUser.ForeColor = System.Drawing.Color.White;
|
||||
this.btnOpUser.Location = new System.Drawing.Point(174, 328);
|
||||
this.btnOpUser.Name = "btnOpUser";
|
||||
this.btnOpUser.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnOpUser.TabIndex = 34;
|
||||
this.btnOpUser.Text = "添加用户";
|
||||
this.btnOpUser.UseVisualStyleBackColor = false;
|
||||
this.btnOpUser.Click += new System.EventHandler(this.btnOpUser_Click);
|
||||
//
|
||||
// label30
|
||||
//
|
||||
this.label30.AutoSize = true;
|
||||
@@ -198,6 +245,7 @@
|
||||
//
|
||||
// groupIdcomboBox
|
||||
//
|
||||
this.groupIdcomboBox.Enabled = false;
|
||||
this.groupIdcomboBox.FormattingEnabled = true;
|
||||
this.groupIdcomboBox.Items.AddRange(new object[] {
|
||||
"客服",
|
||||
@@ -209,7 +257,7 @@
|
||||
this.groupIdcomboBox.Name = "groupIdcomboBox";
|
||||
this.groupIdcomboBox.Size = new System.Drawing.Size(148, 25);
|
||||
this.groupIdcomboBox.TabIndex = 26;
|
||||
this.groupIdcomboBox.Text = "采购";
|
||||
this.groupIdcomboBox.Text = "客服";
|
||||
//
|
||||
// label37
|
||||
//
|
||||
@@ -273,53 +321,6 @@
|
||||
this.label40.TabIndex = 18;
|
||||
this.label40.Text = "账户名:";
|
||||
//
|
||||
// btnRefresh
|
||||
//
|
||||
this.btnRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRefresh.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnRefresh.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnRefresh.ForeColor = System.Drawing.Color.White;
|
||||
this.btnRefresh.Location = new System.Drawing.Point(267, 5);
|
||||
this.btnRefresh.Name = "btnRefresh";
|
||||
this.btnRefresh.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnRefresh.TabIndex = 36;
|
||||
this.btnRefresh.Text = "刷新列表";
|
||||
this.btnRefresh.UseVisualStyleBackColor = false;
|
||||
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnCancel.ForeColor = System.Drawing.Color.White;
|
||||
this.btnCancel.Location = new System.Drawing.Point(59, 328);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnCancel.TabIndex = 35;
|
||||
this.btnCancel.Text = "取消编辑";
|
||||
this.btnCancel.UseVisualStyleBackColor = false;
|
||||
this.btnCancel.Visible = false;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnOpUser
|
||||
//
|
||||
this.btnOpUser.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnOpUser.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
|
||||
this.btnOpUser.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnOpUser.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnOpUser.ForeColor = System.Drawing.Color.White;
|
||||
this.btnOpUser.Location = new System.Drawing.Point(174, 328);
|
||||
this.btnOpUser.Name = "btnOpUser";
|
||||
this.btnOpUser.Size = new System.Drawing.Size(86, 25);
|
||||
this.btnOpUser.TabIndex = 34;
|
||||
this.btnOpUser.Text = "添加用户";
|
||||
this.btnOpUser.UseVisualStyleBackColor = false;
|
||||
this.btnOpUser.Click += new System.EventHandler(this.btnOpUser_Click);
|
||||
//
|
||||
// dgvUser
|
||||
//
|
||||
this.dgvUser.AllowUserToAddRows = false;
|
||||
@@ -328,6 +329,7 @@
|
||||
this.dgvUser.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.dgvUser.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dgvUser.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dgvUser.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)));
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
StringBuilder data = new StringBuilder();
|
||||
data.Append(UserLogin.GetSignaturex());
|
||||
data.Append("&name=" + GetHtml.UrlEncodeUtf8(nametextBox.Text));
|
||||
data.Append("&username=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
||||
data.Append("&mobile=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
||||
data.Append("&sub_user_name=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
||||
data.Append("&sub_user_mobile=" + GetHtml.UrlEncodeUtf8(mobiletextBox.Text));
|
||||
if (groupIdcomboBox.Text == "客服")
|
||||
data.Append("&group_id=4");
|
||||
else if (groupIdcomboBox.Text == "采购")
|
||||
@@ -64,7 +64,7 @@ namespace TemuKJD.KJDForms.ShopForms
|
||||
// data.Append("&group_id=8");
|
||||
if (!string.IsNullOrEmpty(passwordtextBox.Text))
|
||||
data.Append("&password=" + Md5Base.GetMd5(passwordtextBox.Text).ToLower());
|
||||
string url = BaseClass.BuildObjString("user&act=add");
|
||||
string url = BaseClass.BuildObjString("user/add_user");
|
||||
if (btnOpUser.Text != "添加用户" && !string.IsNullOrEmpty(Uid))
|
||||
{
|
||||
data.Append("&id=" + Uid);
|
||||
|
||||
+1035
-690
File diff suppressed because it is too large.
Load diff
@@ -25,6 +25,7 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
public partial class StockUpForm : Form
|
||||
{
|
||||
private CheckBox chkSelectAll = null;
|
||||
//private CheckBox chkCheckAll = null;
|
||||
public CancellationTokenSource cancellationTokenSource { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
@@ -32,6 +33,8 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
/// </summary>
|
||||
List<StockInfo> lstStockInfo = new List<StockInfo>();
|
||||
|
||||
List<SubOrderInfo> lstSubOrderInfo = new List<SubOrderInfo>();
|
||||
|
||||
public StockUpForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -45,6 +48,8 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
dgvShop.Columns["colSelect"].HeaderText = "";
|
||||
chkSelectAll.Width = chkSelectAll.Height = 13;
|
||||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||||
|
||||
this.dgvStock.AddSelectorColumn("colCheck");
|
||||
}
|
||||
|
||||
private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
|
||||
@@ -94,7 +99,7 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
// 绑定其他店铺(含新导入的店铺)
|
||||
foreach (DouShopLoginInfo shopEntity in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(shopEntity.ShopId))
|
||||
if (!string.IsNullOrEmpty(shopEntity.ShopId))
|
||||
BindShop(shopEntity, selectIds);
|
||||
}
|
||||
}
|
||||
@@ -140,20 +145,54 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
return;
|
||||
}
|
||||
|
||||
var columns = this.dgvStock.Columns.Cast<DataGridViewColumn>();
|
||||
foreach (var col in columns)
|
||||
{
|
||||
if (col.Name == "colParentStockId" || col.Name == "colStockId")
|
||||
{
|
||||
col.Visible = true;
|
||||
}
|
||||
if (col.Name == "colTodaySaleVolume" || col.Name == "colInCartNumber7d" || col.Name == "colSalesInventoryNum"
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp")
|
||||
{
|
||||
col.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
lstStockInfo.Clear();
|
||||
dgvStock.Rows.Clear();
|
||||
|
||||
var dgvRows = this.dgvShop.Rows.Cast<DataGridViewRow>();//.Where(r => lstShopId.Contains(r.Cells["colShopId"].Value.ParseToString()));
|
||||
foreach (var row in dgvRows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "";
|
||||
}
|
||||
|
||||
string searchText = txtStockid.Text.Trim();
|
||||
btnSearch.Enabled = false;
|
||||
chkHasCreate.Enabled = false;
|
||||
ucGroupBoxEx2.Enabled = false;
|
||||
ucGroupBoxEx3.Enabled = false;
|
||||
ucGroupBoxEx4.Enabled = false;
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
var lstShopIdTemp = new List<string>();
|
||||
lstShopIdTemp.AddRange(lstShopId);
|
||||
int i = 0;
|
||||
|
||||
foreach (var shopId in lstShopIdTemp)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在查询...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + lstShopIdTemp.Count;
|
||||
this.statusBar.pgbTaskProgress.Maximum = lstShopIdTemp.Count;
|
||||
i++;
|
||||
}));
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
@@ -174,8 +213,9 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopLoginName"].Value.ToString() == shop.LoginName);
|
||||
foreach(var row in rows)
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "店铺掉线";
|
||||
row.Cells["colLoginStatus"].Value = "未登录";
|
||||
row.Cells["colCanUse"].Value = false;
|
||||
}
|
||||
@@ -184,19 +224,34 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
}
|
||||
#endregion
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId);
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "正在查询";
|
||||
}
|
||||
}));
|
||||
|
||||
int page = 1;
|
||||
int totalPage = 1;
|
||||
bool isError = false;
|
||||
while (page <= totalPage)
|
||||
{
|
||||
Thread.Sleep(50 + Randomx.GetId(100));
|
||||
string jsonStr = GetStock(shop, page);
|
||||
Thread.Sleep(100 + Randomx.GetId(200));
|
||||
string jsonStr = GetShopStockList(shop, page, chkHasCreate.Checked ? "已送货" : "待创建");
|
||||
if (jsonStr.Contains("指定的值含有无效的控制字符"))
|
||||
{
|
||||
BaseMsgForm.ShowError("店铺" + shop.LoginName + " " + shop.ShopId + "已掉线");
|
||||
isError = true;
|
||||
break;
|
||||
}
|
||||
if (!jsonStr.Contains("\"success\":true"))
|
||||
jsonStr = GetStock(shop, page);
|
||||
jsonStr = GetShopStockList(shop, page, chkHasCreate.Checked ? "已送货" : "待创建");
|
||||
if (!jsonStr.Contains("\"success\":true"))
|
||||
{
|
||||
isError = true;
|
||||
}
|
||||
|
||||
if (jsonStr.Contains("\"success\":true"))
|
||||
{
|
||||
@@ -204,7 +259,7 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
var jArr = jObj["result"]?["subOrderForSupplierList"] as JArray;
|
||||
if (jArr == null)
|
||||
jArr = new JArray();
|
||||
foreach(var item in jArr)
|
||||
foreach (var item in jArr)
|
||||
{
|
||||
string sItem = item.ToString();
|
||||
StockInfo sInfo = JsonHelper.DeserializeJsonToObject<StockInfo>(sItem); // 反序列化得到类
|
||||
@@ -212,18 +267,14 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
{
|
||||
lstStockInfo.Add(sInfo);
|
||||
|
||||
//string url = "https://i0.wp.com/tvax1.sinaimg.cn/large/005DW9w3ly1h7dc70ghc5j32yo1o0773.jpg";
|
||||
//pictureBox1.Image = Image.FromStream(System.Net.WebRequest.Create(url).GetResponse().GetResponseStream());
|
||||
//var httpClient = new HttpClient();
|
||||
//var stream = httpClient.GetStreamAsync("https://i0.wp.com/tvax1.sinaimg.cn/large/005DW9w3ly1h7dc70ghc5j32yo1o0773.jpg").Result; // 异步下载图片流
|
||||
//Image image = Image.FromStream(stream);
|
||||
|
||||
string url = sInfo.productSkcPicture.Replace("https", "http");
|
||||
var image = Image.FromStream(WebRequest.Create(url).GetResponse().GetResponseStream());
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.dgvStock.Rows.Add(
|
||||
int rowId = this.dgvStock.Rows.Add(
|
||||
"",
|
||||
true,
|
||||
sInfo.supplierId,
|
||||
sInfo.supplierName,
|
||||
sInfo.subPurchaseOrderSn,
|
||||
@@ -235,8 +286,14 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
);
|
||||
|
||||
dgvStock.Rows[rowId].Height = 60;
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -246,23 +303,135 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
totalPage = Math.Ceiling(total / 20.0).ParseToInt();
|
||||
page++;
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId);
|
||||
|
||||
if (!isError)
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "已查询";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "查询失败";
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
btnSearch.Enabled = true;
|
||||
chkHasCreate.Enabled = true;
|
||||
ucGroupBoxEx2.Enabled = true;
|
||||
ucGroupBoxEx3.Enabled = true;
|
||||
ucGroupBoxEx4.Enabled = true;
|
||||
string sRst = "查询结束!";
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
sRst = "已取消查询!";
|
||||
|
||||
BaseMsgForm.ShowInfo(sRst);
|
||||
this.statusBar.lblTaskStatus.Text = sRst;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据店铺获取备货单列表
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
private string GetShopStockList(DouShopLoginInfo shop, int page = 1, string type = "待创建")
|
||||
{
|
||||
page = Math.Max(page, 1);
|
||||
string url = "https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/purchase/manager/querySubOrderList";
|
||||
string body;
|
||||
if (type == "已送货")
|
||||
body = @"{""pageNo"":" + page + @",""pageSize"":20,""urgencyType"":0,""isCustomGoods"":false,""statusList"":[2],""oneDimensionSort"":{""firstOrderByParam"":""realDeliverTime"",""firstOrderByDesc"":1}}"; //已送货
|
||||
else
|
||||
body = @"{""pageNo"":" + page + @",""pageSize"":20,""urgencyType"":0,""isCustomGoods"":false,""statusList"":[0],""oneDimensionSort"":{""firstOrderByParam"":""expectLatestDeliverTime"",""firstOrderByDesc"":0}}"; //待创建
|
||||
|
||||
private string GetStock(DouShopLoginInfo shop, int page=1)
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/order-manage";
|
||||
|
||||
return StockResponse(shop, url, body,refere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消待创建
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="subPurchaseOrderSn"></param>
|
||||
/// <returns></returns>
|
||||
private string CancelSubPurchaseOrder(DouShopLoginInfo shop, string subPurchaseOrderSn)
|
||||
{
|
||||
string url = "https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/purchase/manager/batchCancelSubPurchaseOrder";
|
||||
string body = "{\"subPurchaseOrderSnList\":[\"" + subPurchaseOrderSn + "\"]}";
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/order-manage";
|
||||
|
||||
return StockResponse(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string GetWarehouseList(DouShopLoginInfo shop, int page = 1)
|
||||
{
|
||||
page = Math.Max(page, 1);
|
||||
string url = "https://seller.kuajingmaihuo.com/marvel-mms/cn/api/kiana/venom/sales/management/listWarehouse";
|
||||
string body = @"{""pageNo"":" + page + @",""pageSize"":10,""isLack"":0,""selectStatusList"":[12],""priceAdjustRecentDays"":7}";
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/sale-manage/main";
|
||||
|
||||
return StockResponse(shop, url, body, refere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询单个商品申请备货条件
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="subOrderInfo"></param>
|
||||
/// <returns></returns>
|
||||
private string QueryStockBaseInfo(DouShopLoginInfo shop, SubOrderInfo subOrderInfo)
|
||||
{
|
||||
string url = "https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/sales/management/queryStockBaseInfo";
|
||||
string body = "{\"productSkcId\":" + subOrderInfo.productSkcId
|
||||
+ ",\"warehouseGroupId\":" + subOrderInfo.warehouseGroupIdList.FirstOrDefault() + "}";
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/sale-manage/main";
|
||||
return StockResponse(shop, url, body, refere);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单个商品申请备货
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="subOrderInfo"></param>
|
||||
/// <returns></returns>
|
||||
private string CreateStockOrder(DouShopLoginInfo shop, SubOrderInfo subOrderInfo)
|
||||
{
|
||||
string url = "https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/sales/management/createStockOrder";
|
||||
string body = "{\"productSkcId\":" + subOrderInfo.productSkcId + "," +
|
||||
"\"purchaseDetailList\":[";
|
||||
foreach(var sku in subOrderInfo.skuQuantityDetailList)
|
||||
{
|
||||
if (sku.wantStockUpBound>0)
|
||||
body += "{\"productSkuId\":" + sku.productSkuId + ",\"productSkuPurchaseQuantity\":\"" + sku.wantStockUpBound + "\"},";
|
||||
}
|
||||
body = body.TrimEnd(',');
|
||||
body += "],\"warehouseGroupId\":" + subOrderInfo.warehouseGroupIdList.FirstOrDefault() + "}";
|
||||
string refere = "https://seller.kuajingmaihuo.com/main/sale-manage/main";
|
||||
|
||||
return StockResponse(shop, url, body, refere);
|
||||
}
|
||||
|
||||
private string StockResponse(DouShopLoginInfo shop, string _url, string _data, string referer)
|
||||
{
|
||||
HttpWebResponse response = null;
|
||||
string result;
|
||||
try
|
||||
{
|
||||
page = Math.Max(page, 1);
|
||||
string url = "https://seller.kuajingmaihuo.com/oms/bg/venom/api/supplier/purchase/manager/querySubOrderList";
|
||||
string url = _url;
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
|
||||
request.KeepAlive = true;
|
||||
@@ -279,7 +448,7 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
request.Headers.Add("Sec-Fetch-Site", @"same-origin");
|
||||
request.Headers.Add("Sec-Fetch-Mode", @"cors");
|
||||
request.Headers.Add("Sec-Fetch-Dest", @"empty");
|
||||
request.Referer = "https://seller.kuajingmaihuo.com/main/order-manage";
|
||||
request.Referer = referer;
|
||||
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br, zstd");
|
||||
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
|
||||
request.Headers.Set(HttpRequestHeader.Cookie, shop.Cookies);
|
||||
@@ -287,7 +456,7 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
request.Method = "POST";
|
||||
request.ServicePoint.Expect100Continue = false;
|
||||
|
||||
string body = @"{""pageNo"":" + page + @",""pageSize"":20,""urgencyType"":0,""isCustomGoods"":false,""statusList"":[2],""oneDimensionSort"":{""firstOrderByParam"":""realDeliverTime"",""firstOrderByDesc"":1}}";
|
||||
string body = _data;
|
||||
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
|
||||
request.ContentLength = postBytes.Length;
|
||||
Stream stream = request.GetRequestStream();
|
||||
@@ -331,10 +500,13 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
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
|
||||
{
|
||||
@@ -343,5 +515,528 @@ namespace TemuKJD.KJDForms.UploadForms
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
private void dgvStock_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
string columnName = dgvStock.Columns[e.ColumnIndex].Name;
|
||||
var row = dgvStock.Rows[e.RowIndex];
|
||||
switch (columnName)
|
||||
{
|
||||
case "colCheck":
|
||||
row.Cells["colCheck"].Value = !row.Cells["colCheck"].Value.ParseToBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancelSubPurchaseOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var lstStockOrderSn = dgvStock.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colCheck"]?.Value.ParseToBool() == true).Select(r => r.Cells["colStockId"]?.Value.ToString()).ToList();
|
||||
var lstStock = lstStockInfo.Where(s => lstStockOrderSn.Contains(s.subPurchaseOrderSn)).ToList();
|
||||
if (lstStock.Count == 0)
|
||||
{
|
||||
BaseMsgForm.ShowInfo("请选择要取消的待创建备货单!");
|
||||
return;
|
||||
}
|
||||
|
||||
string searchText = txtStockid.Text.Trim();
|
||||
btnCancelSubPurchaseOrder.Enabled = false;
|
||||
ucGroupBoxEx2.Enabled = false;
|
||||
ucGroupBoxEx3.Enabled = false;
|
||||
ucGroupBoxEx4.Enabled = false;
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var stock in lstStock)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在取消待创建...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + lstStock.Count;
|
||||
this.statusBar.pgbTaskProgress.Maximum = lstStock.Count;
|
||||
i++;
|
||||
}));
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
var rows = this.dgvStock.Rows.Cast<DataGridViewRow>().Where(r =>
|
||||
r.Cells["colStockId"].Value.ToString() == stock.subPurchaseOrderSn);
|
||||
|
||||
|
||||
if (stock.isCancel)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "待创建备货单已取消";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == stock.supplierId.ToString());
|
||||
if (shop == null || shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "店铺掉线或不存在";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "正在取消";
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.Sleep(200 + Randomx.GetId(100));
|
||||
//string jsonStr = "{\"success\":true,\"errorCode\":1000000,\"errorMsg\":null,\"result\":{\"isSuccess\":true,\"errorInfoList\":[],\"successInfoList\":[]}}";
|
||||
string jsonStr = CancelSubPurchaseOrder(shop, stock.subPurchaseOrderSn);
|
||||
bool isError = !jsonStr.Contains("\"success\":true");
|
||||
string sErrMsg = BaseRegex.GetStringJson(ref jsonStr, "errorMsg");
|
||||
if (!isError)
|
||||
{
|
||||
var jObj = JObject.Parse(jsonStr);
|
||||
var jItem = jObj["result"];
|
||||
var subJsonstr = jItem == null ? "" : JsonHelper.SerializeObject(jItem);
|
||||
isError = !subJsonstr.Contains("\"isSuccess\":true");
|
||||
sErrMsg = BaseRegex.GetStringJson(ref subJsonstr, "errorMsg");
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (!isError)
|
||||
{
|
||||
stock.isCancel = true;
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "已取消待创建";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "取消待创建失败:" + sErrMsg;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
btnCancelSubPurchaseOrder.Enabled = true;
|
||||
ucGroupBoxEx2.Enabled = true;
|
||||
ucGroupBoxEx3.Enabled = true;
|
||||
ucGroupBoxEx4.Enabled = true;
|
||||
string sRst = "操作结束(取消待创建)!";
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
sRst = "已取消操作(取消待创建)!";
|
||||
|
||||
BaseMsgForm.ShowInfo(sRst);
|
||||
this.statusBar.lblTaskStatus.Text = sRst;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
private void btnListWarehouse_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;
|
||||
}
|
||||
|
||||
lstSubOrderInfo.Clear();
|
||||
dgvStock.Rows.Clear();
|
||||
|
||||
int scale1 = this.txtScale1.Text.ParseToInt();
|
||||
int scale2 = this.txtScale2.Text.ParseToInt();
|
||||
|
||||
var dgvRows = this.dgvShop.Rows.Cast<DataGridViewRow>();//.Where(r => lstShopId.Contains(r.Cells["colShopId"].Value.ParseToString()));
|
||||
foreach (var row in dgvRows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "";
|
||||
}
|
||||
|
||||
var columns = this.dgvStock.Columns.Cast<DataGridViewColumn>();
|
||||
foreach (var col in columns)
|
||||
{
|
||||
if (col.Name == "colParentStockId" || col.Name == "colStockId")
|
||||
{
|
||||
col.Visible = false;
|
||||
}
|
||||
if (col.Name == "colTodaySaleVolume" || col.Name == "colInCartNumber7d" || col.Name == "colSalesInventoryNum"
|
||||
|| col.Name == "colWaitReceiveNum" || col.Name == "colNeedStockUp")
|
||||
{
|
||||
col.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
string searchText = txtStockid.Text.Trim();
|
||||
btnListWarehouse.Enabled = false;
|
||||
btnSearch.Enabled = false;
|
||||
chkHasCreate.Enabled = false;
|
||||
ucGroupBoxEx2.Enabled = false;
|
||||
ucGroupBoxEx3.Enabled = false;
|
||||
ucGroupBoxEx4.Enabled = false;
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
var lstShopIdTemp = new List<string>();
|
||||
lstShopIdTemp.AddRange(lstShopId);
|
||||
int i = 0;
|
||||
|
||||
foreach (var shopId in lstShopIdTemp)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在查询...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + lstShopIdTemp.Count;
|
||||
this.statusBar.pgbTaskProgress.Maximum = lstShopIdTemp.Count;
|
||||
i++;
|
||||
}));
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == shopId);
|
||||
if (shop == null)
|
||||
continue;
|
||||
|
||||
#region 检测登录
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ShopListForm.Instance == null)
|
||||
ShopListForm.Instance = new ShopListForm();
|
||||
ShopListForm.Instance.CheckShopLogin(new string[] { shop.LoginName }, false);
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopLoginName"].Value.ToString() == shop.LoginName);
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "店铺掉线";
|
||||
row.Cells["colLoginStatus"].Value = "未登录";
|
||||
row.Cells["colCanUse"].Value = false;
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId);
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "正在查询";
|
||||
}
|
||||
}));
|
||||
|
||||
int page = 1;
|
||||
int totalPage = 1;
|
||||
bool isError = false;
|
||||
while (page <= totalPage)
|
||||
{
|
||||
Thread.Sleep(100 + Randomx.GetId(200));
|
||||
string jsonStr = GetWarehouseList(shop, page);
|
||||
if (jsonStr.Contains("指定的值含有无效的控制字符"))
|
||||
{
|
||||
BaseMsgForm.ShowError("店铺" + shop.LoginName + " " + shop.ShopId + "已掉线");
|
||||
isError = true;
|
||||
break;
|
||||
}
|
||||
if (!jsonStr.Contains("\"success\":true"))
|
||||
jsonStr = GetWarehouseList(shop, page);
|
||||
if (!jsonStr.Contains("\"success\":true"))
|
||||
{
|
||||
isError = true;
|
||||
}
|
||||
|
||||
if (jsonStr.Contains("\"success\":true"))
|
||||
{
|
||||
var jObj = JObject.Parse(jsonStr);
|
||||
var jArr = jObj["result"]?["subOrderList"] as JArray;
|
||||
if (jArr == null)
|
||||
jArr = new JArray();
|
||||
foreach (var item in jArr)
|
||||
{
|
||||
string sItem = item.ToString();
|
||||
SubOrderInfo sInfo = JsonHelper.DeserializeJsonToObject<SubOrderInfo>(sItem); // 反序列化得到类
|
||||
if (sInfo != null)
|
||||
{
|
||||
foreach(var sku in sInfo.skuQuantityDetailList)
|
||||
{
|
||||
// 近7日加购>今日销量使用系数2,否则使用系数1
|
||||
// 拟申请备货数量=今日销量×系数-仓内可用库存-已发货库存
|
||||
// 实际备货数量=平台实际允许数量和拟申请备货数量取小(申请备货时计算)
|
||||
int scale = scale1;
|
||||
if (sku.inCartNumber7d.ParseToInt() > sku.todaySaleVolume.ParseToInt())
|
||||
{
|
||||
scale = scale2;
|
||||
}
|
||||
sku.wantStockUpBound = sku.todaySaleVolume.ParseToInt() * scale
|
||||
- sku.inventoryNumInfo.warehouseInventoryNum.ParseToInt()
|
||||
- sku.inventoryNumInfo.waitReceiveNum.ParseToInt();
|
||||
sku.wantStockUpBound = Math.Max(sku.wantStockUpBound, 0);
|
||||
}
|
||||
if (sInfo.skuQuantityDetailList.Any(s => s.wantStockUpBound > 0))
|
||||
sInfo.needStockUp = true;
|
||||
else
|
||||
sInfo.needStockUp = false;
|
||||
lstSubOrderInfo.Add(sInfo);
|
||||
|
||||
string url = sInfo.productSkcPicture.Replace("https", "http");
|
||||
var image = Image.FromStream(WebRequest.Create(url).GetResponse().GetResponseStream());
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
int rowId = this.dgvStock.Rows.Add(
|
||||
"",
|
||||
true,
|
||||
sInfo.supplierId,
|
||||
sInfo.supplierName,
|
||||
"",//sInfo.subPurchaseOrderSn,
|
||||
"",//sInfo.originalPurchaseOrderSn,
|
||||
image,
|
||||
sInfo.productId,
|
||||
sInfo.productSkcId,
|
||||
sInfo.productName,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
sInfo.skuQuantityTotalInfo.inCartNumber7d,
|
||||
sInfo.skuQuantityTotalInfo.todaySaleVolume,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.warehouseInventoryNum,
|
||||
sInfo.skuQuantityTotalInfo.inventoryNumInfo.waitReceiveNum,
|
||||
sInfo.needStockUp == false ? "无需备货" : "可备货",
|
||||
""
|
||||
);
|
||||
|
||||
dgvStock.Rows[rowId].Height = 60;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int total = BaseRegex.GetStringJson(ref jsonStr, "total").ParseToInt();
|
||||
totalPage = Math.Ceiling(total / 10.0).ParseToInt();
|
||||
page++;
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rows = this.dgvShop.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colShopId"].Value.ToString() == shop.ShopId);
|
||||
|
||||
if (!isError)
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "已查询";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMessage"].Value = "查询失败";
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
btnListWarehouse.Enabled = true;
|
||||
btnSearch.Enabled = true;
|
||||
chkHasCreate.Enabled = true;
|
||||
ucGroupBoxEx2.Enabled = true;
|
||||
ucGroupBoxEx3.Enabled = true;
|
||||
ucGroupBoxEx4.Enabled = true;
|
||||
string sRst = "查询结束!";
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
sRst = "已取消查询!";
|
||||
|
||||
BaseMsgForm.ShowInfo(sRst);
|
||||
this.statusBar.lblTaskStatus.Text = sRst;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
private void btnStartStockUp_Click(object sender, EventArgs e)
|
||||
{
|
||||
var lstSkc = dgvStock.Rows.Cast<DataGridViewRow>().Where(row
|
||||
=> row.Cells["colCheck"]?.Value.ParseToBool() == true).Select(r => r.Cells["colProdSkc"]?.Value.ToString()).ToList();
|
||||
var lstStockUp = lstSubOrderInfo.Where(s => lstSkc.Contains(s.productSkcId.ParseToString())).ToList();
|
||||
if (lstStockUp.Count == 0)
|
||||
{
|
||||
BaseMsgForm.ShowInfo("请选择要创建备货单的商品!");
|
||||
return;
|
||||
}
|
||||
|
||||
ucGroupBoxEx2.Enabled = false;
|
||||
ucGroupBoxEx3.Enabled = false;
|
||||
ucGroupBoxEx4.Enabled = false;
|
||||
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var stockUp in lstStockUp)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "正在创建备货单...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + lstStockUp.Count;
|
||||
this.statusBar.pgbTaskProgress.Maximum = lstStockUp.Count;
|
||||
i++;
|
||||
}));
|
||||
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
var rows = this.dgvStock.Rows.Cast<DataGridViewRow>().Where(r =>
|
||||
r.Cells["colProdSkc"].Value.ToString() == stockUp.productSkcId.ParseToString());
|
||||
|
||||
|
||||
if (stockUp.needStockUp != true)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "无需创建备货单";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ShopId == stockUp.supplierId.ToString());
|
||||
if (shop == null || shop.LoginStatus != "登录成功")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "店铺掉线或不存在";
|
||||
}
|
||||
}));
|
||||
continue;
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "正在创建";
|
||||
}
|
||||
}));
|
||||
|
||||
Thread.Sleep(200 + Randomx.GetId(100));
|
||||
string jsonStr = this.QueryStockBaseInfo(shop, stockUp);
|
||||
bool isError = !jsonStr.Contains("\"success\":true");
|
||||
string sErrMsg1 = BaseRegex.GetStringJson(ref jsonStr, "errorMsg").ParseToString();
|
||||
if (!isError)
|
||||
{
|
||||
Thread.Sleep(Randomx.GetId(200, 400));
|
||||
|
||||
var jObj = JObject.Parse(jsonStr);
|
||||
var jItem = jObj["result"];
|
||||
var jStr = jObj["result"].ParseToString();
|
||||
stockBaseInfo sBaseInfo = JsonHelper.DeserializeJsonToObject<stockBaseInfo>(jStr);
|
||||
|
||||
foreach(var sku in stockUp.skuQuantityDetailList)
|
||||
{
|
||||
if (sku.wantStockUpBound == 0)
|
||||
continue;
|
||||
|
||||
var sBaseSku = sBaseInfo.purchaseConfigDetailList.FirstOrDefault(s => s.productSkuId == sku.productSkuId);
|
||||
if (sBaseSku == null)
|
||||
sku.wantStockUpBound = 0;
|
||||
|
||||
if (sku.wantStockUpBound > sBaseSku.applyUpperBound.ParseToInt())
|
||||
{
|
||||
sku.wantStockUpBound = sBaseSku.applyUpperBound.ParseToInt();
|
||||
}
|
||||
}
|
||||
|
||||
if (!stockUp.skuQuantityDetailList.Any(s => s.wantStockUpBound > 0))
|
||||
{
|
||||
//如果已备过货但是还未发出,做一个判断
|
||||
isError = true;
|
||||
stockUp.needStockUp = false;
|
||||
sErrMsg1 += "已达平台备货量上限!";
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonStr = this.CreateStockOrder(shop, stockUp);
|
||||
isError = !jsonStr.Contains("\"success\":true");
|
||||
string sErrMsg2 = BaseRegex.GetStringJson(ref jsonStr, "errorMsg").ParseToString();
|
||||
var jObj2 = JObject.Parse(jsonStr);
|
||||
string failDetailList = jObj2["result"]?["failDetailList"].ParseToString();
|
||||
if (failDetailList.Length > 5)
|
||||
{
|
||||
isError = true;
|
||||
sErrMsg2 += failDetailList;
|
||||
}
|
||||
sErrMsg1 += sErrMsg2;
|
||||
}
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (!isError)
|
||||
{
|
||||
stockUp.isStockUp = true;
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "已创建备货单";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var row in rows)
|
||||
{
|
||||
row.Cells["colMsg"].Value = "创建备货单失败:" + sErrMsg1;
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ucGroupBoxEx2.Enabled = true;
|
||||
ucGroupBoxEx3.Enabled = true;
|
||||
ucGroupBoxEx4.Enabled = true;
|
||||
string sRst = "操作结束(创建备货单)!";
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
sRst = "已取消操作(创建备货单)!";
|
||||
|
||||
BaseMsgForm.ShowInfo(sRst);
|
||||
this.statusBar.lblTaskStatus.Text = sRst;
|
||||
}));
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +138,9 @@
|
||||
<metadata name="colUpId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colCheck.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colSupplierId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
@@ -168,6 +171,21 @@
|
||||
<metadata name="colFromFake.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colInCartNumber7d.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colTodaySaleVolume.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colSalesInventoryNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colWaitReceiveNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colNeedStockUp.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colMsg.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
||||
+3
-2
@@ -229,8 +229,9 @@ namespace TemuKJD
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
ViolateManageForm.GetAllViolateRuleName();
|
||||
GetShopViolation();
|
||||
//抖音获取违规信息
|
||||
//ViolateManageForm.GetAllViolateRuleName();
|
||||
//GetShopViolation();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user