Browse Source

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

AddValidOverTime
sanji 2 years ago
parent
commit
3609687eca
  1. 2
      BBWY.Client/GlobalContext.cs
  2. 10
      BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs
  3. 23
      BBWY.Client/Models/Order/Order.cs
  4. 10
      BBWY.Client/Views/Order/OrderListControl.xaml
  5. 5
      BBWY.Server.API/Controllers/TestController.cs
  6. 53
      BBWY.Server.Business/Extensions/OrderCostExtension.cs
  7. 56
      BBWY.Server.Business/Order/OrderBusiness.cs
  8. 41
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  9. 13
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  10. 51
      BBWY.Server.Business/Statistics/StatisticsBusiness.cs
  11. 1009
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  12. 133
      BBWY.Server.Business/TestBusiness.cs
  13. 16
      BBWY.Server.Model/Db/Order/Order.cs
  14. 6
      BBWY.Server.Model/Db/Order/OrderCoupon_New.cs
  15. 3
      BBWY.Server.Model/Db/Order/OrderPromotion.cs
  16. 15
      BBWY.Server.Model/Dto/Request/Test/RepairSkuDetailAndSkuGriooProfit.cs
  17. 150
      BBWY.Server.Model/Dto/Response/JD/OrderSkuCFDetail.cs
  18. 12
      BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs
  19. 19
      BBWY.Server.Model/Dto/Response/Order/XingXinagSearchResponse.cs
  20. 1
      JD.API/Middlewares/CustomExceptionMiddleWare.cs

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 = "10203"; ClientVersion = "10205";
} }

10
BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs

@ -64,6 +64,16 @@ namespace BBWY.Client.Models
/// </summary> /// </summary>
public decimal OrderSellerPrice { get; set; } public decimal OrderSellerPrice { get; set; }
/// <summary>
/// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan)
/// </summary>
public decimal? ActualProductAmount { get; set; } = 0.00M;
/// <summary>
/// 平台承担优惠券
/// </summary>
public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M;
/// <summary> /// <summary>
/// 用户应付金额 /// 用户应付金额
/// </summary> /// </summary>

23
BBWY.Client/Models/Order/Order.cs

@ -82,13 +82,30 @@ namespace BBWY.Client.Models
/// </summary> /// </summary>
public decimal FreightPrice { get; set; } public decimal FreightPrice { get; set; }
/// <summary>
/// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan)
/// </summary>
public decimal? ActualProductAmount { get; set; } = 0.00M;
/// <summary>
/// 平台承担优惠券
/// </summary>
public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M;
/// <summary> /// <summary>
/// 实收金额 /// 实收金额
/// </summary> /// </summary>
public decimal ActualAmount { get { return OrderSellerPrice + FreightPrice; } } public decimal ActualAmount
{
get
{
//return OrderSellerPrice + FreightPrice;
return OrderSellerPrice + FreightPrice + (PingTaiChengDanYouHuiQuan ?? 0M);
}
}
/// <summary> /// <summary>
/// 商家优惠金额 /// 平台优惠金额
/// </summary> /// </summary>
public decimal PreferentialAmount { get; set; } public decimal PreferentialAmount { get; set; }
@ -223,7 +240,7 @@ namespace BBWY.Client.Models
var beforeTotalCost = OrderCost?.BeforeTotalCost ?? 0M; var beforeTotalCost = OrderCost?.BeforeTotalCost ?? 0M;
return OrderState != OrderState. && StorageType != Models.StorageType.SD && return OrderState != OrderState. && StorageType != Models.StorageType.SD &&
((StorageType != null && beforeTotalCost == 0M) || ((StorageType != null && beforeTotalCost == 0M) ||
(beforeTotalCost > OrderSellerPrice + FreightPrice) || (beforeTotalCost > OrderSellerPrice + FreightPrice + PingTaiChengDanYouHuiQuan) ||
(StorageType == null && OrderState != OrderState. && OrderState != OrderState.)); (StorageType == null && OrderState != OrderState. && OrderState != OrderState.));
} }
} }

10
BBWY.Client/Views/Order/OrderListControl.xaml

@ -330,12 +330,16 @@
<ToolTip Style="{StaticResource OrderCouponToolipStyle}"> <ToolTip Style="{StaticResource OrderCouponToolipStyle}">
<StackPanel> <StackPanel>
<TextBlock> <TextBlock>
<Run Text="货款金额"/> <Run Text="订单货款金额"/>
<Run Text="{Binding OrderSellerPrice}"/> <Run Text="{Binding OrderSellerPrice}"/>
</TextBlock> </TextBlock>
<TextBlock> <TextBlock>
<Run Text="用户支付运费"/> <Run Text="用户支付运费"/>
<Run Text="{Binding FreightPrice}"/> <Run Text="{Binding FreightPrice}"/>
</TextBlock>
<TextBlock>
<Run Text="平台承担优惠券"/>
<Run Text="{Binding PingTaiChengDanYouHuiQuan}"/>
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
</ToolTip> </ToolTip>

5
BBWY.Server.API/Controllers/TestController.cs

@ -1,5 +1,6 @@
using BBWY.Server.Business; using BBWY.Server.Business;
using BBWY.Server.Model.Db; using BBWY.Server.Model.Db;
using BBWY.Server.Model.Dto;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
@ -25,9 +26,9 @@ namespace BBWY.Server.API.Controllers
} }
[HttpPost] [HttpPost]
public void XiuFu() public void RepairSkuDetailAndSkuGriooProfit([FromBody] RepairSkuDetailAndSkuGriooProfit request)
{ {
testBusiness.XiuFu(); testBusiness.RepairSkuDetailAndSkuGriooProfit(request);
} }
} }
} }

53
BBWY.Server.Business/Extensions/OrderCostExtension.cs

