api调用加入代发相关逻辑
This commit is contained in:
1 parent
6b1b8507c7
commit
dacacb352c
7 files changed
+167
-38
No files matched your search
@@ -508,30 +508,49 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
return;
|
||||
}
|
||||
|
||||
// 检测是否加入代发
|
||||
if (orderItem.Shop?.LoginStatus == "登录成功" && orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder)
|
||||
{
|
||||
var is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||||
if (!is29SupplierRst.Contains("\"code\":0"))
|
||||
is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||||
if (is29SupplierRst.Contains("\"code\":0") && is29SupplierRst.Contains("\"supplierName\":\"29供货商\"")) // "supplierName":"29供货商"
|
||||
{
|
||||
orderItem.Shop.Is29Supplier = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopBLL.CheckShopLogin(orderItem.Shop);
|
||||
if (orderItem.Shop?.LoginStatus == "登录成功")
|
||||
{
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
BaseMsgWindow.ShowError("店铺后台未查询到该代发单,请确认店铺在线且商品加入代发");
|
||||
btnBuyOrder.Cursor = Cursors.Hand;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Api检测是否加入代发
|
||||
if (orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder)
|
||||
{
|
||||
var apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (apiSearchDropship.Contains("\"ds_order_id_list\":[]"))
|
||||
{
|
||||
var apiAddDropship = new WxApiBLL().WxApiDropshipAssign(orderItem.Shop, orderItem.order_id, orderItem.product_id, orderItem.sku_id, orderItem.sku_cnt.ParseToInt());
|
||||
}
|
||||
apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (apiSearchDropship.Contains("\"ds_order_id_list\":[]"))
|
||||
BaseMsgWindow.ShowError("店铺后台未查询到该代发单,请确商品已加入29供货商代发");
|
||||
}
|
||||
|
||||
// 模拟检测是否加入代发
|
||||
//if (orderItem.Shop?.LoginStatus == "登录成功" && orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder)
|
||||
//{
|
||||
// var is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||||
// if (!is29SupplierRst.Contains("\"code\":0"))
|
||||
// is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||||
// if (!is29SupplierRst.Contains("\"code\":0"))
|
||||
// {
|
||||
// ShopBLL.CheckShopLogin(orderItem.Shop);
|
||||
// if (orderItem.Shop?.LoginStatus != "登录成功")
|
||||
// {
|
||||
// Dispatcher.Invoke(new Action(() =>
|
||||
// {
|
||||
// BaseMsgWindow.ShowAnimateMessage("店铺掉线", "Error", 5);
|
||||
// btnBuyOrder.Cursor = Cursors.Hand;
|
||||
// }));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (!is29SupplierRst.Contains("\"supplierName\":\"29供货商\"")) // "supplierName":"29供货商"
|
||||
// {
|
||||
// Dispatcher.Invoke(new Action(() =>
|
||||
// {
|
||||
// BaseMsgWindow.ShowError("店铺后台未查询到该代发单,请确认店铺在线且商品加入代发");
|
||||
// btnBuyOrder.Cursor = Cursors.Hand;
|
||||
// }));
|
||||
// return;
|
||||
// }
|
||||
// orderItem.Shop.Is29Supplier = true;
|
||||
//}
|
||||
|
||||
// 掉线提示重登
|
||||
if (orderItem.Shop?.LoginStatus != "登录成功")
|
||||
|
||||
+12
-6
@@ -2,6 +2,8 @@
|
||||
using AllBase.DouYinModel.Param.ConfigManage;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Config;
|
||||
using AllBase.Model.DBModel;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Helper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,12 +16,16 @@ namespace _29WxOrderWpf
|
||||
{
|
||||
public class StartUp
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
GlobalConfig.BuyConfig = ConfigHelper.LoadConfig<BuyConfig>("buy_config_260708");
|
||||
if (GlobalConfig.BuyConfig == null)
|
||||
GlobalConfig.BuyConfig = new BuyConfig();
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
GlobalConfig.BuyConfig = ConfigHelper.LoadConfig<BuyConfig>("buy_config_260708");
|
||||
if (GlobalConfig.BuyConfig == null)
|
||||
GlobalConfig.BuyConfig = new BuyConfig();
|
||||
|
||||
GlobalConfig.lstWXShopTokenInfo = ConfigHelper.LoadConfig<ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
|
||||
if (GlobalConfig.lstWXShopTokenInfo == null)
|
||||
GlobalConfig.lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||||
}
|
||||
|
||||
public static void SaveBuyConfig()
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace AllBase
|
||||
/// 版本ID
|
||||
/// </summary>
|
||||
|
||||
public static int VersionCount = 223;
|
||||
public static int VersionCount = 225;
|
||||
|
||||
public static string ServerUrl { get; set; } = "http://1.13.195.131:9000";
|
||||
public static string DebugUrl { get; set; } = "http://localhost:9000";
|
||||
|
||||
@@ -27,10 +27,11 @@ namespace AllBase.Helper
|
||||
/// 店铺列表
|
||||
/// </summary>
|
||||
public static ObservableCollectionThreadSafe<ShopLoginInfo> ShopLoginList { get; set; } = new ObservableCollectionThreadSafe<ShopLoginInfo>();
|
||||
/// <summary>
|
||||
/// 拼多多买手列表
|
||||
/// </summary>
|
||||
public static ObservableCollectionThreadSafe<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
||||
public static ConcurrentList<WXShopTokenInfo> lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
||||
/// <summary>
|
||||
/// 拼多多买手列表
|
||||
/// </summary>
|
||||
public static ObservableCollectionThreadSafe<BuyerLoginInfo> PDDBuyerLoginList { get; set; } = new ObservableCollectionThreadSafe<BuyerLoginInfo>();
|
||||
/// <summary>
|
||||
/// 当前拼多多买手
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AllBase.Model.MvvmBaseClasses;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.MvvmBaseClasses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -91,9 +92,8 @@ namespace AllBase.Model.DBModel
|
||||
public bool is_point_shop_expire { get; set; }
|
||||
public int expire_time { get; set; }
|
||||
|
||||
|
||||
public string openid { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class ShopCompany
|
||||
{
|
||||
@@ -115,4 +115,15 @@ namespace AllBase.Model.DBModel
|
||||
/// </summary>
|
||||
public string openid { get; set; }
|
||||
}
|
||||
|
||||
public class WXShopTokenInfo
|
||||
{
|
||||
public string shopId { get; set; } // "1960967267443618234",
|
||||
public string shopName { get; set; } // "夜笙供应链",
|
||||
public int? type { get; set; } // 500,
|
||||
public int? markupRate { get; set; } // 10,
|
||||
public string accessToken { get; set; } // "100_cw6r7-hhGaLKG7ndv558eO_3z3-5PokAG8d0Y1vc3Rczd3FuIqkefdaqVj5CNtkCYtMbTYvhnwJ7-JkBVQVe9nE0KK5SBI8AlfA7E0_sTtqcwMqKAXoCj1X4h3sjZIMX84dboC-PfzlI0wh0ADHeAHDSVZ"
|
||||
public DateTime mdyTime { get; set; } = DateTime.MinValue;
|
||||
public bool isExpire { get { return mdyTime.AddMinutes(60) < DateTime.Now; } }
|
||||
}
|
||||
}
|
||||
@@ -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