Browse Source

Merge branch 'master' of http://code.qiyue666.com/pengcong001/bbwy

pjzs_starttask_update
506583276@qq.com 2 years ago
parent
commit
357ee8b8a8
  1. 23
      BBWY.Client/APIServices/PurchaseOrderService.cs
  2. 48
      BBWY.Client/APIServices/PurchaseProductAPIService.cs
  3. 41
      BBWY.Client/Converters/InputNumberConverter.cs
  4. 2
      BBWY.Client/GlobalContext.cs
  5. 17
      BBWY.Client/Models/PurchaseOrder/CargoParam.cs
  6. 44
      BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
  7. 5
      BBWY.Server.API/Startup.cs
  8. 3
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  9. 47
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  10. 28
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  11. 49
      BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs
  12. 17
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  13. 2
      BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs

23
BBWY.Client/APIServices/PurchaseOrderService.cs

@ -57,20 +57,13 @@ namespace BBWY.Client.APIServices
/// <param name="consignee"></param> /// <param name="consignee"></param>
/// <param name="purchaseSchemeProductSkuList"></param> /// <param name="purchaseSchemeProductSkuList"></param>
/// <returns></returns> /// <returns></returns>
public ApiResponse<PreviewOrderResponse> PreviewPurchaseOrder(Consignee consignee, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkuList, Platform purchasePlatform, PurchaseAccount purchaseAccount, PurchaseOrderMode purchaseOrderMode) public ApiResponse<PreviewOrderResponse> PreviewPurchaseOrder(Consignee consignee, List<CargoParam> cargoParamList, Platform purchasePlatform, PurchaseAccount purchaseAccount, PurchaseOrderMode purchaseOrderMode)
{ {
return SendRequest<PreviewOrderResponse>(globalContext.BBYWApiHost, "api/purchaseOrder/PreviewPurchaseOrder", new return SendRequest<PreviewOrderResponse>(globalContext.BBYWApiHost, "api/purchaseOrder/PreviewPurchaseOrder", new
{ {
purchaseOrderMode, purchaseOrderMode,
consignee, consignee,
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new CargoParamList = cargoParamList,
{
ProductId = sku.PurchaseProductId,
SkuId = sku.PurchaseSkuId,
SpecId = sku.PurchaseSkuSpecId,
Quantity = sku.ItemTotal,
BelongSkuId = sku.SkuId
}),
Platform = purchasePlatform, Platform = purchasePlatform,
AppKey = purchaseAccount.AppKey, AppKey = purchaseAccount.AppKey,
AppSecret = purchaseAccount.AppSecret, AppSecret = purchaseAccount.AppSecret,
@ -99,7 +92,7 @@ namespace BBWY.Client.APIServices
/// <param name="extensions"></param> /// <param name="extensions"></param>
/// <returns></returns> /// <returns></returns>
public ApiResponse<object> FastCreateOrder(Consignee consignee, public ApiResponse<object> FastCreateOrder(Consignee consignee,
IList<PurchaseSchemeProductSku> purchaseSchemeProductSkuList, List<CargoParam> cargoParamList,
Platform purchasePlatform, Platform purchasePlatform,
PurchaseAccount purchaseAccount, PurchaseAccount purchaseAccount,
PurchaseOrderMode purchaseOrderMode, PurchaseOrderMode purchaseOrderMode,
@ -118,15 +111,7 @@ namespace BBWY.Client.APIServices
{ {
purchaseOrderMode, purchaseOrderMode,
consignee, consignee,
CargoParamList = purchaseSchemeProductSkuList.Select(sku => new CargoParamList = cargoParamList,
{
ProductId = sku.PurchaseProductId,
SkuId = sku.PurchaseSkuId,
SpecId = sku.PurchaseSkuSpecId,
Quantity = sku.ItemTotal,
BelongSkuId = sku.SkuId,
SchemeId = sku.SkuPurchaseSchemeId
}),
Platform = purchasePlatform, Platform = purchasePlatform,
purchaseAccount.AppKey, purchaseAccount.AppKey,
purchaseAccount.AppSecret, purchaseAccount.AppSecret,

48
BBWY.Client/APIServices/PurchaseProductAPIService.cs

@ -25,6 +25,9 @@ namespace BBWY.Client.APIServices
private string qtAppId = "BBWY2023022001"; private string qtAppId = "BBWY2023022001";
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe"; private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe";
private List<string> locationIdList;
private List<string> priceIdList;
private TimeSpan purchaseProductCacheTimeSpan; private TimeSpan purchaseProductCacheTimeSpan;
//private TimeSpan _1688SessionIdTimeSpan; //private TimeSpan _1688SessionIdTimeSpan;
@ -48,6 +51,17 @@ namespace BBWY.Client.APIServices
}; };
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); purchaseProductCacheTimeSpan = TimeSpan.FromDays(1);
this.quanTanProductClient = quanTanProductClient; this.quanTanProductClient = quanTanProductClient;
locationIdList = new List<string>()
{
"300252630336272",
"1081181309101",
"16347413030323"
};
priceIdList = new List<string>() {
"300252630336263",
"1081181309582",
"16347413030316"
};
} }
public (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode) public (Purchaser purchaser, IList<PurchaseSchemeProductSku> purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode)
@ -189,7 +203,7 @@ namespace BBWY.Client.APIServices
if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK) if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK)
return null; return null;
var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA=)(.*)(\r*\n*\s*</script>)"); var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA\s?=)(.*)(\r*\n*\s*</script>)");
if (!match.Success) if (!match.Success)
return null; return null;
@ -200,11 +214,18 @@ namespace BBWY.Client.APIServices
var purchaser = new Purchaser() var purchaser = new Purchaser()
{ {
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(),
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(), Name = jobject["globalData"]["tempModel"]["companyName"].ToString()
Location = jobject["data"]["1081181309101"] != null ?
jobject["data"]["1081181309101"]["data"]["location"].ToString() :
jobject["data"]["16347413030323"]["data"]["location"].ToString()
}; };
foreach (var lid in locationIdList)
{
if (jobject["data"][lid] != null)
{
purchaser.Location = jobject["data"][lid]["data"]["location"].ToString();
break;
}
}
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 || var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 ||
j.Value<int>("fid") == 1627207 || j.Value<int>("fid") == 1627207 ||
@ -217,9 +238,18 @@ namespace BBWY.Client.APIServices
imageUrl = j.Value<string>("imageUrl") imageUrl = j.Value<string>("imageUrl")
}).ToList(); }).ToList();
var firstPrice = jobject["data"]["1081181309582"] != null ? //var firstPrice = jobject["data"]["1081181309582"] != null ?
jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") : // jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") :
jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); // jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
var firstPrice = 0M;
foreach (var pid in priceIdList)
{
if (jobject["data"][pid] != null)
{
firstPrice = jobject["data"][pid]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
break;
}
}
var purchaseSchemeProductSkus = new List<PurchaseSchemeProductSku>(); var purchaseSchemeProductSkus = new List<PurchaseSchemeProductSku>();
@ -238,7 +268,7 @@ namespace BBWY.Client.APIServices
SkuId = skuId, SkuId = skuId,
PurchaseProductId = purchaseProductId, PurchaseProductId = purchaseProductId,
Price = skuPrice == 0M ? firstPrice : skuPrice, Price = skuPrice == 0M ? firstPrice : skuPrice,
Title = name, Title = matchName,
PurchaseSkuId = value.Value<string>("skuId"), PurchaseSkuId = value.Value<string>("skuId"),
PurchaseSkuSpecId = value.Value<string>("specId"), PurchaseSkuSpecId = value.Value<string>("specId"),
Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png" Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png"