@ -13,26 +13,45 @@ namespace BBWY.Server.Business.Extensions
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0); orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
//退款之后平台扣点 //退款之后平台扣点
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio); //orderCost.PlatformCommissionAmount = (order.OrderPayment - order.FreightPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice + (order.PingTaiChengDanYouHuiQuan ?? 0M) - orderCost.RefundAmount) * orderCost.PlatformCommissionRatio;
//orderCost.Profit = order.OrderSellerPrice + order.FreightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount -
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
orderCost.Profit = order.OrderSellerPrice + order.FreightPrice - orderCost.RefundAmount - orderCost.Profit = (order.ActualProductAmount ?? 0M) -
orderCost.RefundAmount -
orderCost.PurchaseAmount - orderCost.PurchaseAmount -
orderCost.DeliveryExpressFreight - orderCost.DeliveryExpressFreight -
orderCost.PlatformCommissionAmount - orderCost.PlatformCommissionAmount -
orderCost.AfterTotalCost + orderCost.AfterTotalCost +
orderCost.RefundPurchaseAmount; orderCost.RefundPurchaseAmount;
} }
public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal orderSellerPrice,decimal freightPrice, IList<AfterSaleOrder> afterSaleOrders) public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal actualAmountProduct, decimal orderSellerPrice, decimal pingtaichengdanyouhuiquan, IList<AfterSaleOrder> afterSaleOrders)
{ {
orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost); orderCost.AfterTotalCost = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.AfterTotalCost);
orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M); orderCost.RefundAmount = afterSaleOrders == null || afterSaleOrders.Count == 0 ? 0M : afterSaleOrders.Sum(aso => aso.RefundAmount ?? 0M);
orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0); orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0);
//退款之后平台扣点 //退款之后平台扣点
orderCost.PlatformCommissionAmount = (orderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio); //orderCost.PlatformCommissionAmount = (orderPayment - freightPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
orderCost.PlatformCommissionAmount = (orderSellerPrice + pingtaichengdanyouhuiquan - orderCost.RefundAmount) * orderCost.PlatformCommissionRatio;
//orderCost.Profit = orderSellerPrice + freightPrice - orderCost.RefundAmount -
// orderCost.PurchaseAmount -
// orderCost.DeliveryExpressFreight -
// orderCost.PlatformCommissionAmount -
// orderCost.AfterTotalCost +
// orderCost.RefundPurchaseAmount;
orderCost.Profit = orderSellerPrice + freightPrice - orderCost.RefundAmount - orderCost.Profit = actualAmountProduct -
orderCost.RefundAmount -
orderCost.PurchaseAmount - orderCost.PurchaseAmount -
orderCost.DeliveryExpressFreight - orderCost.DeliveryExpressFreight -
orderCost.PlatformCommissionAmount - orderCost.PlatformCommissionAmount -
@ -52,5 +71,29 @@ namespace BBWY.Server.Business.Extensions
orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio); orderCost.PlatformCommissionAmount = (order.OrderSellerPrice - orderCost.RefundAmount) * (orderCost.PlatformCommissionRatio);
orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.SDOrderAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount + orderCost.AfterTotalCost) * -1; orderCost.Profit = (orderCost.SDCommissionAmount + orderCost.SDOrderAmount + orderCost.DeliveryExpressFreight + orderCost.PlatformCommissionAmount + orderCost.AfterTotalCost) * -1;
} }
/// <summary>
/// 计算SKU毛利
/// </summary>
/// <param name="ocd"></param>
/// <param name="skuShouldPay"></param>
/// <param name="pingTaiChengDanYouHuiQuan"></param>
/// <param name="superRedEnvelope"></param>
/// <param name="xianPinLeiDongQuan"></param>
/// <param name="skuVenderFee"></param>
/// <param name="platformCommissionRatio"></param>
public static void CalculationSkuGrossProfit(this OrderCostDetail ocd,
decimal skuShouldPay,
decimal pingTaiChengDanYouHuiQuan,
decimal superRedEnvelope,
decimal xianPinLeiDongQuan,
decimal skuVenderFee,
decimal platformCommissionRatio)
{
var pingTaiBuTie = pingTaiChengDanYouHuiQuan + superRedEnvelope + xianPinLeiDongQuan;
var koudian = (skuShouldPay + pingTaiBuTie - skuVenderFee) * ocd.DeductionQuantity * platformCommissionRatio;
ocd.SkuGrossProfit = (skuShouldPay + pingTaiBuTie) * ocd.DeductionQuantity -
ocd.TotalCost - ocd.DeliveryExpressFreight - koudian;
}
} }
} }

56
BBWY.Server.Business/Order/OrderBusiness.cs

@ -131,6 +131,7 @@ namespace BBWY.Server.Business
IsAfterSaleOrder = o.IsAfterSaleOrder, IsAfterSaleOrder = o.IsAfterSaleOrder,
SellerPreferentialAmount = o.SellerPreferentialAmount, SellerPreferentialAmount = o.SellerPreferentialAmount,
PreferentialAmount = o.PreferentialAmount, PreferentialAmount = o.PreferentialAmount,
PingTaiChengDanYouHuiQuan = o.PingTaiChengDanYouHuiQuan,
ContactName = ocs.ContactName, ContactName = ocs.ContactName,
Address = ocs.Address, Address = ocs.Address,
@ -592,7 +593,25 @@ namespace BBWY.Server.Business
SkuAmount = purchaseOrder.SingleSkuAmount * deductionQuantity, SkuAmount = purchaseOrder.SingleSkuAmount * deductionQuantity,
StorageAmount = purchaseOrder.SingleStorageAmount * deductionQuantity StorageAmount = purchaseOrder.SingleStorageAmount * deductionQuantity
}; };
orderCostDetail.SkuGrossProfit = orderSku.Price.Value * deductionQuantity - avgPreferential - (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - orderSku.Price.Value * deductionQuantity * autoCalculationCostRequest.PlatformCommissionRatio; //orderCostDetail.SkuGrossProfit = orderSku.Price.Value * deductionQuantity - avgPreferential - (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - orderSku.Price.Value * deductionQuantity * autoCalculationCostRequest.PlatformCommissionRatio;
//var shouldPay = orderSku.ShouldPay ?? 0M;
//var pingTaiCoupon = orderSku.PingTaiChengDanYouHuiQuan ?? 0M;
//var venderFee = orderSku.VenderFee ?? 0M;
//var koudian = (shouldPay - venderFee) * deductionQuantity * autoCalculationCostRequest.PlatformCommissionRatio;
//orderCostDetail.SkuGrossProfit = (shouldPay + pingTaiCoupon) * deductionQuantity -
// orderCostDetail.TotalCost - orderCostDetail.DeliveryExpressFreight -
// koudian;
orderCostDetail.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M,
orderSku.PingTaiChengDanYouHuiQuan ?? 0M,
orderSku.SuperRedEnvelope ?? 0M,
orderSku.XianPinLeiDongQuan ?? 0M,
orderSku.VenderFee ?? 0M,
autoCalculationCostRequest.PlatformCommissionRatio);
insertOrderCostDetailList.Add(orderCostDetail); insertOrderCostDetailList.Add(orderCostDetail);
} }
} }
@ -660,7 +679,12 @@ namespace BBWY.Server.Business
{ {
osku.SkuId, osku.SkuId,
osku.Price, osku.Price,
osku.ItemTotal osku.ItemTotal,
osku.ShouldPay,
osku.PingTaiChengDanYouHuiQuan,
osku.SuperRedEnvelope,
osku.XianPinLeiDongQuan,
osku.VenderFee
}); });
var avgPreferential = dbOrder.PreferentialAmount / orderSkuList.Count(); var avgPreferential = dbOrder.PreferentialAmount / orderSkuList.Count();
@ -682,9 +706,18 @@ namespace BBWY.Server.Business
var osku = orderSkuList.FirstOrDefault(o => o.SkuId == orderCostDetail.SkuId); var osku = orderSkuList.FirstOrDefault(o => o.SkuId == orderCostDetail.SkuId);
if (osku != null) if (osku != null)
{ {
orderCostDetail.SkuGrossProfit = osku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential - //orderCostDetail.SkuGrossProfit = osku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential -
(orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - // (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) -
osku.Price.Value * orderCostDetail.DeductionQuantity * manualCalculationCostRequest.PlatformCommissionRatio; // osku.Price.Value * orderCostDetail.DeductionQuantity * manualCalculationCostRequest.PlatformCommissionRatio;
//orderCostDetail.SkuGrossProfit = ((osku.ShouldPay ?? 0M) + (osku.Coupon ?? 0M)) * orderCostDetail.DeductionQuantity - orderCostDetail.TotalCost - orderCostDetail.DeliveryExpressFreight;
orderCostDetail.CalculationSkuGrossProfit(osku.ShouldPay ?? 0M,
osku.PingTaiChengDanYouHuiQuan ?? 0M,
osku.SuperRedEnvelope ?? 0M,
osku.XianPinLeiDongQuan ?? 0M,
osku.VenderFee ?? 0M,
manualCalculationCostRequest.PlatformCommissionRatio);
} }
} }
@ -940,9 +973,16 @@ namespace BBWY.Server.Business
var dbOrderSku = dbOrderSkuList.FirstOrDefault(dbosku => dbosku.SkuId == relationOrderSku.SkuId); var dbOrderSku = dbOrderSkuList.FirstOrDefault(dbosku => dbosku.SkuId == relationOrderSku.SkuId);
if (dbOrderSku != null) if (dbOrderSku != null)
{ {
orderCostDetail.SkuGrossProfit = dbOrderSku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential - //orderCostDetail.SkuGrossProfit = dbOrderSku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential -
(orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - // (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) -
dbOrderSku.Price.Value * orderCostDetail.DeductionQuantity * relationPurchaseOrderRequestV2.PlatformCommissionRatio; // dbOrderSku.Price.Value * orderCostDetail.DeductionQuantity * relationPurchaseOrderRequestV2.PlatformCommissionRatio;
//orderCostDetail.SkuGrossProfit = ((dbOrderSku.ShouldPay ?? 0M) + dbOrderSku.Coupon ?? 0M) * orderCostDetail.DeductionQuantity - orderCostDetail.TotalCost - orderCostDetail.DeliveryExpressFreight;
orderCostDetail.CalculationSkuGrossProfit(dbOrderSku.ShouldPay ?? 0M,
dbOrderSku.PingTaiChengDanYouHuiQuan ?? 0M,
dbOrderSku.SuperRedEnvelope ?? 0M,
dbOrderSku.XianPinLeiDongQuan ?? 0M,
dbOrderSku.VenderFee ?? 0M,
relationPurchaseOrderRequestV2.PlatformCommissionRatio);
} }
#endregion #endregion
} }

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

