聚水潭上传微信小店相关逻辑
This commit is contained in:
1 parent
625f4d9420
commit
b4fa5cacb1
26 files changed
+2570
-487
No files matched your search
@@ -972,6 +972,11 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
if (chkSkipUploaded.Checked)
|
||||
{
|
||||
var searchExtCode = "EC1" + dbProd.spu_id + "A";
|
||||
if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
|
||||
{
|
||||
var sku_secret_json = dbProd.sku_secret_json;
|
||||
searchExtCode = BaseRegex.GetStringJson(ref sku_secret_json, "goodsId");
|
||||
}
|
||||
var searchRst = WXUpload.searchProduct(shop, searchExtCode);
|
||||
if (!searchRst.Contains("\"code\":0") && !searchRst.Contains("\"success\":true"))
|
||||
{
|
||||
@@ -994,6 +999,15 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
}
|
||||
|
||||
// 加密数据将聚水潭产品数据格式进行转换
|
||||
if (dbProd.sku_secret_json != null && dbProd.sku_secret_json.Contains("goodsId"))
|
||||
{
|
||||
string convertRst = "";
|
||||
var ob = new PDDProdFormConverter().JstPddProdToPddConvert(out convertRst, dbProd);
|
||||
if (!string.IsNullOrEmpty(convertRst))
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
|
||||
}
|
||||
|
||||
#region 将产品数据初始化成微信小店支持的参数
|
||||
JObject prodJObj = new JObject();
|
||||
try
|
||||
@@ -1436,7 +1450,71 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
#endregion
|
||||
|
||||
#region 售后信息
|
||||
var addressRst = WXUpload.getAddress(shop);
|
||||
|
||||
var afterSaleAddress = "";
|
||||
var afterSaleDetail = "";
|
||||
if (dbProd.wx_cat_leaf != null)
|
||||
{
|
||||
|
||||
var urlAfterSale = BaseClass.BuildObjString("product/wx_get_after_sale");
|
||||
var dataAfterSale = Work.UserLogin.GetSignaturex() +
|
||||
"&coid=" + dbProd.skc_id;
|
||||
var htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
if (string.IsNullOrEmpty(htmlAfterSale) || !htmlAfterSale.Contains("\"code\":200"))
|
||||
htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
if (string.IsNullOrEmpty(htmlAfterSale) || !htmlAfterSale.Contains("\"code\":200"))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (htmlAfterSale.Contains("\"data\":\"\""))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
afterSaleAddress = JsonHelper.SerializeObject(JsonHelper.JObjectParse(htmlAfterSale)["data"]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(afterSaleAddress))
|
||||
{
|
||||
// 获取推单售后地址
|
||||
//https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=10361546&shopId=46568955
|
||||
var urlAfter = "https://po.e57.cn/prod-api/api/sys-api/system/open/api/afterSale/info?warehouseNum=" + dbProd.skc_id; //+ "&userName=阿杰账户";
|
||||
var afterRst = WXHttpResponseBLL.e57GetResponse(urlAfter, "");
|
||||
try
|
||||
{
|
||||
afterSaleAddress = JsonHelper.SerializeObject(JsonHelper.JObjectParse(afterRst)["data"]);
|
||||
if(afterRst.Contains("\"code\":0") && !string.IsNullOrEmpty(afterSaleAddress))
|
||||
{
|
||||
urlAfterSale = BaseClass.BuildObjString("product/wx_add_mdy_after_sale");
|
||||
dataAfterSale = Work.UserLogin.GetSignaturex() +
|
||||
"&coid=" + dbProd.skc_id + "&after_sale_json=" + afterSaleAddress;
|
||||
htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
if (string.IsNullOrEmpty(htmlAfterSale) || !htmlAfterSale.Contains("\"code\":200"))
|
||||
htmlAfterSale = GetHtml.PostUtf8(urlAfterSale, dataAfterSale);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty (afterSaleAddress))
|
||||
{
|
||||
afterSaleDetail = BaseRegex.GetStringJson(ref afterSaleAddress, "detail_info");
|
||||
}
|
||||
|
||||
var addressRst = WXUpload.getAddress(shop, afterSaleDetail);
|
||||
if (!addressRst.Contains("\"code\":0") && !addressRst.Contains("\"success\":true"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref addressRst, "msg");
|
||||
@@ -1444,6 +1522,33 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
error = addressRst;
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"售后地址获取失败 " + error + "\"}";
|
||||
}
|
||||
if (addressRst.Contains("\"totalNum\":0") && !string.IsNullOrEmpty(afterSaleDetail))
|
||||
{
|
||||
string provinceName = BaseRegex.GetStringJson(ref afterSaleAddress, "province_name");
|
||||
string cityName = BaseRegex.GetStringJson(ref afterSaleAddress, "city_name");
|
||||
string countyName = BaseRegex.GetStringJson(ref afterSaleAddress, "county_name");
|
||||
string detailInfo = afterSaleDetail;
|
||||
string userName = BaseRegex.GetStringJson(ref afterSaleAddress, "user_name");
|
||||
string telNumber = BaseRegex.GetStringJson(ref afterSaleAddress, "tel_number");
|
||||
var addAddRst = WXUpload.addAddress(shop, provinceName, cityName, countyName, detailInfo, userName, telNumber);
|
||||
|
||||
Thread.Sleep(Randomx.GetId(500, 1500));
|
||||
|
||||
addressRst = WXUpload.getAddress(shop, afterSaleDetail);
|
||||
if (!addressRst.Contains("\"code\":0") && !addressRst.Contains("\"success\":true"))
|
||||
{
|
||||
var error = BaseRegex.GetStringJson(ref addressRst, "msg");
|
||||
if (string.IsNullOrEmpty(error))
|
||||
error = addressRst;
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"售后地址获取失败 " + error + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
if (addressRst.Contains("\"totalNum\":0"))
|
||||
{
|
||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"售后地址获取失败\"}";
|
||||
}
|
||||
|
||||
upProdParam.product.info.afterSaleInfo = new afterSaleInfoParam();
|
||||
upProdParam.product.info.afterSaleInfo.afterSaleAddressId = BaseRegex.GetStringJson(ref addressRst, "addressId");
|
||||
#endregion
|
||||
@@ -1632,10 +1737,24 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
attrValue = "常规";
|
||||
else if (attrValueLst.Contains("通用"))
|
||||
attrValue = "通用";
|
||||
else if (attrValueLst.Contains("国产"))
|
||||
attrValue = "国产";
|
||||
else if (attr.value.Contains("绒丝;羽毛;白鸭绒;白鹅绒;灰鸭绒;灰鹅绒;鸭毛片;鹅毛片"))
|
||||
{
|
||||
attrValue = "绒丝";
|
||||
}
|
||||
else if (attr.name == "是否进口")
|
||||
{
|
||||
attrValue = "非进口";
|
||||
}
|
||||
else if (attr.name == "商品产地")
|
||||
{
|
||||
attrValue = "中国大陆";
|
||||
}
|
||||
else if (attr.name == "产地")
|
||||
{
|
||||
attrValue = "中国大陆";
|
||||
}
|
||||
else if (attrValueLst.Any(v => v.Contains("%")))
|
||||
{
|
||||
attrValue = attrValueLst.FirstOrDefault();
|
||||
@@ -1819,6 +1938,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
// sku图
|
||||
skuParam.productSkuInfo.thumbImg = upProdParam.product.info.productSaleAttrs[0].items.FirstOrDefault(a => a.value == skuInfo.spec[0].spec_name)?.imgUrl;
|
||||
skuParam.productSkuInfo.skuCode = skuInfo.out_sku_sn;
|
||||
// 库存
|
||||
skuParam.productSkuInfo.stockInfo = new stockInfoParam() { stockNum = defaultAddPriceRule.StockNum };
|
||||
skuParam.productSkuInfo.saleParam = new List<saleParamParam>();
|
||||
@@ -2326,7 +2446,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
"&page=" + 1 +
|
||||
"&page_size=" + pageSize;
|
||||
data += "&in_ext_codes=" + txtExtCodeFilter.Text;
|
||||
data += "&in_skc_ids=" + txtIdFilter.Text;
|
||||
data += "&in_spu_ids=" + txtIdFilter.Text;
|
||||
data += "&in_groups=" + cmbGroupFilter.Text;
|
||||
data += "&in_cates=" + cmbCateFilter.Text;
|
||||
data += "&product_get_type=" + cmbSourceType.Text.Trim();
|
||||
@@ -2648,10 +2768,12 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
|
||||
public class WXUpload
|
||||
{
|
||||
public static string searchProduct(ShopLoginInfo shop, string extCode)
|
||||
public static string searchProduct(ShopLoginInfo shop, string extCode, string extCode2 = "")
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeproductcore/cgi/goods/searchProduct?" +
|
||||
"token=&lang=zh_CN&pageSize=20&productStatus[]=-1&productSource=[1,16,32]&searchSource=1&useNew=true&pageNum=1&status[]=5&spuCode=" + extCode;
|
||||
if (!string.IsNullOrEmpty(extCode2))
|
||||
url += "," + extCode2;
|
||||
string refere = "https://store.weixin.qq.com/shop/goods/list?currentTab=PRODUCT_STATUS_ON";
|
||||
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, refere);
|
||||
return result;
|
||||
@@ -2759,16 +2881,16 @@ Content-Type: image/jpeg
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <returns></returns>
|
||||
public static string getAddress(ShopLoginInfo shop)
|
||||
public static string getAddress(ShopLoginInfo shop, string searchText="")
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeexpress/cgi/getAddress?token=&lang=zh_CN";
|
||||
if (!string.IsNullOrEmpty(searchText))
|
||||
url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeexpress/cgi/getAddress?searchStr=" + GetHtml.UrlEncodeUtf8(searchText) + "&token=&lang=zh_CN";
|
||||
string referer = "https://store.weixin.qq.com/shop/goods/entry";
|
||||
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, referer);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string uploadProductDraft(ShopLoginInfo shop, WXUploadProductParam prodParam)
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/uploadProductDraft?token=&lang=zh_CN";
|
||||
@@ -2809,11 +2931,11 @@ Content-Type: image/jpeg
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取售后地址
|
||||
/// 尝试免审 失败
|
||||
/// </summary>
|
||||
/// <param name="shop"></param>
|
||||
/// <param name="productId"></param>
|
||||
/// <returns></returns>
|
||||
public static string getEditProductV2(ShopLoginInfo shop, string productId)
|
||||
{
|
||||
@@ -2938,6 +3060,26 @@ Content-Type: application/octet-stream
|
||||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加售后地址
|
||||
/// </summary>
|
||||
public static string addAddress(ShopLoginInfo shop, string provinceName, string cityName, string countyName,
|
||||
string detailInfo, string userName, string telNumber)
|
||||
{
|
||||
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeexpress/address/addAddress?token=&lang=zh_CN";
|
||||
string referer = "https://store.weixin.qq.com/shop/address/expressAddressMgmt";
|
||||
string address = "{\"addressInfo\":{\"provinceName\":\"" + provinceName +
|
||||
"\",\"cityName\":\"" + cityName + "\",\"countyName\":\"" + countyName +
|
||||
"\",\"detailInfo\":\"" + detailInfo + "\",\"userName\":\"" + userName +
|
||||
"\",\"telNumber\":\"" + telNumber + "\",\"location\":{}},\"defaultSend\":0,\"defaultRecv\":0}";
|
||||
|
||||
JObject obj = new JObject();
|
||||
obj["data"] = address;
|
||||
string body = JsonHelper.SerializeObject(obj);
|
||||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class AddPriceRule
|
||||
|
||||
Reference in new issue
Block a user