1.Jit客户端功能 2.pdd活动报名新增及优化
This commit is contained in:
1 parent
e77914bafc
commit
480d8c2cd4
41 files changed
+5136
-2863
No files matched your search
@@ -24,7 +24,7 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
public delegate void InfoReceivedHandler(string information);
|
||||
public event InfoReceivedHandler OnInfoReceived;
|
||||
|
||||
public string getProduct(string sProdId, string supplierId)
|
||||
public string getProduct(string sProdId, string supplierId, PDDProductInfo prodInfo = null, bool notSaveDb = false)
|
||||
{
|
||||
var prodId = sProdId.ParseToLong();
|
||||
if (prodId <= 0)
|
||||
@@ -266,93 +266,101 @@ namespace TemuKJD.PDDForms.ShopForms
|
||||
|
||||
string product_json = "{\"detail\":" + detail_json + ",\"size\":" + size_json + ",\"decoration\":" + decoration_json +
|
||||
",\"material3\":" + material3_json + ",\"material1\":" + material1_json + ",\"property\":" + property_json + "}";
|
||||
string main_img = product.image_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.hd_thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
||||
var url = BaseClass.BuildObjString("product/add_product");
|
||||
if (isExist)
|
||||
{
|
||||
bool isCover = false;
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
var ok = BaseMsgForm.ShowConfirm("产品库内已存在相同id商品,是否更新?").DialogResult;
|
||||
if (ok == DialogResult.OK)
|
||||
isCover = true;
|
||||
}));
|
||||
if (isCover)
|
||||
url = BaseClass.BuildObjString("product/mdy_product");
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var data = Work.UserLogin.GetSignaturex() +
|
||||
"&from_shop_id=" + shop.ShopId +
|
||||
"&spu_id=" + product.goods_id.ParseToString() +
|
||||
"&skc_id=" + product.goods_id.ParseToString() +
|
||||
"&price_text=" + product.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + product.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
||||
"&main_cat_id=" + (product.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
||||
"&main_cat_name=" + HttpUtility.UrlEncode((product.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&cat_id=" + (product.cat_id).ParseToString() +
|
||||
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) +
|
||||
"&size_json=" + HttpUtility.UrlEncode(size_json, Encoding.UTF8) +
|
||||
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
|
||||
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
if (notSaveDb)
|
||||
{
|
||||
string msg = "选品商品保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
||||
//OnInfoReceived(msg);
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
BaseMsgForm.ShowError(msg);
|
||||
}));
|
||||
prodInfo = JsonHelper.DeserializeJsonToObject<PDDProductInfo>(product_json);
|
||||
}
|
||||
else
|
||||
{
|
||||
//OnInfoReceived("选品商品保存成功!" + success_err_msg);
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
string main_img = product.image_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.hd_thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = product.thumb_url;
|
||||
if (string.IsNullOrEmpty(main_img))
|
||||
main_img = (product.galleries?.FirstOrDefault()?.url).ParseToString().Replace("https://", "http://");
|
||||
var url = BaseClass.BuildObjString("product/add_product");
|
||||
if (isExist)
|
||||
{
|
||||
BaseMsgForm.ShowInfo("选品商品保存成功!" + success_err_msg);
|
||||
}));
|
||||
bool isCover = false;
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
var ok = BaseMsgForm.ShowConfirm("产品库内已存在相同id商品,是否更新?").DialogResult;
|
||||
if (ok == DialogResult.OK)
|
||||
isCover = true;
|
||||
}));
|
||||
if (isCover)
|
||||
url = BaseClass.BuildObjString("product/mdy_product");
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
var data = Work.UserLogin.GetSignaturex() +
|
||||
"&from_shop_id=" + shop.ShopId +
|
||||
"&spu_id=" + product.goods_id.ParseToString() +
|
||||
"&skc_id=" + product.goods_id.ParseToString() +
|
||||
"&price_text=" + product.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + product.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
||||
"&main_cat_id=" + (product.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
||||
"&main_cat_name=" + HttpUtility.UrlEncode((product.cats?.FirstOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&cat_id=" + (product.cat_id).ParseToString() +
|
||||
"&cat_name=" + HttpUtility.UrlEncode((product.cats?.LastOrDefault(c => !string.IsNullOrEmpty(c))).ParseToString(), Encoding.UTF8) +
|
||||
"&ext_code=" + HttpUtility.UrlEncode(product.out_goods_sn, Encoding.UTF8) +
|
||||
"&product_name=" + HttpUtility.UrlEncode(product.goods_name, Encoding.UTF8) +
|
||||
"&product_json=" + HttpUtility.UrlEncode(product_json, Encoding.UTF8) +
|
||||
"&size_json=" + HttpUtility.UrlEncode(size_json, Encoding.UTF8) +
|
||||
"&main_img=" + HttpUtility.UrlEncode(main_img, Encoding.UTF8);
|
||||
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
string msg = "选品商品保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
||||
//OnInfoReceived(msg);
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
BaseMsgForm.ShowError(msg);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
//OnInfoReceived("选品商品保存成功!" + success_err_msg);
|
||||
MainForm.instance.Invoke(new Action(() =>
|
||||
{
|
||||
BaseMsgForm.ShowInfo("选品商品保存成功!" + success_err_msg);
|
||||
}));
|
||||
}
|
||||
|
||||
//// 创建 SaveFileDialog 的实例
|
||||
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
|
||||
//// 单线程单元(STA)模式运行文件对话框,否则会报错。
|
||||
//System.Threading.Thread InvokeThread = new System.Threading.Thread(new System.Threading.ThreadStart(()=> {
|
||||
|
||||
// // 设置对话框的属性
|
||||
// saveFileDialog.Title = "保存商品";
|
||||
// saveFileDialog.Filter = "商品文件 (*.prd)|*.prd|所有文件 (*.*)|*.*"; // 过滤文件类型
|
||||
// saveFileDialog.FileName = product.productId.ParseToString(); // 默认文件名
|
||||
// saveFileDialog.DefaultExt = "txt"; // 默认文件扩展名
|
||||
|
||||
// // 显示对话框并获取结果
|
||||
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
// {
|
||||
// // 用户点击了“保存”按钮,此时可以获取文件的路径
|
||||
// string filePath = saveFileDialog.FileName;
|
||||
// // 在这里处理文件保存逻辑,例如写入数据到文件
|
||||
// System.IO.File.WriteAllText(filePath, result);
|
||||
|
||||
// //BaseMsgForm.ShowInfo("商品保存成功!");
|
||||
// }
|
||||
//}));
|
||||
//InvokeThread.SetApartmentState(System.Threading.ApartmentState.STA);
|
||||
//InvokeThread.Start();
|
||||
//InvokeThread.Join();
|
||||
}
|
||||
|
||||
//// 创建 SaveFileDialog 的实例
|
||||
//SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
|
||||
//// 单线程单元(STA)模式运行文件对话框,否则会报错。
|
||||
//System.Threading.Thread InvokeThread = new System.Threading.Thread(new System.Threading.ThreadStart(()=> {
|
||||
|
||||
// // 设置对话框的属性
|
||||
// saveFileDialog.Title = "保存商品";
|
||||
// saveFileDialog.Filter = "商品文件 (*.prd)|*.prd|所有文件 (*.*)|*.*"; // 过滤文件类型
|
||||
// saveFileDialog.FileName = product.productId.ParseToString(); // 默认文件名
|
||||
// saveFileDialog.DefaultExt = "txt"; // 默认文件扩展名
|
||||
|
||||
// // 显示对话框并获取结果
|
||||
// if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
// {
|
||||
// // 用户点击了“保存”按钮,此时可以获取文件的路径
|
||||
// string filePath = saveFileDialog.FileName;
|
||||
// // 在这里处理文件保存逻辑,例如写入数据到文件
|
||||
// System.IO.File.WriteAllText(filePath, result);
|
||||
|
||||
// //BaseMsgForm.ShowInfo("商品保存成功!");
|
||||
// }
|
||||
//}));
|
||||
//InvokeThread.SetApartmentState(System.Threading.ApartmentState.STA);
|
||||
//InvokeThread.Start();
|
||||
//InvokeThread.Join();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user