食品类目自动复用授权开通功能
This commit is contained in:
1 parent
d2d2396804
commit
fc31b4c48f
4 files changed
+164
-4
No files matched your search
@@ -195,6 +195,7 @@
|
|||||||
<Compile Include="Model\Param\PDDCouponParam\PDDActivityMarketingParam.cs" />
|
<Compile Include="Model\Param\PDDCouponParam\PDDActivityMarketingParam.cs" />
|
||||||
<Compile Include="Model\Param\PDDCouponParam\PDDCouponParam.cs" />
|
<Compile Include="Model\Param\PDDCouponParam\PDDCouponParam.cs" />
|
||||||
<Compile Include="Model\Param\OutServerGoodsParam.cs" />
|
<Compile Include="Model\Param\OutServerGoodsParam.cs" />
|
||||||
|
<Compile Include="Model\Param\WXParam\WXCateAuthParam.cs" />
|
||||||
<Compile Include="Model\Param\WXParam\WXCoupon.cs" />
|
<Compile Include="Model\Param\WXParam\WXCoupon.cs" />
|
||||||
<Compile Include="Model\Param\WXParam\WXGetShortTitleParam.cs" />
|
<Compile Include="Model\Param\WXParam\WXGetShortTitleParam.cs" />
|
||||||
<Compile Include="Model\Param\WXParam\WXUploadProductInitParam.cs" />
|
<Compile Include="Model\Param\WXParam\WXUploadProductInitParam.cs" />
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace AllBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 版本ID
|
/// 版本ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int VersionCount = 873;
|
public static int VersionCount = 875;
|
||||||
//public static int VersionCount = 613;
|
//public static int VersionCount = 613;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AllBase.Model.Param.WXParam
|
||||||
|
{
|
||||||
|
public class WXCateAuthParam
|
||||||
|
{
|
||||||
|
public categoryAuthInfoParam categoryInfo { get; set; } = new categoryAuthInfoParam();
|
||||||
|
public List<object> brandIdList { get; set; } = new List<object>();
|
||||||
|
public long? leafCategoryId { get; set; } // 7483
|
||||||
|
public int? reuse { get; set; } = 0;
|
||||||
|
public string applyType { get; set; } = "normalApply";
|
||||||
|
}
|
||||||
|
public class categoryAuthInfoParam
|
||||||
|
{
|
||||||
|
public List<WXCateId> categories { get; set; } = new List<WXCateId>();
|
||||||
|
public string categoryDeposit { get; set; } // "1000.00";
|
||||||
|
public bool? isNewApplyCat { get; set; } = true;
|
||||||
|
public List<licenseGroup> licenseGroupList { get; set; } = new List<licenseGroup>();
|
||||||
|
public int? ruleVersion { get; set; }
|
||||||
|
public List<object> certificate { get; set; } = new List<object>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class licenseGroup
|
||||||
|
{
|
||||||
|
public string licenseGroupId { get; set; } = "1";
|
||||||
|
public licenseParam license { get; set; } = new licenseParam();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class licenseParam
|
||||||
|
{
|
||||||
|
public string licenseId { get; set; } = "4";
|
||||||
|
public List<string> cosIdList { get; set; } = new List<string>();
|
||||||
|
public List<KeyValueParam> licenseFieldList { get; set; } = new List<KeyValueParam>();
|
||||||
|
public bool? isReuse { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class KeyValueParam
|
||||||
|
{
|
||||||
|
public string key { get; set; } // "audit_license_registration_no" // "search_url"
|
||||||
|
public string value { get; set; } // "YB23509020049441" // ""
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WXCateId
|
||||||
|
{
|
||||||
|
public long? id { get; set; } // 10000215
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1951,6 +1951,8 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
|
|
||||||
// 检测是否有类目上传权限
|
// 检测是否有类目上传权限
|
||||||
var cateUpCheckRst = WXUpload.batchCheckCategoryRelation(shop, leafCatId);
|
var cateUpCheckRst = WXUpload.batchCheckCategoryRelation(shop, leafCatId);
|
||||||
|
//"{\"code\":0,\"list\":[{\"category_id\":\"1427\",\"result\":0,\"no_auth_reason_type\":0}]}"
|
||||||
|
//"{\"code\":0,\"list\":[{\"category_id\":\"7486\",\"result\":0,\"no_auth_reason_type\":0}]}"
|
||||||
if (!cateUpCheckRst.Contains("\"code\":0") && !cateUpCheckRst.Contains("\"success\":true"))
|
if (!cateUpCheckRst.Contains("\"code\":0") && !cateUpCheckRst.Contains("\"success\":true"))
|
||||||
{
|
{
|
||||||
var error = BaseRegex.GetStringJson(ref cateUpCheckRst, "msg");
|
var error = BaseRegex.GetStringJson(ref cateUpCheckRst, "msg");
|
||||||
@@ -1959,17 +1961,85 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目校验错误 " + error + "\"}";
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目校验错误 " + error + "\"}";
|
||||||
}
|
}
|
||||||
if (!cateUpCheckRst.Contains("\"result\":1"))
|
if (!cateUpCheckRst.Contains("\"result\":1"))
|
||||||
|
{
|
||||||
|
if (aiCateIdLst.FirstOrDefault() == 10000215)
|
||||||
|
{
|
||||||
|
//@"{""categoryInfo"":{""categories"":[{""id"":10000215},{""id"":10000222},{""id"":7483}],""categoryDeposit"":""1000.00"",""isNewApplyCat"":true,""licenseGroupList"":[{""licenseGroupId"":""1"",""license"":{""licenseId"":""4"",""cosIdList"":[""1771897594802-oM5657FQAaKYlf2uP300NBgx9HYY-0581""],""licenseFieldList"":[{""key"":""audit_license_registration_no"",""value"":""YB23509020049441""},{""key"":""search_url"",""value"":""""}],""isReuse"":true}}],""ruleVersion"":5234,""certificate"":[]},""brandIdList"":[],""leafCategoryId"":7483,""reuse"":0,""applyType"":""normalApply""}";
|
||||||
|
var getCatDataRst = WXUpload.getSingleCategoryData(shop, leafCatId, aiCateIdLst);
|
||||||
|
if (!getCatDataRst.Contains("\"code\":0") && !getCatDataRst.Contains("\"success\":true"))
|
||||||
|
{
|
||||||
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请失败 查询类目资质文件失败" + "\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
WXCateAuthParam wxCateAuthParam = new WXCateAuthParam();
|
||||||
|
wxCateAuthParam.leafCategoryId = leafCatId;
|
||||||
|
wxCateAuthParam.categoryInfo.categoryDeposit = bound.cat_bound.ToString("0.00");
|
||||||
|
wxCateAuthParam.categoryInfo.ruleVersion = BaseRegex.GetIntJson(ref getCatDataRst, "ruleVersion");
|
||||||
|
foreach (var cateId in aiCateIdLst)
|
||||||
|
{
|
||||||
|
wxCateAuthParam.categoryInfo.categories.Add(new WXCateId() { id = cateId });
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!JsonHelper.JObjectParse(getCatDataRst)["reuseApplyData"].IsJTokenNullOrEmpty())
|
||||||
|
{
|
||||||
|
var jlicenseGroupList = JsonHelper.JObjectParse(getCatDataRst)["reuseApplyData"]["catInfo"]["licenseGroupList"];
|
||||||
|
var licenseGroupListStr = JsonHelper.SerializeObject(jlicenseGroupList);
|
||||||
|
wxCateAuthParam.categoryInfo.licenseGroupList = JsonHelper.DeserializeJsonToList<licenseGroup>(licenseGroupListStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var licenseGroup = new licenseGroup();
|
||||||
|
wxCateAuthParam.categoryInfo.licenseGroupList.Add(licenseGroup);
|
||||||
|
licenseGroup.license.licenseId = "4";
|
||||||
|
var cosIdList = "[" + BaseRegex.GetMatchRegexString(ref getCatDataRst, "\"cosIdList\":\\[([\\s\\S]*?)\\]") + "]";
|
||||||
|
licenseGroup.license.cosIdList = JsonHelper.DeserializeJsonToList<string>(cosIdList);
|
||||||
|
var licenseFieldList = "[" + BaseRegex.GetMatchRegexString(ref getCatDataRst, "\"licenseFieldList\":\\[([\\s\\S]*?)\\]") + "]";
|
||||||
|
licenseGroup.license.licenseFieldList = JsonHelper.DeserializeJsonToList<KeyValueParam>(licenseFieldList);
|
||||||
|
}
|
||||||
|
var authCateRst = WXUpload.wxCateAuth(shop, aiCateIdLst, wxCateAuthParam);
|
||||||
|
if (!authCateRst.Contains("\"code\":0") && !authCateRst.Contains("\"success\":true"))
|
||||||
|
{
|
||||||
|
var error = BaseRegex.GetStringJson(ref authCateRst, "msg");
|
||||||
|
if (string.IsNullOrEmpty(error))
|
||||||
|
error = BaseRegex.GetStringJson(ref authCateRst, "errmsg");
|
||||||
|
if (string.IsNullOrEmpty(error))
|
||||||
|
error = authCateRst;
|
||||||
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请失败 " + error + "\"}";
|
||||||
|
}
|
||||||
|
Thread.Sleep(Randomx.GetId(5000, 7000));
|
||||||
|
cateUpCheckRst = WXUpload.batchCheckCategoryRelation(shop, leafCatId);
|
||||||
|
if (!cateUpCheckRst.Contains("\"code\":0") && !cateUpCheckRst.Contains("\"success\":true"))
|
||||||
|
{
|
||||||
|
var error = BaseRegex.GetStringJson(ref cateUpCheckRst, "msg");
|
||||||
|
if (string.IsNullOrEmpty(error))
|
||||||
|
error = cateUpCheckRst;
|
||||||
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请校验错误 " + error + "\"}";
|
||||||
|
}
|
||||||
|
if (!cateUpCheckRst.Contains("\"result\":1"))
|
||||||
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请审核中 请稍后再试\"}";
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请失败 复用资质文件失败,请重新提交资质文件" + "\"}";
|
||||||
|
}
|
||||||
|
//return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请失败 请手动申请资质类目" + "\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Thread.Sleep(Randomx.GetId(1000, 2000));
|
Thread.Sleep(Randomx.GetId(1000, 2000));
|
||||||
var cateAuthorRst = WXUpload.addFinderCategoryV2(shop, leafCatId);
|
var cateAuthorRst = WXUpload.addFinderCategoryV2(shop, leafCatId);
|
||||||
if (!cateAuthorRst.Contains("\"code\":0") && !cateAuthorRst.Contains("\"success\":true"))
|
if (!cateAuthorRst.Contains("\"code\":0") && !cateAuthorRst.Contains("\"success\":true"))
|
||||||
{
|
{
|
||||||
var error = BaseRegex.GetStringJson(ref cateAuthorRst, "msg");
|
var error = BaseRegex.GetStringJson(ref cateAuthorRst, "msg");
|
||||||
|
if (string.IsNullOrEmpty(error))
|
||||||
|
error = BaseRegex.GetStringJson(ref cateAuthorRst, "errmsg");
|
||||||
if (string.IsNullOrEmpty(error))
|
if (string.IsNullOrEmpty(error))
|
||||||
error = cateAuthorRst;
|
error = cateAuthorRst;
|
||||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请错误 " + error + "\"}";
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"类目申请错误 " + error + "\"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 短标题 // ai获取短标题 // 暂时注释
|
#region 短标题 // ai获取短标题 // 暂时注释
|
||||||
@@ -2408,8 +2478,11 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
var productAttr = upProdParam.product.info.category.LastOrDefault().catInfo.productAttr;
|
var productAttr = upProdParam.product.info.category.LastOrDefault().catInfo.productAttr;
|
||||||
foreach (var propInfo in prodInfo.property.goods_properties)
|
foreach (var propInfo in prodInfo.property.goods_properties)
|
||||||
{
|
{
|
||||||
|
if (propInfo.values.Count == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
var attr = productAttr.attr.FirstOrDefault(r => r.name == propInfo.name);
|
var attr = productAttr.attr.FirstOrDefault(r => r.name == propInfo.name);
|
||||||
if (propInfo.name == "生产日期")
|
if (propInfo.name == "生产日期" && propInfo.values.Count > 0)
|
||||||
{
|
{
|
||||||
propInfo.values.FirstOrDefault().value = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd");
|
propInfo.values.FirstOrDefault().value = DateTime.Now.Date.AddDays(-15).ToString("yyyy-MM-dd");
|
||||||
propInfo.values.FirstOrDefault().raw_value = propInfo.values.FirstOrDefault().value;
|
propInfo.values.FirstOrDefault().raw_value = propInfo.values.FirstOrDefault().value;
|
||||||
@@ -2466,7 +2539,11 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
attr = productAttr.attr.FirstOrDefault(r => r.name == "生产日期");
|
attr = productAttr.attr.FirstOrDefault(r => r.name == "生产日期");
|
||||||
}
|
}
|
||||||
else if (propInfo.name == "产品重量")
|
else if (propInfo.name == "产品重量")
|
||||||
|
{
|
||||||
attr = productAttr.attr.FirstOrDefault(r => r.name == "单件净含量");
|
attr = productAttr.attr.FirstOrDefault(r => r.name == "单件净含量");
|
||||||
|
if (attr == null)
|
||||||
|
attr = productAttr.attr.FirstOrDefault(r => r.name == "净含量");
|
||||||
|
}
|
||||||
else if (propInfo.name == "包装方式")
|
else if (propInfo.name == "包装方式")
|
||||||
attr = productAttr.attr.FirstOrDefault(r => r.name == "包装方式");
|
attr = productAttr.attr.FirstOrDefault(r => r.name == "包装方式");
|
||||||
//else if (propInfo.name == "配料表")
|
//else if (propInfo.name == "配料表")
|
||||||
@@ -2484,10 +2561,12 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
var attrValueLst = attr.value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
var attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault().value);
|
var attrValue = attrValueLst.FirstOrDefault(v => v == propInfo.values.FirstOrDefault()?.value);
|
||||||
if (propInfo.name == "保质期" )
|
if (propInfo.name == "保质期" )
|
||||||
{
|
{
|
||||||
attrValue = "30 天";
|
attrValue = "30 天";
|
||||||
|
if (propInfo.values.Count > 0)
|
||||||
|
{
|
||||||
if (propInfo.values.FirstOrDefault().value.Contains("年") || propInfo.values.FirstOrDefault().value.Contains("月")
|
if (propInfo.values.FirstOrDefault().value.Contains("年") || propInfo.values.FirstOrDefault().value.Contains("月")
|
||||||
|| propInfo.values.FirstOrDefault().value.Contains("日") || propInfo.values.FirstOrDefault().value.Contains("天")
|
|| propInfo.values.FirstOrDefault().value.Contains("日") || propInfo.values.FirstOrDefault().value.Contains("天")
|
||||||
|| propInfo.values.FirstOrDefault().value.Contains("见包装"))
|
|| propInfo.values.FirstOrDefault().value.Contains("见包装"))
|
||||||
@@ -2499,6 +2578,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"食品保质期小于30天,跳过上传\"}";
|
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"食品保质期小于30天,跳过上传\"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (propInfo.name == "产品重量" )
|
if (propInfo.name == "产品重量" )
|
||||||
{
|
{
|
||||||
@@ -2666,7 +2746,7 @@ namespace TemuKJD.WXForms.ProductForms
|
|||||||
attrValue = "见包装";
|
attrValue = "见包装";
|
||||||
if (attr.name == "单件净含量")
|
if (attr.name == "单件净含量")
|
||||||
{
|
{
|
||||||
//attrValue = "见包装";
|
attrValue = "见包装";
|
||||||
}
|
}
|
||||||
if (attr.name == "包装方式")
|
if (attr.name == "包装方式")
|
||||||
attrValue = "袋装";
|
attrValue = "袋装";
|
||||||
@@ -4345,6 +4425,34 @@ Content-Type: image/jpeg
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 申请资质类目前获取类目信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="shop"></param>
|
||||||
|
/// <param name="catId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string getSingleCategoryData(ShopLoginInfo shop, long catId, List<long> catIdLst)
|
||||||
|
{
|
||||||
|
var catIds = "[\"" + string.Join("\",\"", catIdLst) + "\"]";
|
||||||
|
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradecategory/cgi/getSingleCategoryData?token=&lang=zh_CN&categoryId=" + catId;
|
||||||
|
string referer = "https://store.weixin.qq.com/shop/brandAndCat/category/apply?defaultCategoryIds=" + GetHtml.UrlEncodeUtf8(catIds) + "&source=goods&type=apply";
|
||||||
|
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, referer);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string wxCateAuth(ShopLoginInfo shop, List<long> catIdLst, WXCateAuthParam wxCateAuthParam)
|
||||||
|
{
|
||||||
|
var catIds = "[\"" + string.Join("\",\"", catIdLst) + "\"]";
|
||||||
|
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradecategory/cgi/addFinderCategoryV2?token=&lang=zh_CN";
|
||||||
|
string referer = "https://store.weixin.qq.com/shop/brandAndCat/category/apply?defaultCategoryIds=" + GetHtml.UrlEncodeUtf8(catIds) + "&source=goods&type=apply";
|
||||||
|
string data = JsonHelper.SerializeObject(wxCateAuthParam);
|
||||||
|
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, data, referer);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static string genProductShortTitle(ShopLoginInfo shop, WXGetShortTitleParam getShortTitleParam)
|
public static string genProductShortTitle(ShopLoginInfo shop, WXGetShortTitleParam getShortTitleParam)
|
||||||
{
|
{
|
||||||
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/genProductShortTitle?token=&lang=zh_CN";
|
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/genProductShortTitle?token=&lang=zh_CN";
|
||||||
|
|||||||
Reference in new issue
Block a user