优化拍单代发相关流程
This commit is contained in:
1 parent
abb2759bdf
commit
259b8027d3
3 files changed
+211
-150
No files matched your search
@@ -15,6 +15,8 @@ using AllBase.Model.Result;
|
||||
using CefSharp.DevTools.DOM;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.Formula.PTG;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -477,77 +479,23 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/supply/consignmentOrderList";
|
||||
shopLoginForm.IsGetSupplierPage = true;
|
||||
shopLoginForm.ShowDialog();
|
||||
|
||||
// 不是立即生效的,不用立即刷新
|
||||
//var is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierList(orderItem.Shop);
|
||||
//if (!is29SupplierRst.Contains("\"code\":0"))
|
||||
// is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierList(orderItem.Shop);
|
||||
//if (is29SupplierRst.Contains("\"code\":0") && is29SupplierRst.Contains("\"name\":\"29供货商\""))
|
||||
//{
|
||||
// orderItem.Shop.Is29Supplier = true;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// ShopBLL.CheckShopLogin(orderItem.Shop);
|
||||
// orderItem.Shop.Is29Supplier = false;
|
||||
//}
|
||||
//foreach (var order in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == orderItem.Shop.ErpShopId).ToList())
|
||||
//{
|
||||
// // 更新代发管理情况
|
||||
// foreach (var o in order.orderItems)
|
||||
// Dispatcher.Invoke(new Action(() => { o.UpdateOrderItemBuyButton(); }));
|
||||
//}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Api检测是否加入代发
|
||||
if (orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder)
|
||||
{
|
||||
string supplierId = "", supplierName="";
|
||||
try
|
||||
{
|
||||
var apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (!apiSearchDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失败!" + BaseRegex.GetStringJson(ref apiSearchDropship, "msg"));
|
||||
|
||||
var dsOrderId = JsonHelper.JObjectParse(apiSearchDropship)["ds_order_id_list"].FirstOrDefault().ParseToString();
|
||||
if (!string.IsNullOrEmpty(dsOrderId))
|
||||
{
|
||||
var apiSearchDropshipDetail = new WxApiBLL().WxApiDropshipSearchDetail(orderItem.Shop, dsOrderId);
|
||||
if (!apiSearchDropshipDetail.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失败!" + BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "msg"));
|
||||
|
||||
supplierId = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_appid");
|
||||
supplierName = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_name");
|
||||
if (!string.IsNullOrEmpty(supplierId) && !supplierId.Contains("wxfc630d60a1af6c6f") && !supplierName.Contains("29供货商"))
|
||||
{
|
||||
var apiCancelDropship = await new WxApiBLL().WxApiDropshipCancel(orderItem.Shop, orderItem.ItemOrder, dsOrderId);
|
||||
if (!apiCancelDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("取消其他代发失败!请确认商品未加入其他代发!" + BaseRegex.GetStringJsonByRegs(ref apiCancelDropship, apiCancelDropship, "errmsg"));
|
||||
dsOrderId = "";
|
||||
supplierId = "";
|
||||
supplierName = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!supplierId.Contains("wxfc630d60a1af6c6f") && !supplierName.Contains("29供货商"))
|
||||
{
|
||||
// 设置29供货商代发
|
||||
var apiAddDropship = new WxApiBLL().WxApiDropshipAssign(orderItem.Shop, orderItem.order_id, orderItem.product_id, orderItem.sku_id, orderItem.sku_cnt.ParseToInt());
|
||||
if (!apiAddDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
throw new Exception("设置代发失败!请确商品已加入29供货商代发!" + BaseRegex.GetStringJson(ref apiAddDropship, "msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
//if (orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder) // 异常拍单不改变订单供应商
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// await SetSendOrderSupplier(orderItem, "wxfc630d60a1af6c6f", "29供货商");
|
||||
// }
|
||||
// catch(Exception ex)
|
||||
// {
|
||||
// BaseMsgWindow.ShowError(ex.Message);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
// 掉线提示重登
|
||||
if (orderItem.Shop?.LoginStatus != "登录成功")
|
||||
@@ -605,10 +553,108 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
buyOrderForm.AbnormalTransitWarehouseOrderInfo = orderItem.ItemTransitOrder;
|
||||
buyOrderForm.ShowDialog();
|
||||
OrderListCtrl.IsAutoBuy = buyOrderForm.IsAutoBuy;
|
||||
|
||||
if (buyOrderForm.IsBuySuccess)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (orderItem.BuyGoodsBtnTxt == "云仓拍单" && !isAbnormalOrder) // 异常拍单不改变订单供应商
|
||||
{
|
||||
try
|
||||
{
|
||||
await SetSendOrderSupplier(orderItem, "wxfc630d60a1af6c6f", "29供货商");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="orderItem">要发货的订单物品</param>
|
||||
/// <param name="targetSupplierId">targetSupplierId 和 targetSupplierName 都为空表示取消代发</param>
|
||||
/// <param name="targetSupplierName">targetSupplierId 和 targetSupplierName 都为空表示取消代发</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public static async Task SetSendOrderSupplier(oms_wei_order_item_info orderItem, string targetSupplierId, string targetSupplierName)
|
||||
{
|
||||
string supplierId = "", supplierName = "";
|
||||
try
|
||||
{
|
||||
// 查询代发列表
|
||||
var apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (!apiSearchDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失败!" + BaseRegex.GetStringJsonByRegs(ref apiSearchDropship, apiSearchDropship, "msg", "errmsg"));
|
||||
|
||||
var dsOrderId = JsonHelper.JObjectParse(apiSearchDropship)["ds_order_id_list"].FirstOrDefault().ParseToString();
|
||||
|
||||
// 取消代发判断
|
||||
if (targetSupplierId.IsNullOrEmpty() && targetSupplierName.IsNullOrEmpty())
|
||||
{
|
||||
if (!string.IsNullOrEmpty(dsOrderId))
|
||||
{
|
||||
var apiCancelDropship = await new WxApiBLL().WxApiDropshipCancel(orderItem.Shop, orderItem.ItemOrder, dsOrderId);
|
||||
if (!apiCancelDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJsonByRegs(ref apiCancelDropship, apiCancelDropship, "msg", "errmsg");
|
||||
throw new Exception("取消代发失败!请手动取消代发!" + errMsg);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 更换或新增代发判断
|
||||
if (!string.IsNullOrEmpty(dsOrderId))
|
||||
{
|
||||
// 查询代发详情
|
||||
var apiSearchDropshipDetail = new WxApiBLL().WxApiDropshipSearchDetail(orderItem.Shop, dsOrderId);
|
||||
if (!apiSearchDropshipDetail.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失详情失败!" + BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "msg"));
|
||||
|
||||
supplierId = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_appid");
|
||||
supplierName = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_name");
|
||||
if (!string.IsNullOrEmpty(supplierId) && !supplierId.Contains(targetSupplierId) && !supplierName.Contains(targetSupplierName))
|
||||
{
|
||||
// 取消代发
|
||||
var apiCancelDropship = await new WxApiBLL().WxApiDropshipCancel(orderItem.Shop, orderItem.ItemOrder, dsOrderId);
|
||||
if (!apiCancelDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
var errMsg = BaseRegex.GetStringJsonByRegs(ref apiCancelDropship, apiCancelDropship, "msg", "errmsg");
|
||||
throw new Exception("取消其他代发失败!请确认商品加入的是 " + targetSupplierName + " 代发!" + errMsg);
|
||||
}
|
||||
dsOrderId = "";
|
||||
supplierId = "";
|
||||
supplierName = "";
|
||||
}
|
||||
}
|
||||
|
||||
// 设置或新增代发
|
||||
if (!supplierId.Contains(targetSupplierId) && !supplierName.Contains(targetSupplierName))
|
||||
{
|
||||
// 设置29供货商代发wxfc630d60a1af6c6f或其他代发
|
||||
var apiAddDropship = new WxApiBLL().WxApiDropshipAssign(orderItem.Shop, orderItem.order_id, orderItem.product_id, orderItem.sku_id, orderItem.sku_cnt.ParseToInt(), targetSupplierId);
|
||||
if (!apiAddDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
throw new Exception("设置代发失败!请确认商品已加入" + targetSupplierName + "代发!" + BaseRegex.GetStringJson(ref apiAddDropship, "msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message);
|
||||
//BaseMsgWindow.ShowError(ex.Message);
|
||||
//return;
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is oms_wei_order_item_info order_item)
|
||||
@@ -1283,84 +1329,46 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
if (CheckIsRefund(orderItem))
|
||||
return;
|
||||
|
||||
if (GlobalConfig.BuyConfig.IsSyncDirectBuyOrderWaybill == true)
|
||||
{
|
||||
// 设置同步物流单代发
|
||||
//var rst = new WxApiBLL().GetShopSupplier(orderItem.Shop);
|
||||
//if (!rst.Contains("wx7809625286c28f2f") && !rst.Contains("百川日用"))
|
||||
//{
|
||||
// rst = new WxApiBLL().SetShopSupplier(orderItem.Shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
// if (!rst.Contains("\"errcode\":0"))
|
||||
// {
|
||||
// BaseMsgWindow.ShowAnimateMessage("绑定同步单发货失败", "Error", 5);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
string supplierId = "", supplierName = "";
|
||||
try
|
||||
{
|
||||
// 查询直拍单是否绑定了同步单代发(放到同步单发货前处理)
|
||||
var apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (!apiSearchDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失败!" + BaseRegex.GetStringJson(ref apiSearchDropship, "msg"));
|
||||
|
||||
var dsOrderId = JsonHelper.JObjectParse(apiSearchDropship)["ds_order_id_list"].FirstOrDefault().ParseToString();
|
||||
if (!string.IsNullOrEmpty(dsOrderId))
|
||||
{
|
||||
var apiSearchDropshipDetail = new WxApiBLL().WxApiDropshipSearchDetail(orderItem.Shop, dsOrderId);
|
||||
if (!apiSearchDropshipDetail.Contains("\"errcode\":0"))
|
||||
throw new Exception("查询代发失详情败!" + BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "msg"));
|
||||
|
||||
supplierId = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_appid");
|
||||
supplierName = BaseRegex.GetStringJson(ref apiSearchDropshipDetail, "supplier_name");
|
||||
if (!string.IsNullOrEmpty(supplierId) && !supplierId.Contains("wx7809625286c28f2f") && !supplierName.Contains("百川日用"))
|
||||
{
|
||||
var apiCancelDropship = await new WxApiBLL().WxApiDropshipCancel(orderItem.Shop, orderItem.ItemOrder, dsOrderId);
|
||||
if (!apiCancelDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("取消其他代发失败!请确认商品未加入其他代发!" + BaseRegex.GetStringJsonByRegs(ref apiCancelDropship, apiCancelDropship, "errmsg"));
|
||||
dsOrderId = "";
|
||||
supplierId = "";
|
||||
supplierName = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!supplierId.Contains("wx7809625286c28f2f") && !supplierName.Contains("百川日用"))
|
||||
{
|
||||
// 设置同步单供货商代发
|
||||
var apiAddDropship = new WxApiBLL().WxApiDropshipAssign(orderItem.Shop, orderItem.order_id, orderItem.product_id, orderItem.sku_id, orderItem.sku_cnt.ParseToInt(), "wx7809625286c28f2f");
|
||||
if (!apiAddDropship.Contains("\"errcode\":0"))
|
||||
throw new Exception("设置同步单代发失败!请确商品已加入同步单代发!" + BaseRegex.GetStringJson(ref apiAddDropship, "msg"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查询订单是否在代发货中,如果代发需要取消代发
|
||||
var apiSearchDropship = new WxApiBLL().WxApiDropshipSearch(orderItem.Shop, orderItem.order_id, 100);
|
||||
if (!apiSearchDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
BaseMsgWindow.ShowError("代发查询失败," + BaseRegex.GetStringJsonByRegs(ref apiSearchDropship, apiSearchDropship, "errmsg"));
|
||||
return;
|
||||
}
|
||||
if (apiSearchDropship.Contains("ds_order_id_list") && !apiSearchDropship.Contains("\"ds_order_id_list\":[]"))
|
||||
{
|
||||
var dsOrderId = JsonHelper.JObjectParse(apiSearchDropship)["ds_order_id_list"].FirstOrDefault().ParseToString();
|
||||
var apiCancelDropship = await new WxApiBLL().WxApiDropshipCancel(orderItem.Shop, orderItem.ItemOrder, dsOrderId);
|
||||
|
||||
if (!apiCancelDropship.Contains("\"errcode\":0"))
|
||||
{
|
||||
BaseMsgWindow.ShowError("取消代发失败!请确认商品未加入代发!" + BaseRegex.GetStringJsonByRegs(ref apiSearchDropship, apiSearchDropship, "errmsg"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Api检测代发状态
|
||||
//if (GlobalConfig.BuyConfig.IsSyncDirectBuyOrderWaybill == true)
|
||||
//{
|
||||
// // 设置同步物流单代发
|
||||
// //var rst = new WxApiBLL().GetShopSupplier(orderItem.Shop);
|
||||
// //if (!rst.Contains("wx7809625286c28f2f") && !rst.Contains("百川日用"))
|
||||
// //{
|
||||
// // rst = new WxApiBLL().SetShopSupplier(orderItem.Shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
// // if (!rst.Contains("\"errcode\":0"))
|
||||
// // {
|
||||
// // BaseMsgWindow.ShowAnimateMessage("绑定同步单发货失败", "Error", 5);
|
||||
// // return;
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// try
|
||||
// {
|
||||
// // 查询直拍单是否绑定了同步单代发(放到同步单发货前处理)
|
||||
// await SetSendOrderSupplier(orderItem, "wx7809625286c28f2f", "百川日用");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// BaseMsgWindow.ShowError(ex.Message);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// // 查询订单是否在代发货中,如果代发需要取消代发
|
||||
// try
|
||||
// {
|
||||
// // 查询直拍单是否绑定了同步单代发(放到同步单发货前处理)
|
||||
// await SetSendOrderSupplier(orderItem, "", "");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// BaseMsgWindow.ShowError(ex.Message);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
// 检测买手号是否掉线
|
||||
if (GlobalConfig.CurrentPddBuyer.status == "在线")
|
||||
@@ -1379,7 +1387,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
|
||||
|
||||
// 打开拍单窗口
|
||||
Dispatcher.Invoke(new Action(() =>
|
||||
Dispatcher.Invoke(new Action(async () =>
|
||||
{
|
||||
btnBuyOrder.Cursor = Cursors.Hand;
|
||||
|
||||
@@ -1410,6 +1418,49 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
buyOrderForm.pnlMap.Visible = false;
|
||||
}
|
||||
buyOrderForm.ShowDialog();
|
||||
|
||||
if (buyOrderForm.IsBuySuccess)
|
||||
{
|
||||
if (GlobalConfig.BuyConfig.IsSyncDirectBuyOrderWaybill == true)
|
||||
{
|
||||
// 设置同步物流单代发
|
||||
//var rst = new WxApiBLL().GetShopSupplier(orderItem.Shop);
|
||||
//if (!rst.Contains("wx7809625286c28f2f") && !rst.Contains("百川日用"))
|
||||
//{
|
||||
// rst = new WxApiBLL().SetShopSupplier(orderItem.Shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
// if (!rst.Contains("\"errcode\":0"))
|
||||
// {
|
||||
// BaseMsgWindow.ShowAnimateMessage("绑定同步单发货失败", "Error", 5);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
try
|
||||
{
|
||||
// 查询直拍单是否绑定了同步单代发(放到同步单发货前处理)
|
||||
await SetSendOrderSupplier(orderItem, "wx7809625286c28f2f", "百川日用");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查询订单是否在代发货中,如果代发需要取消代发
|
||||
try
|
||||
{
|
||||
// 查询直拍单是否绑定了同步单代发(放到同步单发货前处理)
|
||||
await SetSendOrderSupplier(orderItem, "", "");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError(ex.Message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -362,14 +362,22 @@ namespace _29WxOrderWpf
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
var rst = new WxApiBLL().GetShopSupplier(shop);
|
||||
if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
|
||||
continue;
|
||||
|
||||
rst = new WxApiBLL().SetShopSupplier(shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
if (!rst.Contains("\"errcode\":0"))
|
||||
try
|
||||
{
|
||||
//return;
|
||||
var jArr = JsonHelper.JObjectParse(rst)["list"] as JArray;
|
||||
// appid "wx7809625286c28f2f" name "百川日用";
|
||||
if (jArr.Any(aa => aa["appid"].ParseToString() == "wx7809625286c28f2f" && aa["status"].ParseToInt() == 1))
|
||||
//if (rst.Contains("wx7809625286c28f2f") || rst.Contains("百川日用"))
|
||||
continue;
|
||||
|
||||
rst = new WxApiBLL().SetShopSupplier(shop, "wx7809625286c28f2f", "4431685489938137094");
|
||||
if (!rst.Contains("\"errcode\":0"))
|
||||
{
|
||||
//return;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace TemuKJD.ToolForms
|
||||
|
||||
public bool IsClose { get; set; } = false;
|
||||
public bool IsAutoBuy { get; set; } = false;
|
||||
public bool IsBuySuccess { get; set; } = false;
|
||||
public bool IsFormLoad { get; set; } = false;
|
||||
public bool ShowBuyMask { get; set; } = false;
|
||||
public string BuyErrMsg { get; set; } = "";
|
||||
@@ -1569,6 +1570,7 @@ namespace TemuKJD.ToolForms
|
||||
#endregion
|
||||
}
|
||||
this.IsClose = true;
|
||||
this.IsBuySuccess = true;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user