Browse Source

合并

AddValidOverTime
506583276@qq.com 2 years ago
parent
commit
d21dab20b2
  1. 4
      BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs
  2. 2
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  3. 68
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  4. 10
      BBWY.Server.Business/Statistics/JDReportFormStatisticsBusiness.cs
  5. 51
      BBWY.Server.Business/Statistics/StatisticsBusiness.cs
  6. 24
      BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs
  7. 19
      BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs

4
BBWY.Client/ViewModels/BatchPurchase/BatchPurchaseCreateNewOrderViewModel.cs

@ -105,7 +105,7 @@ namespace BBWY.Client.ViewModels
this.City = "泉州市"; this.City = "泉州市";
this.County = "鲤城区"; this.County = "鲤城区";
this.Town = "金龙街道"; this.Town = "金龙街道";
this.Address = "南环路1129号创鑫产业园3楼齐越"; this.Address = "古龙路媒人桥2号三文公寓一楼齐越中转仓";//"南环路1129号创鑫产业园3楼齐越";
this.ContactName = globalContext.User.Shop.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == Platform.)?.AccountName; this.ContactName = globalContext.User.Shop.PurchaseAccountList.FirstOrDefault(pa => pa.PurchasePlatformId == Platform.)?.AccountName;
} }
@ -394,6 +394,6 @@ namespace BBWY.Client.ViewModels
purchaseSchemeProductSku.ItemTotal--; purchaseSchemeProductSku.ItemTotal--;
} }
} }
} }

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

@ -610,7 +610,7 @@ namespace BBWY.Server.Business
MainProductSkuInStore = mainProductSkuInStore, MainProductSkuInStore = mainProductSkuInStore,
OuterId = dbPromotionTask.OuterId OuterId = dbPromotionTask.OuterId
}, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 600); }, GetYunDingRequestHeader(), HttpMethod.Post, timeOutSeconds: 700);
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK) if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(httpApiResult.Content); throw new BusinessException(httpApiResult.Content);

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