@ -138,7 +138,10 @@ namespace BBWY.Server.Business
var pageSize = 20; var pageSize = 20;
var totalPageSize = 1; var totalPageSize = 1;
if (!string.IsNullOrEmpty(searchProductSkuRequest.Spu)) if (!string.IsNullOrEmpty(searchProductSkuRequest.Spu))
{
totalPageSize = 1; totalPageSize = 1;
searchProductSkuRequest.IsCheckSkuCount = false;
}
else if (!string.IsNullOrEmpty(searchProductSkuRequest.Sku)) else if (!string.IsNullOrEmpty(searchProductSkuRequest.Sku))
{ {
skuIdList = searchProductSkuRequest.Sku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); skuIdList = searchProductSkuRequest.Sku.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
@ -182,7 +185,9 @@ namespace BBWY.Server.Business
{ {
var targetSkuIdList = skuList.Select(s => s.Id); var targetSkuIdList = skuList.Select(s => s.Id);
var exceptSkuIdList = skuIdList.Except(targetSkuIdList); var exceptSkuIdList = skuIdList.Except(targetSkuIdList);
throw new BusinessException($"{searchProductSkuRequest.CheckStep}-sku条件数量和查询结果数量不一致\r\n{string.Join(",", exceptSkuIdList)}"); // throw new BusinessException($"{searchProductSkuRequest.CheckStep}-sku条件数量和查询结果数量不一致\r\n{string.Join(",", exceptSkuIdList)}");
//throw new BusinessException($"{JsonConvert.SerializeObject(skuIdList)} 以上SKU可能已下架,请修改任务将该SKU移除奶妈列表");
throw new BusinessException($"以上{searchProductSkuRequest.CheckStep}状态异常,可能被系统自动下架,请检查任务的精简标题是否正确\r\n{string.Join(",", exceptSkuIdList)}");
} }
return skuList; return skuList;
@ -852,6 +857,15 @@ namespace BBWY.Server.Business
} }
} }
private string SkuShangJiaFanYi(string errorMsg)
{
if (errorMsg.Contains("销售属性值组合重复") && errorMsg.Contains("业务要求唯一性"))
errorMsg = "该任务已上架赠品,请手动下架赠品,系统10分钟后将自动重新启动该任务";
if (errorMsg.Contains("属性[产品尺寸]扩展值数量与值数量不一致"))
errorMsg = "上架赠品失败,评价助手暂无法上架带有[产品尺寸]的商品,请手动上架赠品后在评价助手创建已上架赠品模式";
return errorMsg;
}
public override StartPromotionTaskResponse StartJDPromotionTask(StartPromotionTaskRequest2 request) public override StartPromotionTaskResponse StartJDPromotionTask(StartPromotionTaskRequest2 request)
{ {
var stepText = string.Empty; var stepText = string.Empty;
@ -886,7 +900,7 @@ namespace BBWY.Server.Business
{ {
stepText = "查询奶妈模板SKU"; stepText = "查询奶妈模板SKU";
searchProductSkuRequest.Sku = request.MotherTemplateSku; searchProductSkuRequest.Sku = request.MotherTemplateSku;
searchProductSkuRequest.CheckStep = "奶妈模板"; searchProductSkuRequest.CheckStep = "奶妈模板SKU";
motherTemplateSkuList = GetProductSkuList(searchProductSkuRequest); motherTemplateSkuList = GetProductSkuList(searchProductSkuRequest);
} }
#endregion #endregion
@ -896,7 +910,7 @@ namespace BBWY.Server.Business
{ {
stepText = "查询自定义奶妈SKU"; stepText = "查询自定义奶妈SKU";
searchProductSkuRequest.Sku = request.CustomMotherSku; searchProductSkuRequest.Sku = request.CustomMotherSku;
searchProductSkuRequest.CheckStep = "自定义奶妈"; searchProductSkuRequest.CheckStep = "自定义奶妈SKU";
customerMotherSkuList = GetProductSkuList(searchProductSkuRequest); customerMotherSkuList = GetProductSkuList(searchProductSkuRequest);
} }
#endregion #endregion
@ -906,7 +920,7 @@ namespace BBWY.Server.Business
{ {
stepText = "查询主商品SKU"; stepText = "查询主商品SKU";
searchProductSkuRequest.Sku = request.MainProductSku; searchProductSkuRequest.Sku = request.MainProductSku;
searchProductSkuRequest.CheckStep = "主商品"; searchProductSkuRequest.CheckStep = "主商品SKU";
mainProductSkuList = GetProductSkuList(searchProductSkuRequest); mainProductSkuList = GetProductSkuList(searchProductSkuRequest);
if (mainProductSkuList != null && mainProductSkuList.Any(s => s.ProductId != request.MainProductSpu)) if (mainProductSkuList != null && mainProductSkuList.Any(s => s.ProductId != request.MainProductSpu))
throw new BusinessException("主商品SKU归属有误"); throw new BusinessException("主商品SKU归属有误");
@ -918,7 +932,7 @@ namespace BBWY.Server.Business
{ {
stepText = "查询主商品赠品SKU"; stepText = "查询主商品赠品SKU";
searchProductSkuRequest.Sku = request.MainProductGiftSku; searchProductSkuRequest.Sku = request.MainProductGiftSku;
searchProductSkuRequest.CheckStep = "主商品赠品"; searchProductSkuRequest.CheckStep = "赠品SKU";
giftSkuList = GetProductSkuList(searchProductSkuRequest); giftSkuList = GetProductSkuList(searchProductSkuRequest);
giftSkuIdList = giftSkuList.Select(gs => gs.Id).ToList(); giftSkuIdList = giftSkuList.Select(gs => gs.Id).ToList();
@ -1137,12 +1151,14 @@ namespace BBWY.Server.Business
errorMsg = res.Body.Contains("en_desc") ? errorMsg = res.Body.Contains("en_desc") ?
res.Json["error_response"].Value<string>("en_desc") : res.Json["error_response"].Value<string>("en_desc") :
(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg); (string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg);
errorMsg = SkuShangJiaFanYi(errorMsg);
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
throw new BusinessException($"上架sku失败-{errorMsg}"); throw new BusinessException($"上架sku失败-{errorMsg}");
} }
} }
else else
{ {
errorMsg = SkuShangJiaFanYi(errorMsg);
RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false); RollBackWhenStartPromotionError(request.AppKey, request.AppSecret, request.AppToken, null, request.MainProductSpu, request.FullTitle, brandName, false);
throw new BusinessException($"上架sku失败-{errorMsg}"); throw new BusinessException($"上架sku失败-{errorMsg}");
} }
@ -1424,6 +1440,9 @@ namespace BBWY.Server.Business
ddMsg.AppendLine($"任务奶妈数:{request.JoinSkuCount}"); ddMsg.AppendLine($"任务奶妈数:{request.JoinSkuCount}");
ddMsg.AppendLine($"参与奶妈数:{lastQueryJoinCount}"); ddMsg.AppendLine($"参与奶妈数:{lastQueryJoinCount}");
ddMsg.AppendLine("参与任务的奶妈数异常请检查"); ddMsg.AppendLine("参与任务的奶妈数异常请检查");
//ddMsg.AppendLine("以上SKU可能已下架或同时参与多个赠品促销活动");
//ddMsg.AppendLine("1.如已下架请将对应的SKU移除奶妈列表");
//ddMsg.AppendLine("2.系统会自动剔除同时参与多个赠品促销的SKU,请检查以上SKU是否在失效的促销活动,请及时删除,已暂停或已停止的促销活动");
} }
if (!string.IsNullOrEmpty(request.PJZSDingDingKey) && !string.IsNullOrEmpty(request.PJZSDingDingWebHook)) if (!string.IsNullOrEmpty(request.PJZSDingDingKey) && !string.IsNullOrEmpty(request.PJZSDingDingWebHook))
dingDingBusiness.SendDingDingBotMessage(request.PJZSDingDingKey, request.PJZSDingDingWebHook, ddMsg.ToString()); dingDingBusiness.SendDingDingBotMessage(request.PJZSDingDingKey, request.PJZSDingDingWebHook, ddMsg.ToString());
@ -1693,10 +1712,10 @@ namespace BBWY.Server.Business
public override JToken GetOrderCouponDetail(QueryOrderCouponDetailRequest request) public override JToken GetOrderCouponDetail(QueryOrderCouponDetailRequest request)
{ {
var jdClient = GetJdClient(request.AppKey, request.AppSecret); var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new PopOrderCoupondetailRequest(); //var req = new PopOrderCoupondetailRequest();
var req = new PopOrderQueryCouponDetaiRequest();
req.orderId = Convert.ToInt64(request.OrderId);
req.orderId = request.OrderId;
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.Json == null) if (res.Json == null)
@ -1762,7 +1781,7 @@ namespace BBWY.Server.Business
public override JToken GetProductById(GetProductByIdRequest request) public override JToken GetProductById(GetProductByIdRequest request)
{ {
var jdClient = GetJdClient(request.AppKey, request.AppSecret); var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new WareReadFindWareByIdRequest() { wareId = request.SpuId}; var req = new WareReadFindWareByIdRequest() { wareId = request.SpuId };
if (request.Field != null) if (request.Field != null)
req.field = request.Field; req.field = request.Field;
@ -1777,9 +1796,9 @@ namespace BBWY.Server.Business
public override JToken GetAttrsByCategoryId(GetAttrsByCategoryIdRequest request) public override JToken GetAttrsByCategoryId(GetAttrsByCategoryIdRequest request)
{ {
var jdClient = GetJdClient(request.AppKey, request.AppSecret); var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new CategoryReadFindAttrsByCategoryIdUnlimitCateRequest() { cid=request.CatId}; var req = new CategoryReadFindAttrsByCategoryIdUnlimitCateRequest() { cid = request.CatId };
if(request.AttributeType!=null) if (request.AttributeType != null)
req.attributeType = request.AttributeType; req.attributeType = request.AttributeType;
if (request.Field != null) if (request.Field != null)
req.field = request.Field; req.field = request.Field;

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

@ -13,7 +13,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yitter.IdGenerator; using Yitter.IdGenerator;
using BBWY.Server.Business.Extensions;
namespace BBWY.Server.Business namespace BBWY.Server.Business
{ {
public class PurchaseOrderBusiness : BaseBusiness, IDenpendency public class PurchaseOrderBusiness : BaseBusiness, IDenpendency
@ -263,7 +263,16 @@ namespace BBWY.Server.Business
//UnitCost = purchaseOrder.UnitCost, //UnitCost = purchaseOrder.UnitCost,
//TotalCost = currentOrderSkuProductAmount + currentOrderSkuFreightAmount//purchaseOrder.UnitCost * orderSku.ItemTotal.Value //TotalCost = currentOrderSkuProductAmount + currentOrderSkuFreightAmount//purchaseOrder.UnitCost * orderSku.ItemTotal.Value
}; };
orderCostDetail.SkuGrossProfit = orderSku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential - (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - orderSku.Price.Value * orderCostDetail.DeductionQuantity * createOnlinePurchaseOrderRequest.PlatformCommissionRatio; //orderCostDetail.SkuGrossProfit = orderSku.Price.Value * orderCostDetail.DeductionQuantity - avgPreferential - (orderCostDetail.TotalCost + orderCostDetail.DeliveryExpressFreight) - orderSku.Price.Value * orderCostDetail.DeductionQuantity * createOnlinePurchaseOrderRequest.PlatformCommissionRatio;
//orderCostDetail.SkuGrossProfit = ((orderSku.ShouldPay ?? 0M) + orderSku.Coupon ?? 0M) * orderCostDetail.DeductionQuantity - orderCostDetail.TotalCost - orderCostDetail.DeliveryExpressFreight;
orderCostDetail.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M,
orderSku.PingTaiChengDanYouHuiQuan ?? 0M,
orderSku.SuperRedEnvelope ?? 0M,
orderSku.XianPinLeiDongQuan ?? 0M,
orderSku.VenderFee ?? 0M,
createOnlinePurchaseOrderRequest.PlatformCommissionRatio);
insertOrderCostDetails.Add(orderCostDetail); insertOrderCostDetails.Add(orderCostDetail);
#endregion #endregion
} }

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

@ -144,7 +144,8 @@ namespace BBWY.Server.Business
return list; return list;
} }
private void XingXiangCumulative(IList<XingXiangItemResponse> detailList, string spuId, bool isSD, decimal profit, decimal spuProductAmount, decimal sdProductAmount, decimal sdCost) private void XingXiangCumulative(IList<XingXiangItemResponse> detailList,
string spuId, bool isSD, decimal profit, decimal actualAmount, decimal sdCost)
{ {
var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId); var xxRespose = detailList.FirstOrDefault(xx => xx.Spu == spuId);
if (xxRespose == null) if (xxRespose == null)
@ -153,11 +154,11 @@ namespace BBWY.Server.Business
detailList.Add(xxRespose); detailList.Add(xxRespose);
} }
xxRespose.Profit += profit; xxRespose.Profit += profit;
xxRespose.ActualAmount += spuProductAmount; xxRespose.ActualAmount += actualAmount;
if (isSD) if (isSD)
{ {
xxRespose.SDOrderCount++; xxRespose.SDOrderCount++;
xxRespose.SDOrderAmount += sdProductAmount; xxRespose.SDOrderAmount += actualAmount;
xxRespose.SDOrderCost += sdCost; xxRespose.SDOrderCost += sdCost;
} }
} }
@ -207,6 +208,7 @@ namespace BBWY.Server.Business
var spuIdList = orderSkuList.Select(osku => osku.ProductId).Distinct().ToList(); var spuIdList = orderSkuList.Select(osku => osku.ProductId).Distinct().ToList();
List<GOIBySpu> spuGoiList = null; List<GOIBySpu> spuGoiList = null;
GOIByShop shopGoi = null; GOIByShop shopGoi = null;
#region spu goi #region spu goi
{ {
var httpResult = restApiService.SendRequest("http://snapi.qiyue666.com/", "Api/GOI/QueryPopularizeLevelGOIBySpuId", new var httpResult = restApiService.SendRequest("http://snapi.qiyue666.com/", "Api/GOI/QueryPopularizeLevelGOIBySpuId", new
@ -246,45 +248,49 @@ 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, order.OrderSellerPrice + order.FreightPrice, 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));
XingXiangCumulative(detailList, currentOrderSkuList[0].ProductId, true, order.Profit ?? 0M, order.OrderSellerPrice + order.FreightPrice, Math.Abs(order.Profit ?? 0M));
continue; continue;
} }
var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id); var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id);
var spuGroups = currentOrderSkuList.GroupBy(osku => osku.ProductId); var spuGroups = currentOrderSkuList.GroupBy(osku => osku.ProductId);
var tempOrderProdcutAmount = currentOrderSkuList.Sum(osku => osku.ItemTotal * osku.Price) ?? 0M; //var tempOrderProdcutAmount = currentOrderSkuList.Sum(osku => osku.ItemTotal * osku.Price) ?? 0M;
var tempOrderCost = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.TotalCost) : 0M; //var tempOrderCost = currentOrderCostDetailList.Count() > 0 ? currentOrderCostDetailList.Sum(ocd => ocd.TotalCost) : 0M;
var tempOrderProfit = tempOrderProdcutAmount - tempOrderCost; //var tempOrderProfit = tempOrderProdcutAmount - tempOrderCost;
foreach (var spuGroup in spuGroups) foreach (var spuGroup in spuGroups)
{ {
var currentSpuCostDetailList = currentOrderCostDetailList.Where(ocd => ocd.ProductId == spuGroup.Key); var currentSpuCostDetailList = currentOrderCostDetailList.Where(ocd => ocd.ProductId == spuGroup.Key);
var currentSkuOrderSkuList = currentOrderSkuList.Where(osku => osku.ProductId == spuGroup.Key);
var totalActualAmount = currentSkuOrderSkuList.Sum(osku => osku.ShouldPay ?? 0M);
var totalProfit = currentSpuCostDetailList.Sum(ocd => ocd.SkuGrossProfit);
var tempSpuProductAmount = spuGroup.Sum(osku => osku.Price * osku.ItemTotal) ?? 0M; XingXiangCumulative(detailList, spuGroup.Key, false, totalProfit, totalActualAmount, 0);
var tempSpuCost = currentSpuCostDetailList.Count() > 0 ? currentSpuCostDetailList.Sum(ocd => ocd.TotalCost) : 0M;
var tempSpuProfit = tempSpuProductAmount - tempSpuCost;
var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit;
var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent; //var tempSpuProductAmount = spuGroup.Sum(osku => osku.Price * osku.ItemTotal) ?? 0M;
XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, tempSpuProductAmount, 0, 0); //var tempSpuCost = currentSpuCostDetailList.Count() > 0 ? currentSpuCostDetailList.Sum(ocd => ocd.TotalCost) : 0M;
//var tempSpuProfit = tempSpuProductAmount - tempSpuCost;
//var spuProfitPercent = tempOrderProfit == 0M ? 0M : tempSpuProfit / tempOrderProfit;
//var realSpuProfit = (order.Profit ?? 0M) * spuProfitPercent;
//XingXiangCumulative(detailList, spuGroup.Key, false, realSpuProfit, tempSpuProductAmount, 0, 0);
} }
} }
var shopProductAmount = orderSkuList.Sum(osku => osku.ItemTotal * osku.Price); //var shopProductAmount = orderSkuList.Sum(osku => osku.ItemTotal * osku.Price);
var shopActualAmount = orderSkuList.Sum(osku => osku.ShouldPay ?? 0M);
foreach (var d in detailList) foreach (var d in detailList)
{ {
var spuGoi = spuGoiList?.FirstOrDefault(x => x.Spu == d.Spu); var spuGoi = spuGoiList?.FirstOrDefault(x => x.Spu == d.Spu);
if (spuGoi != null) if (spuGoi != null)
{ {
var productAmount = orderSkuList.Where(osku => osku.ProductId == d.Spu).Sum(osku => osku.ItemTotal * osku.Price); //var spuActualAmount = orderSkuList.Where(osku => osku.ProductId == d.Spu).Sum(osku => osku.ShouldPay ?? 0M);
d.SpuYingLiRatio = Math.Round((spuGoi.Profit - spuGoi.Cost) / productAmount.Value, 2); d.SpuYingLiRatio = d.ActualAmount == 0 ? 0 : Math.Round((spuGoi.Profit - spuGoi.Cost) / d.ActualAmount, 2);
//d.SpuYingLiRatio = Math.Round((d.Profit - spuGoi.Cost) / productAmount.Value, 2);
} }
d.ShopYingLiRatio = shopProductAmount == 0 ? 0 : Math.Round((shopGoi.Profit - shopGoi.Cost) / shopProductAmount.Value, 2);
d.ShopProfitRatio = shopProductAmount == 0 ? 0 : Math.Round(shopGoi.Profit / shopProductAmount.Value, 2);
} }
@ -297,8 +303,9 @@ namespace BBWY.Server.Business
TotalSDOrderCount = sdOrderList.Count(), TotalSDOrderCount = sdOrderList.Count(),
TotalSDOrderCost = detailList.Sum(xx => xx.SDOrderCost), TotalSDOrderCost = detailList.Sum(xx => xx.SDOrderCost),
TotalProfit = detailList.Sum(xx => xx.Profit), TotalProfit = detailList.Sum(xx => xx.Profit),
ShopYingLiRatio = detailList.FirstOrDefault()?.ShopYingLiRatio, ShopYingLiRatio = shopActualAmount == 0 ? 0 : Math.Round((shopGoi.Profit - shopGoi.Cost) / shopActualAmount, 2),
ShopProfitRatio = detailList.FirstOrDefault()?.ShopProfitRatio ShopProfitRatio = shopActualAmount == 0 ? 0 : Math.Round(shopGoi.Profit / shopActualAmount, 2),
ShopActualAmount = shopActualAmount
}; };
} }

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

