1702 lines
76 KiB
C#
1702 lines
76 KiB
C#
using AllBase;
|
||
using AllBase.Helper;
|
||
using AllBase.Model.Param.FissionManage;
|
||
using AllBase.Model.Result;
|
||
using LittleRabbit.Extension;
|
||
using LittleRabbit.LittleRabbitForms.BaseForms;
|
||
using NaiBa.Util.Extension;
|
||
using Newtonsoft.Json;
|
||
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.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
using Work;
|
||
using Work.Api;
|
||
using Work.BLL.Upload;
|
||
using Work.CollectClass;
|
||
using Work.DouyinApiClass;
|
||
|
||
namespace LittleRabbit.LittleRabbitForms.UploadForms
|
||
{
|
||
public partial class FissionDataBaseForm : Form
|
||
{
|
||
public int ClickType = 0; // 0删除 1从删除产品中恢复数据
|
||
public bool IsStop = false;
|
||
public bool IsUserProxyIp = false;
|
||
/// <summary>
|
||
/// 校验时上家下架则删除
|
||
/// </summary>
|
||
public bool IsDeleteUpDown = false;
|
||
/// <summary>
|
||
/// 上家sku变化时自动更新(功能隐藏)
|
||
/// </summary>
|
||
public bool IsUpdateUpChange = false;
|
||
/// <summary>
|
||
/// 商品校验结果需要更新或删除 1 校验通过 9 上家已下架 0 上家有变化需要更新
|
||
/// </summary>
|
||
public int ProductUpdateCheckResult = 1;
|
||
/// <summary>
|
||
/// 是否自动翻页
|
||
/// </summary>
|
||
public bool IsAutoTurnPage = false;
|
||
/// <summary>
|
||
/// 是否正在翻页
|
||
/// </summary>
|
||
public bool IsTurnPage = false;
|
||
|
||
public List<FissionData> LstFission = new List<FissionData>();
|
||
|
||
CheckBox chkAll = null;
|
||
|
||
public static FissionDataBaseForm Instance = null;
|
||
|
||
public FissionDataBaseForm()
|
||
{
|
||
InitializeComponent();
|
||
|
||
Instance = this;
|
||
}
|
||
|
||
private void FissionDataBaseForm_Load(object sender, EventArgs e)
|
||
{
|
||
chkAll = this.dgvFissionProduct.AddSelectorColumn("ColSelect");
|
||
this.cmbSource.SelectedIndex = 0;
|
||
this.cmbCheckResult.SelectedIndex = 0;
|
||
|
||
SetCateGroupOptions();
|
||
SetMainCateOptions();
|
||
SetPageOptions();
|
||
RefreshShop();
|
||
}
|
||
|
||
private void btnSearchFission_Click(object sender, EventArgs e)
|
||
{
|
||
this.txtCurrentPage.Text = "1";
|
||
|
||
SearchFission();
|
||
}
|
||
|
||
public void SearchFission()
|
||
{
|
||
// 选择时间框一个选择了,另一个没选则提示两个都要选(或者都不选)
|
||
if ((dtBaginTime.Text.Trim() == "" ^ dtEndTime.Text.Trim() == ""))
|
||
{
|
||
BaseMsgForm.ShowInfo("请检查开始时间和结束时间是否都选择了!");
|
||
return;
|
||
}
|
||
// 时间判断结束时间不能比开始时间小
|
||
if (!string.IsNullOrEmpty(dtBaginTime.Text) && !string.IsNullOrEmpty(dtEndTime.Text))
|
||
{
|
||
if (DateTime.Compare(DateTime.Parse(dtBaginTime.Text), DateTime.Parse(dtEndTime.Text)) > 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("结束日期比开始日期大,请检查日期选择!");
|
||
return;
|
||
}
|
||
}
|
||
|
||
IsStop = false;
|
||
LstFission.Clear();
|
||
dgvFissionProduct.Rows.Clear();
|
||
string min_price = txtPriceMin.Text;
|
||
string max_price = txtPriceMax.Text;
|
||
string min_sales = txtSaleAmountMin.Text;
|
||
string max_sales = txtSaleAmountMax.Text;
|
||
string min_times = txtMinTimes.Text;
|
||
string max_times = txtMaxTimes.Text;
|
||
string teamGroup = cmbGroup.Text;
|
||
string beginTime = string.IsNullOrEmpty(dtBaginTime.Text) ? "" : DateTime.Parse(dtBaginTime.Text).ToString("yyyy-MM-dd");
|
||
string endtime = string.IsNullOrEmpty(dtEndTime.Text) ? "" : DateTime.Parse(dtEndTime.Text).ToString("yyyy-MM-dd");
|
||
if (string.IsNullOrEmpty(teamGroup) || teamGroup == "不限")
|
||
teamGroup = "";
|
||
string cat1 = cmbShopCat1.Text;
|
||
if (string.IsNullOrEmpty(cat1) || cat1 == "不限")
|
||
cat1 = cmbCat1.Text;
|
||
if (string.IsNullOrEmpty(cat1) || cat1 == "不限")
|
||
cat1 = "";
|
||
ProductUpdateCheckResult = 1;
|
||
if (cmbCheckResult.Text == "需更新商品")
|
||
ProductUpdateCheckResult = 0;
|
||
if (cmbCheckResult.Text == "上家下架")
|
||
ProductUpdateCheckResult = 9;
|
||
|
||
string UseStatus = "";
|
||
string current_page = this.lblCurrentPage.Text = this.txtCurrentPage.Text;
|
||
string pagesize = cboxDisplayCount.Text;
|
||
|
||
string url = BaseClass.BuildFissionObjString("fession_api");
|
||
string paraStr = "&min_price=" + min_price
|
||
+ "&max_price=" + max_price
|
||
+ "&min_sales=" + min_sales
|
||
+ "&max_sales=" + max_sales
|
||
+ "&min_times=" + min_times
|
||
+ "&max_times=" + max_times
|
||
+ "&begin_time=" + beginTime
|
||
+ "&end_time=" + endtime
|
||
+ "¤t_page=" + current_page
|
||
+ "&pagesize=" + pagesize
|
||
+ "&fessiontitle=" + HttpUtility.UrlEncode(txtFisssionTitle.Text, Encoding.UTF8) // 关键字 /其实查的是title
|
||
+ (!string.IsNullOrEmpty(UseStatus) ? "×=" + UseStatus : "") // 使用次数
|
||
+ (cmbSource.Text != "" && cmbSource.Text != "不限" ? "&source=" + cmbSource.Text : "") // 来源
|
||
+ (cmbGroup.Text != "" && cmbGroup.Text != "不限" ? "&category=" + HttpUtility.UrlEncode(teamGroup, Encoding.UTF8) : "") // 店铺分组
|
||
+ "&main_cate=" + cat1 // 一级类目
|
||
+ (cmbShopCat2.Text != "" && cmbShopCat2.Text != "不限" ? "&cat2_name=" + cmbShopCat2.Text : "") // 二级类目
|
||
+ (cmbShopCat3.Text != "" && cmbShopCat3.Text != "不限" ? "&cat3_name=" + cmbShopCat3.Text : "") // 三级类目
|
||
+ (ProductUpdateCheckResult == 1 ? "" : ("&update_check_passed=" + ProductUpdateCheckResult));
|
||
string requestData = UserLogin.GetSignaturex() + "&act=get" + paraStr;
|
||
|
||
try
|
||
{
|
||
string htmlData = GetHtml.PostUtf8(url, requestData);
|
||
var FessionObj = JsonConvert.DeserializeObject<FissionRoot>(htmlData); // 反序列化
|
||
if (FessionObj != null)
|
||
{
|
||
LstFission.AddRange(FessionObj.list);
|
||
SetFessionData(FessionObj);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add(Name, "访问服务器返回裂变数据异常");
|
||
}
|
||
|
||
IsTurnPage = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置分组信息列表
|
||
/// </summary>
|
||
private void SetCateGroupOptions()
|
||
{
|
||
var groupList = new FissionDataBaseBLL().GetCategoryGroup();
|
||
cmbGroup.DataSource = groupList;
|
||
}
|
||
/// <summary>
|
||
/// 设置类目信息列表
|
||
/// </summary>
|
||
private void SetMainCateOptions()
|
||
{
|
||
var mainCateList = new FissionDataBaseBLL().GetMainCate();
|
||
cmbCat1.DataSource = mainCateList;
|
||
}
|
||
/// <summary>
|
||
/// 设置分页选项列表
|
||
/// </summary>
|
||
private void SetPageOptions()
|
||
{
|
||
Dictionary<int, int> kvDictonary = new Dictionary<int, int>();
|
||
|
||
kvDictonary.Add(1, 30);
|
||
kvDictonary.Add(2, 50);
|
||
kvDictonary.Add(3, 100);
|
||
kvDictonary.Add(4, 500);
|
||
BindingSource bs = new BindingSource();
|
||
bs.DataSource = kvDictonary;
|
||
this.cboxDisplayCount.DataSource = bs;
|
||
this.cboxDisplayCount.ValueMember = "Key";
|
||
this.cboxDisplayCount.DisplayMember = "Value";
|
||
}
|
||
|
||
public void RefreshShop()
|
||
{
|
||
cmbShop.Items.Clear();
|
||
cmbShop.Items.Add("不限");
|
||
foreach (var shop in GlobalConfig.DouShopLoginList)
|
||
{
|
||
cmbShop.Items.Add(shop.ShopAccount);
|
||
}
|
||
if (cmbShop.Items.Count > 0)
|
||
cmbShop.SelectedIndex = 0;
|
||
}
|
||
|
||
private void cboxShop_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
cmbShopCat1.DataSource = null;
|
||
cmbShopCat2.DataSource = null;
|
||
cmbShopCat3.DataSource = null;
|
||
cmbShopCat1.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把一级类目清空
|
||
cmbShopCat2.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把二级类目清空
|
||
cmbShopCat3.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把三级类目清空
|
||
List<GoodsCategoryModel> catList1 = new List<GoodsCategoryModel>();
|
||
catList1.Insert(0, new GoodsCategoryModel() { name = "不限", parent_id = 0, level = 0, enable = true, is_leaf = false, id = -1, main_cat_id = 0 });
|
||
|
||
string shopname = cmbShop.Text;
|
||
var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(x => x.ShopAccount == shopname);
|
||
if (shop != null)
|
||
{
|
||
catList1.AddRange(GetCategoryList(0, shop));
|
||
}
|
||
|
||
cmbShopCat1.DataSource = catList1;
|
||
cmbShopCat1.DisplayMember = "name";
|
||
if (cmbShopCat1.Items.Count > 0)
|
||
cmbShopCat1.SelectedIndex = 0;
|
||
|
||
if (cmbShop.Text != "" && cmbShop.Text != "不限")
|
||
{
|
||
cmbCat1.SelectedIndex = 0;
|
||
cmbCat1.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
cmbCat1.Enabled = true;
|
||
}
|
||
}
|
||
|
||
private void cmbShopCat1_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
cmbShopCat2.DataSource = null;
|
||
cmbShopCat3.DataSource = null;
|
||
cmbShopCat2.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把二级类目清空
|
||
cmbShopCat3.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把一级类目清空
|
||
List<GoodsCategoryModel> catList2 = new List<GoodsCategoryModel>();
|
||
string shopname = cmbShop.Text;
|
||
var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(x => x.ShopAccount == shopname);
|
||
if (shop != null)
|
||
{
|
||
if (cmbShopCat1.SelectedItem is GoodsCategoryModel)
|
||
catList2 = GetCategoryList((cmbShopCat1.SelectedItem as GoodsCategoryModel).id, shop);
|
||
}
|
||
catList2.Insert(0, new GoodsCategoryModel() { name = "不限", parent_id = 0, level = 0, enable = true, is_leaf = false, id = -1, main_cat_id = 0 });
|
||
cmbShopCat2.DataSource = catList2;
|
||
cmbShopCat2.DisplayMember = "name";
|
||
if (cmbShopCat2.Items.Count > 0)
|
||
cmbShopCat2.SelectedIndex = 0;
|
||
}
|
||
|
||
private void cmbShopCat2_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
cmbShopCat3.DataSource = null;
|
||
cmbShopCat3.Items.Clear(); // 防止有的店铺没有一级、二级、三级类目,所以,更改店铺前要把三级类目清空
|
||
List<GoodsCategoryModel> catList3 = new List<GoodsCategoryModel>();
|
||
string shopname = cmbShop.Text;
|
||
var shop = GlobalConfig.DouShopLoginList.FirstOrDefault(x => x.ShopAccount == shopname);
|
||
if (shop != null)
|
||
{
|
||
if (cmbShopCat2.SelectedItem is GoodsCategoryModel)
|
||
catList3 = GetCategoryList((cmbShopCat2.SelectedItem as GoodsCategoryModel).id, shop);
|
||
}
|
||
catList3.Insert(0, new GoodsCategoryModel() { name = "不限", parent_id = 0, level = 0, enable = true, is_leaf = false, id = -1, main_cat_id = 0 });
|
||
cmbShopCat3.DataSource = catList3;
|
||
cmbShopCat3.DisplayMember = "name";
|
||
if (cmbShopCat3.Items.Count > 0)
|
||
cmbShopCat3.SelectedIndex = 0;
|
||
}
|
||
|
||
private void cmbShopCat3_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
public List<GoodsCategoryModel> GetCategoryList(int catId, DouShopLoginInfo shop)
|
||
{
|
||
List<GoodsCategoryModel> cateList = new List<GoodsCategoryModel>();
|
||
if (catId < 0)
|
||
return cateList;
|
||
DouyinApi api = new DouyinApi(shop);
|
||
var result = api.GetShopCategory(catId);
|
||
if (result.Contains("已过期"))
|
||
{
|
||
shop.ApiAuthStatus = "未授权";
|
||
StartUp.SaveLocalShopLoginInfo();
|
||
GoodsCategoryModel cat = new GoodsCategoryModel()
|
||
{
|
||
enable = true,
|
||
id = 0,
|
||
is_leaf = false,
|
||
level = 0,
|
||
name = "店铺未授权",
|
||
parent_id = 0
|
||
};
|
||
cateList.Add(cat);
|
||
}
|
||
else if (result.Contains("\"code\":10000"))
|
||
{
|
||
var mc = BaseRegex.GetMatchRegex(ref result, "{([\\s\\S]+?)}");
|
||
foreach (Match m in mc)
|
||
{
|
||
string r = m.Value;
|
||
|
||
bool enable = BaseRegex.GetBoolJson(ref r, "enable");
|
||
bool is_leaf = BaseRegex.GetBoolJson(ref r, "is_leaf");
|
||
int level = BaseRegex.GetIntJson(ref r, "level");
|
||
int id = BaseRegex.GetIntJson(ref r, "id");
|
||
int parent_id = BaseRegex.GetIntJson(ref r, "parent_id");
|
||
string name = BaseRegex.GetStringJson(ref r, "name");
|
||
if (!string.IsNullOrEmpty(name))
|
||
{
|
||
GoodsCategoryModel cat = new GoodsCategoryModel()
|
||
{
|
||
enable = enable,
|
||
id = id,
|
||
is_leaf = is_leaf,
|
||
level = level,
|
||
name = name,
|
||
parent_id = parent_id
|
||
};
|
||
cateList.Add(cat);
|
||
}
|
||
}
|
||
}
|
||
return cateList;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定裂变数据
|
||
/// </summary>
|
||
public void SetFessionData(FissionRoot fissionRoot)
|
||
{
|
||
|
||
int loadCount = int.Parse(this.cboxDisplayCount.Text == "" ? "30" : this.cboxDisplayCount.Text);
|
||
int totalPage = fissionRoot.count % loadCount == 0 ? fissionRoot.count / loadCount : (fissionRoot.count / loadCount) + 1;
|
||
if (int.Parse(this.lblTotalPage.Text) != totalPage)
|
||
this.lblTotalPage.Text = totalPage.ToString();
|
||
|
||
List<FissionData> FessionTempList = fissionRoot.list;
|
||
while (FessionTempList.Count > 0)
|
||
{
|
||
var o = FessionTempList[0];
|
||
FessionTempList.RemoveAt(0);
|
||
if (o == null)
|
||
return;
|
||
|
||
string catStr = Fission.GetFullCatString(o.cate_id.ParseToInt());
|
||
if (string.IsNullOrEmpty(catStr))
|
||
catStr = o.full_category_name;
|
||
if (string.IsNullOrEmpty(catStr))
|
||
catStr = o.main_cate;
|
||
if (catStr == null)
|
||
catStr = "";
|
||
|
||
if (IsStop) // 当清空列表数据,停止绑定数据
|
||
return;
|
||
|
||
int iGrid = GetGridViewIndex(dgvFissionProduct, "ColId", o.id.ToString());
|
||
if (iGrid < 0) // 如果表内没有已存在的数据,新增一条数据
|
||
{
|
||
iGrid = this.dgvFissionProduct.Rows.Add();
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColSelect"].Value = false; //选择
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColId"].Value = o.id; //ID
|
||
}
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColOriginalTitle"].Value = o.title; // 原始标题
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["OriginalId"].Value = o.fession_id; // 原始ID
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["Title"].Value = o.fession_title; // 新标题
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["Price"].Value = o.price; // 价格
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["SaleAmount"].Value = o.sales; // 销量
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColCategory"].Value = o.category; // 组别
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColFullCategory"].Value = catStr; // 完整类目
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColCategory1"].Value = o.main_cate; // 类目1
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColCategory2"].Value = o.cat2_name; // 类目2
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColCategory3"].Value = o.cat3_name; // 类目3
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColTitleNum"].Value = o.TitleNum; // 标题数量
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColUseCount"].Value = o.times; // 使用次数
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColDel"].Value = ClickType == 0 ? "删除" : "恢复"; // 操作
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColReEdit"].Value = "编辑"; // 再次净化编辑数据
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["colMessage"].Value = ""; // 消息
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColSource"].Value = o.source; // 来源
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColSourceFake"].Value = "货源网"; // 来源Fake
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColRkTime"].Value = o.addtime; // 入库时间
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColUpdateTime"].Value = o.update_time; // 修改时间
|
||
this.dgvFissionProduct.Rows[iGrid].Cells["ColNeedUpdate"].Value = o.update_check_passed == 1 ? "" : (o.update_check_passed == 9 ? "上家下架" : "请更新商品"); // 校验更新
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取 datagridview所在的行下标,找不到则返回-1
|
||
/// </summary>
|
||
/// <param name="dgv"></param>
|
||
/// <param name="columnName"></param>
|
||
/// <param name="columnValue"></param>
|
||
/// <returns></returns>
|
||
int GetGridViewIndex(UserComponent.DataGridViewEx dgv, string columnName, string columnValue)
|
||
{
|
||
|
||
for (int i = 0; i < dgv.Rows.Count; i++)
|
||
{
|
||
|
||
string value = dgv.Rows[i].Cells[columnName].Value.ToString();
|
||
if (value == columnValue)
|
||
{
|
||
return i;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
|
||
private void btnGoTo_Click(object sender, EventArgs e)
|
||
{
|
||
int pageNum = 0;
|
||
if (string.IsNullOrEmpty(this.txtCurrentPage.Text))
|
||
{
|
||
return;
|
||
}
|
||
if (int.TryParse(txtCurrentPage.Text, out pageNum))
|
||
{
|
||
if (pageNum > 0 && pageNum <= int.Parse(this.lblTotalPage.Text))
|
||
{
|
||
this.lblCurrentPage.Text = txtCurrentPage.Text;
|
||
SearchFission();
|
||
}
|
||
else
|
||
{
|
||
BaseMsgForm.ShowInfo("输入的数字超出范围!");
|
||
this.txtCurrentPage.Text = string.Empty;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
BaseMsgForm.ShowInfo("请输入有效数字!");
|
||
this.txtCurrentPage.Text = string.Empty;
|
||
}
|
||
}
|
||
|
||
private void dgvFissionProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.RowIndex < 0 || e.ColumnIndex < 0)
|
||
return;
|
||
|
||
var columnName = dgvFissionProduct.Columns[e.ColumnIndex].Name;
|
||
var headerText = dgvFissionProduct.Columns[e.ColumnIndex].HeaderText;
|
||
if (headerText == "选" || columnName == "ColSelect")
|
||
{
|
||
dgvFissionProduct.Rows[e.RowIndex].Cells["ColSelect"].Value = !dgvFissionProduct.Rows[e.RowIndex].Cells["ColSelect"].Value.ParseToBool();
|
||
}
|
||
else if (headerText == "操作")
|
||
{
|
||
string OperatingName = dgvFissionProduct.Rows[e.RowIndex].Cells["ColDel"].Value.ToString();
|
||
string Id = dgvFissionProduct.Rows[e.RowIndex].Cells["ColId"].Value.ToString();
|
||
string OrgId = dgvFissionProduct.Rows[e.RowIndex].Cells["OriginalId"].Value.ToString(); // 原商品ID
|
||
if (OperatingName == "删除")
|
||
{
|
||
//if (BaseMsgForm.ShowConfirm("是否确认删除此数据?\r\n注:如果上货列表中有此数据将会一并删除。").DialogResult.Equals(DialogResult.Cancel)) return;
|
||
if (BaseMsgForm.ShowConfirm("是否确认删除此数据?").DialogResult.Equals(DialogResult.Cancel)) return;
|
||
// 根据上家标题,原始Id删除数据库数据
|
||
Task.Factory.StartNew(() => { new FissionDataBaseBLL().DelFessionData(Id); });
|
||
//// 删除listFissionPcb
|
||
//UploadProductForm.lstFissionPcb.RemoveAll(x => x != null && x.from_id == OrgId.ParseToLong());
|
||
//// 删除上货列表备用商品
|
||
//UploadProductBLL.ProductStock.RemoveAll(x => x.FromId == OrgId.ParseToLong());
|
||
//// 删除本地数据库备用商品
|
||
//UploadProductBLL.Delete(OrgId);
|
||
//// 刷新上传界面的上传队列数量
|
||
//UploadProductForm.instance?.remain();
|
||
}
|
||
else
|
||
{
|
||
if (BaseMsgForm.ShowConfirm("是否确认恢复此数据?").DialogResult.Equals(DialogResult.Cancel)) return;
|
||
// 根据上家标题,原始Id恢复
|
||
Task.Factory.StartNew(() => new FissionDataBaseBLL().RestoreFessionData(Id.ToString()));
|
||
}
|
||
// 删除行
|
||
dgvFissionProduct.Rows.RemoveAt(e.RowIndex); // 从集合中移除指定的行
|
||
}
|
||
else if (headerText == "原始ID")
|
||
{
|
||
string source = dgvFissionProduct.Rows[e.RowIndex].Cells["ColSource"].Value.ToString(); // 来源
|
||
string OrgId = dgvFissionProduct.Rows[e.RowIndex].Cells["OriginalId"].Value.ToString(); // 原商品ID
|
||
string url = GetFromUrl(source, OrgId);
|
||
|
||
GetHtml.OpenUrl(url);
|
||
}
|
||
else if (headerText == "编辑")
|
||
{
|
||
string Id = dgvFissionProduct.Rows[e.RowIndex].Cells["ColId"].Value.ToString();
|
||
var Fiss = this.LstFission.FirstOrDefault(f => f.id.ToString() == Id);
|
||
if (Fiss != null)
|
||
{
|
||
try
|
||
{
|
||
var fissionTemp = new FissionDataBaseBLL().GetFessionDetailById(Id.ParseToInt());
|
||
Fiss.fession_title = fissionTemp.fession_title;
|
||
Fiss.container_info = fissionTemp?.container_info.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
Fiss.main_pic = fissionTemp.main_pic;
|
||
Fiss.prop_pic = fissionTemp.prop_pic;
|
||
Fiss.props = fissionTemp.props;
|
||
Fiss.mainWord = fissionTemp.mainWord;
|
||
Fiss.viceword = fissionTemp.viceword;
|
||
Fiss.prop = fissionTemp.prop;
|
||
Fiss.skus = fissionTemp.skus;
|
||
Fiss.from_shop_name = fissionTemp.from_shop_name;
|
||
Fiss.qualifications = fissionTemp.qualifications;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("获取裂变明细信息发生异常" + ex.Message);
|
||
}
|
||
if (string.IsNullOrEmpty(Fiss.fession_title))
|
||
return;
|
||
if (Fiss.source == "laiyuan")
|
||
{
|
||
if (Fiss.main_pic.Contains("pddpic") || Fiss.prop_pic.Contains("pddpic") || Fiss.container_info.Contains("pddpic"))
|
||
{
|
||
Fiss.source = "拼多多";
|
||
}
|
||
}
|
||
ProductCollectBase pcb = FissionData2Pcb(Fiss, Fiss.fession_title);
|
||
|
||
// 校验总店商品是否发生变化
|
||
string msg = "";
|
||
var pcb_new = CheckProductStatus(pcb, out msg);
|
||
if (msg == "商品已下架")
|
||
{
|
||
BaseMsgForm.ShowInfo("总店商品已下架 !");
|
||
return;
|
||
}
|
||
if (pcb_new != pcb && BaseMsgForm.ShowConfirm("原商品发生变化,点击 确定 打开变化后的商品,点击 取消 编辑原数据库商品").DialogResult == DialogResult.OK)
|
||
{
|
||
string createHtmlPath = Fission.creatFissionPage(pcb_new);
|
||
Fission fs = new Fission(createHtmlPath, pcb.from_url, null, pcb, Fiss.category, Fiss.full_category_name, Fiss.fession_title);
|
||
fs.Show();
|
||
}
|
||
else
|
||
{
|
||
string createHtmlPath = Fission.creatFissionPage(pcb);
|
||
Fission fs = new Fission(createHtmlPath, pcb.from_url, new List<FissionData>() { Fiss }, pcb, Fiss.category, Fiss.full_category_name, Fiss.fession_title);
|
||
fs.Show();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private static string GetFromUrl(string source, string OrgId)
|
||
{
|
||
string url = "";
|
||
if (source == "1688" || source == "阿里巴巴")
|
||
{
|
||
url = "https://detail.1688.com/offer/" + OrgId + ".html";
|
||
}
|
||
else if (source == "拼多多")
|
||
{
|
||
url = "https://yangkeduo.com/goods2.html?goods_id=" + OrgId;
|
||
}
|
||
else if (source == "京喜" || source == "京东")
|
||
{
|
||
url = "https://item.jd.com/" + OrgId + ".html";
|
||
}
|
||
else if (source == "抖音")
|
||
{
|
||
url = "https://haohuo.jinritemai.com/views/product/detail?id=" + OrgId;
|
||
}
|
||
else
|
||
{
|
||
url = "https://item.taobao.com/item.htm?id=" + OrgId;
|
||
}
|
||
return url;
|
||
}
|
||
|
||
private void btnAddFissToUpload_Click(object sender, EventArgs e)
|
||
{
|
||
var fissionIdList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool())
|
||
.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
if (fissionIdList.Count == 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("请选择要上传的数据", "提示");
|
||
return;
|
||
}
|
||
btnAddFissToUpload.Enabled = false;
|
||
progressBarX1.Visible = true;
|
||
progressBarX1.Maximum = fissionIdList.Count;
|
||
progressBarX1.Value = 0;
|
||
pbLoading.Visible = true;
|
||
Task.Run(() =>
|
||
{
|
||
UploadFessionData(fissionIdList);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加到上货 isTryUpload 是否试水上货
|
||
/// </summary>
|
||
/// <param name="selectFissionIdList"></param>
|
||
public void UploadFessionData(List<string> selectFissionIdList)
|
||
{
|
||
DateTime startTime = DateTime.Now;
|
||
|
||
// 重置操作信息状态
|
||
for (int i = 0; i < selectFissionIdList.Count; i++)
|
||
{
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == selectFissionIdList[i].ToString())
|
||
row.Cells["colMessage"].Value = "";
|
||
}
|
||
}
|
||
|
||
string fissionDataBaseIds = "";
|
||
List<ProductCollectBase> pcbList = new List<ProductCollectBase>();
|
||
for (int i = 0; i < selectFissionIdList.Count; i++)
|
||
{
|
||
var FissId = selectFissionIdList[i].ParseToInt();
|
||
var Fiss = LstFission.Find(f => f != null && f.id == FissId);
|
||
if (Fiss != null)
|
||
{
|
||
fissionDataBaseIds += FissId + ";";
|
||
string dataSource = Fiss.source == null ? "" : Fiss.source;
|
||
string OriginalId = Fiss.fession_id;
|
||
if (string.IsNullOrEmpty(Fiss.main_pic))
|
||
{
|
||
try
|
||
{
|
||
//var fissionTemp = new FissionDataBaseBLL().GetFessionDetailById(FissId);
|
||
//Fiss.fession_title = fissionTemp.fession_title;
|
||
//Fiss.container_info = fissionTemp.container_info?.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
//Fiss.main_pic = fissionTemp.main_pic;
|
||
//Fiss.prop_pic = fissionTemp.prop_pic;
|
||
//Fiss.props = fissionTemp.props;
|
||
//Fiss.mainWord = fissionTemp.mainWord;
|
||
//Fiss.viceword = fissionTemp.viceword;
|
||
//Fiss.prop = fissionTemp.prop;
|
||
//Fiss.skus = fissionTemp.skus;
|
||
//Fiss.from_shop_name = fissionTemp.from_shop_name;
|
||
//Fiss.qualifications = fissionTemp.qualifications;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("获取裂变明细信息发生异常" + ex.Message);
|
||
}
|
||
}
|
||
|
||
var result = "";
|
||
var fission_title = Fiss?.fession_title?.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)?[0];
|
||
ProductCollectBase pcb = FissionData2Pcb(Fiss, fission_title);
|
||
if (pcb != null)
|
||
{
|
||
pcbList.Add(pcb);
|
||
}
|
||
else
|
||
{
|
||
result = "添加失败";
|
||
}
|
||
|
||
// 更新DataGridView // isTitleNumLimited 是否限定每个裂变商品的上传个数
|
||
UpdateUseCount(FissId);
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == FissId.ToString())
|
||
{
|
||
row.Cells["colMessage"].Value = result;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (pcbList.Count >= 50)
|
||
{
|
||
// 添加到上传数据库
|
||
UploadProductForm.ImportFromFission(pcbList);
|
||
pcbList.Clear();
|
||
// 记录使用次数
|
||
SetUseCount(fissionDataBaseIds);
|
||
fissionDataBaseIds = "";
|
||
}
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
progressBarX1.Value = i;
|
||
}));
|
||
}
|
||
|
||
// 添加到上传数据库
|
||
UploadProductForm.ImportFromFission(pcbList);
|
||
pcbList.Clear();
|
||
// 记录使用次数
|
||
SetUseCount(fissionDataBaseIds);
|
||
fissionDataBaseIds = "";
|
||
|
||
Invoke(new Action(() =>
|
||
{
|
||
progressBarX1.Value = progressBarX1.Maximum;
|
||
this.btnAddFissToUpload.Enabled = true;
|
||
var ts = DateTime.Now - startTime;
|
||
var min = (int)Math.Floor(ts.TotalMinutes);
|
||
var sec = (int)Math.Floor(ts.TotalSeconds) % 60;
|
||
BaseMsgForm.ShowInfo("添加完成,累计耗时:" + min + "分" + sec + "秒", "提示");
|
||
pbLoading.Visible = false;
|
||
progressBarX1.Visible = false;
|
||
}));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置使用次数信息更新
|
||
/// </summary>
|
||
public void SetUseCount(string fessDbIds)
|
||
{
|
||
try
|
||
{
|
||
string getRequestData = UserLogin.GetSignaturex() + "&act=set&id=" + fessDbIds;
|
||
string getUrl = BaseClass.BuildFissionObjString("fession_api");
|
||
string Result = GetHtml.PostUtf8(getUrl, getRequestData);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("SetUseCount发生异常:" + ex.Message);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新使用次数
|
||
/// </summary>
|
||
/// <param name="FessId"></param>
|
||
public void UpdateUseCount(int FessId, int useCount = 1)
|
||
{
|
||
for (int i = 0; i < dgvFissionProduct.Rows.Count; i++)
|
||
{
|
||
var id = dgvFissionProduct.Rows[i].Cells["ColId"].Value.ToString();
|
||
if (id != FessId.ToString())
|
||
continue;
|
||
|
||
int sUserCount = Convert.ToInt32(dgvFissionProduct.Rows[i].Cells["ColUseCount"].Value.ToString());
|
||
dgvFissionProduct.Rows[i].Cells["ColUseCount"].Value = sUserCount + useCount;
|
||
var Fess = LstFission.Find(f => f != null && f.id == FessId);
|
||
Fess.times += useCount;
|
||
break;
|
||
}
|
||
}
|
||
|
||
FissionDataModel Fiss2FissionDataModel(FissionData fissData)
|
||
{
|
||
if (fissData == null)
|
||
return null;
|
||
|
||
FissionDataModel fdm = new FissionDataModel()
|
||
{
|
||
addPricePercent = fissData.add_pricepercent.ParseToDecimal(),
|
||
adjustPrice = fissData.is_changeprice.ParseToInt(),
|
||
baseAddPrice = fissData.base_addprice.ParseToInt(),
|
||
cat2_name = fissData.cat2_name,
|
||
cat3_name = fissData.cat3_name,
|
||
cate_id = fissData.cate_id.ParseToInt(),
|
||
//content_pic = fissData.container_info.Split(';').ToList(),
|
||
discount = fissData.discount,
|
||
fessionCount = fissData.fession_count,
|
||
fessionTitle = fissData.fession_title.Split(new string[] { ";", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(),
|
||
fession_id = fissData.fession_id,
|
||
from_shop_name = fissData.from_shop_name,
|
||
fullCategoryName = fissData.full_category_name,
|
||
id = fissData.fession_id,
|
||
mainCategory = fissData.main_cate,
|
||
mainWord = fissData.mainWord,
|
||
main_cate_id = fissData.main_cateid.ParseToInt(),
|
||
main_pic = fissData.main_pic.Split(';').ToList(),
|
||
postFree = fissData.postFree,
|
||
price = fissData.price,
|
||
prop = fissData.prop,
|
||
props = fissData.props,
|
||
prop_pic = fissData.prop_pic.Split(';').ToList(),
|
||
qualifications = fissData.qualifications,
|
||
sales = fissData.sales,
|
||
secondCategory = fissData.second_cate,
|
||
skus = fissData.skus,
|
||
source = fissData.source,
|
||
teamGroup = fissData.category,
|
||
title = fissData.title,
|
||
viceWord = fissData.viceword,
|
||
};
|
||
|
||
fdm.content_pic = new List<string>();
|
||
var container_infos = fissData.container_info?.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
var containerGroupList = container_infos.Split(new string[] { "<br/>" }, StringSplitOptions.RemoveEmptyEntries);
|
||
for (int i = 0; i < containerGroupList.Length; i++)
|
||
{
|
||
var container_info = containerGroupList[i];
|
||
var content_imgs = BaseRegex.GetMatchRegex(ref container_info, "<img src='([\\s\\S]+?)'>");
|
||
if (content_imgs != null)
|
||
{
|
||
List<string> content = new List<string>();
|
||
foreach (Match m in content_imgs)
|
||
{
|
||
var src = m.Groups[1]?.ToString();
|
||
if (src != null)
|
||
content.Add(src);
|
||
}
|
||
// 添加分组间隔
|
||
if (content.Count > 0 && i > 0)
|
||
fdm.content_pic.Add("new_group");
|
||
fdm.content_pic.AddRange(content);
|
||
}
|
||
}
|
||
|
||
return fdm;
|
||
}
|
||
|
||
public FissionData FissDataModel2Fission(FissionDataModel fissionDataModel)
|
||
{
|
||
if (fissionDataModel == null)
|
||
return null;
|
||
|
||
if (fissionDataModel.prop_pic == null)
|
||
fissionDataModel.prop_pic = new List<string>();
|
||
fissionDataModel.prop_pic?.Clear();
|
||
var props = JsonHelper.DeserializeJsonToObject<List<PropBase>>(fissionDataModel.props);
|
||
foreach (var prop in props)
|
||
{
|
||
foreach (var value in prop.Values)
|
||
{
|
||
if (!string.IsNullOrEmpty(value.image))
|
||
{
|
||
var strImg = value.image;
|
||
if (!strImg.StartsWith("http"))
|
||
strImg = "http:" + strImg;
|
||
fissionDataModel.prop_pic.Add(strImg);
|
||
}
|
||
}
|
||
}
|
||
|
||
FissionData fd = new FissionData()
|
||
{
|
||
add_pricepercent = fissionDataModel.addPricePercent.ParseToInt(),
|
||
is_changeprice = fissionDataModel.adjustPrice.ToString(),
|
||
base_addprice = fissionDataModel.baseAddPrice.ParseToInt(),
|
||
cat2_name = fissionDataModel.cat2_name,
|
||
cat3_name = fissionDataModel.cat3_name,
|
||
cate_id = fissionDataModel.cate_id.ParseToString(),
|
||
//content_pic = fissData.container_info.Split(';').ToList(),
|
||
discount = fissionDataModel.discount,
|
||
fession_count = fissionDataModel.fessionCount,
|
||
fession_title = string.Join(";", fissionDataModel.fessionTitle),
|
||
fession_id = fissionDataModel.fession_id,
|
||
from_shop_name = fissionDataModel.from_shop_name,
|
||
full_category_name = fissionDataModel.fullCategoryName,
|
||
id = fissionDataModel.id.ParseToInt(),
|
||
main_cate = fissionDataModel.mainCategory,
|
||
mainWord = fissionDataModel.mainWord,
|
||
main_cateid = fissionDataModel.main_cate_id.ToString(),
|
||
main_pic = string.Join(";", fissionDataModel.main_pic),
|
||
postFree = fissionDataModel.postFree,
|
||
price = fissionDataModel.price,
|
||
prop = fissionDataModel.prop,
|
||
props = fissionDataModel.props,
|
||
prop_pic = string.Join(";", fissionDataModel.prop_pic),
|
||
qualifications = fissionDataModel.qualifications,
|
||
sales = fissionDataModel.sales,
|
||
second_cate = fissionDataModel.secondCategory,
|
||
skus = fissionDataModel.skus,
|
||
source = fissionDataModel.source,
|
||
category = fissionDataModel.teamGroup,
|
||
title = fissionDataModel.title,
|
||
viceword = fissionDataModel.viceWord,
|
||
};
|
||
|
||
fd.container_info = "";
|
||
foreach (var picUrl in fissionDataModel.content_pic)
|
||
{
|
||
if (picUrl == "new_group")
|
||
fd.container_info += "<br/>";
|
||
else
|
||
fd.container_info += "<img src='" + picUrl + "'>";
|
||
}
|
||
|
||
return fd;
|
||
}
|
||
|
||
public static ProductCollectBase FissionData2Pcb(FissionData fissData, string title)
|
||
{
|
||
// 是否调节价格 对应字段:ProductCollectBase.is_changeprice
|
||
// 加价倍数 对应字段:ProductCollectBase.addPricePe rcent
|
||
// 基础加价 对应字段:ProductCollectBase.baseAddPrice
|
||
// 拼团折扣 对应字段:ProductCollectBase.discount
|
||
|
||
if (fissData == null)
|
||
return null;
|
||
|
||
ProductCollectBase pcb = new ProductCollectBase();
|
||
|
||
pcb.fissionDataBaseId = fissData.id;
|
||
// 是否是进化数据商品
|
||
pcb.isFission = true;
|
||
// 商品id
|
||
pcb.from_id = fissData.fession_id.ParseToLong();
|
||
// 销量
|
||
pcb.saleCount = fissData.sales.ParseToInt();
|
||
// 价格
|
||
pcb.price = fissData.price.ParseToDecimal();
|
||
// 原标题:不用修改
|
||
pcb.from_title = pcb.from_name = fissData.title;
|
||
// 裂变标题
|
||
pcb.fission_names = fissData.fession_title?.Split(new string[] { "\r", "\n", ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
// 修改后的标题
|
||
pcb.name = pcb.fission_names != null && pcb.fission_names.Count > 0 ? pcb.fission_names[0] : fissData.title;
|
||
// 来源
|
||
pcb.from = fissData.source;
|
||
// 来源地址
|
||
pcb.from_url = GetFromUrl(fissData.source, fissData.fession_id);
|
||
// 邮费金额
|
||
pcb.express_price = fissData.postFree == null ? 0 : fissData.postFree.ParseToDecimal();
|
||
// 主图
|
||
pcb.Images = string.IsNullOrEmpty(fissData.main_pic) ? new List<string>() : fissData.main_pic.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||
// 详情图
|
||
pcb.content = fissData.container_info?.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
// 子分类id
|
||
pcb.cat_id = fissData.cate_id.ParseToInt();
|
||
// 主分类id
|
||
pcb.main_cid = fissData.main_cateid.ParseToInt();
|
||
// 主分类名称
|
||
pcb.main_cat_name = fissData.main_cate;
|
||
// 是否调节价格
|
||
pcb.is_changeprice = fissData.is_changeprice == "1" ? "True" : "False";
|
||
// 加价比例
|
||
pcb.addPricePercent = fissData.add_pricepercent.ParseToDecimal();
|
||
// 基础加价
|
||
pcb.baseAddPrice = fissData.base_addprice.ParseToDecimal();
|
||
// 折扣比例
|
||
pcb.discount = fissData.discount;
|
||
// 商品属性
|
||
try
|
||
{
|
||
pcb.Prop = JsonHelper.DeserializeJsonToList<KeyValueBase>(fissData.prop);
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
// sku属性列表
|
||
try
|
||
{
|
||
pcb.Props = JsonHelper.DeserializeJsonToList<PropBase>(fissData.props);
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
// 来源店铺名称
|
||
pcb.from_shop_name = fissData.from_shop_name;
|
||
// sku列表
|
||
try
|
||
{
|
||
pcb.SkuMaps = JsonHelper.DeserializeJsonToList<SkuMapBase>(fissData.skus);
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
// 资质文件列表
|
||
try
|
||
{
|
||
pcb.qualifications = JsonHelper.DeserializeJsonToList<quality_file>(fissData.qualifications);
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
|
||
if (pcb.from == "淘宝") pcb.from_site_id = 1;
|
||
else if (pcb.from == "拼多多") pcb.from_site_id = 2;
|
||
else if (pcb.from == "阿里巴巴" || pcb.from == "1688") pcb.from_site_id = 3;
|
||
else if (pcb.from == "京喜") pcb.from_site_id = 4;
|
||
else if (pcb.from == "微店") pcb.from_site_id = 6;
|
||
else if (pcb.from == "抖音") pcb.from_site_id = 7;
|
||
|
||
return pcb;
|
||
}
|
||
|
||
private void btnClearParams_Click(object sender, EventArgs e)
|
||
{
|
||
this.txtPriceMin.Text = "0";
|
||
this.txtPriceMax.Text = "99999";
|
||
this.txtSaleAmountMin.Text = "0";
|
||
this.txtSaleAmountMax.Text = "99999";
|
||
this.txtMinTimes.Text = "0";
|
||
this.txtMaxTimes.Text = "99999";
|
||
this.txtFisssionTitle.Text = "";
|
||
this.dtBaginTime.Text = "";
|
||
this.dtEndTime.Text = "";
|
||
this.cmbSource.SelectedIndex = 0;
|
||
if (cmbCat1.Items.Count > 0)
|
||
cmbCat1.SelectedIndex = 0;
|
||
if (cmbShopCat1.Items.Count > 0)
|
||
cmbShopCat1.SelectedIndex = 0;
|
||
if (cmbGroup.Items.Count > 0)
|
||
this.cmbGroup.SelectedIndex = 0;
|
||
if (cmbCheckResult.Items.Count > 0)
|
||
cmbCheckResult.SelectedIndex = 0;
|
||
}
|
||
|
||
private void btnClearList_Click(object sender, EventArgs e)
|
||
{
|
||
DialogResult result = BaseMsgForm.ShowConfirm("确认清空当前搜索结果吗?", "提示").DialogResult;
|
||
if (result == DialogResult.OK)
|
||
{
|
||
IsStop = true;
|
||
this.dgvFissionProduct.Rows.Clear();
|
||
LstFission.Clear();
|
||
}
|
||
}
|
||
|
||
private void btnDeleteSelect_Click(object sender, EventArgs e)
|
||
{
|
||
if (ClickType == 1)
|
||
{
|
||
BaseMsgForm.ShowInfo("产品回收站的数据无法删除!");
|
||
return;
|
||
}
|
||
var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool()).ToList();
|
||
var fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
if (fissionIdList.Count == 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("请选择要删除的数据", "提示");
|
||
return;
|
||
}
|
||
//if (BaseMsgForm.ShowConfirm("是否确认删除勾选数据?\r\n注:如果上货列表中有此数据将会一并删除。").DialogResult.Equals(DialogResult.Cancel)) return;
|
||
if (BaseMsgForm.ShowConfirm("是否确认删除勾选数据?").DialogResult.Equals(DialogResult.Cancel)) return;
|
||
|
||
// 根据上家标题,原始Id删除数据库数据
|
||
string strTemp = "";
|
||
foreach (var id in fissionIdList)
|
||
{
|
||
strTemp += id + ",";
|
||
}
|
||
new FissionDataBaseBLL().DelFessionData(strTemp);
|
||
|
||
foreach (var row in fissionRowList)
|
||
{
|
||
string OrgId = row.Cells["OriginalId"].Value.ToString(); // 原商品ID
|
||
//// 删除listFissionPcb
|
||
//UploadProductForm.lstFissionPcb.RemoveAll(x => x != null && x.from_id == OrgId.ParseToLong());
|
||
//// 删除上货列表备用商品
|
||
//UploadProductBLL.ProductStock.RemoveAll(x => x.FromId == OrgId.ParseToLong());
|
||
//// 删除本地数据库备用商品
|
||
//UploadProductBLL.Delete(OrgId);
|
||
//// 刷新上传界面的上传队列数量
|
||
//UploadProductForm.instance?.remain();
|
||
}
|
||
// 删除行
|
||
foreach (var row in fissionRowList)
|
||
{
|
||
dgvFissionProduct.Rows.Remove(row);
|
||
}
|
||
}
|
||
|
||
private void btnToUpload_Click(object sender, EventArgs e)
|
||
{
|
||
if (UploadForm.instance != null)
|
||
UploadForm.instance.SetTvSelect("商品发布");
|
||
}
|
||
|
||
private void pnlDelCate_Click(object sender, EventArgs e)
|
||
{
|
||
string groupName = cmbGroup.SelectedItem.ToString();
|
||
if (groupName == "不限")
|
||
{
|
||
BaseMsgForm.ShowInfo("不能删除不限!");
|
||
return;
|
||
}
|
||
|
||
if (BaseMsgForm.ShowConfirm("确定要删除选中的裂变分组和数据吗?", "提示").DialogResult == DialogResult.OK)
|
||
{
|
||
// 删除分组
|
||
string requestData = UserLogin.GetSignaturex() + "&act=delete_category&category=" +
|
||
GetHtml.UrlEncodeUtf8(groupName);
|
||
string url = BaseClass.BuildFissionObjString("fession_api");
|
||
string result = GetHtml.PostUtf8(url, requestData);
|
||
if (result != "ok")
|
||
{
|
||
LogSave.Add("删除组失败", "group name: " + groupName + " result: " + result);
|
||
}
|
||
else
|
||
{
|
||
BaseMsgForm.ShowInfo("删除组成功");
|
||
var groupList = new FissionDataBaseBLL().GetCategoryGroup();
|
||
cmbGroup.DataSource = groupList;
|
||
cmbGroup.SelectedIndex = 0;
|
||
var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColCategory"].Value.ParseToString() == groupName);
|
||
// 删除行
|
||
foreach (var row in fissionRowList)
|
||
{
|
||
dgvFissionProduct.Rows.Remove(row);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private void lblPrev_Click(object sender, EventArgs e)
|
||
{
|
||
if (txtCurrentPage.Text.ParseToInt() > 1)
|
||
txtCurrentPage.Text = (txtCurrentPage.Text.ParseToInt() - 1).ToString();
|
||
SearchFission();
|
||
}
|
||
|
||
private void lblNext_Click(object sender, EventArgs e)
|
||
{
|
||
if (txtCurrentPage.Text.ParseToInt() < lblTotalPage.Text.ParseToInt())
|
||
txtCurrentPage.Text = (txtCurrentPage.Text.ParseToInt() + 1).ToString();
|
||
SearchFission();
|
||
}
|
||
|
||
private void cmbCat1_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
public bool isCheckRun = false;
|
||
private void btnCheckUpProduct_Click(object sender, EventArgs e)
|
||
{
|
||
this.btnCheckUpProduct.Enabled = false;
|
||
Task.Run(() =>
|
||
{
|
||
Thread.Sleep(3000);
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.btnCheckUpProduct.Enabled = true;
|
||
}));
|
||
});
|
||
|
||
if (this.btnCheckUpProduct.Text == "停止校验")
|
||
{
|
||
isCheckRun = false;
|
||
return;
|
||
}
|
||
|
||
var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool()).ToList();
|
||
var fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
if (fissionIdList.Count == 0)
|
||
{
|
||
this.btnCheckUpProduct.Enabled = true;
|
||
BaseMsgForm.ShowInfo("请选择要校验的数据", "提示");
|
||
return;
|
||
}
|
||
|
||
this.isCheckRun = true;
|
||
this.btnCheckUpProduct.Text = "停止校验";
|
||
|
||
IsAutoTurnPage = chkAutoTurnPage.Checked && fissionIdList.Count == this.dgvFissionProduct.RowCount;
|
||
Task.Run(() =>
|
||
{
|
||
autoTurnPage:
|
||
foreach (var Id in fissionIdList)
|
||
{
|
||
if (!isCheckRun)
|
||
break;
|
||
|
||
Thread.Sleep(50);
|
||
var Fiss = this.LstFission.FirstOrDefault(f => f.id.ToString() == Id);
|
||
if (Fiss == null)
|
||
continue;
|
||
try
|
||
{
|
||
var fissionTemp = new FissionDataBaseBLL().GetFessionDetailById(Id.ParseToInt());
|
||
Fiss.fession_title = fissionTemp.fession_title;
|
||
while (fissionTemp.container_info != null && fissionTemp.container_info.Contains("<img src='<"))
|
||
{
|
||
fissionTemp.container_info = fissionTemp.container_info.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
}
|
||
Fiss.container_info = fissionTemp.container_info;
|
||
Fiss.main_pic = fissionTemp.main_pic;
|
||
Fiss.prop_pic = fissionTemp.prop_pic;
|
||
Fiss.props = fissionTemp.props;
|
||
Fiss.mainWord = fissionTemp.mainWord;
|
||
Fiss.viceword = fissionTemp.viceword;
|
||
Fiss.prop = fissionTemp.prop;
|
||
Fiss.skus = fissionTemp.skus;
|
||
Fiss.from_shop_name = fissionTemp.from_shop_name;
|
||
Fiss.qualifications = fissionTemp.qualifications;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("获取裂变明细信息发生异常" + ex.Message);
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(Fiss.fession_title))
|
||
continue;
|
||
|
||
if (Fiss.update_time.ParseToDateTime() > DateTime.Now.Date.AddDays(-7))
|
||
{
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == Fiss.id.ToString())
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colMessage"].Value = "近期已校验";
|
||
}));
|
||
break;
|
||
}
|
||
}
|
||
continue;
|
||
}
|
||
|
||
ProductCollectBase pcb = FissionData2Pcb(Fiss, Fiss.fession_title);
|
||
|
||
// 校验总店商品是否发生变化或下架
|
||
string msg = "";
|
||
var pcb_new = CheckProductStatus(pcb, out msg);
|
||
if (msg == "商品已下架")
|
||
{
|
||
FissionDataModel fdm = Fiss2FissionDataModel(Fiss);
|
||
fdm.update_check_passed = 9;
|
||
if (!IsDeleteUpDown)
|
||
{
|
||
string result = new FissionBrowserObject().updateFessionDate(JsonHelper.SerializeObject(fdm));
|
||
}
|
||
|
||
var FissId = Fiss.id.ToString();
|
||
DataGridViewRow dgvRow = null;
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == FissId)
|
||
{
|
||
dgvRow = row;
|
||
Invoke(new Action(() =>
|
||
{
|
||
dgvRow.Cells["colMessage"].Value = "总店商品已下架,请删除";
|
||
row.Cells["ColNeedUpdate"].Value = fdm.update_check_passed == 9 ? "上家下架" : ""; // 校验更新
|
||
}));
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (IsDeleteUpDown)
|
||
{
|
||
new FissionDataBaseBLL().DelFessionData(Id);
|
||
|
||
if (dgvRow != null)
|
||
this.dgvFissionProduct.Rows.Remove(dgvRow);
|
||
this.LstFission.Remove(Fiss);
|
||
}
|
||
}
|
||
else if (pcb_new != pcb || msg == "商品价格发生变化")
|
||
{
|
||
if ((pcb_new != pcb && IsUpdateUpChange) || msg == "商品价格发生变化")
|
||
{
|
||
Fiss.price = pcb_new.price.ToString();
|
||
Fiss.skus = JsonHelper.SerializeObject(pcb_new.SkuMaps);
|
||
Fiss.prop = JsonHelper.SerializeObject(pcb_new.Prop);
|
||
Fiss.props = JsonHelper.SerializeObject(pcb_new.Props);
|
||
Fiss.main_pic = string.Join(";", pcb_new.Images);
|
||
Fiss.prop_pic = "";
|
||
foreach (var p in pcb_new.Props)
|
||
{
|
||
foreach (var pv in p.Values)
|
||
{
|
||
if (!string.IsNullOrEmpty(pv.image))
|
||
Fiss.prop_pic += pv.image + ";";
|
||
}
|
||
}
|
||
Fiss.prop_pic = Fiss.prop_pic.TrimEnd(';');
|
||
|
||
FissionDataModel fdm = Fiss2FissionDataModel(Fiss);
|
||
fdm.update_check_passed = 1;
|
||
string result = new FissionBrowserObject().updateFessionDate(JsonHelper.SerializeObject(fdm));
|
||
if (result == null)
|
||
result = "";
|
||
result = JsonHelper.SerializeObject(JObject.Parse(result));
|
||
string updateMsg = BaseRegex.GetStringJson(ref result, "msg");
|
||
|
||
if (result.Contains("\"code\":0"))
|
||
{
|
||
updateMsg = "总店商品规格变化更新成功";
|
||
if (msg == "商品价格发生变化")
|
||
updateMsg = "总店商品价格变化更新成功";
|
||
}
|
||
else
|
||
{
|
||
updateMsg = "总店商品规格变化更新失败";
|
||
if (msg == "商品价格发生变化")
|
||
updateMsg = "总店商品价格变化更新失败";
|
||
}
|
||
|
||
var FissId = Fiss.id.ToString();
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == FissId)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colMessage"].Value = updateMsg;
|
||
row.Cells["ColNeedUpdate"].Value = fdm.update_check_passed == 1 ? "" : "请更新商品"; // 校验更新
|
||
}));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
FissionDataModel fdm = Fiss2FissionDataModel(Fiss);
|
||
fdm.update_check_passed = 0;
|
||
string result = new FissionBrowserObject().updateFessionDate(JsonHelper.SerializeObject(fdm));
|
||
|
||
var FissId = Fiss.id.ToString();
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == FissId)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colMessage"].Value = "总店商品规格变化,请更新";
|
||
row.Cells["ColNeedUpdate"].Value = fdm.update_check_passed == 1 ? "" : "请更新商品"; // 校验更新
|
||
}));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
FissionDataModel fdm = Fiss2FissionDataModel(Fiss);
|
||
string result = new FissionBrowserObject().updateFessionDate(JsonHelper.SerializeObject(fdm));
|
||
|
||
var FissId = Fiss.id.ToString();
|
||
foreach (DataGridViewRow row in this.dgvFissionProduct.Rows)
|
||
{
|
||
if (row.Cells["ColId"].Value.ToString() == FissId)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
row.Cells["colMessage"].Value = msg == "商品采集失败" ? msg : "商品无需更新";
|
||
row.Cells["ColNeedUpdate"].Value = ""; // 校验更新
|
||
}));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (IsAutoTurnPage && isCheckRun && lblCurrentPage.Text.ParseToInt() < lblTotalPage.Text.ParseToInt())
|
||
{
|
||
IsTurnPage = true;
|
||
Invoke(new Action(() =>
|
||
{
|
||
lblNext_Click(null, null);
|
||
chkAll.Checked = true;
|
||
fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool()).ToList();
|
||
fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
}));
|
||
Thread.Sleep(1000);
|
||
goto autoTurnPage;
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
this.btnCheckUpProduct.Text = "校验勾选";
|
||
}));
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取上家商品最新详情与当前数据库商品(pcb_old)校验是否有更新
|
||
/// </summary>
|
||
/// <param name="pcb_old"></param>
|
||
/// <param name="msg"></param>
|
||
/// <returns></returns>
|
||
private ProductCollectBase CheckProductStatus(ProductCollectBase pcb_old, out string msg)
|
||
{
|
||
msg = "";
|
||
bool isPriceChange = false;
|
||
bool isProductChange = false;
|
||
|
||
ProductCollectBase pcb_new = GetNewPcb(pcb_old, out msg);
|
||
|
||
if (msg == "商品已下架")
|
||
return pcb_old;
|
||
|
||
if (string.IsNullOrEmpty(pcb_new.image) && (pcb_new.Images == null || pcb_new.Images.Count == 0 || string.IsNullOrEmpty(pcb_new.Images[0])))
|
||
{
|
||
msg = "商品采集失败";
|
||
return pcb_old;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(pcb_old.image) && (pcb_old.Images == null || pcb_old.Images.Count == 0 || string.IsNullOrEmpty(pcb_old.Images[0])))
|
||
{
|
||
isProductChange = true;
|
||
return pcb_new;
|
||
}
|
||
|
||
if (pcb_old.price != pcb_new.price)
|
||
{
|
||
msg = "商品价格发生变化";
|
||
isPriceChange = true;
|
||
pcb_old.price = pcb_new.price;
|
||
}
|
||
|
||
foreach (var sku in pcb_old.SkuMaps)
|
||
{
|
||
var sku_new = pcb_new.SkuMaps.FirstOrDefault(s => s.name == sku.name);
|
||
if (sku_new != null)
|
||
{
|
||
if (sku_new.price != sku.price)
|
||
{
|
||
msg = "商品价格发生变化";
|
||
isPriceChange = true;
|
||
sku.price = sku_new.price;
|
||
}
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
isProductChange = true;
|
||
return pcb_new;
|
||
}
|
||
}
|
||
|
||
return pcb_old;
|
||
}
|
||
|
||
public ProductCollectBase GetNewPcb(ProductCollectBase pcb_old, out string msg)
|
||
{
|
||
msg = "";
|
||
|
||
ProductCollectBase pcb_new = new ProductCollectBase();
|
||
pcb_new.from_id = pcb_old.from_id;
|
||
pcb_new.from_url = GetFromUrl(pcb_old.from, pcb_new.from_id.ToString());
|
||
|
||
if (pcb_old.from == "抖音")
|
||
{
|
||
CollectDoyin cd = new CollectDoyin(pcb_new);
|
||
cd.GetProduct();
|
||
cd.Product.from = "抖音";
|
||
cd.Product.from_url = GetFromUrl("抖音", pcb_new.from_id.ToString());
|
||
pcb_new = cd.Product;
|
||
|
||
if (!cd.Product.IsOnSale)
|
||
msg = "商品已下架";
|
||
}
|
||
else if (pcb_old.from == "拼多多")
|
||
{
|
||
TaobaoProductBase tp = new TaobaoProductBase();
|
||
tp.FromId = pcb_old.from_id;
|
||
tp.FromType = "拼多多";
|
||
tp.GoodsId = tp.FromId;
|
||
|
||
PinduoduoProductCollect pdd = new PinduoduoProductCollect(Name, tp);
|
||
pdd.Get();
|
||
pdd.pb.from = "拼多多";
|
||
pdd.pb.from_url = "http://mobile.yangkeduo.com/goods.html?goods_id=" + tp.GoodsId;
|
||
pcb_new = pdd.pb;
|
||
|
||
if (!pdd.OnSale)
|
||
msg = "商品已下架";
|
||
}
|
||
else if (pcb_old.from == "阿里巴巴" || pcb_old.from == "1688")
|
||
{
|
||
AlibabaProductGet alibbProInfo = new AlibabaProductGet(pcb_new);
|
||
alibbProInfo.Get();
|
||
alibbProInfo.Product.from = "阿里巴巴";
|
||
alibbProInfo.Product.from_url = pcb_new.from_url;
|
||
pcb_new = alibbProInfo.Product;
|
||
|
||
if (!alibbProInfo.OnSale)
|
||
msg = "商品已下架";
|
||
}
|
||
else if (pcb_old.from == "京喜" || pcb_old.from == "京东")
|
||
{
|
||
JingXiCollect tm = new JingXiCollect(pcb_new);
|
||
tm.Get();
|
||
tm.Product.from = "京喜";
|
||
tm.Product.from_url = pcb_new.from_url;
|
||
pcb_new = tm.Product;
|
||
|
||
if (!tm.IsOnSale)
|
||
msg = "商品已下架";
|
||
}
|
||
else
|
||
{
|
||
TaobaoMobileCollect goodsInfo = new TaobaoMobileCollect(pcb_new);
|
||
goodsInfo.Get();
|
||
goodsInfo.Product.from = pcb_old.from;
|
||
goodsInfo.Product.from_url = pcb_new.from_url;
|
||
pcb_new = goodsInfo.Product;
|
||
|
||
if (goodsInfo.IsDown)
|
||
msg = "商品已下架";
|
||
}
|
||
|
||
pcb_new.message_alert = msg;
|
||
|
||
return pcb_new;
|
||
}
|
||
|
||
private void chkDeleteUpDown_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
IsDeleteUpDown = chkDeleteUpDown.Checked;
|
||
}
|
||
|
||
private void chkUpdateUpChange_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
IsUpdateUpChange = chkUpdateUpChange.Checked;
|
||
}
|
||
|
||
private void btnEditCheckUpdate_Click(object sender, EventArgs e)
|
||
{
|
||
var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColNeedUpdate"].Value.ToString() == "请更新商品").ToList();
|
||
var fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
if (fissionIdList.Count == 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("没有需要更新的商品", "提示");
|
||
return;
|
||
}
|
||
|
||
//var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool()).ToList();
|
||
//var fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
//if (fissionIdList.Count == 0)
|
||
//{
|
||
// BaseMsgForm.ShowInfo("请选择要编辑的数据", "提示");
|
||
// return;
|
||
//}
|
||
var Fissions = LstFission.Where(f => fissionIdList.Contains(f.id.ToString())).ToList();
|
||
if (Fissions.Count > 0)
|
||
{
|
||
var Fiss = Fissions[0];
|
||
try
|
||
{
|
||
var fissionTemp = new FissionDataBaseBLL().GetFessionDetailById(Fiss.id.ParseToInt());
|
||
Fiss.fession_title = fissionTemp.fession_title;
|
||
Fiss.container_info = fissionTemp.container_info?.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
Fiss.main_pic = fissionTemp.main_pic;
|
||
Fiss.prop_pic = fissionTemp.prop_pic;
|
||
Fiss.props = fissionTemp.props;
|
||
Fiss.mainWord = fissionTemp.mainWord;
|
||
Fiss.viceword = fissionTemp.viceword;
|
||
Fiss.prop = fissionTemp.prop;
|
||
Fiss.skus = fissionTemp.skus;
|
||
Fiss.from_shop_name = fissionTemp.from_shop_name;
|
||
Fiss.qualifications = fissionTemp.qualifications;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("获取裂变明细信息发生异常" + ex.Message);
|
||
}
|
||
if (string.IsNullOrEmpty(Fiss.fession_title))
|
||
return;
|
||
if (Fiss.source == "laiyuan")
|
||
{
|
||
if (Fiss.main_pic.Contains("pddpic") || Fiss.prop_pic.Contains("pddpic") || Fiss.container_info.Contains("pddpic"))
|
||
{
|
||
Fiss.source = "拼多多";
|
||
}
|
||
}
|
||
ProductCollectBase pcb = FissionData2Pcb(Fiss, Fiss.fession_title);
|
||
|
||
// 校验总店商品是否发生变化
|
||
string msg = "";
|
||
var pcb_new = CheckProductStatus(pcb, out msg);
|
||
if (msg == "商品已下架")
|
||
{
|
||
BaseMsgForm.ShowInfo("总店商品已下架 !");
|
||
//return;
|
||
}
|
||
|
||
string createHtmlPath = Fission.creatFissionPage(pcb_new);
|
||
var sFromUrl = "";
|
||
foreach (var fi in Fissions)
|
||
{
|
||
sFromUrl += GetFromUrl(fi.source, fi.fession_id) + "\r\n";
|
||
}
|
||
sFromUrl = sFromUrl.TrimEnd('\r', '\n');
|
||
Fission fs = new Fission(createHtmlPath, sFromUrl, null, pcb, Fiss.category, Fiss.full_category_name, Fiss.fession_title);
|
||
fs.Show();
|
||
}
|
||
}
|
||
|
||
private void chkNeedUpdate_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
//ProductUpdateCheckResult = chkNeedUpdate.Checked;
|
||
}
|
||
|
||
private void btnMulitEdit_Click(object sender, EventArgs e)
|
||
{
|
||
var fissionRowList = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["ColSelect"].Value.ParseToBool()).ToList();
|
||
var fissionIdList = fissionRowList.Select(r => r.Cells["ColId"].Value.ToString()).ToList();
|
||
if (fissionIdList.Count == 0)
|
||
{
|
||
BaseMsgForm.ShowInfo("没有勾选商品", "提示");
|
||
return;
|
||
}
|
||
|
||
var Fissions = LstFission.Where(f => fissionIdList.Contains(f.id.ToString())).ToList();
|
||
if (Fissions.Count > 0)
|
||
{
|
||
var Fiss = Fissions[0];
|
||
try
|
||
{
|
||
var fissionTemp = new FissionDataBaseBLL().GetFessionDetailById(Fiss.id.ParseToInt());
|
||
Fiss.fession_title = fissionTemp.fession_title;
|
||
Fiss.container_info = fissionTemp.container_info?.Replace("<img src='<", "<").Replace("'>'>", "'>");
|
||
Fiss.main_pic = fissionTemp.main_pic;
|
||
Fiss.prop_pic = fissionTemp.prop_pic;
|
||
Fiss.props = fissionTemp.props;
|
||
Fiss.mainWord = fissionTemp.mainWord;
|
||
Fiss.viceword = fissionTemp.viceword;
|
||
Fiss.prop = fissionTemp.prop;
|
||
Fiss.skus = fissionTemp.skus;
|
||
Fiss.from_shop_name = fissionTemp.from_shop_name;
|
||
Fiss.qualifications = fissionTemp.qualifications;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogSave.Add("获取裂变明细信息发生异常" + ex.Message);
|
||
}
|
||
if (string.IsNullOrEmpty(Fiss.fession_title))
|
||
return;
|
||
ProductCollectBase pcb = FissionData2Pcb(Fiss, Fiss.fession_title);
|
||
|
||
// 校验总店商品是否发生变化
|
||
string msg = "";
|
||
var pcb_new = GetNewPcb(pcb, out msg);
|
||
|
||
string createHtmlPath = Fission.creatFissionPage(pcb);
|
||
var sFromUrl = "";
|
||
foreach (var fi in Fissions)
|
||
{
|
||
sFromUrl += GetFromUrl(fi.source, fi.fession_id) + "\r\n";
|
||
}
|
||
sFromUrl = sFromUrl.TrimEnd('\r', '\n');
|
||
Fission fs = new Fission(createHtmlPath, sFromUrl, Fissions, pcb, Fiss.category, Fiss.full_category_name, Fiss.fession_title);
|
||
fs.Show();
|
||
}
|
||
}
|
||
|
||
public void UpdateFissionData(FissionDataModel fissionDataModel)
|
||
{
|
||
var fissionExist = FissionDataBaseForm.Instance.LstFission.Find(f => f.fession_id == fissionDataModel.fession_id);
|
||
if (fissionExist != null)
|
||
{
|
||
var fissionNew = FissionDataBaseForm.Instance.FissDataModel2Fission(fissionDataModel);
|
||
fissionExist.add_pricepercent = fissionNew.add_pricepercent;
|
||
fissionExist.base_addprice = fissionNew.base_addprice;
|
||
fissionExist.cat2_name = fissionNew.cat2_name;
|
||
fissionExist.cat3_name = fissionNew.cat3_name;
|
||
fissionExist.category = fissionNew.category;
|
||
fissionExist.cate_id = fissionNew.cate_id;
|
||
fissionExist.container_info = fissionNew.container_info;
|
||
fissionExist.discount = fissionNew.discount;
|
||
fissionExist.fession_count = fissionNew.fession_count;
|
||
fissionExist.fession_title = fissionNew.fession_title;
|
||
fissionExist.full_category_name = fissionNew.full_category_name;
|
||
fissionExist.is_changeprice = fissionNew.is_changeprice;
|
||
fissionExist.mainWord = fissionNew.mainWord;
|
||
fissionExist.main_cate = fissionNew.main_cate;
|
||
fissionExist.main_cateid = fissionNew.main_cateid;
|
||
fissionExist.main_pic = fissionNew.main_pic;
|
||
fissionExist.postFree = fissionNew.postFree;
|
||
fissionExist.price = fissionNew.price;
|
||
fissionExist.prop = fissionNew.prop;
|
||
fissionExist.props = fissionNew.props;
|
||
fissionExist.prop_pic = fissionNew.prop_pic;
|
||
fissionExist.qualifications = fissionNew.qualifications;
|
||
fissionExist.second_cate = fissionNew.second_cate;
|
||
fissionExist.skus = fissionNew.skus;
|
||
fissionExist.title = fissionNew.title;
|
||
fissionExist.viceword = fissionNew.viceword;
|
||
|
||
var row = this.dgvFissionProduct.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["ColId"].Value?.ToString() == fissionExist.id.ToString());
|
||
if (row != null)
|
||
{
|
||
string catStr = Fission.GetFullCatString(fissionExist.cate_id.ParseToInt());
|
||
if (string.IsNullOrEmpty(catStr))
|
||
catStr = fissionExist.full_category_name;
|
||
if (string.IsNullOrEmpty(catStr))
|
||
catStr = fissionExist.main_cate;
|
||
if (catStr == null)
|
||
catStr = "";
|
||
|
||
row.Cells["Title"].Value = fissionExist.fession_title; // 新标题
|
||
row.Cells["ColCategory"].Value = fissionExist.category; // 组别
|
||
row.Cells["ColFullCategory"].Value = catStr; // 完整类目
|
||
row.Cells["ColCategory1"].Value = fissionExist.main_cate; // 类目1
|
||
row.Cells["ColCategory2"].Value = fissionExist.cat2_name; // 类目2
|
||
row.Cells["ColCategory3"].Value = fissionExist.cat3_name; // 类目3
|
||
row.Cells["ColTitleNum"].Value = fissionExist.TitleNum; // 标题数量
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|