@ -775,7 +775,7 @@ namespace BBWY.Server.Business
{ {
var jdClient = GetJdClient(appKey, appSecret); var jdClient = GetJdClient(appKey, appSecret);
if (haveGiftTemplateSku) if (haveGiftTemplateSku && deleteSkuList != null && deleteSkuList.Count() > 0 && !deleteSkuList.Any(s => string.IsNullOrEmpty(s)))
DeleteSkuList(new DeleteSkuListRequest() DeleteSkuList(new DeleteSkuListRequest()
{ {
AppKey = appKey, AppKey = appKey,
@ -853,15 +853,15 @@ namespace BBWY.Server.Business
public override StartPromotionTaskResponse StartJDPromotionTask(StartPromotionTaskRequest2 request) public override StartPromotionTaskResponse StartJDPromotionTask(StartPromotionTaskRequest2 request)
{ {
var stepText = string.Empty; var stepText = string.Empty;
//stepText.AppendLine($"任务Id {request.Id} 店铺Id {request.ShopId}"); List<string> giftSkuIdList = new List<string>();
var brandName = string.Empty;
var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0;
try try
{ {
var jdClient = GetJdClient(request.AppKey, request.AppSecret); var jdClient = GetJdClient(request.AppKey, request.AppSecret);
long wareId = long.Parse(request.MainProductSpu); long wareId = long.Parse(request.MainProductSpu);
List<string> giftSkuIdList = new List<string>();
long promotionId = 0; long promotionId = 0;
var brandName = string.Empty;
var haveGiftTemplateSku = request.GiftTemplateSkuList != null && request.GiftTemplateSkuList.Count() > 0;
#region 前置检查各项sku #region 前置检查各项sku
var searchProductSkuRequest = new SearchProductSkuRequest() var searchProductSkuRequest = new SearchProductSkuRequest()
@ -921,9 +921,6 @@ namespace BBWY.Server.Business
if (giftSkuList != null && giftSkuList.Any(s => s.ProductId != request.MainProductSpu)) if (giftSkuList != null && giftSkuList.Any(s => s.ProductId != request.MainProductSpu))
throw new BusinessException("主商品赠品SKU归属有误"); throw new BusinessException("主商品赠品SKU归属有误");
//stepText = "添加赠品SKU";
//AddJDPromotionSku(jdClient, request.AppToken, promotionId, skuList, true);
} }
#endregion #endregion
@ -949,7 +946,6 @@ namespace BBWY.Server.Business
stepText = "设置精简标题"; stepText = "设置精简标题";
var req = new WareWriteUpdateWareTitleRequest(); var req = new WareWriteUpdateWareTitleRequest();
req.wareId = wareId; req.wareId = wareId;
//req.title = request.SimpleTitle;
if (string.IsNullOrEmpty(request.SimpleTitle) || !request.SimpleTitle.StartsWith(brandName)) if (string.IsNullOrEmpty(request.SimpleTitle) || !request.SimpleTitle.StartsWith(brandName))
req.title = $"{brandName}{request.SimpleTitle}"; req.title = $"{brandName}{request.SimpleTitle}";
else else
@ -975,9 +971,6 @@ namespace BBWY.Server.Business
var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); var response = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (response.Json == null) if (response.Json == null)
response.Json = JObject.Parse(response.Body); response.Json = JObject.Parse(response.Body);
//nLogManager.Default().Info($"获取销售属性 任务Id {request.Id} 返回内容 {response.Body} 模板sku数量 {request.GiftTemplateSkuList.Count()}");
var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j.Value<string>("name") == "颜色"); var colorProperty = response.Json["jingdong_category_read_findAttrsByCategoryIdUnlimitCate_responce"]["findattrsbycategoryidunlimitcate_result"].FirstOrDefault(j => j.Value<string>("name") == "颜色");
if (colorProperty == null) if (colorProperty == null)
{ {
@ -1008,34 +1001,23 @@ namespace BBWY.Server.Business
{ {
type = "com.jd.pop.ware.ic.api.domain.Sku", type = "com.jd.pop.ware.ic.api.domain.Sku",
wareId = wareId, wareId = wareId,
//skuId = long.Parse(sku.Id),
jdPrice = giftSku.Price ?? 0, jdPrice = giftSku.Price ?? 0,
stockNum = 9999, stockNum = 9999,
barCode = request.MainProductBarCode, barCode = request.MainProductBarCode,
outerId = $"{request.OuterId}{(i + 1).ToString().PadLeft(3, '0')}", outerId = $"{request.OuterId}{(i + 1).ToString().PadLeft(3, '0')}",
saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>() saleAttrs = new List<SkuWriteUpdateSkusItemSaleAttrs>()
{ {
//new SkuWriteUpdateSkusItemSaleAttrs()
//{
// type = "com.jd.pop.ware.ic.api.domain.Prop",
// attrId = colorProperty.Value<string>("attId"),
// attrValues = new List<string>() { colorProperty.Value<string>("id") },
// index = takeColorIndex,
// attrValuesSeqNo = new List<int?>(){ takeColorIndex }
//}
new SkuWriteUpdateSkusItemSaleAttrs() new SkuWriteUpdateSkusItemSaleAttrs()
{ {
type = "com.jd.pop.ware.ic.api.domain.Prop", type = "com.jd.pop.ware.ic.api.domain.Prop",
attrId = colorPropertyValue.Value<string>("attId"), attrId = colorPropertyValue.Value<string>("attId"),
//attrValues = new List<string>() { colorPropertyValue.Value<string>("id") }, attrValueAlias = new List<string>(){ giftSku.Title },
attrValueAlias = new List<string>(){ giftSku.Title }, // colorPropertyValue.Value<string>("name")
index = takeColorIndex, index = takeColorIndex,
attrValuesSeqNo = new List<int?>(){ takeColorIndex } attrValuesSeqNo = new List<int?>(){ takeColorIndex }
} }
}, },
saleAttrTemplateId = "POP_MODEL" saleAttrTemplateId = "POP_MODEL"
//promiseId = 30603710 //固定时效模板Id 48小时发货
}; };
p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>(); p.multiCateProps = new List<SkuWriteUpdateSkusItemSaleAttrs>();
@ -1051,27 +1033,6 @@ namespace BBWY.Server.Business
} }
} }
////修改标题参数
//updateSkuTitleParamList.Add(new WareWriteUpdateWareSaleAttrvalueAliasRequestItem()
//{
// attrId = p.saleAttrs[0].attrId,
// attrValues = p.saleAttrs[0].attrValues,
// attrValueAlias = new List<string>() { giftSku.Title }
//});
////修改商品细节图参数
//var imgUrlBuilder = new StringBuilder();
//var imgIndexBuilder = new StringBuilder();
//imgUrlBuilder.Append($"{giftSku.Logo.Substring(giftSku.Logo.IndexOf("jfs"))},");
//imgIndexBuilder.Append("1,");
//imageWriteUpdateRequestList.Add(new ImageWriteUpdateRequest()
//{
// wareId = wareId,
// colorId = colorProperty.Value<string>("id"),
// imgUrl = imgUrlBuilder.ToString().Trim(','),
// imgIndex = imgIndexBuilder.ToString().Trim(',')
//});
takeColorIndex--; takeColorIndex--;
skusParamList.Add(p); skusParamList.Add(p);
} }
@ -1101,6 +1062,7 @@ namespace BBWY.Server.Business
int? promiseId = null; int? promiseId = null;
#region 查询时效模板 #region 查询时效模板
{ {
stepText = "查询时效模板";
var shixiaoReq = new SellerDeliverySendPromiseTemplateJsfServiceQuerySendTemplateByCategoryRequest(); var shixiaoReq = new SellerDeliverySendPromiseTemplateJsfServiceQuerySendTemplateByCategoryRequest();
shixiaoReq.categoryId = int.Parse(request.MainProductCategoryId); shixiaoReq.categoryId = int.Parse(request.MainProductCategoryId);
shixiaoReq.dzSku = true; shixiaoReq.dzSku = true;
@ -1121,7 +1083,7 @@ namespace BBWY.Server.Business
promiseId = shixiaoJToken.Value<int>("templateId"); promiseId = shixiaoJToken.Value<int>("templateId");
} }
#endregion #endregion
stepText = "再次上架sku";
foreach (var skuParam in req.skus) foreach (var skuParam in req.skus)
skuParam.promiseId = promiseId; skuParam.promiseId = promiseId;
res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
@ -1141,10 +1103,14 @@ namespace BBWY.Server.Business
} }
} }
//记录上架返回值
nLogManager.Default().Info($"任务Id {request.Id} 店铺Id {request.ShopId} 上架赠品返回值 {res.Body}");
stepText = "获取上架skuId";
var newSkuIdList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList(); var newSkuIdList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList().Select(x => x.Value<string>("skuId")).ToList();
giftSkuIdList.AddRange(newSkuIdList); giftSkuIdList.AddRange(newSkuIdList);
stepText = "获取上架sku";
var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList(); var newSkuList = res.Json["jingdong_sku_write_updateSkus_responce"]["skuList"].ToList();
var imgIndex = 1; var imgIndex = 1;
StringBuilder colorBuilder = new StringBuilder(); StringBuilder colorBuilder = new StringBuilder();
@ -1153,7 +1119,12 @@ namespace BBWY.Server.Business
foreach (var skuJToken in newSkuList) foreach (var skuJToken in newSkuList)
{ {
var skuTitle = skuJToken["saleAttrs"][0]["attrValueAlias"][0].ToString(); var skuTitle = skuJToken["saleAttrs"][0]["attrValueAlias"][0].ToString();
var colorId = skuJToken["saleAttrs"][0]["attrValues"][0].ToString(); var colorId = "0000000000";
try
{
colorId = skuJToken["saleAttrs"][0]["attrValues"][0].ToString();
}
catch { }
var currentImgIndex = imgIndex; var currentImgIndex = imgIndex;
imgIndex++; imgIndex++;
var giftSku = request.GiftTemplateSkuList.FirstOrDefault(x => x.Title == skuTitle); var giftSku = request.GiftTemplateSkuList.FirstOrDefault(x => x.Title == skuTitle);
@ -1324,6 +1295,7 @@ namespace BBWY.Server.Business
catch (Exception ex) catch (Exception ex)
{ {
nLogManager.Default().Error(ex, $"任务Id {request.Id} 店铺Id {request.ShopId} 执行步骤 {stepText}"); nLogManager.Default().Error(ex, $"任务Id {request.Id} 店铺Id {request.ShopId} 执行步骤 {stepText}");
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, giftSkuIdList, request.MainProductSpu, request.FullTitle, brandName, haveGiftTemplateSku);
throw ex; throw ex;
} }
} }