File diff suppressed because it is too large

133
BBWY.Server.Business/TestBusiness.cs

@ -3,12 +3,15 @@ using BBWY.Common.Models;
using BBWY.Server.Model; using BBWY.Server.Model;
using BBWY.Server.Model.Db; using BBWY.Server.Model.Db;
using BBWY.Server.Model.Db.Mds; using BBWY.Server.Model.Db.Mds;
using BBWY.Server.Model.Dto;
using FreeSql; using FreeSql;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading;
using BBWY.Server.Business.Extensions;
namespace BBWY.Server.Business namespace BBWY.Server.Business
{ {
@ -17,14 +20,19 @@ namespace BBWY.Server.Business
private FreeSqlMultiDBManager freeSqlMultiDBManager; private FreeSqlMultiDBManager freeSqlMultiDBManager;
private VenderBusiness venderBusiness; private VenderBusiness venderBusiness;
private IFreeSql fsql; private IFreeSql fsql;
private OrderSyncBusiness orderSyncBusiness;
public TestBusiness(RestApiService restApiService, public TestBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options, IOptions<GlobalConfig> options,
FreeSqlMultiDBManager freeSqlMultiDBManager, FreeSqlMultiDBManager freeSqlMultiDBManager,
VenderBusiness venderBusiness, YunDingBusiness yunDingBusiness, IFreeSql fsql) : base(restApiService, options, yunDingBusiness) VenderBusiness venderBusiness,
YunDingBusiness yunDingBusiness,
IFreeSql fsql,
OrderSyncBusiness orderSyncBusiness) : base(restApiService, options, yunDingBusiness)
{ {
this.freeSqlMultiDBManager = freeSqlMultiDBManager; this.freeSqlMultiDBManager = freeSqlMultiDBManager;
this.venderBusiness = venderBusiness; this.venderBusiness = venderBusiness;
this.fsql = fsql; this.fsql = fsql;
this.orderSyncBusiness = orderSyncBusiness;
} }
public void SyncVenderId() public void SyncVenderId()
@ -129,6 +137,129 @@ namespace BBWY.Server.Business
} }
Console.WriteLine("更新完毕"); Console.WriteLine("更新完毕");
} }
public void RepairSkuDetailAndSkuGriooProfit(RepairSkuDetailAndSkuGriooProfit request)
{
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1);
var banedList = new List<string>()
{
"森王汽车用品专营店",
"森王玩具专营店",
"广发玩具专营店",
"广发汽车用品专营店",
"言义汽车用品专营店",
"杰博玩具专营店",
"安吉玩具专营店",
"布莱特玩具专营店",
"畅阳汽车用品专营店",
"熊猴汽车用品专营店",
"布莱特汽车用品专营店",
"越驭玩具专营店",
"言义玩具专营店",
"瑞源汽车用品专营店",
"熊猴玩具专营店",
"奥德汽车用品专营店",
"创天户外专营店",
"桑妮玩具专营店",
"瑞源玩具专营店"
};
var shopList = venderBusiness.GetShopList(request.ShopId, Enums.Platform.);
var shopIndex = 0;
foreach (var shop in shopList)
{
shopIndex++;
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()}");
var shopId = long.Parse(shop.ShopId);
if (banedList.Contains(shop.ShopName))
continue;
var orderIdList = fsql.Select<Order>()
.Where(o => o.ShopId == shopId &&
o.OrderState != Enums.OrderState. &&
o.StorageType != Enums.StorageType.SD &&
o.StartTime >= request.StartTime &&
o.StartTime <= request.EndTime)
.WhereIf(!string.IsNullOrEmpty(request.OrderId), o => o.Id == request.OrderId)
.ToList(o => o.Id);
fsql.Transaction(() =>
{
fsql.Delete<OrderTotalInfo>(orderIdList).ExecuteAffrows();
fsql.Delete<OrderCoupon_New>().Where(on => orderIdList.Contains(on.OrderId)).ExecuteAffrows();
fsql.Delete<OrderPromotion>().Where(op => orderIdList.Contains(op.OrderId)).ExecuteAffrows();
fsql.Update<OrderSku>().Set(osku => osku.ShouldPay, 0).Where(osku => orderIdList.Contains(osku.OrderId)).ExecuteAffrows();
});
for (var i = 0; i < orderIdList.Count(); i++)
{
var orderId = orderIdList[i];
orderSyncBusiness.SyncOrder(shop, orderId);
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()} {shop.ShopName},orderProgress {i + 1}/{orderIdList.Count()}");
}
// foreach (var orderId in orderIdList)
// {
// orderSyncBusiness.SyncOrder(shop, orderId);
// Thread.Sleep(1000);
// }
var orderList = fsql.Select<Order>(orderIdList).ToList();
var orderSkuList = fsql.Select<OrderSku>().Where(osku => osku.Price > 0 && orderIdList.Contains(osku.OrderId)).ToList();
var orderCostDetailList = fsql.Select<OrderCostDetail>().Where(ocd => orderIdList.Contains(ocd.OrderId) && ocd.IsEnabled == true).ToList();
var orderCostList = fsql.Select<OrderCost>(orderIdList).ToList();
var afterOrderList = fsql.Select<AfterSaleOrder>().Where(af => orderIdList.Contains(af.OrderId)).ToList();
var orderTotalList = fsql.Select<OrderTotalInfo>().Where(on => orderIdList.Contains(on.Id)).ToList();
var orderIndex = 0;
foreach (var order in orderList)
{
orderIndex++;
Console.WriteLine($"shopProgress {shopIndex}/{shopList.Count()}, orderProgress {orderIndex}/{orderList.Count()}");
var currentOrderCostDetailList = orderCostDetailList.Where(ocd => ocd.OrderId == order.Id).ToList();
if (currentOrderCostDetailList.Count() > 0)
{
List<IUpdate<OrderCostDetail>> updateOrderCostDetailList = new List<IUpdate<OrderCostDetail>>();
var currentOrderSkuList = orderSkuList.Where(osku => osku.OrderId == order.Id).ToList();
foreach (var orderSku in currentOrderSkuList)
{
var ocd = currentOrderCostDetailList.FirstOrDefault(x => x.SkuId == orderSku.SkuId);
if (ocd != null)
{
ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M,
orderSku.PingTaiChengDanYouHuiQuan ?? 0M,
orderSku.SuperRedEnvelope ?? 0M,
orderSku.XianPinLeiDongQuan ?? 0M,
orderSku.VenderFee ?? 0M,
shop.PlatformCommissionRatio ?? 0.05M);
var update = fsql.Update<OrderCostDetail>(ocd.Id).Set(x => x.SkuGrossProfit, ocd.SkuGrossProfit);
updateOrderCostDetailList.Add(update);
}
}
var currentAfterOrderList = afterOrderList.Where(af => af.OrderId == order.Id).ToList();
var orderTotal = orderTotalList.FirstOrDefault(on => on.Id == order.Id);
var orderCost = orderCostList.FirstOrDefault(oc => oc.OrderId == order.Id);
if (orderCost != null && orderTotal != null)
{
orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M,
orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M,
orderTotal.TotalVenderFee ?? 0M,
currentAfterOrderList);
if (updateOrderCostDetailList.Count() > 0)
{
fsql.Transaction(() =>
{
foreach (var update in updateOrderCostDetailList)
update.ExecuteAffrows();
fsql.Update<OrderCost>(orderCost.OrderId).Set(oc => oc.Profit, orderCost.Profit)
.Set(oc => oc.PlatformCommissionAmount, orderCost.PlatformCommissionAmount).ExecuteAffrows();
});
}
}
}
}
}
}
} }
public class JPCount public class JPCount

