api调用加入代发相关逻辑
This commit is contained in:
1 parent
6b1b8507c7
commit
dacacb352c
7 files changed
+167
-38
No files matched your search
@@ -267,6 +267,7 @@
|
||||
<Compile Include="_29Tools\BLL\HttpResponseWXBLL.cs" />
|
||||
<Compile Include="_29Tools\BLL\HttpResponseYkdBLL.cs" />
|
||||
<Compile Include="_29Tools\BLL\ShopBLL.cs" />
|
||||
<Compile Include="_29Tools\BLL\WxApiBLL.cs" />
|
||||
<Compile Include="_29Tools\BLL\WxOrderSupplierBLL.cs" />
|
||||
<Compile Include="_29Tools\CefTools\LocalCEFBrowser.cs" />
|
||||
<Compile Include="_29Tools\CefTools\LocalCookieVisitor.cs" />
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.DBModel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Work._29Tools.BLL
|
||||
{
|
||||
public class WxApiBLL
|
||||
{
|
||||
private WXShopTokenInfo UpdateShopWxToken(ShopLoginInfo shop)
|
||||
{
|
||||
var url = BaseClass.Build29WxObjString("shop/e57_get_wx_shop_token");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&shop_id=" + shop.ShopId;
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
// 获取失败
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":0"))
|
||||
{
|
||||
return new WXShopTokenInfo() { shopId = shop.ShopId, accessToken = "", mdyTime = DateTime.Now };
|
||||
}
|
||||
else
|
||||
{
|
||||
var token = new WXShopTokenInfo()
|
||||
{
|
||||
shopId = shop.ShopId,
|
||||
accessToken = BaseRegex.GetStringJson(ref html, "accessToken"),
|
||||
mdyTime = DateTime.Now,
|
||||
};
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
public WXShopTokenInfo GetWxToken(ShopLoginInfo shop)
|
||||
{
|
||||
WXShopTokenInfo token = GlobalConfig.lstWXShopTokenInfo.FirstOrDefault(t => t.shopId == shop.ShopId);
|
||||
if (token == null)
|
||||
token = new WXShopTokenInfo();
|
||||
if (token.isExpire || string.IsNullOrEmpty(token.accessToken))
|
||||
{
|
||||
token = new WxApiBLL().UpdateShopWxToken(shop);
|
||||
|
||||
if (!string.IsNullOrEmpty(token.accessToken))
|
||||
{
|
||||
GlobalConfig.lstWXShopTokenInfo.RemoveAll(t => t.shopId == shop.ShopId);
|
||||
GlobalConfig.lstWXShopTokenInfo.Add(token);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("wx_shop_token_list", GlobalConfig.lstWXShopTokenInfo);
|
||||
}
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
public string WxApiDropshipSearch(ShopLoginInfo shop, string orderId, int status)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(UserLogin.GetSignaturex());
|
||||
sb.Append("&token=").Append(GetWxToken(shop).accessToken);
|
||||
sb.Append("&order_id=").Append(orderId);
|
||||
sb.Append("&status=").Append(status);
|
||||
|
||||
var url = BaseClass.Build29WxObjString("product/wx_api_dropship_search");
|
||||
var data = sb.ToString();
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"errcode\":0"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
public string WxApiDropshipAssign(ShopLoginInfo shop, string orderId, string spuId, string skuId, int cnt)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(UserLogin.GetSignaturex());
|
||||
sb.Append("&token=").Append(GetWxToken(shop).accessToken);
|
||||
sb.Append("&order_id=").Append(orderId);
|
||||
sb.Append("&dropship_product_list=").Append("[{\"spu_id\":\"" + spuId + "\",\"sku_id\":\"" + skuId + "\",\"product_cnt\":" + cnt + "}]");
|
||||
|
||||
var url = BaseClass.Build29WxObjString("product/wx_api_dropship_assign");
|
||||
var data = sb.ToString();
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"errcode\":0"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
return html;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user