10
BBWY.Server.Business/Statistics/JDReportFormStatisticsBusiness.cs

@ -17,6 +17,7 @@ namespace BBWY.Server.Business.Statistics
} }
#region 计划/单元/创意/海投维度GOI
public IList<JDMultiLevelGOIResponse> CalculationCampaignLevelGOI(GOIRequest gOIRequest) public IList<JDMultiLevelGOIResponse> CalculationCampaignLevelGOI(GOIRequest gOIRequest)
{ {
var _7dEndDate = DateTime.Now.Date.AddDays(-1); var _7dEndDate = DateTime.Now.Date.AddDays(-1);
@ -501,6 +502,10 @@ namespace BBWY.Server.Business.Statistics
return list; return list;
} }
#endregion
#region 商品维度
public IList<JDProductAndPopularizeLevelGOIResponse> CalculationCampaignLevelProductGOI(GOIRequest gOIRequest) public IList<JDProductAndPopularizeLevelGOIResponse> CalculationCampaignLevelProductGOI(GOIRequest gOIRequest)
{ {
var _7dEndDate = DateTime.Now.Date.AddDays(-1); var _7dEndDate = DateTime.Now.Date.AddDays(-1);
@ -980,6 +985,9 @@ namespace BBWY.Server.Business.Statistics
return list; return list;
} }
#endregion
#region 推广维度
public IList<JDProductAndPopularizeLevelGOIResponse> CalculationCampaignLevelPopularizeGOI(GOIRequest gOIRequest) public IList<JDProductAndPopularizeLevelGOIResponse> CalculationCampaignLevelPopularizeGOI(GOIRequest gOIRequest)
{ {
@ -1459,5 +1467,7 @@ namespace BBWY.Server.Business.Statistics
} }
return list; return list;
} }
#endregion
} }
} }