16
BBWY.Server.Model/Db/Order/Order.cs

@ -52,13 +52,13 @@ namespace BBWY.Server.Model.Db
public decimal OrderSellerPrice { get; set; } = 0.00M; public decimal OrderSellerPrice { get; set; } = 0.00M;
/// <summary> /// <summary>
/// 平台补贴 /// 优惠金额(订单总价-订单实收货款-用户支付运费)
/// </summary> /// </summary>
[Column(DbType = "decimal(20,2)")] [Column(DbType = "decimal(20,2)")]
public decimal PreferentialAmount { get; set; } = 0.00M; public decimal PreferentialAmount { get; set; } = 0.00M;
/// <summary> /// <summary>
/// 商家优惠金额(商家承担) /// 商家优惠金额(商家承担)(废弃)
/// </summary> /// </summary>
[Column(DbType = "decimal(20,2)")] [Column(DbType = "decimal(20,2)")]
public decimal SellerPreferentialAmount { get; set; } = 0.00M; public decimal SellerPreferentialAmount { get; set; } = 0.00M;
@ -185,6 +185,18 @@ namespace BBWY.Server.Model.Db
[Column(DbType = "bit")] [Column(DbType = "bit")]
public bool IsGift { get; set; } = false; public bool IsGift { get; set; } = false;
/// <summary>
/// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan)
/// </summary>
[Column(DbType = "decimal(18, 2)")]
public decimal? ActualProductAmount { get; set; } = 0.00M;
/// <summary>
/// 平台承担优惠券
/// </summary>
[Column(DbType = "decimal(18, 2)")]
public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M;
#region 订单成本 #region 订单成本
/// <summary> /// <summary>
/// 平台扣点金额 /// 平台扣点金额

