temu客户端程序
This commit is contained in:
commit
4aaf264e89
694 files changed
+263780
No files matched your search
@@ -0,0 +1,518 @@
|
||||
using AllBase;
|
||||
using AllBase.Extension;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Result;
|
||||
using LittleRabbit.Extension;
|
||||
using LittleRabbit.LittleRabbitForms.BaseForms;
|
||||
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.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work.BLL.Product;
|
||||
|
||||
namespace LittleRabbit.LittleRabbitForms.SalesCenterForms
|
||||
{
|
||||
public partial class CouponShopForm : Form
|
||||
{
|
||||
private CheckBox chkSelectAll = null;
|
||||
|
||||
DouShopLoginInfo shop = null;
|
||||
public CouponForm couponForm = null;
|
||||
public bool isGetProductSalesSuccess = false;
|
||||
public Dictionary<string, int> dicProductSales = new Dictionary<string, int>();
|
||||
public List<DouProductWithSalesListInfo> productList = new List<DouProductWithSalesListInfo>();
|
||||
|
||||
public CouponShopForm(DouShopLoginInfo _shop)
|
||||
{
|
||||
InitializeComponent();
|
||||
shop = _shop;
|
||||
}
|
||||
|
||||
private void CouponShopForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
chkSelectAll = dgvProduct.Columns["colSelect"].AddHeaderCheckBox(HorizontalAlignment.Center, 0, 0, null, null, false);
|
||||
dgvProduct.Columns["colSelect"].HeaderText = "";
|
||||
|
||||
chkSelectAll.Width = chkSelectAll.Height = 13;
|
||||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||||
}
|
||||
|
||||
private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!chkSelectAll.Checked)
|
||||
{
|
||||
foreach (DataGridViewRow row in dgvProduct.Rows)
|
||||
{
|
||||
row.Cells["colSelect"].Value = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DataGridViewRow row in dgvProduct.Rows)
|
||||
{
|
||||
row.Cells["colSelect"].Value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GetProduct(decimal priceMin, decimal priceMax, int salesMin, int salesMax, List<string> productName = null, List<string> filterWords = null)
|
||||
{
|
||||
if (shop == null)
|
||||
return;
|
||||
|
||||
ShowVisitorMessage("");
|
||||
foreach (DataGridViewRow r in this.dgvProduct.Rows)
|
||||
{
|
||||
r.Cells["colSales"].Value = "获取中";
|
||||
}
|
||||
foreach (var p in productList)
|
||||
{
|
||||
p.sell_num = null;
|
||||
}
|
||||
|
||||
List<Task> tList = new List<Task>();
|
||||
|
||||
var t1 = Task.Run(() =>
|
||||
{
|
||||
int page = 0;
|
||||
int pageSize = 100;
|
||||
int totalNum = 99999;
|
||||
while (page < 100)
|
||||
{
|
||||
if (couponForm == null || couponForm.cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
page++;
|
||||
var html = new ShopProductBLL().GetShopProductListData(shop, 0, page, pageSize);
|
||||
//测试查找商品详情
|
||||
//Work.DouyinApiClass.DouyinApi api = new Work.DouyinApiClass.DouyinApi(shop);
|
||||
//api.JsonData = new Dictionary<string, string>();
|
||||
//api.JsonData["product_id"] = "3558439046600598747";
|
||||
//var detail = api.GetProductDetail();
|
||||
|
||||
while (!html.Contains("\"code\":10000"))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
html = new ShopProductBLL().GetShopProductListData(shop, 0, page, pageSize);
|
||||
}
|
||||
totalNum = BaseRegex.GetIntJson(ref html, "total");
|
||||
|
||||
try
|
||||
{
|
||||
JObject jObj = JObject.Parse(html);
|
||||
var jObjDataStr = jObj["data"]?["data"]?.ToString();
|
||||
if (!string.IsNullOrEmpty(jObjDataStr))
|
||||
{
|
||||
var addList = JsonHelper.DeserializeJsonToList<DouProductWithSalesListInfo>(jObjDataStr);
|
||||
if (addList != null)
|
||||
{
|
||||
// 有关键词或商品id的,过滤符合关键词
|
||||
if (productName != null && productName.Any())
|
||||
addList = addList.Where(p => productName.Any(n => p.name.Contains(n) || p.product_id.ToString().Contains(n))).ToList();
|
||||
|
||||
if (filterWords != null && filterWords.Any())
|
||||
addList = addList.Where(p => !filterWords.Any(f => p.name.Contains(f) || p.product_id.ToString().Contains(f))).ToList();
|
||||
|
||||
productList.AddRange(addList);
|
||||
productList = productList.DistinctBy(p => p.product_id).ToList();
|
||||
}
|
||||
foreach (var prod in addList)
|
||||
{
|
||||
var row = dgvProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colProductId"].Value.ToString() == prod.product_id.ToString());
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (row == null)
|
||||
{
|
||||
dgvProduct.Rows.Add(
|
||||
false,
|
||||
prod.product_id,
|
||||
prod.name,
|
||||
"获取中",
|
||||
prod.discount_price / 100,
|
||||
BaseClass.StampToDateTime((int)prod.create_time));
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Cells["colSales"].Value = "获取中";
|
||||
row.Cells["colPrice"].Value = prod.discount_price / 100;
|
||||
row.Cells["colCreateTime"].Value = BaseClass.StampToDateTime((int)prod.create_time);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
var totalPage = Math.Ceiling(totalNum / (pageSize * 1M));
|
||||
var message = "已获取:" + page + "页,共" + Math.Ceiling(totalNum / (pageSize * 1M)) + "页,商品获取中...";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = message;
|
||||
this.statusBar.pgbTaskProgress.Value = page;
|
||||
this.statusBar.pgbTaskProgress.Text = page + "/" + totalPage;
|
||||
this.statusBar.pgbTaskProgress.Maximum = (int)totalPage;
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgForm.ShowError("获取商品发生错误:" + ex.Message);
|
||||
}
|
||||
|
||||
if (page * pageSize >= totalNum)
|
||||
break;
|
||||
}
|
||||
});
|
||||
tList.Add(t1);
|
||||
|
||||
if (ShopForms.ShopListForm.Instance == null)
|
||||
ShopForms.ShopListForm.Instance = new ShopForms.ShopListForm();
|
||||
ShopForms.ShopListForm.Instance.CheckShopLogin(new string[] { shop.ShopAccount }, false);
|
||||
|
||||
var t2 = Task.Run(() =>
|
||||
{
|
||||
if (shop.LoginStatus == "登录成功")
|
||||
couponForm.GetSales(this.shop);
|
||||
|
||||
var rowsTemp = dgvProduct.Rows.Cast<DataGridViewRow>().ToList();
|
||||
rowsTemp.Reverse();
|
||||
foreach (var r in rowsTemp)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (r.Cells["colPrice"].Value.ParseToDecimal() < priceMin || r.Cells["colPrice"].Value.ParseToDecimal() > priceMax
|
||||
|| r.Cells["colSales"].Value.ParseToDecimal() < salesMin || r.Cells["colSales"].Value.ParseToDecimal() > salesMax
|
||||
|| (productName?.Count > 0 && !productName.Any(n => r.Cells["colProductName"].Value.ToString().Contains(n) || r.Cells["colProductId"].Value.ToString().Contains(n)))
|
||||
|| (filterWords?.Count > 0 && filterWords.Any(f => r.Cells["colProductName"].Value.ToString().Contains(f) || r.Cells["colProductId"].Value.ToString().Contains(f))))
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
dgvProduct.Rows.Remove(r);
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
tList.Add(t2);
|
||||
t2.Wait();
|
||||
|
||||
SetSalesCount();
|
||||
//SetVisitorCount();
|
||||
|
||||
productList = productList.Where(p => p.discount_price >= priceMin && p.discount_price <= priceMax && p.sell_num >= salesMin && p.sell_num <= salesMax
|
||||
&& (productName?.Count > 0 == false || productName.Any(n => p.name.Contains(n) || p.product_id.ToString().Contains(n)))
|
||||
&& (filterWords?.Count > 0 == false || !filterWords.Any(f => p.name.Contains(f) || p.product_id.ToString().Contains(f)))).ToList();
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (couponForm == null || couponForm.cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "获取中断";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.statusBar.lblTaskStatus.Text = "获取完成";
|
||||
}
|
||||
this.statusBar.pgbTaskProgress.Value = 0;
|
||||
this.statusBar.pgbTaskProgress.Text = 0 + "/" + 0;
|
||||
this.statusBar.pgbTaskProgress.Maximum = 0;
|
||||
}));
|
||||
var errMsg = "";
|
||||
if (shop.LoginStatus != "登录成功")
|
||||
errMsg += " 店铺掉线,请重新登录!";
|
||||
if (shop.ApiAuthStatus != "授权成功")
|
||||
errMsg += " 授权过期,请重新授权!";
|
||||
ShowVisitorMessage(errMsg);
|
||||
}
|
||||
|
||||
public void ShowVisitorMessage(string msg)
|
||||
{
|
||||
Invoke(new Action(() => { this.label1.Text = msg; }));
|
||||
}
|
||||
|
||||
public void SetSalesCount()
|
||||
{
|
||||
foreach (var key in dicProductSales.Keys)
|
||||
{
|
||||
var row = this.dgvProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colProductId"].Value.ToString() == key);
|
||||
if (row != null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells["colSales"].Value = dicProductSales[key];
|
||||
}));
|
||||
}
|
||||
var product = this.productList.Find(p => p.product_id.ToString() == key);
|
||||
if (product != null)
|
||||
product.sell_num = dicProductSales[key];
|
||||
}
|
||||
|
||||
foreach (DataGridViewRow row in dgvProduct.Rows)
|
||||
{
|
||||
if (row.Cells["colSales"].Value.ToString() == "获取中")
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
if (isGetProductSalesSuccess)
|
||||
{
|
||||
row.Cells["colSales"].Value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Cells["colSales"].Value = "获取失败";
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (isGetProductSalesSuccess)
|
||||
{
|
||||
foreach (var prod in this.productList)
|
||||
{
|
||||
if (prod.sell_num == null)
|
||||
prod.sell_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dgvProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
string headerText = dgvProduct.Columns[e.ColumnIndex].HeaderText;
|
||||
string columnName = dgvProduct.Columns[e.ColumnIndex].Name;
|
||||
var row = dgvProduct.Rows[e.RowIndex];
|
||||
switch (columnName)
|
||||
{
|
||||
case "colSelect":
|
||||
//row.Cells["colSelect"].Value = !row.Cells["colSelect"].Value.ParseToBool();
|
||||
//chkSelectAll.CheckedChanged -= chkSelectAll_CheckedChanged;
|
||||
//if (dgvProduct.Rows.Cast<DataGridViewRow>().All(r => r.Cells["colSelect"].Value.ParseToBool()))
|
||||
// chkSelectAll.Checked = true;
|
||||
//else
|
||||
// chkSelectAll.Checked = false;
|
||||
//chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool isSelecting = false;
|
||||
bool isCheck = true;
|
||||
private void dgvProduct_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
|
||||
var columnName = dgvProduct.Columns[e.ColumnIndex].Name;
|
||||
if (MouseButtons == MouseButtons.Left)
|
||||
{
|
||||
if (columnName == "colSelect")
|
||||
{
|
||||
dgvProduct.Rows[e.RowIndex].Cells["colSelect"].Value = !dgvProduct.Rows[e.RowIndex].Cells["colSelect"].Value.ParseToBool();
|
||||
|
||||
isSelecting = true;
|
||||
isCheck = dgvProduct.Rows[e.RowIndex].Cells["colSelect"].Value.ParseToBool();
|
||||
|
||||
chkSelectAll.CheckedChanged -= chkSelectAll_CheckedChanged;
|
||||
if (dgvProduct.Rows.Cast<DataGridViewRow>().All(r => r.Cells["colSelect"].Value.ParseToBool()))
|
||||
chkSelectAll.Checked = true;
|
||||
else
|
||||
chkSelectAll.Checked = false;
|
||||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dgvProduct_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
isSelecting = false;
|
||||
}
|
||||
|
||||
private void dgvProduct_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
|
||||
var row = dgvProduct.Rows[e.RowIndex];
|
||||
if (MouseButtons == MouseButtons.Left)
|
||||
{
|
||||
var columnName = dgvProduct.Columns[e.ColumnIndex].Name;
|
||||
if (isSelecting)
|
||||
{
|
||||
dgvProduct.Rows[e.RowIndex].Cells["colSelect"].Value = isCheck;
|
||||
|
||||
chkSelectAll.CheckedChanged -= chkSelectAll_CheckedChanged;
|
||||
if (dgvProduct.Rows.Cast<DataGridViewRow>().All(r => r.Cells["colSelect"].Value.ParseToBool()))
|
||||
chkSelectAll.Checked = true;
|
||||
else
|
||||
chkSelectAll.Checked = false;
|
||||
chkSelectAll.CheckedChanged += chkSelectAll_CheckedChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string SetCoupon(int periodType,
|
||||
int favouredType,
|
||||
long startApplyStamps,
|
||||
long endApplyStamps,
|
||||
long startUseStamps,
|
||||
long endUseStamps,
|
||||
int validDays,
|
||||
int totalCount,
|
||||
int countLimit,
|
||||
decimal discount, // (折扣券的)折扣
|
||||
int threshold, // 满x元
|
||||
int credit, // 减x元
|
||||
bool ignore,
|
||||
bool oneProductEachCoupon,
|
||||
string couponName = "")
|
||||
{
|
||||
List<DataGridViewRow> rows = this.dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value?.ParseToBool() == true).ToList();
|
||||
var goodsIdList = rows.Select(r => r.Cells["colProductId"].Value?.ToString()).ToList();
|
||||
var goodsIds = "\"" + string.Join("\",\"", goodsIdList) + "\"";
|
||||
if (!oneProductEachCoupon)
|
||||
{
|
||||
var goodsIdListTemp = new List<string>();
|
||||
goodsIdListTemp.AddRange(goodsIdList);
|
||||
goodsIdList.Clear();
|
||||
int numCount = 0;
|
||||
goodsIds = "";
|
||||
foreach (var goodsId in goodsIdListTemp)
|
||||
{
|
||||
numCount++;
|
||||
goodsIds += "\"" + goodsId + "\",";
|
||||
if (numCount % 200 == 0 || numCount >= goodsIdListTemp.Count)
|
||||
{
|
||||
goodsIdList.Add(goodsIds.Trim(','));
|
||||
goodsIds = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(couponName))
|
||||
couponName = DateTime.Now.ToString("yyMMddHHmm");
|
||||
string setResult = "";
|
||||
|
||||
foreach (var id in goodsIdList)
|
||||
{
|
||||
// 指定商品折扣券
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":"""",""channel"":3,""coupon_name"":""优惠123"",""period_type"":2,""ignore"":false,""favoured_type"":41,""total_amount"":13,""max_apply_times"":1,""valid_period"":""3"",""discount"":95,""goods"":[""3552987839555832450"",""3552273829277663255"",""3552271209347574338""],""start_apply_time"":1654531200,""end_apply_time"":1654617599,""jump_type"":4}";
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":""7086106181462163749"",""shop_omp_activity_type"":8,""channel"":3,""coupon_name"":""111"",""period_type"":1,""ignore"":false,""favoured_type"":41,""total_amount"":1,""max_apply_times"":1,""goods"":[""3554315317469660534"",""3553784680702692298""],""discount"":90,""start_time"":1655395200,""expire_time"":1655481599,""start_apply_time"":1655395200,""end_apply_time"":1655481599,""jump_type"":4}";
|
||||
// 指定商品直减券
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":""7086106181462163749"",""shop_omp_activity_type"":8,""channel"":3,""coupon_name"":""2131"",""period_type"":1,""ignore"":false,""favoured_type"":42,""total_amount"":1,""max_apply_times"":1,""goods"":[""3557115286081690584""],""credit"":200,""start_time"":1657123200,""expire_time"":1657209599,""start_apply_time"":1657123200,""end_apply_time"":1657209599,""jump_type"":2,""jump_product_id"":""3557115286081690584""}";
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":""7086106181462163749"",""shop_omp_activity_type"":8,""channel"":3,""coupon_name"":""1223"",""period_type"":1,""ignore"":false,""favoured_type"":42,""total_amount"":1,""max_apply_times"":1,""goods"":[""3554511661782200678""],""credit"":200,""start_time"":1657123200,""expire_time"":1657209599,""start_apply_time"":1657123200,""end_apply_time"":1657209599,""jump_type"":2,""jump_product_id"":""3554511661782200678""}";
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":""7086106181462163749"",""shop_omp_activity_type"":8,""channel"":3,""coupon_name"":""2311"",""period_type"":1,""ignore"":false,""favoured_type"":42,""total_amount"":1,""max_apply_times"":1,""goods"":[""3554333221040862310"",""3554511661782200678""],""credit"":200,""start_time"":1657123200,""expire_time"":1657209599,""start_apply_time"":1657123200,""end_apply_time"":1657209599,""jump_type"":4}";
|
||||
// 指定商品满减券
|
||||
//string body = @"{""support_type"":4,""shop_omp_activity_id"":""7086106181462163749"",""shop_omp_activity_type"":8,""channel"":3,""coupon_name"":""1ad"",""period_type"":1,""ignore"":false,""favoured_type"":43,""total_amount"":1,""max_apply_times"":1,""goods"":[""3556136493124815095"",""3558423829472753852""],""threshold"":9900,""credit"":1100,""start_time"":1657123200,""expire_time"":1657209599,""start_apply_time"":1657123200,""end_apply_time"":1657209599,""jump_type"":4}";
|
||||
|
||||
string body = "{\"support_type\":4," +
|
||||
"\"shop_omp_activity_id\":\"\"," +
|
||||
"\"channel\":3," +
|
||||
"\"coupon_name\":\"" + couponName + "\"," + // 优惠券名称
|
||||
"\"period_type\":" + periodType + "," + // 使用时间 1=限制日期范围 2=限制有效天数
|
||||
"\"ignore\":" + ignore.ToString().ToLower() + "," + // 价格风险预警 true=不计入 false=计入
|
||||
"\"favoured_type\":" + favouredType + "," + // 优惠内容 41=指定商品折扣券 42=指定商品直减券 43=指定商品满减券
|
||||
"\"total_amount\":" + totalCount + "," + // 发放量
|
||||
"\"max_apply_times\":" + countLimit + ","; // 每人限领
|
||||
if (periodType == 2)
|
||||
body += "\"valid_period\":\"" + validDays + "\","; // 有效期天数
|
||||
if (periodType == 1)
|
||||
{
|
||||
body += "\"start_time\":" + startUseStamps + ","; // 开始日期
|
||||
body += "\"expire_time\":" + endUseStamps + ","; // 结束日期
|
||||
}
|
||||
if (favouredType == 41)
|
||||
{
|
||||
body += "\"discount\":" + (int)(10 * discount) + ","; // 折扣
|
||||
}
|
||||
else if (favouredType == 42)
|
||||
{
|
||||
body += "\"credit\":" + 100 * credit + ","; // 减x元 单位分
|
||||
}
|
||||
else if (favouredType == 43)
|
||||
{
|
||||
body += "\"threshold\":" + 100 * threshold + ","; // 满x元 单位分
|
||||
body += "\"credit\":" + 100 * credit + ","; // 减x元 单位分
|
||||
}
|
||||
body += "\"goods\":[" + id + "]," + // 商品编号
|
||||
"\"start_apply_time\":" + startApplyStamps + "," + // 领取开始时间
|
||||
"\"end_apply_time\":" + endApplyStamps + "," + // 领取结束时间
|
||||
"\"jump_type\":4}";
|
||||
|
||||
string url = "https://fxg.jinritemai.com/marketing/coupons/v1/check?_bid=ecom_market_shop&appid=1&_=" + BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
string referer = "https://fxg.jinritemai.com/market/center/coupon/detail?type=4";
|
||||
|
||||
CommonSimRequest simRequest = new CommonSimRequest();
|
||||
simRequest.Accept = "application/json, text/plain, */*";
|
||||
simRequest.ContentType = "application/json";
|
||||
|
||||
var result = simRequest.Request_Post(url, referer, new Dictionary<string, string>(), shop.Cookies, body);
|
||||
if (!result.Contains("成功") && !result.Contains("Gateway Timeout"))
|
||||
{
|
||||
foreach (DataGridViewRow row in rows)
|
||||
{
|
||||
if (id.Contains(row.Cells["colProductId"].Value.ToString()))
|
||||
Invoke(new Action(() => { row.Cells["colMessage"].Value = "优惠券 " + couponName + " 规则校验失败,无法设置。"; }));
|
||||
}
|
||||
setResult += id + "|error^";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("18565722666|13928836672,18565722666,13928836672,18937517772,18135637272,18888888888".Contains(BaseClass.UserName))
|
||||
Thread.Sleep(Randomx.GetId(10, 20));
|
||||
else
|
||||
Thread.Sleep(Randomx.GetId(100, 500));
|
||||
url = "https://fxg.jinritemai.com/marketing/coupons/v1/shopcoupons?_bid=ecom_market_shop&appid=1&_=" + BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
result = simRequest.Request_Post(url, referer, new Dictionary<string, string>(), shop.Cookies, body);
|
||||
if (!result.Contains("成功"))
|
||||
{
|
||||
var msg = BaseRegex.GetStringJson(ref result, "msg");
|
||||
foreach (DataGridViewRow row in rows)
|
||||
{
|
||||
if (id.Contains(row.Cells["colProductId"].Value.ToString()))
|
||||
Invoke(new Action(() => { row.Cells["colMessage"].Value = "优惠券 " + couponName + " 设置失败。" + msg; }));
|
||||
}
|
||||
setResult += id + "|error^";
|
||||
continue;
|
||||
}
|
||||
foreach (DataGridViewRow row in rows)
|
||||
{
|
||||
if (id.Contains(row.Cells["colProductId"].Value.ToString()))
|
||||
Invoke(new Action(() => { row.Cells["colMessage"].Value = "优惠券 " + couponName + " 设置成功。"; }));
|
||||
}
|
||||
setResult += id + "|success^";
|
||||
|
||||
if (goodsIdList.Count > 1)
|
||||
{
|
||||
if ("18565722666|13928836672,18565722666,13928836672,18937517772,18135637272,18888888888".Contains(BaseClass.UserName))
|
||||
Thread.Sleep(Randomx.GetId(50, 150));
|
||||
else
|
||||
Thread.Sleep(Randomx.GetId(200, 700));
|
||||
}
|
||||
}
|
||||
return setResult;
|
||||
}
|
||||
|
||||
private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<DataGridViewRow> rows = this.dgvProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value?.ParseToBool() == true).ToList();
|
||||
var goodsIdList = rows.Select(r => r.Cells["colProductId"].Value?.ToString()).ToList();
|
||||
var goodsIds = "\"" + string.Join("\",\"", goodsIdList) + "\"";
|
||||
|
||||
CouponMulitAddForm form = new CouponMulitAddForm();
|
||||
form.couponShopForm = this;
|
||||
form.Show();
|
||||
}
|
||||
|
||||
public void ClearData()
|
||||
{
|
||||
this.dgvProduct.Rows.Clear();
|
||||
this.productList.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user