51
BBWY.Server.Business/Statistics/StatisticsBusiness.cs

@ -138,15 +138,16 @@ namespace BBWY.Server.Business
return list; return list;
} }
private void XingXiangCumulative(IList<XingXiangItemResponse> detailList, string spuId, bool isSD, decimal profit, decimal sdProductAmount, decimal sdCost) private void XingXiangCumulative(IList<XingXiangItemResponse> detailList, string spuId, bool isSD, decimal profit, decimal spuProductAmount, decimal sdProductAmount, decimal sdCost)
{ {
var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId); var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId);
if (xxRespose == null) if (xxRespose == null)
{ {
xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M }; xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M, ActualAmount = 0M };
detailList.Add(xxRespose); detailList.Add(xxRespose);
} }
xxRespose.Profit += profit; xxRespose.Profit += profit;
xxRespose.ActualAmount += spuProductAmount;
if (isSD) if (isSD)
{ {
xxRespose.SDOrderCount++; xxRespose.SDOrderCount++;
@ -182,6 +183,7 @@ namespace BBWY.Server.Business
//DeliveryExpressFreight = oc.DeliveryExpressFreight, //DeliveryExpressFreight = oc.DeliveryExpressFreight,
//PreferentialAmount = oc.PreferentialAmount, //PreferentialAmount = oc.PreferentialAmount,
OrderSellerPrice = o.OrderSellerPrice, OrderSellerPrice = o.OrderSellerPrice,
FreightPrice = o.FreightPrice,
//SellerPreferentialAmount = o.SellerPreferentialAmount, //SellerPreferentialAmount = o.SellerPreferentialAmount,
Profit = oc.Profit Profit = oc.Profit
}); });
@ -202,7 +204,7 @@ namespace BBWY.Server.Business
if (order.StorageType == Enums.StorageType.SD) if (order.StorageType == Enums.StorageType.SD)
{ {
XingXiangCumulative(detailList, currentOrderSkuList[0].ProductId, true, order.Profit ?? 0M, order.OrderSellerPrice, Math.Abs(order.Profit ?? 0M)); XingXiangCumulative(detailList, currentOrderSkuList[0].ProductId, true, order.Profit ?? 0M, order.OrderSellerPrice, order.OrderSellerPrice + order.FreightPrice, Math.Abs(order.Profit ?? 0M));
continue; continue;
} }
@ -223,49 +225,8 @@ namespace BBWY.Server.Business
var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit; var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit;
var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent; var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent;
XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, 0, 0); XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, tempSpuProductAmount, 0, 0);
} }
//foreach (var group in spuGroups)
//{
// var spuId = group.Key;
// var profit = 0M;
// var sdCost = 0M;
// var prodcutAmount = group.Sum(osku => osku.Price * osku.ItemTotal) ?? 0; //货款
// var skuSellerPreferentialAmount = order.SellerPreferentialAmount / skuCount * group.Count(); //该SPU分摊的商家优惠金额
// prodcutAmount -= skuSellerPreferentialAmount;
// var commissionAmount = prodcutAmount * platformCommissionRatio; //该SPU的平台扣点金额
// var freightPriceByUser = order.FreightPrice == 0 ? 0 : order.FreightPrice / skuCount * group.Count(); //该SPU分摊的用户承担运费
// var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id && ocd.ProductId == spuId).ToList();
// var purchaseAmount = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.TotalCost) : 0;
// var deliveryFreight = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.DeliveryExpressFreight) : 0;
// if (order.StorageType != Enums.StorageType.SD)
// {
// profit = prodcutAmount + freightPriceByUser - purchaseAmount - deliveryFreight - commissionAmount;
// }
// else
// {
// var sdCommissionAmount = order.SDCommissionAmount.Value / skuCount * group.Count();
// profit = 0;
// sdCost = sdCommissionAmount + commissionAmount + order.DeliveryExpressFreight ?? 0M;
// totalSDOrderCost += sdCost;
// }
// var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId);
// if (xxRespose == null)
// {
// xxRespose = new XingXiangItemResponse() { Spu = spuId, Profit = 0M };
// detailList.Add(xxRespose);
// }
// xxRespose.Profit += profit;
// if (order.StorageType == Enums.StorageType.SD)
// {
// xxRespose.SDOrderCount++;
// xxRespose.SDOrderAmount += prodcutAmount;
// xxRespose.SDOrderCost += sdCost;
// }
//}
} }
var sdOrderList = orderList.Where(o => o.StorageType == Enums.StorageType.SD); var sdOrderList = orderList.Where(o => o.StorageType == Enums.StorageType.SD);

