You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ERP/TradeManageNew/API_OrderInfoServiceNew.cs

127 lines
5.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TradeModel;
using TradeData;
using NetLibrary.OnlineTrade;
using NetLibrary.Log;
namespace TradeManageNew
{
public class API_OrderInfoServiceNew
{
#region Walmart数据导入
public static string ImportWalmart(DateTime? StartDate, DateTime? StopDate, List<int> ListModel)
{
string error = "";
if (StartDate == null)
StartDate = DateTime.Today.AddDays(-5);
WalmartApi obj = new WalmartApi();
foreach (int ShopId in ListModel)
{
JC_Shop ShopModel = JC_ShopService.GetModel(ShopId);
WalmartApi.ShopId = ShopModel.ShopId;
WalmartApi.ACCESS_TOKEN = ShopModel.AccessToken;
WalmartApi.ClientID = ShopModel.Appkey;
WalmartApi.ClientSecret = ShopModel.DeveKey;
WalmartApi.GetTokenTime = ShopModel.AccessTokenUpdateTime;
List<OrderModel> ListOrderModel = obj.GetWalmartOrder(StartDate, StopDate, out error);
if (ListOrderModel == null) ListOrderModel = new List<OrderModel>();
if (string.IsNullOrEmpty(error) == false) return "导入订单失败:" + error;
error = "导入订单:" + ListOrderModel.Count.ToString() + "条;";
API_OrderInfoService.SaveOrderModel(ShopModel.CompanyId, ShopId, ShopModel.ShopName, 6, 0, ListOrderModel);
List<OrderModel> ListOrderModel2 = obj.GetWalmartOrderFBA(StartDate, StopDate, out error);//FBA订单
if (ListOrderModel2== null) ListOrderModel2 = new List<OrderModel>();
// if (string.IsNullOrEmpty(error) == false) return "导入订单失败:" + error;
// error = "导入订单:" + ListOrderModel.Count.ToString() + "条;";
API_OrderInfoService.SaveOrderModel(ShopModel.CompanyId, ShopId, ShopModel.ShopName, 6, 1, ListOrderModel2);
//确认
try
{
string error2 = "";
foreach (var md in ListOrderModel)
{
obj.GetWalmartOrderSure(md.OrderCode, out error2);
if (string.IsNullOrEmpty(error2) == false)
{
ErrorFollow.TraceWrite("沃尔玛订单确认", "单号:" + md.OrderCode, error2);
}
}
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("确认" + ex.TargetSite.Name, ex.StackTrace, ex.Message);
}
}
return error;
}
#endregion
public static string ImportAlibab(DateTime? StartDate, DateTime? StopDate, List<int> ListModel)
{
string error = "";
foreach (int ShopId in ListModel)
{
JC_Shop model = JC_ShopService.GetModel(ShopId);
if (model.Code != null && model.Code != "")
{
AlibabaApiQMNew obj = new AlibabaApiQMNew();
obj.ShopId = model.ShopId.Value;
obj.sessionKey = model.Code;
var olist = API_OrderInfoService.GetOrderCodeList(2000, model.ShopId.Value);
//obj.GetLoanOrder(StartDate, StopDate, out error);
try
{
List<OrderModel> ListOrderModel = obj.GetWaitGoods("WAIT_SELLER_SEND_GOODS", 1, StartDate, StopDate, true, olist, out error);
//List<OrderModel> ListOrderModel = obj.GetPayMoneyGoods(true, out error);
if (string.IsNullOrEmpty(error) == false)
{
ErrorFollow.TraceWrite("自动导入速卖通订单", "店铺名称:" + model.ShopName, "导入订单失败" + error);
continue;
}
string einfo = "";
if (ListOrderModel == null)
{
einfo = "采集到账订单0";
ErrorFollow.TraceWrite("自动导入速卖通订单", "店铺名称:" + model.ShopName, "未发货数量:0");
}
else
{
einfo = "采集到账订单:" + ListOrderModel.Count;
ErrorFollow.TraceWrite("自动导入速卖通订单", "店铺名称:" + model.ShopName, "未发货数量:" + ListOrderModel.Count);
API_OrderInfoService.SaveOrderModel(model.CompanyId, model.ShopId.Value, model.ShopName, 1, 0, ListOrderModel);
}
}
catch (Exception ex)
{
ErrorFollow.TraceWrite(ex.TargetSite.Name, ex.StackTrace, ex.Message);
continue;
}
}
}
return error;
}
}
}