6
BBWY.Server.Model/Db/Order/OrderCoupon_New.cs

@ -14,14 +14,12 @@ namespace BBWY.Server.Model.Db
/// <summary> /// <summary>
/// 优惠券数量/发行量 /// 优惠券数量/发行量
/// </summary> /// </summary>
[Column(DbType = "int")] public long? CouponNum { get; set; } = 0;
public int? CouponNum { get; set; } = 0;
/// <summary> /// <summary>
/// POP优惠券ID /// POP优惠券ID
/// </summary> /// </summary>
[Column(DbType = "int")] public long? CouponId { get; set; }
public int? CouponId { get; set; }
/// <summary> /// <summary>
/// 活动名称 /// 活动名称

3
BBWY.Server.Model/Db/Order/OrderPromotion.cs

@ -35,8 +35,7 @@ namespace BBWY.Server.Model.Db
/// <summary> /// <summary>
/// pop促销ID /// pop促销ID
/// </summary> /// </summary>
[Column(DbType = "int")] public long? PromotionId { get; set; }
public int? PromotionId { get; set; }
/// <summary> /// <summary>
/// 活动名称 /// 活动名称

15
BBWY.Server.Model/Dto/Request/Test/RepairSkuDetailAndSkuGriooProfit.cs

@ -0,0 +1,15 @@
using System;
namespace BBWY.Server.Model.Dto
{
public class RepairSkuDetailAndSkuGriooProfit
{
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public long? ShopId { get; set; }
public string OrderId { get; set; }
}
}