24
BBWY.Server.Business/Sync/StoreHouseSyncBusiness.cs

@ -78,19 +78,19 @@ namespace BBWY.Server.Business.Sync
} }
} }
//var storeHouseIds = storeHouseList.Select(s => s.Id).ToArray(); var storeHouseIds = storeHouseList.Select(s => s.Id).ToArray();
//var dbStoreIds = fsql.Select<Storehouse>(storeHouseIds).ToList(s => s.Id); var dbStoreIds = fsql.Select<Storehouse>(storeHouseIds).ToList(s => s.Id);
//var exceptIds = storeHouseIds.Except(dbStoreIds); var exceptIds = storeHouseIds.Except(dbStoreIds);
//if (exceptIds.Count() > 0) if (exceptIds.Count() > 0)
//{
// var insertList = storeHouseList.Where(s => exceptIds.Contains(s.Id)).ToList();
// fsql.Insert(insertList).ExecuteAffrows();
//}
fsql.Transaction(() =>
{ {
fsql.Delete<Storehouse>().Where(s => 1 == 1).ExecuteAffrows(); var insertList = storeHouseList.Where(s => exceptIds.Contains(s.Id)).ToList();
fsql.Insert(storeHouseList).ExecuteAffrows(); fsql.Insert(insertList).ExecuteAffrows();
}); }
//fsql.Transaction(() =>
//{
// fsql.Delete<Storehouse>().Where(s => 1 == 1).ExecuteAffrows();
// fsql.Insert(storeHouseList).ExecuteAffrows();
//});
} }

19
BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace BBWY.Server.Model.Dto namespace BBWY.Server.Model.Dto
{ {
@ -38,6 +39,22 @@ namespace BBWY.Server.Model.Dto
public decimal Profit { get; set; } public decimal Profit { get; set; }
/// <summary>
/// 实收金额
/// </summary>
public decimal ActualAmount { get; set; }
/// <summary>
/// 毛利率
/// </summary>
public decimal ProfitRatio
{
get
{
return ActualAmount == 0 ? 0 : Math.Round(Profit / ActualAmount * 100, 2);
}
}
/// <summary> /// <summary>
/// 刷单单量 /// 刷单单量
/// </summary> /// </summary>

Loading…
Cancel
Save