41
BBWY.Client/Converters/InputNumberConverter.cs

@ -1,4 +1,5 @@
using System; using MathNet.Numerics;
using System;
using System.Globalization; using System.Globalization;
using System.Windows; using System.Windows;
using System.Windows.Data; using System.Windows.Data;
@ -16,14 +17,44 @@ namespace BBWY.Client.Converters
{ {
string strValue = value as string; string strValue = value as string;
if (string.IsNullOrEmpty(strValue)) if (string.IsNullOrEmpty(strValue))
{
return null; return null;
}
decimal result; decimal result;
var dotIndex = strValue.IndexOf('.'); if (strValue.IndexOf('.') == strValue.Length - 1 || (strValue.IndexOf('0') == strValue.Length - 1 && strValue.IndexOf('.') != -1) || !decimal.TryParse(strValue, out result))
if (dotIndex == strValue.Length - 1 || {
(dotIndex != -1 && strValue.EndsWith("0")) ||
!decimal.TryParse(strValue, out result))
return DependencyProperty.UnsetValue; return DependencyProperty.UnsetValue;
}
return result; return result;
//if (string.IsNullOrEmpty(strValue))
// return DependencyProperty.UnsetValue;
//if (strValue.EndsWith("."))
// return DependencyProperty.UnsetValue;
//decimal result = 0M;
//var dotIndex = strValue.IndexOf('.');
//if (dotIndex == -1)
// decimal.TryParse(strValue, out result);
//else
//{
// //var intValueStr = strValue.Substring(0, dotIndex);
// var decimalValueStr = strValue.Substring(dotIndex + 1);
// var n = 1M;
// if (decimalValueStr.Length == 1)
// n = 1.0M;
// if (decimalValueStr.Length == 2)
// n = 1.00M;
// if (decimalValueStr.Length == 3)
// n = 1.000M;
// if (decimalValueStr.Length == 4)
// n = 1.0000M;
// if (decimal.TryParse(strValue, out result))
// result = decimal.Round(result * n, decimalValueStr.Length);
// else
// return DependencyProperty.UnsetValue;
//}
//return result;
} }
} }
} }

