4052 lines
158 KiB
C#
4052 lines
158 KiB
C#
using AllBase;
|
|
using AllBase.Model.Result;
|
|
using AllBase.Model.Result._1688;
|
|
using AllBase.Model.Result.PDDResult;
|
|
using AllBase.Model.Result.WXResult;
|
|
using NaiBa.Util.Extension;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using TemuKJD.BLL.ImportConverts;
|
|
using Work;
|
|
|
|
namespace TemuKJD.BLL
|
|
{
|
|
public class PDDProdFormConverter
|
|
{
|
|
/// <summary>
|
|
/// 拼多多前端采集转拼多多后台采集数据
|
|
/// </summary>
|
|
/// <param name="outProdJson"></param>
|
|
/// <param name="UpdateOldData"></param>
|
|
/// <param name="specialProdType"></param>
|
|
/// <returns></returns>
|
|
public string PddFrontToPddBackConvert(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
|
{
|
|
PDDFrontProductInfo frontProdInfo = null;
|
|
try
|
|
{
|
|
frontProdInfo = JsonHelper.DeserializeJsonToObject<PDDFrontProductInfo>(outProdJson);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "转换错误" + ex.Message;
|
|
}
|
|
if (frontProdInfo == null || frontProdInfo.goods_id == null)
|
|
{
|
|
return "商品数据信息为空";
|
|
}
|
|
|
|
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
//source_json = JsonHelper.JObjectParse(outProdJson),
|
|
source_json = null,
|
|
sale_count = frontProdInfo.goods.sold_quantity.ParseToString(),
|
|
sale_count_text = frontProdInfo.goods.side_sales_tip,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = frontProdInfo.goods.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>() { frontProdInfo.goods.cat_id_1.ParseToInt(), frontProdInfo.goods.cat_id_2.ParseToInt(), frontProdInfo.goods.cat_id_3.ParseToInt(), frontProdInfo.goods.cat_id_4.ParseToInt() };
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
int galleryIndex = 0;
|
|
foreach (var frontGallery in frontProdInfo.goods.gallery)
|
|
{
|
|
if (frontGallery.type == 6)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery.url,
|
|
type = frontGallery.type,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
}
|
|
else
|
|
{
|
|
//string getImgError;
|
|
//var image = GetHtml.GetUrlImg(frontGallery.url.Replace("https://", "http://"), out getImgError);
|
|
//if (!string.IsNullOrEmpty(getImgError))
|
|
//{
|
|
// return getImgError;
|
|
//}
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery.url,
|
|
type = frontGallery.type,
|
|
//width = image.Width,
|
|
//height = image.Height,
|
|
});
|
|
}
|
|
galleryIndex++;
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = frontProdInfo.goods.share_desc;
|
|
prodInfo.detail.goods_id = frontProdInfo.goods.goods_id ?? frontProdInfo.goods_id;
|
|
prodInfo.detail.goods_name = frontProdInfo.goods.goods_name;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
prodInfo.detail.hd_thumb_url = frontProdInfo.goods.hd_thumb_url;
|
|
prodInfo.detail.id = 0; // 编辑id,随意填写
|
|
prodInfo.detail.image_url = frontProdInfo.goods.image_url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
prodInfo.detail.mall_id = frontProdInfo.goods.mall_id;
|
|
prodInfo.detail.mall_info = new mall_info_item() { mall_name = frontProdInfo.mall?.mall_name };
|
|
prodInfo.detail.market_price = frontProdInfo.price.line_price;
|
|
prodInfo.detail.max_group_price = frontProdInfo.price.max_group_price;
|
|
prodInfo.detail.min_group_price = frontProdInfo.price.min_group_price;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
prodInfo.detail.out_goods_sn = "";
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
prodInfo.detail.share_desc = frontProdInfo.goods.share_desc;
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (var frontSku in frontProdInfo.sku)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = frontSku.sku_id,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)(frontSku.group_price.ParseToDecimal() * 100),
|
|
multi_price_in_yuan = null,
|
|
price = (int)(frontSku.normal_price.ParseToDecimal() * 100),
|
|
price_in_yuan = null,
|
|
quantity = 0,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = frontSku.thumb_url,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = frontSku.quantity,
|
|
spec = new List<spec_item>(),
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
List<string> specIds = frontSku.spec.Split(',').ToList();
|
|
List<string> specKeys = frontSku.spec_keys.Split(';').ToList();
|
|
List<string> specValues = frontSku.spec_values.Split(';').ToList();
|
|
for (int i = 0; i < specIds.Count; i++)
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_name = specKeys[i],
|
|
spec_id = specIds[i].ParseToLong(),
|
|
spec_name = specValues[i],
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
prodInfo.detail.thumb_url = frontProdInfo.goods.thumb_url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
foreach (var frontProp in frontProdInfo.goods.property)
|
|
{
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
propInfo.name = frontProp.key;
|
|
propInfo.values = new List<value_item>();
|
|
foreach (var frontPropValue in frontProp.values)
|
|
{
|
|
propInfo.values.Add(new value_item() { value = frontPropValue, raw_value = frontPropValue, unit = "" });
|
|
}
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
}
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
|
string collectAuthorityTag = "";
|
|
if (IsCollectAuthorityUser)
|
|
collectAuthorityTag = "-" + BaseClass.UserName;
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodInfo.detail.goods_id + collectAuthorityTag;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
else
|
|
{
|
|
return "入库失败,产品数据库已存在商品查询失败";
|
|
}
|
|
|
|
var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
if (UpdateOldData)
|
|
{
|
|
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
}
|
|
else
|
|
{
|
|
return "已存在相同id商品,跳过";
|
|
}
|
|
}
|
|
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + frontProdInfo.mall?.mall_id +
|
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
|
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
"&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
"&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
"&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
"&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", Encoding.UTF8);
|
|
if (!string.IsNullOrEmpty(specialProdType))
|
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
|
if (IsCollectAuthorityUser)
|
|
{
|
|
data += "&add_user_name=" + BaseClass.UserName;
|
|
data += "&group=用户" + BaseClass.UserName;
|
|
}
|
|
|
|
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"))
|
|
{
|
|
return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 拼多多前端采集转拼多多后台采集数据
|
|
/// </summary>
|
|
/// <param name="outProdJson"></param>
|
|
/// <param name="UpdateOldData"></param>
|
|
/// <param name="specialProdType"></param>
|
|
/// <returns></returns>
|
|
public string PddFrontToPddBackConvert2(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
|
{
|
|
PDDFrontProductInfo2 frontProdInfo = null;
|
|
try
|
|
{
|
|
frontProdInfo = JsonHelper.DeserializeJsonToObject<PDDFrontProductInfo2>(outProdJson);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "转换错误" + ex.Message;
|
|
}
|
|
if (frontProdInfo == null || frontProdInfo.goods.goods_id == null)
|
|
{
|
|
return "商品数据信息为空";
|
|
}
|
|
|
|
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
//source_json = JsonHelper.JObjectParse(outProdJson),
|
|
source_json = null,
|
|
sale_count = frontProdInfo.goods.sold_quantity.ParseToLong().ParseToString(),
|
|
sale_count_text = frontProdInfo.goods.side_sales_tip,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = frontProdInfo.goods.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>() { frontProdInfo.goods.cat_id_1.ParseToInt(), frontProdInfo.goods.cat_id_2.ParseToInt(), frontProdInfo.goods.cat_id_3.ParseToInt(), frontProdInfo.goods.cat_id_4.ParseToInt() };
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
if (!frontProdInfo.goods.gallery.Any(g => g.type == 1))
|
|
{
|
|
var jsonStr = BaseRegex.GetJsonObjStrJson(ref outProdJson, "carousel_section").OrderByDescending(s => s.Length).FirstOrDefault();
|
|
if (jsonStr != null)
|
|
{
|
|
var jArrStr = BaseRegex.GetJsonArrStrJson(ref jsonStr, "picture_list").OrderByDescending(s => s.Length).FirstOrDefault();
|
|
if (jArrStr != null)
|
|
{
|
|
foreach (var jObj in JArray.Parse(jArrStr))
|
|
{
|
|
var jStr = JsonHelper.SerializeObject(jObj);
|
|
var type = BaseRegex.GetIntJson(ref jStr, "type");
|
|
var img_url = BaseRegex.GetStringJson(ref jStr, "url");
|
|
var id = BaseRegex.GetLongJson(ref jStr, "id");
|
|
var goods_id = BaseRegex.GetLongJson(ref jStr, "goods_id");
|
|
var width = BaseRegex.GetIntJson(ref jStr, "width");
|
|
var height = BaseRegex.GetIntJson(ref jStr, "height");
|
|
var enable_share = BaseRegex.GetIntJson(ref jStr, "enable_share");
|
|
var gallery_pic = BaseRegex.GetIntJson(ref jStr, "gallery_pic");
|
|
if (!img_url.IsNullOrEmpty() && !type.IsNullOrZero())
|
|
{
|
|
frontProdInfo.goods.gallery.Add(new PDDFrontProductInfo2_gallery()
|
|
{
|
|
enable_share = enable_share,
|
|
goods_id = goods_id,
|
|
width = width,
|
|
height = height,
|
|
id = id,
|
|
type = type,
|
|
url = img_url,
|
|
priority = frontProdInfo.goods.gallery.Count,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!frontProdInfo.goods.gallery.Any(g => g.type == 1) && frontProdInfo.goods.gallery.Any(g => g.type == 13))
|
|
{
|
|
foreach (var g in frontProdInfo.goods.gallery)
|
|
{
|
|
if (g.type == 13)
|
|
g.type = 1;
|
|
}
|
|
}
|
|
if (!frontProdInfo.goods.gallery.Any(g => g.type == 1) && frontProdInfo.goods.gallery.Any(g => g.type == 2))
|
|
{
|
|
foreach (var g in frontProdInfo.goods.gallery.Where(g => g.type == 2)
|
|
.OrderBy(g => Math.Abs(100m - 100m * g.width.ParseToDecimal() / g.height.ParseToDecimal(1))).Take(3).ToList())
|
|
{
|
|
frontProdInfo.goods.gallery.Add(new PDDFrontProductInfo2_gallery()
|
|
{
|
|
enable_share = g.enable_share,
|
|
goods_id = g.goods_id,
|
|
height = g.height,
|
|
id = g.id,
|
|
priority = g.priority,
|
|
type = 1,
|
|
url = g.url,
|
|
width = g.width,
|
|
});
|
|
}
|
|
}
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
int galleryIndex = 0;
|
|
foreach (var frontGallery in frontProdInfo.goods.gallery)
|
|
{
|
|
if (frontGallery.type == 6)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery.url,
|
|
type = frontGallery.type,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
}
|
|
else if (frontGallery.type == 9 && !string.IsNullOrEmpty(frontGallery.video_url))
|
|
{
|
|
//"url": "http://video3.yangkeduo.com/i1/2020-06-06/bec95fd51b79e5c572153f7cb923a1c3.mp4.0_0.p0.jpg",
|
|
//"video_url": "https://video3.pddpic.com/i1/2020-06-06/bec95fd51b79e5c572153f7cb923a1c3.mp4.f30.mp4",
|
|
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery.video_url,
|
|
type = 6,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
}
|
|
else
|
|
{
|
|
//string getImgError;
|
|
//var image = GetHtml.GetUrlImg(frontGallery.url.Replace("https://", "http://"), out getImgError);
|
|
//if (!string.IsNullOrEmpty(getImgError))
|
|
//{
|
|
// return getImgError;
|
|
//}
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery.url,
|
|
type = frontGallery.type,
|
|
//width = image.Width,
|
|
//height = image.Height,
|
|
});
|
|
}
|
|
galleryIndex++;
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = frontProdInfo.goods.share_desc;
|
|
prodInfo.detail.goods_id = frontProdInfo.goods.goods_id;
|
|
prodInfo.detail.goods_name = frontProdInfo.goods.goods_name;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
prodInfo.detail.hd_thumb_url = frontProdInfo.goods.hd_thumb_url;
|
|
prodInfo.detail.id = 0; // 编辑id,随意填写
|
|
prodInfo.detail.image_url = frontProdInfo.goods.image_url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
prodInfo.detail.mall_id = frontProdInfo.goods.mall_id;
|
|
prodInfo.detail.mall_info = new mall_info_item() { mall_name = frontProdInfo.mall_entrance?.mall_data?.mall_name };
|
|
prodInfo.detail.market_price = frontProdInfo.price.line_price;
|
|
prodInfo.detail.max_group_price = frontProdInfo.price.max_group_price;
|
|
prodInfo.detail.min_group_price = frontProdInfo.price.min_group_price;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
prodInfo.detail.out_goods_sn = "";
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
prodInfo.detail.share_desc = frontProdInfo.goods.share_desc;
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (var frontSku in frontProdInfo.sku)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = frontSku.sku_id,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)frontSku.group_price.ParseToDecimal(),
|
|
multi_price_in_yuan = null,
|
|
price = (int)frontSku.normal_price.ParseToDecimal(),
|
|
price_in_yuan = null,
|
|
quantity = 0,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = frontSku.thumb_url,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = frontSku.quantity,
|
|
spec = new List<spec_item>(),
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
if (frontSku?.sku_price != null && frontSku.sku_price > 0)
|
|
skuInfo.multi_price = Math.Min(skuInfo.multi_price.ParseToInt(), (int)frontSku.sku_price.ParseToDecimal());
|
|
|
|
//List<string> specIds = frontSku.spec.Split(',').ToList();
|
|
//List<string> specKeys = frontSku.spec_keys.Split(';').ToList();
|
|
//List<string> specValues = frontSku.spec_values.Split(';').ToList();
|
|
//for (int i = 0; i < specIds.Count; i++)
|
|
//{
|
|
// skuInfo.spec.Add(new spec_item()
|
|
// {
|
|
// parent_name = specKeys[i],
|
|
// spec_id = specIds[i].ParseToLong(),
|
|
// spec_name = specValues[i],
|
|
// });
|
|
//}
|
|
foreach (var frontSpec in frontSku.specs)
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = frontSpec.spec_key_id,
|
|
parent_name = frontSpec.spec_key,
|
|
spec_id = frontSpec.spec_value_id,
|
|
spec_name = frontSpec.spec_value,
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
prodInfo.detail.thumb_url = frontProdInfo.goods.thumb_url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
foreach (var frontProp in frontProdInfo.goods.goods_property)
|
|
{
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
propInfo.name = frontProp.key;
|
|
propInfo.values = new List<value_item>();
|
|
foreach (var frontPropValue in frontProp.values)
|
|
{
|
|
propInfo.values.Add(new value_item() { value = frontPropValue, raw_value = frontPropValue, unit = "" });
|
|
}
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
}
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
|
string collectAuthorityTag = "";
|
|
if (IsCollectAuthorityUser)
|
|
collectAuthorityTag = "-" + BaseClass.UserName;
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodInfo.detail.goods_id + collectAuthorityTag;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
else
|
|
{
|
|
return "入库失败,产品数据库已存在商品查询失败";
|
|
}
|
|
|
|
var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
if (UpdateOldData)
|
|
{
|
|
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
}
|
|
else
|
|
{
|
|
return "已存在相同id商品,跳过";
|
|
}
|
|
}
|
|
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + frontProdInfo.goods?.mall_id +
|
|
"&from_shop_name=" + prodInfo.detail.mall_info.mall_name +
|
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
|
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
"&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
"&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
"&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
"&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", Encoding.UTF8);
|
|
if (!string.IsNullOrEmpty(specialProdType))
|
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
|
if (IsCollectAuthorityUser)
|
|
{
|
|
data += "&add_user_name=" + BaseClass.UserName;
|
|
data += "&group=用户" + BaseClass.UserName;
|
|
}
|
|
|
|
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"))
|
|
{
|
|
return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
}
|
|
return "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 驼峰命名的一种新的拼多多格式
|
|
/// </summary>
|
|
/// <param name="outProdJson"></param>
|
|
/// <param name="UpdateOldData"></param>
|
|
/// <param name="specialProdType"></param>
|
|
/// <param name="IsCollectAuthorityUser"></param>
|
|
/// <returns></returns>
|
|
public string PddFrontToPddBackConvert3(string outProdJson3, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
|
{
|
|
initDataObjInfo frontProdInfo = null;
|
|
try
|
|
{
|
|
frontProdInfo = JsonHelper.DeserializeJsonToObject<PDDFrontProductInfo3>(outProdJson3)?.store?.initDataObj;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "转换错误" + ex.Message;
|
|
}
|
|
if (frontProdInfo == null || frontProdInfo.goods?.goodsID == null || frontProdInfo.mall?.mallId == null || frontProdInfo.mall?.mallName == null)
|
|
{
|
|
return "商品数据信息为空";
|
|
}
|
|
|
|
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
//source_json = JsonHelper.JObjectParse(outProdJson),
|
|
source_json = null,
|
|
sale_count = BaseRegex.GetStringJson(ref outProdJson3, "sold_quantity").ParseToLong().ParseToString(),
|
|
sale_count_text = BaseRegex.GetStringJson(ref outProdJson3, "sales_tip"),
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = frontProdInfo.goods.catID.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>() { frontProdInfo.goods.catID1.ParseToInt(), frontProdInfo.goods.catID2.ParseToInt(), frontProdInfo.goods.catID3.ParseToInt(), frontProdInfo.goods.catID4.ParseToInt() };
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
int galleryIndex = 0;
|
|
foreach (var topGallery in frontProdInfo.goods.topGallery)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = topGallery.url,
|
|
type = 1,
|
|
//width = image.Width,
|
|
//height = image.Height,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
foreach (var videoGallery in frontProdInfo.goods.videoGallery)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = videoGallery.url,
|
|
type = 6,
|
|
//width = image.Width,
|
|
//height = image.Height,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
foreach (var detailGallery in frontProdInfo.goods.detailGallery)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = detailGallery.url,
|
|
type = 2,
|
|
//width = image.Width,
|
|
//height = image.Height,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = frontProdInfo.goods.shareDesc;
|
|
prodInfo.detail.goods_id = frontProdInfo.goods.goodsID;
|
|
prodInfo.detail.goods_name = frontProdInfo.goods.goodsName;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
prodInfo.detail.hd_thumb_url = frontProdInfo.goods.hdThumbUrl;
|
|
prodInfo.detail.id = 0; // 编辑id,随意填写
|
|
prodInfo.detail.image_url = frontProdInfo.goods.topGallery.FirstOrDefault()?.url; // frontProdInfo.goods.image_url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
prodInfo.detail.mall_id = frontProdInfo.mall.mallId.ParseToLong();
|
|
prodInfo.detail.mall_info = new mall_info_item() { mall_name = frontProdInfo.mall.mallName };
|
|
prodInfo.detail.market_price = (frontProdInfo.goods.linePrice.ParseToDecimal() * 100).ParseToInt();
|
|
prodInfo.detail.max_group_price = frontProdInfo.goods.maxOnSaleGroupPriceInCent;
|
|
prodInfo.detail.min_group_price = frontProdInfo.goods.minOnSaleGroupPriceInCent;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
prodInfo.detail.out_goods_sn = "";
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
prodInfo.detail.share_desc = frontProdInfo.goods.shareDesc;
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (var frontSku in frontProdInfo.goods.skus)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = frontSku.skuId,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)(frontSku.groupPrice.ParseToDecimal() * 100),
|
|
multi_price_in_yuan = null,
|
|
price = (int)(frontSku.normalPrice.ParseToDecimal() * 100),
|
|
price_in_yuan = null,
|
|
quantity = 0,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = frontSku.thumbUrl,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = frontSku.quantity,
|
|
spec = new List<spec_item>(),
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
if ((int)(frontSku.groupPrice.ParseToDecimal() * 100) > 0)
|
|
skuInfo.multi_price = Math.Min(skuInfo.multi_price.ParseToInt(), (int)(frontSku.groupPrice.ParseToDecimal() * 100));
|
|
|
|
//List<string> specIds = frontSku.spec.Split(',').ToList();
|
|
//List<string> specKeys = frontSku.spec_keys.Split(';').ToList();
|
|
//List<string> specValues = frontSku.spec_values.Split(';').ToList();
|
|
//for (int i = 0; i < specIds.Count; i++)
|
|
//{
|
|
// skuInfo.spec.Add(new spec_item()
|
|
// {
|
|
// parent_name = specKeys[i],
|
|
// spec_id = specIds[i].ParseToLong(),
|
|
// spec_name = specValues[i],
|
|
// });
|
|
//}
|
|
foreach (var frontSpec in frontSku.specs)
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = frontSpec.spec_key_id,
|
|
parent_name = frontSpec.spec_key,
|
|
spec_id = frontSpec.spec_value_id,
|
|
spec_name = frontSpec.spec_value,
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
prodInfo.detail.thumb_url = frontProdInfo.goods.thumbUrl;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
foreach (var frontProp in frontProdInfo.goods.goodsProperty)
|
|
{
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
propInfo.name = frontProp.key;
|
|
propInfo.values = new List<value_item>();
|
|
foreach (var frontPropValue in frontProp.values)
|
|
{
|
|
propInfo.values.Add(new value_item() { value = frontPropValue, raw_value = frontPropValue, unit = "" });
|
|
}
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
}
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
|
string collectAuthorityTag = "";
|
|
if (IsCollectAuthorityUser)
|
|
collectAuthorityTag = "-" + BaseClass.UserName;
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodInfo.detail.goods_id + collectAuthorityTag;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
else
|
|
{
|
|
return "入库失败,产品数据库已存在商品查询失败";
|
|
}
|
|
|
|
var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
if (UpdateOldData)
|
|
{
|
|
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
}
|
|
else
|
|
{
|
|
return "已存在相同id商品,跳过";
|
|
}
|
|
}
|
|
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + frontProdInfo.mall?.mallId +
|
|
"&from_shop_name=" + frontProdInfo.mall?.mallName +
|
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
|
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
"&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
"&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
"&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
"&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", Encoding.UTF8);
|
|
if (!string.IsNullOrEmpty(specialProdType))
|
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
|
if (IsCollectAuthorityUser)
|
|
{
|
|
data += "&add_user_name=" + BaseClass.UserName;
|
|
data += "&group=用户" + BaseClass.UserName;
|
|
}
|
|
|
|
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"))
|
|
{
|
|
return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
}
|
|
return "";
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 外来格式 中文属性转拼多多格式
|
|
/// </summary>
|
|
/// <param name="outProdJson"></param>
|
|
/// <param name="UpdateOldData"></param>
|
|
/// <param name="specialProdType"></param>
|
|
/// <param name="IsCollectAuthorityUser"></param>
|
|
/// <returns></returns>
|
|
public string PddFrontToPddBackConvertV4(string outProdJson, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
|
{
|
|
|
|
|
|
PDDFrontProductInfo4 frontProdInfo = null;
|
|
try
|
|
{
|
|
frontProdInfo = JsonHelper.DeserializeJsonToObject<PDDFrontProductInfo4>(outProdJson);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "转换错误" + ex.Message;
|
|
}
|
|
if (frontProdInfo == null || frontProdInfo.ProductId == null)
|
|
{
|
|
return "商品数据信息为空";
|
|
}
|
|
|
|
long mallId = Randomx.GetId(10000000, 99999999);
|
|
if (!string.IsNullOrEmpty(frontProdInfo.ProductUrl))
|
|
{
|
|
mallId = Math.Abs(frontProdInfo.ProductUrl.GetHashCode());
|
|
}
|
|
string thumbUrl = frontProdInfo.MainImages.FirstOrDefault();
|
|
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
//source_json = JsonHelper.JObjectParse(outProdJson),
|
|
source_json = null,
|
|
//sale_count = frontProdInfo.goods.sold_quantity.ParseToString(),
|
|
//sale_count_text = frontProdInfo.goods.side_sales_tip,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = frontProdInfo.Category.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
int galleryIndex = 0;
|
|
foreach (var frontGallery in frontProdInfo.MainImages)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery,
|
|
type = 1,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
foreach (var frontGallery in frontProdInfo.DetailImages)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery,
|
|
type = 2,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = frontProdInfo.Description;
|
|
prodInfo.detail.goods_id = frontProdInfo.ProductId.ParseToLong();
|
|
prodInfo.detail.goods_name = frontProdInfo.Title;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
prodInfo.detail.hd_thumb_url = "";
|
|
prodInfo.detail.id = 0; // 编辑id,随意填写
|
|
prodInfo.detail.image_url = frontProdInfo.MainImages?.FirstOrDefault() ?? "";
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
prodInfo.detail.mall_id = mallId;
|
|
prodInfo.detail.mall_info = new mall_info_item() { mall_name = mallId.ToString() };
|
|
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
prodInfo.detail.out_goods_sn = "";
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
prodInfo.detail.share_desc = frontProdInfo.Description;
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
int maxPrice = int.MinValue;
|
|
int minPrice = int.MaxValue;
|
|
foreach (KeyValuePair<string, PriceStock> frontSku in frontProdInfo.SKU)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = null,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)(frontSku.Value.Price.ParseToDecimal() * 100),
|
|
multi_price_in_yuan = null,
|
|
price = (int)(frontSku.Value.Price.ParseToDecimal() * 100 + 100),
|
|
price_in_yuan = null,
|
|
quantity = 0,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = frontSku.Value.SpecImage,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = frontSku.Value.Stock,
|
|
spec = new List<spec_item>(),
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
|
|
maxPrice = Math.Max(maxPrice, skuInfo.price.Value);
|
|
minPrice = Math.Min(minPrice, skuInfo.price.Value);
|
|
|
|
var specList = frontSku.Value.SpecValue.Split(';').ToList();
|
|
foreach (var specItem in specList)
|
|
{
|
|
string parentName = "";
|
|
foreach (var item in frontProdInfo.Specifications)
|
|
{
|
|
if (item.Value.Contains(specItem))
|
|
{
|
|
parentName = item.Key;
|
|
break;
|
|
}
|
|
}
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_name = parentName,
|
|
spec_name = specItem,
|
|
spec_id = null,
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
|
|
prodInfo.detail.market_price = maxPrice * 2;
|
|
prodInfo.detail.max_group_price = maxPrice;
|
|
prodInfo.detail.min_group_price = minPrice;
|
|
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
prodInfo.detail.thumb_url = thumbUrl;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
foreach (var frontProp in frontProdInfo.Attributes)
|
|
{
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
propInfo.name = frontProp.Key;
|
|
propInfo.values = new List<value_item>();
|
|
string[] p_values = frontProp.Value.Split(',');
|
|
foreach (var frontPropValue in p_values)
|
|
{
|
|
propInfo.values.Add(new value_item() { value = frontPropValue, raw_value = frontPropValue, unit = "" });
|
|
}
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
}
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
|
string collectAuthorityTag = "";
|
|
if (IsCollectAuthorityUser)
|
|
collectAuthorityTag = "-" + BaseClass.UserName;
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodInfo.detail.goods_id + collectAuthorityTag;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
else
|
|
{
|
|
return "入库失败,产品数据库已存在商品查询失败";
|
|
}
|
|
|
|
var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
if (UpdateOldData)
|
|
{
|
|
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
}
|
|
else
|
|
{
|
|
return "已存在相同id商品,跳过";
|
|
}
|
|
}
|
|
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + mallId +
|
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
|
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
"&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
"&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
"&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
"&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", Encoding.UTF8);
|
|
if (!string.IsNullOrEmpty(specialProdType))
|
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
|
if (IsCollectAuthorityUser)
|
|
{
|
|
data += "&add_user_name=" + BaseClass.UserName;
|
|
data += "&group=用户" + BaseClass.UserName;
|
|
}
|
|
|
|
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"))
|
|
{
|
|
return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
}
|
|
return "";
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 外来格式V5
|
|
/// </summary>
|
|
/// <param name="outProdJson"></param>
|
|
/// <param name="UpdateOldData"></param>
|
|
/// <param name="specialProdType"></param>
|
|
/// <param name="IsCollectAuthorityUser"></param>
|
|
/// <returns></returns>
|
|
public string PddFrontToPddBackConvertFactory(string filePath, bool UpdateOldData = true, string specialProdType = null, bool IsCollectAuthorityUser = false)
|
|
{
|
|
PDDFrontProductInfo5 frontProdInfo = null;
|
|
try
|
|
{
|
|
frontProdInfo = ConverterToPddFactory.Convert(filePath);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return "转换错误" + ex.Message;
|
|
}
|
|
|
|
if (frontProdInfo == null || frontProdInfo.GoodsId == null)
|
|
{
|
|
return "商品数据信息为空";
|
|
}
|
|
|
|
|
|
KJDDBProduct dbProd = new KJDDBProduct() { size_json = "{}" };
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
//source_json = JsonHelper.JObjectParse(outProdJson),
|
|
source_json = null,
|
|
//sale_count = frontProdInfo.goods.sold_quantity.ParseToString(),
|
|
//sale_count_text = frontProdInfo.goods.side_sales_tip,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = frontProdInfo.CategoryId;
|
|
prodInfo.detail.cat_ids = frontProdInfo.CategoryPath.Select(a => (int?)a).ToList();
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
int galleryIndex = 0;
|
|
foreach (var frontGallery in frontProdInfo.MainImages)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery,
|
|
type = 1,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
foreach (var frontGallery in frontProdInfo.DetailImages)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = frontGallery,
|
|
type = 2,
|
|
width = 0,
|
|
height = 0,
|
|
});
|
|
galleryIndex++;
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = frontProdInfo.Description;
|
|
prodInfo.detail.goods_id = frontProdInfo.GoodsId;
|
|
prodInfo.detail.goods_name = frontProdInfo.Title;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
prodInfo.detail.hd_thumb_url = "";
|
|
prodInfo.detail.id = 0; // 编辑id,随意填写
|
|
prodInfo.detail.image_url = frontProdInfo.MainImages?.FirstOrDefault() ?? "";
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
prodInfo.detail.mall_id = frontProdInfo.MallId;
|
|
prodInfo.detail.mall_info = new mall_info_item() { mall_name = frontProdInfo.MallName };
|
|
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
prodInfo.detail.out_goods_sn = "";
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
prodInfo.detail.share_desc = frontProdInfo.Description;
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
int maxPrice = int.MinValue;
|
|
int minPrice = int.MaxValue;
|
|
foreach (var skuItem in frontProdInfo.Skus)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = null,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)(skuItem.Price.ParseToDecimal() * 100),
|
|
multi_price_in_yuan = null,
|
|
price = (int)(skuItem.Price.ParseToDecimal() * 100 + 100),
|
|
price_in_yuan = null,
|
|
quantity = 0,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = skuItem.SpecImage,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = skuItem.Stock,
|
|
spec = new List<spec_item>(),
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
|
|
maxPrice = Math.Max(maxPrice, skuInfo.price.Value);
|
|
minPrice = Math.Min(minPrice, skuInfo.price.Value);
|
|
|
|
var specList = skuItem.Spec.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
foreach (var spec in specList)
|
|
{
|
|
string specKey = spec.Split(':')[0];
|
|
string specValue = spec.Split(':')[1];
|
|
var specItem = frontProdInfo.Specs.FirstOrDefault(a => a.SpecKey == specKey && a.SpecValue == specValue);
|
|
if (specItem == null) continue;
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_name = specItem.SpecKey,
|
|
spec_name = specItem.SpecValue,
|
|
});
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
|
|
prodInfo.detail.market_price = maxPrice * 2;
|
|
prodInfo.detail.max_group_price = maxPrice;
|
|
prodInfo.detail.min_group_price = minPrice;
|
|
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
prodInfo.detail.thumb_url = frontProdInfo.ThumbUrl;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
foreach (var frontProp in frontProdInfo.Propertys)
|
|
{
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
propInfo.name = frontProp.Key;
|
|
propInfo.values = new List<value_item>();
|
|
string[] p_values = frontProp.Value.Split(',');
|
|
foreach (var frontPropValue in p_values)
|
|
{
|
|
propInfo.values.Add(new value_item() { value = frontPropValue, raw_value = frontPropValue, unit = "" });
|
|
}
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
}
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
// 商品采集权限用户采集的数据加上用户前缀(商品前缀显示给用户的时候隐藏)
|
|
string collectAuthorityTag = "";
|
|
if (IsCollectAuthorityUser)
|
|
collectAuthorityTag = "-" + BaseClass.UserName;
|
|
|
|
bool isExist = false;
|
|
var existUrl = BaseClass.BuildPDDObjString("product/get_product_spu_id_list");
|
|
string existData = UserLogin.GetSignaturex() + "&search_spu_ids=" + prodInfo.detail.goods_id + collectAuthorityTag;
|
|
string html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = GetHtml.PostUtf8(existUrl, existData);
|
|
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
{
|
|
if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
isExist = true;
|
|
}
|
|
else
|
|
{
|
|
return "入库失败,产品数据库已存在商品查询失败";
|
|
}
|
|
|
|
var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
if (isExist)
|
|
{
|
|
if (UpdateOldData)
|
|
{
|
|
url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
}
|
|
else
|
|
{
|
|
return "已存在相同id商品,跳过";
|
|
}
|
|
}
|
|
string product_get_type = "多多外部数据";
|
|
|
|
switch (frontProdInfo.Platform)
|
|
{
|
|
case PlatformType.WX:
|
|
product_get_type = "微信外部数据";
|
|
break;
|
|
}
|
|
var data = Work.UserLogin.GetSignaturex() +
|
|
"&from_shop_id=" + frontProdInfo.MallId +
|
|
"&spu_id=" + prodInfo.detail.goods_id.ParseToString() + collectAuthorityTag +
|
|
"&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
"&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
"&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
"&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
"&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
"&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
"&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
"&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
"&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
"&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
"&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
"&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
"&product_get_type=" + HttpUtility.UrlEncode(product_get_type, Encoding.UTF8);
|
|
|
|
if (!string.IsNullOrEmpty(specialProdType))
|
|
data += "&special_prod_type=" + HttpUtility.UrlEncode(specialProdType, Encoding.UTF8);
|
|
if (IsCollectAuthorityUser)
|
|
{
|
|
data += "&add_user_name=" + BaseClass.UserName;
|
|
data += "&group=用户" + BaseClass.UserName;
|
|
}
|
|
|
|
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"))
|
|
{
|
|
return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
}
|
|
return "";
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 聚水潭转pdd格式
|
|
/// </summary>
|
|
/// <param name="convertRst"></param>
|
|
/// <param name="dbProd"></param>
|
|
/// <returns></returns>
|
|
public PDDProductInfo JstPddProdToPddConvert(out string convertRst, KJDDBProduct dbProd)
|
|
{
|
|
convertRst = "";
|
|
try
|
|
{
|
|
var prodObj = JsonHelper.JObjectParse(dbProd.product_json);
|
|
if (prodObj["pddData"].IsJTokenNullOrEmpty())
|
|
{
|
|
convertRst = "缺少指定的数据格式";
|
|
return null;
|
|
}
|
|
var jstGoodsObj = prodObj["pddData"];
|
|
var jstPddPropMapLst = JsonHelper.DeserializeJsonToList<PDDPropRefPidNameMap>(JsonHelper.SerializeObject(prodObj["pddPropMap"]));
|
|
//{"goodsId":"2016474712785620994","warehouseGoodsId":"C7108311198A4217B022DCA87B6A5863","spuCode":"3783056947394249077","skus":[{"skuId":"2016692758292738050","warehouseSkuId":"C742B3FCB0364448AF92332F8F6005A6","skuCode":"ZH-XP-YWQYW-010"},{"skuId":"2016692758317903874","warehouseSkuId":"703E87F1B7774C14923821A57EEE6EFA","skuCode":"ZH-XP-YWQYW-010-111"},{"skuId":"2016692758338875394","warehouseSkuId":"895EDCDF6ECC4FAE8AD4DB9503719002","skuCode":"ZH-XP-YWQYW-010-222"}]}
|
|
var jstSecretCodeLst = JsonHelper.JObjectParse(dbProd.sku_secret_json.TrimStart('[').TrimEnd(']'));
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
sale_count = dbProd.sale_count.ParseToString(),
|
|
sale_count_text = dbProd.sale_count_text,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = jstGoodsObj["catId"].ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
var catLst = (jstGoodsObj["categoryData"] as JArray).Select(a => a.ParseToInt()).ToList();
|
|
foreach (var cId in catLst)
|
|
{
|
|
prodInfo.detail.cat_ids.Add(cId);
|
|
}
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
foreach (var imgObj in jstGoodsObj["carouselGallery"])
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgObj.ParseToString(),
|
|
type = 1,
|
|
});
|
|
}
|
|
foreach (var imgObj in jstGoodsObj["detailGallery"])
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgObj.ParseToString(),
|
|
type = 2,
|
|
});
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = jstGoodsObj["goodsDesc"].ParseToString();
|
|
// 聚水潭为string,散列取数值
|
|
prodInfo.detail.goods_id = jstGoodsObj["itemSpuId"].ParseToString().GetHashCode();
|
|
prodInfo.detail.goods_name = jstGoodsObj["itemName"].ParseToString();
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.hd_thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
// 编辑id,随意填写
|
|
prodInfo.detail.id = 0;
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.image_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
// 聚水潭没有
|
|
prodInfo.detail.mall_id = 0;
|
|
// 聚水潭没有
|
|
prodInfo.detail.mall_info = new mall_info_item();
|
|
// 聚水潭没有此处随意填
|
|
prodInfo.detail.market_price = 0;
|
|
// 聚水潭没有此处随意填
|
|
prodInfo.detail.max_group_price = 0;
|
|
// 聚水潭没有此处随意填
|
|
prodInfo.detail.min_group_price = 0;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
// 货号
|
|
prodInfo.detail.out_goods_sn = jstSecretCodeLst["goodsId"].ParseToString();
|
|
// 货号直接替换成加密的,注意千万不要再把这个ext_code入库
|
|
dbProd.ext_code = prodInfo.detail.out_goods_sn;
|
|
if (prodInfo.detail.out_goods_sn.IsNullOrEmpty())
|
|
{
|
|
convertRst = "货号不存在";
|
|
return null;
|
|
}
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
// 聚水潭没有
|
|
prodInfo.detail.share_desc = "";
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
|
|
if (jstGoodsObj["skuInfo"].IsJTokenNullOrEmpty() || jstGoodsObj["skuInfo"]["goodsSkuDetail"].IsJTokenNullOrEmpty())
|
|
{
|
|
convertRst = "缺少sku信息";
|
|
return null;
|
|
}
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (JObject jSku in jstGoodsObj["skuInfo"]["goodsSkuDetail"])
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
// 聚水潭为string,散列取数值
|
|
sku_id = jSku["baseSkuId"].ParseToString().GetHashCode(),
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (int)(jSku["supplyPrice"].ParseToDecimal() * 100),
|
|
multi_price_in_yuan = null,
|
|
price = (int)(jSku["supplyPrice"].ParseToDecimal() * 100 + 100),
|
|
price_in_yuan = null,
|
|
quantity = jSku["quantity"].ParseToInt(),
|
|
reserve_quantity = 0,
|
|
weight = (int)(jSku["weight"].ParseToDecimal() * 1000),
|
|
thumb_url = jSku["pic"].ParseToString(),
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = 0,
|
|
spec = new List<spec_item>(),
|
|
// sku货号下面单独设置
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
// 聚水潭广告sku价格为0库存不为零的给库存也改为0
|
|
if (skuInfo.multi_price == 0)
|
|
{
|
|
skuInfo.quantity = 0;
|
|
skuInfo.quantity_delta = 0;
|
|
}
|
|
|
|
// 聚水潭供应商价加价10%(最低1元)赚取差价
|
|
int addPrice = (skuInfo.multi_price * 0.1).ParseToInt();
|
|
if (addPrice < 100)
|
|
addPrice = 100;
|
|
skuInfo.multi_price += addPrice;
|
|
skuInfo.price += addPrice;
|
|
foreach (JObject jSpec in jSku["skus"])
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = jSpec["kid"].ParseToLong(),
|
|
parent_name = jSpec["k"].ParseToString(),
|
|
spec_id = jSpec["vid"].ParseToLong(),
|
|
spec_name = jSpec["v"].ParseToString(),
|
|
});
|
|
}
|
|
var itemNo = jSku["itemNo"].ParseToString();
|
|
var baseSkuId = jSku["baseSkuId"].ParseToString();
|
|
// skuCode可能不唯一,使用skuId取加密后的货号
|
|
//var skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["skuCode"].ParseToString() == itemNo)?["skuId"].ParseToString();
|
|
var skuStr = jSku.ParseToString();
|
|
var jstSecretCodeLstSkuStr = jstSecretCodeLst["skus"].ParseToString();
|
|
var skuId = jstSecretCodeLst["skus"].FirstOrDefault(s => s["warehouseSkuId"].ParseToString() == baseSkuId)?["skuId"].ParseToString();
|
|
if (skuId.IsNullOrEmpty() || string.IsNullOrEmpty(itemNo))
|
|
{
|
|
convertRst = "SKU货号不存在";
|
|
return null;
|
|
}
|
|
// 外部编码(货号)
|
|
skuInfo.out_sku_sn = skuId;
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
// 测试发现skuCoke重复可能对推单有影响,先吧skuCode重复的排除掉
|
|
var skuCount = jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["baseSkuId"].ParseToString()).Distinct().Count();
|
|
var itemNoCount = jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["itemNo"].ParseToString()).Distinct().Count();
|
|
var skusStr = jstGoodsObj["skuInfo"]["goodsSkuDetail"].ParseToString();
|
|
var skuSkuIdStr = string.Join("\r\n", jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["baseSkuId"].ParseToString()));
|
|
var skuItemNoStr = string.Join("\r\n", jstGoodsObj["skuInfo"]["goodsSkuDetail"].Select(s => s["itemNo"].ParseToString()));
|
|
if (skuCount != itemNoCount)
|
|
{
|
|
//convertRst = "SKU货号重复";
|
|
//return null;
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
// 复用前面填过的主图
|
|
prodInfo.detail.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
|
|
if (!jstGoodsObj["goodsProperties"].IsJTokenNullOrEmpty())
|
|
{
|
|
foreach (JObject jProp in jstGoodsObj["goodsProperties"])
|
|
{
|
|
string name = "";
|
|
if (!jProp["propName"].IsJTokenNullOrEmpty())
|
|
name = jProp["propName"].ParseToString();
|
|
else
|
|
{
|
|
try
|
|
{
|
|
if (jstPddPropMapLst != null)
|
|
name = jstPddPropMapLst.FirstOrDefault(p => p.ref_pid.ParseToString() == jProp["refPid"].ParseToString())?.name;
|
|
if (string.IsNullOrEmpty(name))
|
|
name = jProp["refPid"].ParseToString();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
propInfo.name = name;
|
|
propInfo.ref_pid = jProp["refPid"].ParseToInt();
|
|
string propStr = JsonHelper.SerializeObject(jProp);
|
|
propInfo.values = new List<value_item>();
|
|
if (propStr.Contains("multipleValue") && !propStr.Contains("\"multipleValue\":[]"))
|
|
{
|
|
foreach (var propValueObj in jProp["multipleValue"])
|
|
{
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = propValueObj["label"].ParseToString(),
|
|
raw_value = propValueObj["label"].ParseToString(),
|
|
vid = propValueObj["value"].ParseToLong(),
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var label = BaseRegex.GetStringJson(ref propStr, "label");
|
|
var valueId = BaseRegex.GetStringJson(ref propStr, "value").ParseToLong();
|
|
if (string.IsNullOrEmpty(label))
|
|
label = BaseRegex.GetStringJson(ref propStr, "inputValue") + " " + BaseRegex.GetStringJson(ref propStr, "valueUnit");
|
|
label = label.Trim();
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = label,
|
|
raw_value = label,
|
|
vid = valueId,
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//outGoodsParam.productAttrs.Add(new osProductAttrParam { attrKey = "品牌", attrValue = "无品牌" });
|
|
}
|
|
// 主图
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
return prodInfo;
|
|
|
|
//bool isExist = false;
|
|
//var existUrl = BaseClass.BuildPDDObjString("product/get_product_list");
|
|
//string existData = UserLogin.GetSignaturex() + "&search_spu=" + prodInfo.detail.goods_id;
|
|
//string html = GetHtml.PostUtf8(existUrl, existData);
|
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
// html = GetHtml.PostUtf8(existUrl, existData);
|
|
//if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
// html = GetHtml.PostUtf8(existUrl, existData);
|
|
//if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
|
//{
|
|
// if (html.Contains("\"data\":[") && !html.Contains("\"data\":[]"))
|
|
// isExist = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// return "入库失败,产品数据库已存在商品查询失败";
|
|
//}
|
|
|
|
//var url = BaseClass.BuildPDDObjString("product/add_product");
|
|
//if (isExist)
|
|
//{
|
|
// if (UpdateOldData)
|
|
// {
|
|
// url = BaseClass.BuildPDDObjString("product/mdy_product");
|
|
// }
|
|
// else
|
|
// {
|
|
// return "已存在相同id商品,跳过";
|
|
// }
|
|
//}
|
|
|
|
//var data = Work.UserLogin.GetSignaturex() +
|
|
// "&from_shop_id=" + frontProdInfo.mall?.mall_id +
|
|
// "&spu_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
// "&skc_id=" + prodInfo.detail.goods_id.ParseToString() +
|
|
// "&price_text=" + prodInfo.detail.sku.Min(s => s.multi_price).ParseToInt() * 0.01m + "-" + prodInfo.detail.sku.Max(s => s.multi_price).ParseToInt() * 0.01m +
|
|
// "&main_cat_id=" + (prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString() +
|
|
// "&main_cat_name=" + HttpUtility.UrlEncode((prodInfo.detail.cat_ids?.FirstOrDefault(c => c != null)).ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
// "&cat_id=" + prodInfo.detail.cat_id.ParseToString() +
|
|
// "&cat_name=" + HttpUtility.UrlEncode(prodInfo.detail.cat_id.ParseToString(), Encoding.UTF8) + // 取不到catname直接用catid,上货时候再取
|
|
// "&ext_code=" + HttpUtility.UrlEncode(prodInfo.detail.out_goods_sn, Encoding.UTF8) +
|
|
// "&product_name=" + HttpUtility.UrlEncode(prodInfo.detail.goods_name, Encoding.UTF8) +
|
|
// "&product_json=" + HttpUtility.UrlEncode(dbProd.product_json, Encoding.UTF8) +
|
|
// "&size_json=" + HttpUtility.UrlEncode(dbProd.size_json, Encoding.UTF8) +
|
|
// "&main_img=" + HttpUtility.UrlEncode(dbProd.main_img, Encoding.UTF8) +
|
|
// "&sale_count=" + HttpUtility.UrlEncode(prodInfo.sale_count, Encoding.UTF8) +
|
|
// "&sale_count_text=" + HttpUtility.UrlEncode(prodInfo.sale_count_text, Encoding.UTF8) +
|
|
// "&product_get_type=" + HttpUtility.UrlEncode("多多外部数据", 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"))
|
|
//{
|
|
// return "商品采集保存失败!请检查网络连接:" + BaseRegex.GetStringJson(ref html, "msg");
|
|
//}
|
|
//return "";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
convertRst = "转换错误 " + ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 微信店铺采集转拼多多
|
|
/// </summary>
|
|
/// <param name="convertRst"></param>
|
|
/// <param name="dbProd"></param>
|
|
/// <returns></returns>
|
|
public PDDProductInfo WXProdToPddConvert(out string convertRst, KJDDBProduct dbProd)
|
|
{
|
|
convertRst = "";
|
|
try
|
|
{
|
|
//var prodObj = JsonHelper.JObjectParse(dbProd.product_json);
|
|
//if (prodObj["pddData"].IsJTokenNullOrEmpty())
|
|
//{
|
|
// convertRst = "缺少指定的数据格式";
|
|
// return null;
|
|
//}
|
|
//var jstGoodsObj = prodObj["pddData"];
|
|
//var jstPddPropMapLst = JsonHelper.DeserializeJsonToList<PDDPropRefPidNameMap>(JsonHelper.SerializeObject(prodObj["pddPropMap"]));
|
|
////{"goodsId":"2016474712785620994","warehouseGoodsId":"C7108311198A4217B022DCA87B6A5863","spuCode":"3783056947394249077","skus":[{"skuId":"2016692758292738050","warehouseSkuId":"C742B3FCB0364448AF92332F8F6005A6","skuCode":"ZH-XP-YWQYW-010"},{"skuId":"2016692758317903874","warehouseSkuId":"703E87F1B7774C14923821A57EEE6EFA","skuCode":"ZH-XP-YWQYW-010-111"},{"skuId":"2016692758338875394","warehouseSkuId":"895EDCDF6ECC4FAE8AD4DB9503719002","skuCode":"ZH-XP-YWQYW-010-222"}]}
|
|
//var jstSecretCodeLst = JsonHelper.JObjectParse(dbProd.sku_secret_json.TrimStart('[').TrimEnd(']'));
|
|
|
|
WXGetEditProductInfoLite wxEditProdInfo = JsonHelper.DeserializeJsonToObject<WXGetEditProductInfoLite>(dbProd.product_json);
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
sale_count = dbProd.sale_count.ParseToString(),
|
|
sale_count_text = dbProd.sale_count_text,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = dbProd.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
//微信商品的类目直接输入,上传的时候不用。
|
|
foreach (var category in wxEditProdInfo.product.info.category)
|
|
{
|
|
prodInfo.detail.cat_ids.Add(category.catId.ParseToInt());
|
|
}
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
foreach (var imgItem in wxEditProdInfo.product.info.headImg)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 1,
|
|
});
|
|
}
|
|
foreach (var imgItem in wxEditProdInfo.product.info.detail.detailImg)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 2,
|
|
});
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = wxEditProdInfo.product.info.title;
|
|
prodInfo.detail.goods_id = wxEditProdInfo.product.productKey.productId.ParseToLong();
|
|
prodInfo.detail.goods_name = wxEditProdInfo.product.info.title;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.hd_thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
// 编辑id,随意填写
|
|
prodInfo.detail.id = 0;
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.image_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
// 微信没有
|
|
prodInfo.detail.mall_id = 0;
|
|
// 微信没有
|
|
prodInfo.detail.mall_info = new mall_info_item();
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.market_price = 0;
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.max_group_price = 0;
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.min_group_price = 0;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
// 货号
|
|
prodInfo.detail.out_goods_sn = wxEditProdInfo.product.info.spuCode;
|
|
//if (prodInfo.detail.out_goods_sn.IsNullOrEmpty())
|
|
//{
|
|
// convertRst = "货号不存在";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
// 聚水潭没有
|
|
prodInfo.detail.share_desc = "";
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
|
|
//if (jstGoodsObj["skuInfo"].IsJTokenNullOrEmpty() || jstGoodsObj["skuInfo"]["goodsSkuDetail"].IsJTokenNullOrEmpty())
|
|
//{
|
|
// convertRst = "缺少sku信息";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
//foreach (JObject jSku in jstGoodsObj["skuInfo"]["goodsSkuDetail"])
|
|
foreach (var wxEditSkuInfo in wxEditProdInfo.product.productSkus)
|
|
{
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = wxEditSkuInfo.skuKey.skuId.ParseToLong(),
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = wxEditSkuInfo.productSkuInfo.salePrice.ParseToInt(),
|
|
multi_price_in_yuan = null,
|
|
price = wxEditSkuInfo.productSkuInfo.salePrice.ParseToInt() + 100,
|
|
price_in_yuan = null,
|
|
quantity = wxEditSkuInfo.productSkuInfo.realStockInfo?.stockNum ?? wxEditSkuInfo.productSkuInfo.stockInfo?.stockNum.ParseToInt(),
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = wxEditSkuInfo.productSkuInfo.thumbImg,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = 0,
|
|
spec = new List<spec_item>(),
|
|
// sku货号下面单独设置
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
//// 聚水潭供应商价加价10%(最低1元)赚取差价
|
|
//int addPrice = (skuInfo.multi_price * 0.1).ParseToInt();
|
|
//if (addPrice < 100)
|
|
// addPrice = 100;
|
|
//skuInfo.multi_price += addPrice;
|
|
//skuInfo.price += addPrice;
|
|
foreach (var wxSpec in wxEditSkuInfo.productSkuInfo.saleParam)
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = wxSpec.categorys[0].catId.ParseToLong(),
|
|
parent_name = wxSpec.categorys[0].name,
|
|
spec_id = wxSpec.categorys[1].catId.ParseToLong(),
|
|
spec_name = wxSpec.categorys[1].name,
|
|
});
|
|
}
|
|
skuInfo.out_sku_sn = wxEditSkuInfo.productSkuInfo.skuCode;
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
// 复用前面填过的主图
|
|
prodInfo.detail.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
|
|
if (1 == 1)
|
|
{
|
|
foreach (var wxProp in wxEditProdInfo.product.info.param)
|
|
{
|
|
string name = wxProp.categorys.FirstOrDefault()?.name;
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
propInfo.name = name;
|
|
propInfo.ref_pid = null;
|
|
//propInfo.wx_input_type = wxProp.categorys.FirstOrDefault()?.catInfo.inputType;
|
|
propInfo.values = new List<value_item>();
|
|
foreach (var wxPropVal in wxProp.categorys)
|
|
{
|
|
// 第一个是属性名,装载属性值的时候跳过
|
|
if (wxProp.categorys.IndexOf(wxPropVal) == 0)
|
|
continue;
|
|
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = wxPropVal.name.ParseToString(),
|
|
raw_value = wxPropVal.name.ParseToString(),
|
|
vid = null,
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//outGoodsParam.productAttrs.Add(new osProductAttrParam { attrKey = "品牌", attrValue = "无品牌" });
|
|
}
|
|
// 主图 复用前面的
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
return prodInfo;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
convertRst = "转换错误 " + ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 1688网页端采集转拼多多
|
|
/// </summary>
|
|
/// <param name="convertRst"></param>
|
|
/// <param name="dbProd"></param>
|
|
/// <returns></returns>
|
|
public PDDProductInfo _1688ClientToPddConvert(out string convertRst, KJDDBProduct dbProd)
|
|
{
|
|
convertRst = "";
|
|
try
|
|
{
|
|
var prod_json = dbProd.product_json;
|
|
var _1688Json = BaseRegex.GetOneJsonObjStrJson(ref prod_json, "_1688DetailData");
|
|
_1688ClientProductInfo _1688ClentProdInfo = JsonHelper.DeserializeJsonToObject<_1688ClientProductInfo>(_1688Json);
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
sale_count = dbProd.sale_count.ParseToString(),
|
|
sale_count_text = dbProd.sale_count_text,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = dbProd.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
//foreach (var category in _1688EditProdInfo.product.info.category)
|
|
//{
|
|
// prodInfo.detail.cat_ids.Add(category.catId.ParseToInt());
|
|
//}
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
foreach (var imgItem in _1688ClentProdInfo.mainImage)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 1,
|
|
});
|
|
}
|
|
foreach (var imgItem in _1688ClentProdInfo.offerImgList)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 2,
|
|
});
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = _1688ClentProdInfo.tempModel.offerTitle;
|
|
prodInfo.detail.goods_id = _1688ClentProdInfo.tempModel.offerId;
|
|
prodInfo.detail.goods_name = _1688ClentProdInfo.tempModel.offerTitle;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.hd_thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
// 编辑id,随意填写
|
|
prodInfo.detail.id = 0;
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.image_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
// 1688没有
|
|
prodInfo.detail.mall_id = 0;
|
|
// 1688没有
|
|
prodInfo.detail.mall_info = new mall_info_item();
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.market_price = 0;
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.max_group_price = 0;
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.min_group_price = 0;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
// 货号 1688没有字段直接标明,可能存在属性里面
|
|
prodInfo.detail.out_goods_sn = (_1688ClentProdInfo.offerDetail?.featureAttributes?.FirstOrDefault(s => s.name == "货号")?.value).ParseToString();
|
|
//if (prodInfo.detail.out_goods_sn.IsNullOrEmpty())
|
|
//{
|
|
// convertRst = "货号不存在";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
// 1688没有
|
|
prodInfo.detail.share_desc = "";
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (string skuKey in _1688ClentProdInfo.skuModel.skuInfoMap.Keys)
|
|
{
|
|
_1688skuInfo _1688skuInfo = _1688ClentProdInfo.skuModel.skuInfoMap[skuKey];
|
|
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = _1688skuInfo.skuId.ParseToLong(),
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (_1688skuInfo.price.ParseToDecimal() * 100 + _1688ClentProdInfo.postFeeValue.ParseToDecimal() * 100).ParseToInt(),
|
|
multi_price_in_yuan = null,
|
|
price = (_1688skuInfo.price.ParseToDecimal() * 100 + _1688ClentProdInfo.postFeeValue.ParseToDecimal() * 100).ParseToInt() + 100,
|
|
price_in_yuan = null,
|
|
quantity = _1688skuInfo.canBookCount,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
//thumb_url = _1688skuInfo.productSkuInfo.thumbImg,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = 0,
|
|
spec = new List<spec_item>(),
|
|
// sku货号
|
|
out_sku_sn = _1688skuInfo.specId,
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
//// 聚水潭供应商价加价10%(最低1元)赚取差价
|
|
//int addPrice = (skuInfo.multi_price * 0.1).ParseToInt();
|
|
//if (addPrice < 100)
|
|
// addPrice = 100;
|
|
//skuInfo.multi_price += addPrice;
|
|
//skuInfo.price += addPrice;
|
|
foreach (_1688skuProp _1688skuProp in _1688ClentProdInfo.skuModel.skuProps)
|
|
{
|
|
foreach (_1688skuValue _1688SpecValue in _1688skuProp.value)
|
|
{
|
|
if ((">" + skuKey + ">").Contains(">" + _1688SpecValue.name + ">"))
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = _1688skuProp.fid.ParseToLong(),
|
|
parent_name = _1688skuProp.prop,
|
|
spec_id = 0,
|
|
spec_name = _1688SpecValue.name,
|
|
});
|
|
if (!string.IsNullOrEmpty(_1688SpecValue.imageUrl))
|
|
skuInfo.thumb_url = _1688SpecValue.imageUrl;
|
|
}
|
|
}
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
// 复用前面填过的主图
|
|
prodInfo.detail.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
|
|
if (1 == 1)
|
|
{
|
|
foreach (_1688featureAttributes _1688Attr in _1688ClentProdInfo.offerDetail.featureAttributes)
|
|
{
|
|
string name = _1688Attr.name;
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
propInfo.name = name;
|
|
propInfo.ref_pid = null;
|
|
//propInfo.wx_input_type = wxProp.categorys.FirstOrDefault()?.catInfo.inputType;
|
|
propInfo.values = new List<value_item>();
|
|
List<string> values = (_1688Attr.values == null || _1688Attr.values.Count() == 0) ? _1688Attr.decisionValues : _1688Attr.values;
|
|
foreach (var wxPropVal in values)
|
|
{
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = wxPropVal,
|
|
raw_value = wxPropVal,
|
|
vid = null,
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//outGoodsParam.productAttrs.Add(new osProductAttrParam { attrKey = "品牌", attrValue = "无品牌" });
|
|
}
|
|
// 主图 复用前面的
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
return prodInfo;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
convertRst = "转换错误 " + ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 1688外部数据转拼多多(万象工具)
|
|
/// </summary>
|
|
/// <param name="convertRst"></param>
|
|
/// <param name="dbProd"></param>
|
|
/// <returns></returns>
|
|
public PDDProductInfo _1688OutToPddConvert(out string convertRst, KJDDBProduct dbProd)
|
|
{
|
|
convertRst = "";
|
|
try
|
|
{
|
|
var prod_json = dbProd.product_json;
|
|
_1688OutProductInfo _1688OutProdInfo = JsonHelper.DeserializeJsonToObject<_1688OutProductInfo>(prod_json);
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
sale_count = dbProd.sale_count.ParseToString(),
|
|
sale_count_text = dbProd.sale_count_text,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = dbProd.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
//foreach (var category in _1688EditProdInfo.product.info.category)
|
|
//{
|
|
// prodInfo.detail.cat_ids.Add(category.catId.ParseToInt());
|
|
//}
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
foreach (var imgItem in _1688OutProdInfo.itemImgs)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 1,
|
|
});
|
|
}
|
|
var desc = _1688OutProdInfo.desc.ParseToString();
|
|
var descLst = desc.Split(new string[] { "src=\"", "\" usemap", "\"/>", "\"" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|
foreach (var imgItem in descLst)
|
|
{
|
|
if (!imgItem.StartsWith("http") || (!imgItem.ToLower().Contains(".jpg") && !imgItem.ToLower().Contains(".jpeg") && !imgItem.ToLower().Contains(".png")))
|
|
continue;
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 2,
|
|
});
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = _1688OutProdInfo.productName;
|
|
prodInfo.detail.goods_id = _1688OutProdInfo.productId.ParseToLong();
|
|
prodInfo.detail.goods_name = _1688OutProdInfo.productName;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.hd_thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
// 编辑id,随意填写
|
|
prodInfo.detail.id = 0;
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.image_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
// 1688没有
|
|
prodInfo.detail.mall_id = 0;
|
|
// 1688没有
|
|
prodInfo.detail.mall_info = new mall_info_item();
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.market_price = 0;
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.max_group_price = 0;
|
|
// 1688没有此处随意填
|
|
prodInfo.detail.min_group_price = 0;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
// 货号
|
|
prodInfo.detail.out_goods_sn = (_1688OutProdInfo.attribute.FirstOrDefault(a => a.key == "货号")?.value).ParseToString();
|
|
//if (prodInfo.detail.out_goods_sn.IsNullOrEmpty())
|
|
//{
|
|
// convertRst = "货号不存在";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
// 1688没有
|
|
prodInfo.detail.share_desc = "";
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
if (_1688OutProdInfo.skus == null)
|
|
_1688OutProdInfo.skus = new List<_1688Sku>();
|
|
if (_1688OutProdInfo.skus.Count == 0)
|
|
{
|
|
_1688OutProdInfo.skus.Add(new _1688Sku()
|
|
{
|
|
skuId = -1,
|
|
quantity = 999,
|
|
price = (_1688OutProdInfo.priceHigh.ParseToDecimal() * 100).ParseToInt(),
|
|
});
|
|
}
|
|
foreach (var sku in _1688OutProdInfo.skus)
|
|
{
|
|
var postFeeValue = (_1688OutProdInfo.deliveryInfo?.carriageList?.Max(c => c.price)).ParseToDecimal();
|
|
|
|
//_1688skuInfo _1688skuInfo = _1688OutProdInfo.skuModel.skuInfoMap[sku];
|
|
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = sku.skuId,
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = (sku.price + postFeeValue * 100).ParseToInt(),
|
|
multi_price_in_yuan = null,
|
|
price = (sku.price + postFeeValue * 100).ParseToInt() + 100,
|
|
price_in_yuan = null,
|
|
quantity = sku.quantity,
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
//thumb_url = _1688skuInfo.productSkuInfo.thumbImg,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = 0,
|
|
spec = new List<spec_item>(),
|
|
// sku货号
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
//// 聚水潭供应商价加价10%(最低1元)赚取差价
|
|
//int addPrice = (skuInfo.multi_price * 0.1).ParseToInt();
|
|
//if (addPrice < 100)
|
|
// addPrice = 100;
|
|
//skuInfo.multi_price += addPrice;
|
|
//skuInfo.price += addPrice;
|
|
foreach (_1688PropsName _1688skuProp in _1688OutProdInfo.propsName)
|
|
{
|
|
foreach (_1688PropsNameValue _1688skuPropValue in _1688skuProp.values)
|
|
{
|
|
if ((";" + sku.id + ";").Contains(";" + _1688skuProp.pid + ":" + _1688skuPropValue.vid + ";"))
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = _1688skuProp.pid.ParseToLong(),
|
|
parent_name = _1688skuProp.pname,
|
|
spec_id = _1688skuPropValue.vid.ParseToLong(),
|
|
spec_name = _1688skuPropValue.vname,
|
|
});
|
|
if (!string.IsNullOrEmpty(_1688skuPropValue.sku_url))
|
|
skuInfo.thumb_url = _1688skuPropValue.sku_url;
|
|
}
|
|
}
|
|
}
|
|
if (skuInfo.spec.Count == 0)
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = 0,
|
|
parent_name = "款式",
|
|
spec_id = 0,
|
|
spec_name = "默认",
|
|
});
|
|
if (string.IsNullOrEmpty(skuInfo.thumb_url))
|
|
{
|
|
skuInfo.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
}
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
// 复用前面填过的主图
|
|
prodInfo.detail.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
|
|
if (1 == 1)
|
|
{
|
|
foreach (_1688AttributeInfo _1688Attr in _1688OutProdInfo.attribute)
|
|
{
|
|
// 1688会把商品sku属性放到商品属性里面,需要剔除这个属性
|
|
if (_1688OutProdInfo.propsName.Any(p => p.pname == _1688Attr.key && string.Join(",", p.values.Select(pp => pp.vname)) == _1688Attr.value))
|
|
continue;
|
|
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
propInfo.name = _1688Attr.key;
|
|
propInfo.ref_pid = null;
|
|
propInfo.values = new List<value_item>();
|
|
List<string> values = new List<string> { _1688Attr.value };
|
|
foreach (var wxPropVal in values)
|
|
{
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = wxPropVal,
|
|
raw_value = wxPropVal,
|
|
vid = null,
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//outGoodsParam.productAttrs.Add(new osProductAttrParam { attrKey = "品牌", attrValue = "无品牌" });
|
|
}
|
|
// 主图 复用前面的
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
return prodInfo;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
convertRst = "转换错误 " + ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 微信商城手机版转拼多多
|
|
/// </summary>
|
|
/// <param name="convertRst"></param>
|
|
/// <param name="dbProd"></param>
|
|
/// <returns></returns>
|
|
public PDDProductInfo WXClientToPddConvert(out string convertRst, KJDDBProduct dbProd)
|
|
{
|
|
convertRst = "";
|
|
try
|
|
{
|
|
var wxxdData = JsonHelper.SerializeObject(JsonHelper.JObjectParse(dbProd.product_json)["wxxdData"]);
|
|
var baseData = JsonHelper.JObjectParse(dbProd.product_json)["baseData"].ParseToString();
|
|
|
|
var str_lst = BaseRegex.GetJsonArrStrJson(ref baseData, "productSkus");
|
|
try
|
|
{
|
|
var regex_str = str_lst.OrderByDescending(s => s.Length).FirstOrDefault();
|
|
var productSkus = JsonHelper.DeserializeJsonToList<WXProductSkuInfoLite>(regex_str);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
|
|
WXClientProductInfoLite wxClientProdInfo = JsonHelper.DeserializeJsonToObject<WXClientProductInfoLite>(wxxdData);
|
|
if (wxClientProdInfo.info.sku_list == null)
|
|
{
|
|
wxClientProdInfo.info.sku_list = new wx_sku();
|
|
}
|
|
if (wxClientProdInfo.info.sku_list.sku_info == null)
|
|
{
|
|
wxClientProdInfo.info.sku_list.sku_info = new List<wx_client_sku_info>();
|
|
|
|
try
|
|
{
|
|
if (baseData.Contains("{\"sku_info\""))
|
|
{
|
|
var skuInfoStr = baseData.Substring(baseData.IndexOf("{\"sku_info\""));
|
|
if (skuInfoStr.Contains(" KB)"))
|
|
skuInfoStr = skuInfoStr.Substring(0, skuInfoStr.IndexOf(" KB)"));
|
|
while (skuInfoStr.IndexOf("{\"sku_id\"") >= 0)
|
|
{
|
|
skuInfoStr = skuInfoStr.Substring(skuInfoStr.IndexOf("{\"sku_id\""));
|
|
var wxClientSkuInfo = new wx_client_sku_info();
|
|
wxClientSkuInfo.sku_id = BaseRegex.GetStringJson(ref skuInfoStr, "sku_id");
|
|
wxClientSkuInfo.price = BaseRegex.GetIntJson(ref skuInfoStr, "price");
|
|
wxClientSkuInfo.is_discounted = BaseRegex.GetBoolJson(ref skuInfoStr, "is_discounted");
|
|
wxClientSkuInfo.discounted_price = BaseRegex.GetIntJson(ref skuInfoStr, "discounted_price");
|
|
wxClientSkuInfo.origin_price = BaseRegex.GetIntJson(ref skuInfoStr, "origin_price");
|
|
if (wxClientSkuInfo.price != null && wxClientSkuInfo.is_discounted != null && wxClientSkuInfo.discounted_price != null && wxClientSkuInfo.origin_price != null)
|
|
{
|
|
wxClientProdInfo.info.sku_list.sku_info.Add(wxClientSkuInfo);
|
|
}
|
|
skuInfoStr = skuInfoStr.Substring(skuInfoStr.IndexOf("{\"sku_id\"") + "{\"sku_id\"".Length);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
|
|
PDDProductInfo prodInfo = new PDDProductInfo()
|
|
{
|
|
sale_count = dbProd.sale_count.ParseToString(),
|
|
sale_count_text = dbProd.sale_count_text,
|
|
};
|
|
prodInfo.chance_id = null;
|
|
prodInfo.chance_refere = null;
|
|
prodInfo.chance_tab = null;
|
|
prodInfo.decoration = new PDDProductDecorationInfo() { floor_list = new List<PDDProdfloorItem>() };
|
|
|
|
// 商品详情
|
|
prodInfo.detail = new PDDProductDetailInfo();
|
|
prodInfo.detail.allergy_refund = 0;
|
|
prodInfo.detail.allowed_region = new List<object>();
|
|
//prodInfo.detail.appeal_status = null;
|
|
//prodInfo.detail.app_id = null;
|
|
//prodInfo.detail.app_name = null;
|
|
//prodInfo.detail.bad_claim_text = null;
|
|
prodInfo.detail.bad_fruit_claim = 0;
|
|
//prodInfo.detail.business_source_type = null;
|
|
prodInfo.detail.can_appeal = null;
|
|
prodInfo.detail.card_verification_list = null;
|
|
prodInfo.detail.cats = new List<string>();
|
|
prodInfo.detail.cat_id = dbProd.cat_id.ParseToInt();
|
|
prodInfo.detail.cat_ids = new List<int?>();
|
|
//微信商品的类目直接输入,上传的时候不用。
|
|
foreach (var category in wxClientProdInfo.info.category)
|
|
{
|
|
prodInfo.detail.cat_ids.Add(category.catIdStr.ParseToInt());
|
|
}
|
|
prodInfo.detail.check_status = 9;
|
|
//prodInfo.detail.check_type = null;
|
|
//prodInfo.detail.client_id = null;
|
|
prodInfo.detail.commit_deleted = 0;
|
|
//prodInfo.detail.commit_extension = null;
|
|
//prodInfo.detail.community_group_buying = null;
|
|
prodInfo.detail.cost_template_id = 0;
|
|
//prodInfo.detail.country = null;
|
|
prodInfo.detail.country_id = 0;
|
|
//prodInfo.detail.created_at = null;
|
|
//prodInfo.detail.creator_name = null;
|
|
prodInfo.detail.customizable = 0;
|
|
prodInfo.detail.customs = "";
|
|
prodInfo.detail.damage_claim = 0;
|
|
prodInfo.detail.delivery_one_day = 0;
|
|
//prodInfo.detail.delivery_type = null;
|
|
//prodInfo.detail.elec_goods_attributes = null;
|
|
prodInfo.detail.estimate_quantity = 0;
|
|
prodInfo.detail.event_type = 0;
|
|
prodInfo.detail.extend_warranty_dto = new extend_warranty_dto_item() { extend_warranty = 0 };
|
|
//prodInfo.detail.fabric = null;
|
|
//prodInfo.detail.fabric_content = null;
|
|
prodInfo.detail.galleries = new List<gallery_item>();
|
|
foreach (var imgItem in wxClientProdInfo.info.head_img)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 1,
|
|
});
|
|
}
|
|
foreach (var imgItem in wxClientProdInfo.info.detail.detail_img_real)
|
|
{
|
|
prodInfo.detail.galleries.Add(new gallery_item()
|
|
{
|
|
url = imgItem,
|
|
type = 2,
|
|
});
|
|
}
|
|
prodInfo.detail.gold_price_template_id = null;
|
|
prodInfo.detail.gold_price_type = null;
|
|
prodInfo.detail.goods_certificate = null;
|
|
prodInfo.detail.goods_commit_check = new List<object>();
|
|
prodInfo.detail.goods_desc = wxClientProdInfo.info.title;
|
|
prodInfo.detail.goods_id = wxClientProdInfo.product_key.product_id.ParseToLong();
|
|
prodInfo.detail.goods_name = wxClientProdInfo.info.title;
|
|
prodInfo.detail.goods_name_prefix = "";
|
|
prodInfo.detail.goods_pattern = 8;
|
|
prodInfo.detail.goods_property_list = null;
|
|
prodInfo.detail.goods_sn = null;
|
|
prodInfo.detail.goods_srv_templates = new List<object>();
|
|
prodInfo.detail.goods_trade_attr = null;
|
|
prodInfo.detail.goods_travel_attr = null;
|
|
prodInfo.detail.goods_type = 1;
|
|
prodInfo.detail.groups = new group_item() { single_price = 0, group_price = 0, customer_num = 2, buy_limit = 999999, order_limit = 999999 };
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.hd_thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
// 编辑id,随意填写
|
|
prodInfo.detail.id = 0;
|
|
// 复用前面已经填写过的
|
|
prodInfo.detail.image_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.instruction_vo = new instruction_vo_item() { template_status = -1 };
|
|
prodInfo.detail.invoice_mode = null;
|
|
prodInfo.detail.invoice_mode_sub_type = null;
|
|
prodInfo.detail.invoice_status = 0;
|
|
prodInfo.detail.is_all_weight_same = true;
|
|
prodInfo.detail.is_app = 0;
|
|
prodInfo.detail.is_bangdan = 0;
|
|
prodInfo.detail.is_card_secret = false;
|
|
prodInfo.detail.is_certificate_provide = 0;
|
|
prodInfo.detail.is_customized = 0;
|
|
prodInfo.detail.is_customs = 0;
|
|
prodInfo.detail.is_deposit = false;
|
|
prodInfo.detail.is_draft = false;
|
|
prodInfo.detail.is_folt = 0;
|
|
prodInfo.detail.is_general_trade = 0;
|
|
prodInfo.detail.is_gold_price_matched = null;
|
|
prodInfo.detail.is_goods_copy = null;
|
|
prodInfo.detail.is_goods_decoration = 1;
|
|
prodInfo.detail.is_group_pre_sale = 0;
|
|
prodInfo.detail.is_only_for_remote_area = false;
|
|
prodInfo.detail.is_pre_sale = 0;
|
|
prodInfo.detail.is_refundable = 1;
|
|
prodInfo.detail.is_refundable_fifteen_day = 0;
|
|
prodInfo.detail.is_shop = 1;
|
|
prodInfo.detail.is_size_change_casually = 0;
|
|
prodInfo.detail.is_sku_pre_sale = 0;
|
|
prodInfo.detail.is_sku_shipment = 0;
|
|
prodInfo.detail.is_small_group = null;
|
|
prodInfo.detail.is_spring_festival_open_tag = false;
|
|
prodInfo.detail.is_two_num_group = false;
|
|
prodInfo.detail.is_warranty_one_year = 0;
|
|
prodInfo.detail.is_wms = 0;
|
|
prodInfo.detail.is_wp_service = 0;
|
|
prodInfo.detail.lack_of_weight_claim = 0;
|
|
prodInfo.detail.last_commit_check_status = 2;
|
|
prodInfo.detail.list_desc = new List<object>();
|
|
prodInfo.detail.local_service_id_list = null;
|
|
prodInfo.detail.mai_jia_zi_ti = null;
|
|
// 微信没有
|
|
prodInfo.detail.mall_id = 0;
|
|
// 微信没有
|
|
prodInfo.detail.mall_info = new mall_info_item();
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.market_price = 0;
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.max_group_price = 0;
|
|
// 微信没有此处随意填
|
|
prodInfo.detail.min_group_price = 0;
|
|
prodInfo.detail.must_check_type = 0;
|
|
prodInfo.detail.name_prefix = "";
|
|
prodInfo.detail.origin_country_id = 0;
|
|
prodInfo.detail.origin_country_name = "";
|
|
// 货号
|
|
prodInfo.detail.out_goods_sn = wxClientProdInfo.info.spuCode;
|
|
//if (prodInfo.detail.out_goods_sn.IsNullOrEmpty())
|
|
//{
|
|
// convertRst = "货号不存在";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.out_source_goods_id = null;
|
|
prodInfo.detail.out_source_type = null;
|
|
prodInfo.detail.oversea_goods = null;
|
|
prodInfo.detail.oversea_type = 0;
|
|
prodInfo.detail.owner = "主账号";
|
|
prodInfo.detail.owner_name = "";
|
|
prodInfo.detail.paper_length = null;
|
|
prodInfo.detail.paper_net_weight = null;
|
|
prodInfo.detail.paper_plies_num = null;
|
|
prodInfo.detail.paper_width = null;
|
|
prodInfo.detail.pre_sale_time = 0;
|
|
prodInfo.detail.privacy_delivery = 0;
|
|
prodInfo.detail.processing_charges = null;
|
|
prodInfo.detail.processing_charges_type = null;
|
|
prodInfo.detail.promised_delivery_seconds = null;
|
|
prodInfo.detail.purchase_info_supply = 0;
|
|
prodInfo.detail.qualification_id_list = new List<object>();
|
|
prodInfo.detail.quan_guo_lian_bao = 0;
|
|
prodInfo.detail.quick_refund = 0;
|
|
prodInfo.detail.reason = null;
|
|
prodInfo.detail.region_limit = 1;
|
|
prodInfo.detail.reject_reason = null;
|
|
prodInfo.detail.reject_status = null;
|
|
prodInfo.detail.same_city_template_id = 0;
|
|
prodInfo.detail.schedule_sale = new schedule_sale_item() { sale_type = 0 };
|
|
prodInfo.detail.second_hand = 0;
|
|
prodInfo.detail.sf_markup_template_sn = null;
|
|
prodInfo.detail.shang_men_an_zhuang = null;
|
|
// 聚水潭没有
|
|
prodInfo.detail.share_desc = "";
|
|
prodInfo.detail.shipment_limit_second = 172800;
|
|
prodInfo.detail.shoes_template_id = null;
|
|
prodInfo.detail.shop_group_id = null;
|
|
prodInfo.detail.shop_group_name = null;
|
|
prodInfo.detail.show_activity_price = false;
|
|
prodInfo.detail.size_parent_spec_id = null;
|
|
prodInfo.detail.size_spec_id = null;
|
|
|
|
//if (jstGoodsObj["skuInfo"].IsJTokenNullOrEmpty() || jstGoodsObj["skuInfo"]["goodsSkuDetail"].IsJTokenNullOrEmpty())
|
|
//{
|
|
// convertRst = "缺少sku信息";
|
|
// return null;
|
|
//}
|
|
prodInfo.detail.sku = new List<sku_item>();
|
|
foreach (var wxEditSkuInfo in wxClientProdInfo.productSkus)
|
|
{
|
|
var wxDisSku = wxClientProdInfo.info.sku_list.sku_info.FirstOrDefault(s => s.sku_id == wxEditSkuInfo.skuKey.skuId);
|
|
var discountedValue = (wxDisSku?.discounted_price).ParseToInt();
|
|
sku_item skuInfo = new sku_item()
|
|
{
|
|
id = 0,
|
|
sku_id = wxEditSkuInfo.skuKey.skuId.ParseToLong(),
|
|
sku_sn = null,
|
|
carnival_price = 0,
|
|
init_quantity = 0,
|
|
is_onsale = 1,
|
|
limit_quantity = 999999,
|
|
multi_price = wxEditSkuInfo.productSkuInfo.salePrice.ParseToInt() - discountedValue,
|
|
multi_price_in_yuan = null,
|
|
price = wxEditSkuInfo.productSkuInfo.salePrice.ParseToInt() - discountedValue + 100,
|
|
price_in_yuan = null,
|
|
quantity = wxEditSkuInfo.productSkuInfo?.stockInfo?.stockNum?.ParseToInt(),
|
|
reserve_quantity = 0,
|
|
weight = 0,
|
|
thumb_url = wxEditSkuInfo.productSkuInfo.thumbImg,
|
|
thumb_url_file_id = null,
|
|
thumb_url_status = null,
|
|
thumb_url_is_deleted = null,
|
|
quantity_delta = 0,
|
|
spec = new List<spec_item>(),
|
|
// sku货号下面单独设置
|
|
out_sku_sn = "",
|
|
batch_id = null,
|
|
priority = 1,
|
|
ware_id = 0,
|
|
ware_biz_type = null,
|
|
advice_price = null,
|
|
length = null,
|
|
oversea_sku = null,
|
|
cspu_id = null,
|
|
child_skus = null,
|
|
ref_sku_commit_id = 0,
|
|
start_time = null,
|
|
end_time = null,
|
|
sku_srv_templates = null,
|
|
calendar_rule_id = null,
|
|
hot_live_group = null,
|
|
pre_sale_time = 0,
|
|
out_source_sku_id = null,
|
|
dd_grocery_sku_params = null,
|
|
sku_extended_attribute_dtos = null,
|
|
sku_basic_property_dtos = null,
|
|
spec_note_map = null,
|
|
delivery_schedule_dtos = null,
|
|
shipment_limit_second_list = null,
|
|
sku69_code = "",
|
|
};
|
|
//// 聚水潭供应商价加价10%(最低1元)赚取差价
|
|
//int addPrice = (skuInfo.multi_price * 0.1).ParseToInt();
|
|
//if (addPrice < 100)
|
|
// addPrice = 100;
|
|
//skuInfo.multi_price += addPrice;
|
|
//skuInfo.price += addPrice;
|
|
if (wxEditSkuInfo.productSkuInfo.saleParam != null)
|
|
{
|
|
foreach (var wxSpec in wxEditSkuInfo.productSkuInfo.saleParam)
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = wxSpec.categorys[0].catId.ParseToLong(),
|
|
parent_name = wxSpec.categorys[0].name,
|
|
spec_id = wxSpec.categorys[1].catId.ParseToLong(),
|
|
spec_name = wxSpec.categorys[1].name,
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
skuInfo.spec.Add(new spec_item()
|
|
{
|
|
parent_id = 0,
|
|
parent_name = "规格",
|
|
spec_id = 0,
|
|
spec_name = "默认",
|
|
});
|
|
}
|
|
skuInfo.out_sku_sn = wxEditSkuInfo.productSkuInfo.skuCode;
|
|
prodInfo.detail.sku.Add(skuInfo);
|
|
}
|
|
prodInfo.detail.sku_type = null;
|
|
prodInfo.detail.song_huo_an_zhuang = null;
|
|
prodInfo.detail.song_huo_ru_hu = null;
|
|
prodInfo.detail.source = 0;
|
|
prodInfo.detail.spu_id = null;
|
|
prodInfo.detail.spu_version = null;
|
|
prodInfo.detail.submit_time = 0;
|
|
prodInfo.detail.thawed_refund = 0;
|
|
prodInfo.detail.third_type = 0;
|
|
// 复用前面填过的主图
|
|
prodInfo.detail.thumb_url = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1)?.url;
|
|
prodInfo.detail.tiny_name = "";
|
|
prodInfo.detail.transport_type_list = null;
|
|
prodInfo.detail.two_pieces_discount = 99;
|
|
prodInfo.detail.user_source = 1;
|
|
prodInfo.detail.warehouse = "";
|
|
prodInfo.detail.warm_tips = "";
|
|
prodInfo.detail.zhi_huan_bu_xiu = 0;
|
|
|
|
prodInfo.size = null;
|
|
prodInfo.material1 = null;
|
|
prodInfo.material3 = null;
|
|
prodInfo.property = new PDDProductPropertyInfo();
|
|
prodInfo.property.sku_properties = new object();
|
|
prodInfo.property.goods_properties = new List<goods_propertie_item>();
|
|
|
|
if (1 == 1)
|
|
{
|
|
foreach (var wxProp in wxClientProdInfo.info.param)
|
|
{
|
|
string name = wxProp.categorys.FirstOrDefault()?.name;
|
|
goods_propertie_item propInfo = new goods_propertie_item();
|
|
prodInfo.property.goods_properties.Add(propInfo);
|
|
propInfo.name = name;
|
|
propInfo.ref_pid = null;
|
|
//propInfo.wx_input_type = wxProp.categorys.FirstOrDefault()?.catInfo.inputType;
|
|
propInfo.values = new List<value_item>();
|
|
foreach (var wxPropVal in wxProp.categorys)
|
|
{
|
|
// 第一个是属性名,装载属性值的时候跳过
|
|
if (wxProp.categorys.IndexOf(wxPropVal) == 0)
|
|
continue;
|
|
|
|
propInfo.values.Add(new value_item()
|
|
{
|
|
value = wxPropVal.name.ParseToString(),
|
|
raw_value = wxPropVal.name.ParseToString(),
|
|
vid = null,
|
|
unit = ""
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//outGoodsParam.productAttrs.Add(new osProductAttrParam { attrKey = "品牌", attrValue = "无品牌" });
|
|
}
|
|
// 主图 复用前面的
|
|
dbProd.main_img = prodInfo.detail.galleries.FirstOrDefault(g => g.type == 1).url;
|
|
dbProd.product_json = JsonHelper.SerializeObject(prodInfo);
|
|
|
|
return prodInfo;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
convertRst = "转换错误 " + ex.Message;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|