150
BBWY.Server.Model/Dto/Response/JD/OrderSkuCFDetail.cs

@ -0,0 +1,150 @@
namespace BBWY.Server.Model.Dto
{
/// <summary>
/// 订单Sku拆分明细对象
/// </summary>
public class OrderSkuCFDetail
{
public string OrderId { get; set; }
public string SkuId { get; set; }
/// <summary>
/// 京东支付优惠,计价单位:元
/// </summary>
public decimal? JdZhiFuYouHui { get; set; } = 0.00M;
/// <summary>
/// plus会员95折优惠,计价单位:元
/// </summary>
public decimal? Plus95 { get; set; } = 0.00M;
/// <summary>
/// 余额,计价单位:元
/// </summary>
public decimal? Balance { get; set; } = 0.00M;
/// <summary>
/// 基础优惠,计价单位:元
/// </summary>
public decimal? BaseDiscount { get; set; } = 0.00M;
/// <summary>
/// 基础运费,计价单位:元
/// </summary>
public decimal? BaseFee { get; set; } = 0.00M;
/// <summary>
/// 优惠券,计价单位:元
/// </summary>
public decimal? Coupon { get; set; } = 0.00M;
/// <summary>
/// 东券,计价单位:元
/// </summary>
public decimal? DongQuan { get; set; } = 0.00M;
/// <summary>
/// 满期赠促销
/// </summary>
public decimal? ExpiryGiftDiscount { get; set; } = 0.00M;
/// <summary>
/// 全球购一般贸易税(包税),计价单位:元
/// </summary>
public decimal? GlobalGeneralIncludeTax { get; set; } = 0.00M;
/// <summary>
/// 全球购一般贸易税,计价单位:元
/// </summary>
public decimal? GlobalGeneralTax { get; set; } = 0.00M;
/// <summary>
/// 京豆,计价单位:元
/// </summary>
public decimal? JingDou { get; set; } = 0.00M;
/// <summary>
/// 京券,计价单位:元
/// </summary>
public decimal? JingQuan { get; set; } = 0.00M;
/// <summary>
/// 京享礼金(首单礼金或重逢礼金),计价单位:元
/// </summary>
public decimal? JingXiangLiJin { get; set; } = 0.00M;
/// <summary>
/// 礼金优惠,计价单位:元
/// </summary>
public decimal? LiJinYouHui { get; set; } = 0.00M;
/// <summary>
/// 落地配服务,计价单位:元
/// </summary>
public decimal? LuoDiPeiService { get; set; } = 0.00M;
/// <summary>
/// 满减,计价单位:元
/// </summary>
public decimal? ManJian { get; set; } = 0.00M;
/// <summary>
/// 按比例平台承担优惠券,计价单位:元
/// </summary>
public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M;
/// <summary>
/// 跨店满减促销
/// </summary>
public decimal? PromotionDiscount { get; set; } = 0.00M;
/// <summary>
/// 偏远运费,计价单位:元
/// </summary>
public decimal? RemoteFee { get; set; } = 0.00M;
/// <summary>
/// 应付金额,计价单位:元
/// </summary>
public decimal? ShouldPay { get; set; } = 0.00M;
/// <summary>
/// 超级红包,计价单位:元
/// </summary>
public decimal? SuperRedEnvelope { get; set; } = 0.00M;
/// <summary>
/// 全球购税费,计价单位:元
/// </summary>
public decimal? TaxFee { get; set; } = 0.00M;
/// <summary>
/// 退换货无忧,计价单位:元
/// </summary>
public decimal? TuiHuanHuoWuYou { get; set; } = 0.00M;
/// <summary>
/// 商家运费,计价单位:元
/// </summary>
public decimal? VenderFee { get; set; } = 0.00M;
/// <summary>
/// 限品类东券,计价单位:元
/// </summary>
public decimal? XianPinLeiDongQuan { get; set; } = 0.00M;
/// <summary>
/// 限品类京券,计价单位:元
/// </summary>
public decimal? XianPinLeiJingQuan { get; set; } = 0.00M;
/// <summary>
/// 支付营销优惠,计价单位:元
/// </summary>
public decimal? ZhiFuYingXiaoYouHui { get; set; } = 0.00M;
}
}

