1688上传类目转换等优化 充值用户服务充值和用户续费店铺功能

This commit is contained in:
wule committed 2026-05-27 22:01:04 +08:00
1 parent ecb291e3d7
commit aab73b978f
56 files changed
+4532 -1748

No files matched your search

@@ -29,6 +29,8 @@ using AllBase.Model.Result.WXResult;
using Newtonsoft.Json;
using NaiBa.Util;
using AllBase.Model.Config;
using CefSharp;
using AllBase.Extension;
namespace TemuKJD.WXForms.ProductForms
{
@@ -53,6 +55,8 @@ namespace TemuKJD.WXForms.ProductForms
"真丝", "蚕丝", "香云纱", "羊绒", "羊毛", "羊羔绒", "羊羔毛", "羽绒", "皮草"
};
string DefaultAdultBrandId = "";
// 微信带货助手cookie
List<Cookie> lstWxSaleAssistantCookie = new List<Cookie>();
public WXDBProdUploadForm()
{
@@ -61,6 +65,15 @@ namespace TemuKJD.WXForms.ProductForms
private void UserSelectDbProductForm_Load(object sender, EventArgs e)
{
if (!BaseClass.UserAuthority.Contains("佣金上货"))
this.ucTabControlMetro1.TabPages.Remove(佣金上货);
else
{
lstWxSaleAssistantCookie = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<Cookie>>("wx_sale_assistant_cookies");
if (lstWxSaleAssistantCookie == null)
lstWxSaleAssistantCookie = new List<Cookie>();
}
GlobalConfig.lstWxShopAuthInfo = NaiBa.Util.Helper.ConfigHelper.LoadConfig<NaiBa.Util.ConcurrentList<AuthInfo>>("wx_shop_auth_list");
if (GlobalConfig.lstWxShopAuthInfo == null)
GlobalConfig.lstWxShopAuthInfo = new ConcurrentList<AuthInfo>();
@@ -589,7 +602,7 @@ namespace TemuKJD.WXForms.ProductForms
{
if (shopEntity == null)
return;
if (shopEntity.is_shop_expire)
if (shopEntity.is_point_shop_expire)
return;
if (selectShopId == null)
selectShopId = new List<string>();
@@ -819,7 +832,7 @@ namespace TemuKJD.WXForms.ProductForms
if (GlobalConfig.GlobalSettings.IsWxUseSoftwareDefaultAddress == true && !IsWxNotUseSoftwareDefaultAddressOnce &&
lstTemuDBProductSelect.Any(p => p.product_get_type_text != "厂商直采" && p.product_get_type_text != "1688厂家"))
{
if (GlobalConfig.WXShopDefaultAddressList.Any(a => !shopIdLst.Contains(a.shop_id)))
if (shopIdLst.Any(a => !GlobalConfig.WXShopDefaultAddressList.Any(aa => aa.shop_id == a)))
WXShopDefaultAddressListForm.GetShopDefaultAddress();
var addressLst = GlobalConfig.WXShopDefaultAddressList.Where(s => shopIdLst.Contains(s.shop_id)).ToList();
foreach (var add in addressLst)
@@ -1118,7 +1131,8 @@ namespace TemuKJD.WXForms.ProductForms
}
result = UploadProduct(shop, kjdDbProdTmp, selectProd, row.Cells["colOpResult"], startTime);
if (result.Contains("今日提审次数已用尽,请明日再试") || result.Contains("如需上架请先缴纳足额保证金") || result.Contains("在架商品数已达到上限"))
if (result.Contains("今日提审次数已用尽,请明日再试") || result.Contains("如需上架请先缴纳足额保证金") || result.Contains("在架商品数已达到上限") ||
result.Contains("拥金上货失败:需要开通优选联盟"))
{
var shopRow = dgvShop.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colShopId"].Value.ParseToString() == shop.ShopId);
if (shopRow != null)
@@ -1363,6 +1377,85 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
#region 处理佣金上传
int commissionRate = 0;
int minCommissionRate = 0;
int maxCommissionRate = 0;
int commissionRateChange = 0;
int? fromCommissionRate = 0;
if (BaseClass.UserAuthority.Contains("佣金上货") && chkCommission.Checked)
{
if (dbProd.special_prod_type != "爆款数据" && dbProd.product_get_type_text != "微信小店")
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"拥金上货失败:仅爆款微信小店数据支持佣金上传!\"}";
var rst = WXUpload.GetAndUpdateWebStatus(shop);
if (!rst.Contains("\"isOpenLeague\":true"))
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"拥金上货失败:需要开通优选联盟!\"}";
}
var url = BaseClass.BuildObjString("product/wx_get_commission_rate");
var date = UserLogin.GetSignaturex();
date += "&spu_ids=" + dbProd.spu_id;
var prodCommissionRst = GetHtml.PostUtf8(url, date);
if (!prodCommissionRst.Contains("\"code\":200"))
{
var errMsg = BaseRegex.GetStringJsonByRegs(ref prodCommissionRst, prodCommissionRst, "msg");
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"拥金上货失败:" + errMsg + "\"}";
}
fromCommissionRate = BaseRegex.GetStringJson(ref prodCommissionRst, "commission_rate").ParseToNullableInt();
if (fromCommissionRate == null)
fromCommissionRate = -1;
if (prodCommissionRst.Contains("\"data\":[]"))
{
var assistantShop = new ShopLoginInfo();
assistantShop.Cookies = JsonHelper.SerializeObject(lstWxSaleAssistantCookie);
var result = WxGetAssistant.wxGetAssistant(assistantShop, dbProd.spu_id);
if (result.Contains("mcn magic invalid"))
{
Invoke(new Action(() =>
{
BaseMsgForm.ShowError("拥金上货失败:请先登录上货助手");
btnLoginAssistant_Click(null, null);
}));
assistantShop.Cookies = JsonHelper.SerializeObject(lstWxSaleAssistantCookie);
result = WxGetAssistant.wxGetAssistant(assistantShop, dbProd.spu_id);
if (result.Contains("mcn magic invalid"))
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"拥金上货失败:请先登录上货助手\"}";
}
fromCommissionRate = BaseRegex.GetStringJson(ref result, "commissionRate").ParseToNullableInt();
var prodName = BaseRegex.GetStringJson(ref result, "name");
if (fromCommissionRate == null)
fromCommissionRate = -1;
if (prodName.IsNullOrEmpty())
prodName = dbProd.product_name;
//if (fromCommissionRate != null && !string.IsNullOrEmpty(prodName))
{
url = BaseClass.BuildObjString("product/wx_add_mdy_commission_rate");
date = UserLogin.GetSignaturex();
date += "&spu_id=" + dbProd.spu_id;
date += "&commission_rate=" + fromCommissionRate;
date += "&product_name=" + prodName;
var addCommissionRateRst = GetHtml.PostUtf8(url, date);
}
}
Invoke(new Action(() =>
{
minCommissionRate = this.txtMinUpCommission.Text.Trim().ParseToInt() * 10000;
maxCommissionRate = this.txtMaxUpCommission.Text.Trim().ParseToInt() * 10000;
commissionRateChange = this.txtCommissionChangeValue.Text.Trim().ParseToInt() * 10000;
if (cmbCommissionAddOrReduce.Text != "增加")
commissionRateChange = -commissionRateChange;
commissionRate = fromCommissionRate.ParseToInt() + commissionRateChange;
}));
if (fromCommissionRate < minCommissionRate || fromCommissionRate > maxCommissionRate)
{
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"拥金上货失败:原商品佣金比例 " + fromCommissionRate * 0.0001 + "% 超过设置的佣金范围!\"}";
}
}
#endregion
#region 跳过已上传商品
if (chkSkipUploaded.Checked)
{
@@ -1438,6 +1531,13 @@ namespace TemuKJD.WXForms.ProductForms
if (!string.IsNullOrEmpty(convertRst))
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
}
if (dbProd.product_get_type_text == "1688外部数据")
{
string convertRst = "";
var pInfo = new PDDProdFormConverter()._1688OutToPddConvert(out convertRst, dbProd);
if (!string.IsNullOrEmpty(convertRst))
return "{\"success\":false,\"draftId\":0,\"status\":\"未上传\",\"errMsg\":\"商品查询错误 " + convertRst + "\"}";
}
#endregion
#region 微信小店app
@@ -2904,7 +3004,7 @@ namespace TemuKJD.WXForms.ProductForms
{
if (propInfo.name == "出版社名称")
attr = productAttr.attr.FirstOrDefault(r => r.name == "出版社名称");
else if (propInfo.name == "ISBN编号" && !prodInfo.property.goods_properties.Any(p => p.name == "ISBN版号/CN刊号"))
else if ((propInfo.name == "ISBN编号" || propInfo.name == "书号") && !prodInfo.property.goods_properties.Any(p => p.name == "ISBN版号/CN刊号"))
attr = productAttr.attr.FirstOrDefault(r => r.name == "ISBN版号/CN刊号");
else if (propInfo.name == "书名")
attr = productAttr.attr.FirstOrDefault(r => r.name == "书名");
@@ -3680,7 +3780,18 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
// 资质信息
#region 佣金信息,需要权限
if (BaseClass.UserAuthority.Contains("佣金上货") && chkCommission.Checked)
{
upProdParam.product.info.leagueItemInfo = new leagueItemInfoParam();
upProdParam.product.info.leagueItemInfo.itemSwitch = 1;
upProdParam.product.info.leagueItemInfo.itemRatio = commissionRate;
upProdParam.product.info.leagueItemInfo.headSupplierPublicItemSwitch = 1;
upProdParam.product.info.leagueItemInfo.headSupplierPublicItemServiceRatio = commissionRate;
}
#endregion
#region 资质信息
// 微信回采直接复制
if (BaseClass.UserAuthority.ParseToString().Contains("微信回采") && chkUseWXComplateProd.Checked && dbProd.has_wx_format == "1" && wxEditProdInfo != null)
{
@@ -3987,6 +4098,7 @@ namespace TemuKJD.WXForms.ProductForms
}
#endregion
}
#endregion
// 直接使用微信回采情趣商品品牌
if (BaseClass.UserAuthority.ParseToString().Contains("微信回采") && chkUseWXComplateProd.Checked &&
@@ -4059,6 +4171,18 @@ namespace TemuKJD.WXForms.ProductForms
#endregion
upProdParam.product.productKey.productId = BaseRegex.GetLongJson(ref uploadDraftRst, "productId").ParseToString();
var commissionRstStr = "";
if (chkUpDraft.Checked && BaseClass.UserAuthority.Contains("佣金上货") && chkCommission.Checked)
{
var rst = WXUpload.addLeagueItemForUpdatingProduct(shop, 1, commissionRate, 1, commissionRate, upProdParam.product.productKey.productId.ParseToLong());
if (!rst.Contains("\"code\":0"))
{
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "msg", "errMsg", "errorMsg", "err_msg", "error_msg");
commissionRstStr = "设置佣金比例失败 " + rst;
}
}
if (chkUpDraft.Checked)
{
selectProd.wxDraftProduct = upProdParam;
@@ -4068,7 +4192,7 @@ namespace TemuKJD.WXForms.ProductForms
upload_draft_product_lst.Add(selectProd);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_select_upload_draft_products", upload_draft_product_lst);
return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"草稿箱\",\"errMsg\":\"指定上传到草稿箱\"}";
return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"草稿箱\",\"errMsg\":\"指定上传到草稿箱" + commissionRstStr + "\"}";
}
// 提交商品上架
@@ -4088,6 +4212,16 @@ namespace TemuKJD.WXForms.ProductForms
}
if (upProdParam.product.productKey.productId.IsNullOrEmpty())
upProdParam.product.productKey.productId = BaseRegex.GetLongJson(ref uploadProdRst, "productId").ParseToString();
if (BaseClass.UserAuthority.Contains("佣金上货") && chkCommission.Checked)
{
var rst = WXUpload.addLeagueItemForUpdatingProduct(shop, 1, commissionRate, 1, commissionRate, upProdParam.product.productKey.productId.ParseToLong(), 1);
if (!rst.Contains("\"code\":0"))
{
var error = BaseRegex.GetStringJsonByRegs(ref rst, rst, "msg", "errMsg", "errorMsg", "err_msg", "error_msg");
commissionRstStr = "设置佣金比例失败 " + rst;
}
}
}
else
{
@@ -4259,7 +4393,7 @@ namespace TemuKJD.WXForms.ProductForms
}));
}
return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"已上传\",\"msg\":\"上传成功\"}";
return "{\"success\":true,\"draftId\":" + upProdParam.product.productKey.productId + ",\"status\":\"已上传\",\"msg\":\"上传成功" + commissionRstStr + "\"}";
}
@@ -5357,6 +5491,17 @@ namespace TemuKJD.WXForms.ProductForms
cmbJstInitSet.Text = "已设置";
}
}
private void btnLoginAssistant_Click(object sender, EventArgs e)
{
WXSaleAssistantForm assistantForm = new WXSaleAssistantForm();
assistantForm.OpenType = "login";
assistantForm.InitUrl = "https://store.weixin.qq.com/talent/home";
assistantForm.ShowDialog();
lstWxSaleAssistantCookie = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<Cookie>>("wx_sale_assistant_cookies");
if (lstWxSaleAssistantCookie == null)
lstWxSaleAssistantCookie = new List<Cookie>();
}
}
public class WXUpload
@@ -5535,6 +5680,7 @@ Content-Type: image/jpeg
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/uploadProductDraft?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/goods/entry";
JsonSerializerSettings jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
prodParam.type = 1;
var prodStr = JsonConvert.SerializeObject(prodParam, jsonSetting);
JObject jObj = new JObject();
jObj.Add("data", prodStr);
@@ -5715,6 +5861,31 @@ Content-Type: application/octet-stream
var result = WXHttpResponseBLL.WeiXinGetResponse(shop, url, referer);
return result;
}
/// <summary>
/// 店铺首页获取参数,包括是否开通优选联盟
/// </summary>
/// <param name="shop"></param>
/// <returns></returns>
public static string GetAndUpdateWebStatus(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradehome/home/getAndUpdateWebStatus?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/home";
string body = @"{""timeQuery"":{""startMs"":" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddDays(-1)) +
@",""endMs"":" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddSeconds(-1)) + @"}}";
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
return result;
}
public static string addLeagueItemForUpdatingProduct(ShopLoginInfo shop, int itemSwitch, int itemRatio, int headSupplierItemSwitch, int HeadSupplierItemRatio, long prodId, int updType = 2)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeproductupload/common/cgi/goods/addLeagueItemForUpdatingProduct?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/home";
string body = @"{""itemSwitch"":" + itemSwitch + @",""itemRatio"":" + itemRatio + @",""headSupplierPublicItemSwitch"":" + headSupplierItemSwitch +
@",""headSupplierPublicItemServiceRatio"":" + HeadSupplierItemRatio + @",""productId"":" + prodId + @",""scene"":2,""updType"":" + updType + @"}";
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
return result;
}
}
public class AddPriceRule