2
BBWY.Client/GlobalContext.cs

@ -13,7 +13,7 @@ namespace BBWY.Client
{ {
ShopServiceGroupList = new List<string>(); ShopServiceGroupList = new List<string>();
ShopServiceGroupLowerList = new List<string>(); ShopServiceGroupLowerList = new List<string>();
ClientVersion = "10212"; ClientVersion = "10217";
} }

17
BBWY.Client/Models/PurchaseOrder/CargoParam.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace BBWY.Client.Models
{
public class CargoParam
{
public string ProductId { get; set; }
public string SkuId { get; set; }
public string SpecId { get; set; }
public int Quantity { get; set; }
public string BelongSkuId { get; set; }
public long SchemeId { get; set; }
}
}

44
BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs

@ -11,6 +11,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Newtonsoft.Json;
namespace BBWY.Client.ViewModels namespace BBWY.Client.ViewModels
{ {
@ -181,6 +182,8 @@ namespace BBWY.Client.ViewModels
App.Current.Dispatcher.Invoke(() => App.Current.Dispatcher.Invoke(() =>
{ {
foreach (var purchaseSchemeProductSku in data.Value.purchaseSchemeProductSkus) foreach (var purchaseSchemeProductSku in data.Value.purchaseSchemeProductSkus)
{
if (orderSku != null && purchaseSchemeProductSku.SkuId == orderSku.Id)
{ {
purchaseSchemeProductSku.SkuPurchaseSchemeId = purchaseSchemeProduct.SkuPurchaseSchemeId; purchaseSchemeProductSku.SkuPurchaseSchemeId = purchaseSchemeProduct.SkuPurchaseSchemeId;
if (purchaseSchemeProduct.SelectedSkuIdList.Any(s => s == purchaseSchemeProductSku.PurchaseSkuId)) if (purchaseSchemeProduct.SelectedSkuIdList.Any(s => s == purchaseSchemeProductSku.PurchaseSkuId))
@ -190,6 +193,7 @@ namespace BBWY.Client.ViewModels
purchaseSchemeProductSku.OnItemTotalChanged = OnItemTotalChanged; purchaseSchemeProductSku.OnItemTotalChanged = OnItemTotalChanged;
} }
} }
}
}); });
} }
@ -224,6 +228,33 @@ namespace BBWY.Client.ViewModels
return; return;
} }
#region 由于未知原因,会存在不属于当前订单的配件sku,预览时清理一次
for (var i = 0; i < PurchaseSchemeProductSkuList.Count(); i++)
{
var pss = PurchaseSchemeProductSkuList[i];
if (!order.ItemList.Any(osku => osku.Id == pss.SkuId))
{
//这个采购配件不属于这笔订单
PurchaseSchemeProductSkuList.RemoveAt(i);
i--;
}
}
if (PurchaseSchemeProductSkuList.Count() == 0)
{
MessageBox.Show("采购配件数量为0");
return;
}
#endregion
var cargoParamList = PurchaseSchemeProductSkuList.Select(sku => new CargoParam
{
ProductId = sku.PurchaseProductId,
SkuId = sku.PurchaseSkuId,
SpecId = sku.PurchaseSkuSpecId,
Quantity = sku.ItemTotal,
BelongSkuId = sku.SkuId
}).ToList();
IsLoading = true; IsLoading = true;
Task.Factory.StartNew(() => purchaseOrderService.PreviewPurchaseOrder(new Consignee() Task.Factory.StartNew(() => purchaseOrderService.PreviewPurchaseOrder(new Consignee()
{ {
@ -235,7 +266,7 @@ namespace BBWY.Client.ViewModels
Province = Province, Province = Province,
TelePhone = Mobile, TelePhone = Mobile,
Town = Town Town = Town
}, PurchaseSchemeProductSkuList, purchaseAccount.PurchasePlatformId, purchaseAccount, PurchaseOrderMode)) }, cargoParamList, purchaseAccount.PurchasePlatformId, purchaseAccount, PurchaseOrderMode))
.ContinueWith(t => .ContinueWith(t =>
{ {
IsLoading = false; IsLoading = false;
@ -275,6 +306,15 @@ namespace BBWY.Client.ViewModels
MessageBox.Show("收货人信息不全", "下单"); MessageBox.Show("收货人信息不全", "下单");
return; return;
} }
var cargoParamList = PurchaseSchemeProductSkuList.Select(sku => new CargoParam
{
ProductId = sku.PurchaseProductId,
SkuId = sku.PurchaseSkuId,
SpecId = sku.PurchaseSkuSpecId,
Quantity = sku.ItemTotal,
BelongSkuId = sku.SkuId,
SchemeId = sku.SkuPurchaseSchemeId
}).ToList();
IsLoading = true; IsLoading = true;
Task.Factory.StartNew(() => purchaseOrderService.FastCreateOrder(new Consignee() Task.Factory.StartNew(() => purchaseOrderService.FastCreateOrder(new Consignee()
@ -287,7 +327,7 @@ namespace BBWY.Client.ViewModels
Province = Province, Province = Province,
TelePhone = Mobile, TelePhone = Mobile,
Town = Town Town = Town
}, PurchaseSchemeProductSkuList, }, cargoParamList,
purchaseAccount.PurchasePlatformId, purchaseAccount.PurchasePlatformId,
purchaseAccount, purchaseAccount,
PurchaseOrderMode, PurchaseOrderMode,

5
BBWY.Server.API/Startup.cs

@ -19,6 +19,7 @@ using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using Yitter.IdGenerator; using Yitter.IdGenerator;
@ -65,6 +66,10 @@ namespace BBWY.Server.API
services.AddControllers(); services.AddControllers();
services.AddHttpContextAccessor(); services.AddHttpContextAccessor();
services.AddHttpClient(); services.AddHttpClient();
services.AddHttpClient("gzip").ConfigurePrimaryHttpMessageHandler(handler => new HttpClientHandler()
{
AutomaticDecompression = System.Net.DecompressionMethods.GZip
});
services.AddCors(options => services.AddCors(options =>
{ {
options.AddPolicy("cors", p => options.AddPolicy("cors", p =>

3
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -160,6 +160,9 @@ namespace BBWY.Server.Business
if (string.IsNullOrEmpty(request.FullTitle)) if (string.IsNullOrEmpty(request.FullTitle))
throw new BusinessException("缺少完整标题"); throw new BusinessException("缺少完整标题");
if (string.IsNullOrEmpty(request.SimpleTitle))
throw new BusinessException("缺少精简标题");
if (string.IsNullOrEmpty(request.ActivityName)) if (string.IsNullOrEmpty(request.ActivityName))
throw new BusinessException("缺少任务名称"); throw new BusinessException("缺少任务名称");

47
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -1053,7 +1053,52 @@ namespace BBWY.Server.Business
attrId = tempDataJToken.Value<string>("attrId"); attrId = tempDataJToken.Value<string>("attrId");
var tempDataValuesJToken = JObject.Parse(tempDataJToken["valueRules"].ToString()); var tempDataValuesJToken = JObject.Parse(tempDataJToken["valueRules"].ToString());
var tempDataValues_Level1_JToken = tempDataValuesJToken["items"][0]; var tempDataValues_Level1_JToken = tempDataValuesJToken["items"][0];
if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "model") if (tempDataValuesJToken["items"].Count() == 3 &&
tempDataValuesJToken["items"][0]["properties"]["id"]["type"].ToString() == "model" &&
tempDataValuesJToken["items"][1]["properties"]["id"]["type"].ToString() == "number" &&
tempDataValuesJToken["items"][1]["properties"]["value"]["type"].ToString() == "number" &&
tempDataValuesJToken["items"][2]["properties"]["id"]["type"].ToString() == "number" &&
tempDataValuesJToken["items"][2]["properties"]["value"]["type"].ToString() == "string")
{
var f_id = int.Parse(tempDataValuesJToken["items"][0]["properties"]["id"]["enum"][0].ToString());
var f_tempJarray = tempDataValuesJToken["items"][0]["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray;
var f_value = f_tempJarray.FirstOrDefault().Value<string>("name");
var f_valueId = f_tempJarray.FirstOrDefault().Value<int>("id");
var s_id = int.Parse(tempDataValuesJToken["items"][1]["properties"]["id"]["enum"][0].ToString());
var s_unit = tempDataValuesJToken["items"][1]["properties"]["unit"]["enum"][0].ToString();
//var s_value = "1";
var t_id = int.Parse(tempDataValuesJToken["items"][2]["properties"]["id"]["enum"][0].ToString());
var t_value = "待替换的备注";
for (var i = 0; i < request.GiftTemplateSkuList.Count(); i++)
{
strutsSaleAttrValueList.Add(new List<AttrValueAliasJson>()
{
new AttrValueAliasJson()
{
id = f_id,
value = f_value,
valueId = f_valueId,
unit = string.Empty
},
new AttrValueAliasJson()
{
id = s_id,
value = "1",
unit = s_unit
},
new AttrValueAliasJson()
{
id = t_id,
value = t_value,
isReName = true
}
});
}
}
else if (tempDataValues_Level1_JToken["properties"]["id"]["type"].ToString() == "model")
{ {
//[{\"id\":5,\"unit\":\"\",\"value\":\"红色\","valueId":1234567}] //[{\"id\":5,\"unit\":\"\",\"value\":\"红色\","valueId":1234567}]
var tempJarray = tempDataValues_Level1_JToken["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray; var tempJarray = tempDataValues_Level1_JToken["properties"]["value"]["enum"][0]["preprocessingSaleAttrValTemplateValueList"] as JArray;

28
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -131,6 +131,33 @@ namespace BBWY.Server.Business
throw new BusinessException("订单不存在"); throw new BusinessException("订单不存在");
if (dbOrder.OrderState != Enums.OrderState. && dbOrder.OrderState != Enums.OrderState.) if (dbOrder.OrderState != Enums.OrderState. && dbOrder.OrderState != Enums.OrderState.)
throw new BusinessException("只能为等待采购或待出库的订单进行采购"); throw new BusinessException("只能为等待采购或待出库的订单进行采购");
if (createOnlinePurchaseOrderRequest.CargoParamList == null || createOnlinePurchaseOrderRequest.CargoParamList.Count() == 0)
throw new BusinessException("缺少下单参数");
//拦截不要属于当前订单的请求
var orderSkus = fsql.Select<OrderSku>().Where(osku => osku.Price != 0 && osku.OrderId == createOnlinePurchaseOrderRequest.OrderId).ToList();
if (createOnlinePurchaseOrderRequest.CargoParamList.Any(c => !orderSkus.Any(osku => osku.SkuId == c.BelongSkuId)))
{
nLogManager.Default().Info($"NewFastCreateOrder\r\n非法请求\r\n{JsonConvert.SerializeObject(createOnlinePurchaseOrderRequest)}");
//移除不属于当前订单的采购配件
for (var i = 0; i < createOnlinePurchaseOrderRequest.CargoParamList.Count(); i++)
{
var cp = createOnlinePurchaseOrderRequest.CargoParamList[i];
if (!orderSkus.Any(osku => osku.SkuId == cp.BelongSkuId))
{
createOnlinePurchaseOrderRequest.CargoParamList.RemoveAt(i);
i--;
}
}
if (createOnlinePurchaseOrderRequest.CargoParamList.Count() == 0)
throw new BusinessException("经过采购配件的订单sku归属关系过滤之后,剩余采购配件数量为0,请先联系技术人员排查问题之后再手动关联");
//throw new BusinessException("非法sku参数,下单sku中存在不属于该笔订单的sku");
}
var oldPourchaseIdList = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == dbOrder.Id) var oldPourchaseIdList = fsql.Select<OrderCostDetail>().Where(ocd => ocd.OrderId == dbOrder.Id)
.ToList(ocd => ocd.PurchaseOrderPKId); .ToList(ocd => ocd.PurchaseOrderPKId);
@ -138,7 +165,6 @@ namespace BBWY.Server.Business
var deletePurchaseOrder = fsql.Delete<PurchaseOrder>().Where(po => oldPourchaseIdList.Contains(po.Id)); var deletePurchaseOrder = fsql.Delete<PurchaseOrder>().Where(po => oldPourchaseIdList.Contains(po.Id));
var deleteOrderCostDetail = fsql.Delete<OrderCostDetail>().Where(ocd => ocd.OrderId == dbOrder.Id); var deleteOrderCostDetail = fsql.Delete<OrderCostDetail>().Where(ocd => ocd.OrderId == dbOrder.Id);
var isRepurchase = fsql.Select<OrderCost>(dbOrder.Id).Any(); var isRepurchase = fsql.Select<OrderCost>(dbOrder.Id).Any();
var orderSkus = fsql.Select<OrderSku>().Where(osku => osku.Price != 0 && osku.OrderId == createOnlinePurchaseOrderRequest.OrderId).ToList();
var orderSkuIds = orderSkus.Select(osku => osku.Id).ToList(); var orderSkuIds = orderSkus.Select(osku => osku.Id).ToList();
#region 合并重复的采购sku #region 合并重复的采购sku

49
BBWY.Server.Business/PurchaseScheme/PurchaseProductAPIService.cs

@ -25,6 +25,9 @@ namespace BBWY.Server.Business
private string qtAppId = "BBWY2023022001"; private string qtAppId = "BBWY2023022001";
private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe"; private string qtAppSecret = "908e131365d5448ca651ba20ed7ddefe";
private List<string> locationIdList;
private List<string> priceIdList;
private TimeSpan purchaseProductCacheTimeSpan; private TimeSpan purchaseProductCacheTimeSpan;
//private TimeSpan _1688SessionIdTimeSpan; //private TimeSpan _1688SessionIdTimeSpan;
@ -40,7 +43,7 @@ namespace BBWY.Server.Business
this.restApiService = restApiService; this.restApiService = restApiService;
_1688ProductDetailRequestHeader = new Dictionary<string, string>() _1688ProductDetailRequestHeader = new Dictionary<string, string>()
{ {
{ "Host","detail.1688.com"}, //{ "Host","detail.1688.com"},
{ "User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"}, { "User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"},
{ "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}, { "Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"},
{ "Accept-Encoding","gzip, deflate, br"}, { "Accept-Encoding","gzip, deflate, br"},
@ -48,6 +51,17 @@ namespace BBWY.Server.Business
}; };
purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); purchaseProductCacheTimeSpan = TimeSpan.FromDays(1);
this.quanTanProductClient = quanTanProductClient; this.quanTanProductClient = quanTanProductClient;
locationIdList = new List<string>()
{
"300252630336272",
"1081181309101",
"16347413030323"
};
priceIdList = new List<string>() {
"300252630336263",
"1081181309582",
"16347413030316"
};
} }
public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request) public PurchaseSkuBasicInfoResponse GetProductInfo(PurchaseSkuBasicInfoRequest request)
@ -193,12 +207,13 @@ namespace BBWY.Server.Business
$"clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? "order" : "consign")}", $"clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={(request.PriceMode == Enums.PurchaseOrderMode.批发 ? "order" : "consign")}",
_1688ProductDetailRequestHeader, _1688ProductDetailRequestHeader,
HttpMethod.Get, HttpMethod.Get,
httpClientName: "gzip"); httpClientName: "gzip",
getResponseHeader: true);
if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK) if (_1688pageResult.StatusCode != System.Net.HttpStatusCode.OK)
return null; return null;
var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA=)(.*)(\r*\n*\s*</script>)"); var match = Regex.Match(_1688pageResult.Content, @"(window\.__INIT_DATA\s?=)(.*)(\r*\n*\s*</script>)");
if (!match.Success) if (!match.Success)
return null; return null;
@ -209,12 +224,16 @@ namespace BBWY.Server.Business
var purchaser = new Purchaser() var purchaser = new Purchaser()
{ {
Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(),
Name = jobject["globalData"]["tempModel"]["companyName"].ToString(), Name = jobject["globalData"]["tempModel"]["companyName"].ToString()
Location = jobject["data"]["1081181309101"] != null ?
jobject["data"]["1081181309101"]["data"]["location"].ToString() :
jobject["data"]["16347413030323"]["data"]["location"].ToString(),
Platform = Enums.Platform.
}; };
foreach (var lid in locationIdList)
{
if (jobject["data"][lid] != null)
{
purchaser.Location = jobject["data"][lid]["data"]["location"].ToString();
break;
}
}
var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 || var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value<int>("fid") == 3216 ||
j.Value<int>("fid") == 1627207 || j.Value<int>("fid") == 1627207 ||
@ -227,9 +246,15 @@ namespace BBWY.Server.Business
imageUrl = j.Value<string>("imageUrl") imageUrl = j.Value<string>("imageUrl")
}).ToList(); }).ToList();
var firstPrice = jobject["data"]["1081181309582"] != null ? var firstPrice = 0M;
jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price") : foreach (var pid in priceIdList)
jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price"); {
if (jobject["data"][pid] != null)
{
firstPrice = jobject["data"][pid]["data"]["priceModel"]["currentPrices"][0].Value<decimal>("price");
break;
}
}
var list = new List<PurchaseSkuItemBasicInfoResponse>(); var list = new List<PurchaseSkuItemBasicInfoResponse>();
@ -246,7 +271,7 @@ namespace BBWY.Server.Business
{ {
PurchaseProductId = request.PurchaseProductId, PurchaseProductId = request.PurchaseProductId,
Price = skuPrice == 0M ? firstPrice : skuPrice, Price = skuPrice == 0M ? firstPrice : skuPrice,
Title = name, Title = matchName, //name
PurchaseSkuId = value.Value<string>("skuId"), PurchaseSkuId = value.Value<string>("skuId"),
PurchaseSkuSpecId = value.Value<string>("specId"), PurchaseSkuSpecId = value.Value<string>("specId"),
Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png" Logo = colorsProperty.FirstOrDefault(c => c.name == matchName)?.imageUrl ?? "pack://application:,,,/Resources/Images/defaultItem.png"

17
BBWY.Server.Business/Sync/OrderSyncBusiness.cs

@ -306,7 +306,8 @@ namespace BBWY.Server.Business
if (orderCouponDetailResponse.Success) if (orderCouponDetailResponse.Success)
{ {
var jtoken = orderCouponDetailResponse.Data["jingdong_pop_order_queryCouponDetai_responce"]["couponDetailExternal"]["couponDetailVo"]; var jtoken = orderCouponDetailResponse.Data["jingdong_pop_order_queryCouponDetai_responce"]["couponDetailExternal"]["couponDetailVo"];
if (jtoken.Value<decimal>("totalShouldPay") > 0M)
{
#region 订单合计信息 #region 订单合计信息
var orderTotal = new OrderTotalInfo() var orderTotal = new OrderTotalInfo()
{ {
@ -449,7 +450,7 @@ namespace BBWY.Server.Business
} }
} }
#endregion #endregion
}
} }
} }
} }
@ -725,6 +726,17 @@ namespace BBWY.Server.Business
orderState != null && orderState != null &&
orderState != Enums.OrderState. && orderState != Enums.OrderState. &&
orderState != Enums.OrderState.) orderState != Enums.OrderState.)
{
bool checkOrderTotal = true;
if (dbOrder.StorageType == Enums.StorageType. || dbOrder.StorageType == Enums.StorageType.)
{
var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == dbOrder.Id);
if (orderTotalInfo == null)
orderTotalInfo = dbOrderTotalList.FirstOrDefault(x => x.Id == dbOrder.Id);
if (orderTotalInfo == null || orderTotalInfo.TotalShouldPay == 0M)
checkOrderTotal = false;
}
if (checkOrderTotal)
{ {
var orderCost = dbOrderCostList.FirstOrDefault(oc => oc.OrderId == dbOrder.Id); var orderCost = dbOrderCostList.FirstOrDefault(oc => oc.OrderId == dbOrder.Id);
if (orderCost == null && orderSellerPrice > 0M) if (orderCost == null && orderSellerPrice > 0M)
@ -923,6 +935,7 @@ namespace BBWY.Server.Business
} }
} }
} }
}
#endregion #endregion
#region 检查订单信息是否变化 #region 检查订单信息是否变化

2
BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/PreviewOrderReuqest.cs

@ -12,6 +12,6 @@ namespace BBWY.Server.Model.Dto
public ConsigneeRequest Consignee { get; set; } public ConsigneeRequest Consignee { get; set; }
public IList<CargoParamRequest> CargoParamList { get; set; } public List<CargoParamRequest> CargoParamList { get; set; }
} }
} }

Loading…
Cancel
Save