12
BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs

@ -72,13 +72,23 @@ namespace BBWY.Server.Model.Dto
/// </summary> /// </summary>
public decimal OrderPayment { get; set; } public decimal OrderPayment { get; set; }
/// <summary>
/// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan)
/// </summary>
public decimal? ActualProductAmount { get; set; } = 0.00M;
/// <summary>
/// 平台承担优惠券
/// </summary>
public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M;
/// <summary> /// <summary>
/// 商品运费(用户付) /// 商品运费(用户付)
/// </summary> /// </summary>
public decimal FreightPrice { get; set; } public decimal FreightPrice { get; set; }
/// <summary> /// <summary>
/// 平台补贴 /// 优惠金额 订单总价-订单实收货款-用户支付运费
/// </summary> /// </summary>
public decimal PreferentialAmount { get; set; } public decimal PreferentialAmount { get; set; }

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

@ -39,6 +39,11 @@ namespace BBWY.Server.Model.Dto
/// 店铺盈利率 /// 店铺盈利率
/// </summary> /// </summary>
public decimal? ShopYingLiRatio { get; set; } public decimal? ShopYingLiRatio { get; set; }
/// <summary>
/// 店铺实收金额
/// </summary>
public decimal ShopActualAmount { get; set; }
} }
public class XingXiangItemResponse public class XingXiangItemResponse
@ -64,7 +69,7 @@ namespace BBWY.Server.Model.Dto
{ {
get get
{ {
return ActualAmount == 0 ? 0 : Math.Round(Profit / ActualAmount * 100, 2); return ActualAmount == 0 ? 0 : Math.Round(Profit / ActualAmount, 2); //*100
} }
} }
@ -83,19 +88,11 @@ namespace BBWY.Server.Model.Dto
/// </summary> /// </summary>
public decimal SDOrderAmount { get; set; } public decimal SDOrderAmount { get; set; }
/// <summary>
/// 店铺毛利率
/// </summary>
public decimal? ShopProfitRatio { get; set; }
/// <summary>
/// 店铺盈利率
/// </summary>
public decimal? ShopYingLiRatio { get; set; }
/// <summary> /// <summary>
/// SPU盈利率 /// SPU盈利率
/// </summary> /// </summary>
public decimal? SpuYingLiRatio { get; set; } public decimal? SpuYingLiRatio { get; set; }
} }
} }

1
JD.API/Middlewares/CustomExceptionMiddleWare.cs

@ -59,6 +59,7 @@ namespace JD.API.Middlewares
context.Response.Clear(); context.Response.Clear();
context.Response.StatusCode = 500; //发生未捕获的异常,手动设置状态码 context.Response.StatusCode = 500; //发生未捕获的异常,手动设置状态码
nLogManager.Default().Error(ex); //记录错误 nLogManager.Default().Error(ex); //记录错误
//await ErrorHandle(context, context.Response.StatusCode, ex.Message);
} }
} }
finally finally

Loading…
Cancel
Save