diff --git a/BBWY.Client/GlobalContext.cs b/BBWY.Client/GlobalContext.cs index 0e23bf47..e14d54df 100644 --- a/BBWY.Client/GlobalContext.cs +++ b/BBWY.Client/GlobalContext.cs @@ -13,7 +13,7 @@ namespace BBWY.Client { ShopServiceGroupList = new List(); ShopServiceGroupLowerList = new List(); - ClientVersion = "10204"; + ClientVersion = "10205"; } diff --git a/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs b/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs index e10499ea..99c4507c 100644 --- a/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs @@ -64,6 +64,16 @@ namespace BBWY.Client.Models /// public decimal OrderSellerPrice { get; set; } + /// + /// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan) + /// + public decimal? ActualProductAmount { get; set; } = 0.00M; + + /// + /// 平台承担优惠券 + /// + public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M; + /// /// 用户应付金额 /// diff --git a/BBWY.Client/Models/Order/Order.cs b/BBWY.Client/Models/Order/Order.cs index 119a9f04..a53f660f 100644 --- a/BBWY.Client/Models/Order/Order.cs +++ b/BBWY.Client/Models/Order/Order.cs @@ -82,6 +82,16 @@ namespace BBWY.Client.Models /// public decimal FreightPrice { get; set; } + /// + /// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan) + /// + public decimal? ActualProductAmount { get; set; } = 0.00M; + + /// + /// 平台承担优惠券 + /// + public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M; + /// /// 实收金额 /// @@ -90,7 +100,7 @@ namespace BBWY.Client.Models get { //return OrderSellerPrice + FreightPrice; - return OrderPayment + PreferentialAmount; + return OrderSellerPrice + FreightPrice + (PingTaiChengDanYouHuiQuan ?? 0M); } } @@ -230,7 +240,7 @@ namespace BBWY.Client.Models var beforeTotalCost = OrderCost?.BeforeTotalCost ?? 0M; return OrderState != OrderState.已取消 && StorageType != Models.StorageType.SD && ((StorageType != null && beforeTotalCost == 0M) || - (beforeTotalCost > OrderSellerPrice + FreightPrice) || + (beforeTotalCost > OrderSellerPrice + FreightPrice + PingTaiChengDanYouHuiQuan) || (StorageType == null && OrderState != OrderState.等待采购 && OrderState != OrderState.待付款)); } } diff --git a/BBWY.Client/Views/Order/OrderListControl.xaml b/BBWY.Client/Views/Order/OrderListControl.xaml index ddde82cf..7d2ca3d5 100644 --- a/BBWY.Client/Views/Order/OrderListControl.xaml +++ b/BBWY.Client/Views/Order/OrderListControl.xaml @@ -330,14 +330,16 @@ - - - + + - - - + + + + + + diff --git a/BBWY.JDSDK/Request/PopOrderQueryCouponDetaiRequest.cs b/BBWY.JDSDK/Request/PopOrderQueryCouponDetaiRequest.cs new file mode 100644 index 00000000..23c575e2 --- /dev/null +++ b/BBWY.JDSDK/Request/PopOrderQueryCouponDetaiRequest.cs @@ -0,0 +1,24 @@ +using BBWY.JDSDK.Response; +using Jd.Api; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.JDSDK.Request +{ + public class PopOrderQueryCouponDetaiRequest : JdRequestBase + { + public override string ApiName => "jingdong.pop.order.queryCouponDetai"; + + public string orderId { get; set; } + + public bool? queryPromoFlag { get; set; } + + protected override void PrepareParam(IDictionary paramters) + { + paramters.Add("orderId", orderId); + if (queryPromoFlag != null) + paramters.Add("queryPromoFlag", queryPromoFlag); + } + } +} diff --git a/BBWY.JDSDK/Response/PopOrderQueryCouponDetaiResponse.cs b/BBWY.JDSDK/Response/PopOrderQueryCouponDetaiResponse.cs new file mode 100644 index 00000000..0616dad1 --- /dev/null +++ b/BBWY.JDSDK/Response/PopOrderQueryCouponDetaiResponse.cs @@ -0,0 +1,8 @@ +using Jd.Api; + +namespace BBWY.JDSDK.Response +{ + public class PopOrderQueryCouponDetaiResponse : JdResponse + { + } +} diff --git a/BBWY.Server.Business/Extensions/OrderCostExtension.cs b/BBWY.Server.Business/Extensions/OrderCostExtension.cs index 67ac590e..43d32c6a 100644 --- a/BBWY.Server.Business/Extensions/OrderCostExtension.cs +++ b/BBWY.Server.Business/Extensions/OrderCostExtension.cs @@ -13,8 +13,9 @@ namespace BBWY.Server.Business.Extensions orderCost.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0); //退款之后平台扣点 - orderCost.PlatformCommissionAmount = (order.OrderPayment - order.FreightPrice - 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 - @@ -22,8 +23,7 @@ namespace BBWY.Server.Business.Extensions // orderCost.AfterTotalCost + // orderCost.RefundPurchaseAmount; - orderCost.Profit = order.OrderPayment + - order.PreferentialAmount - + orderCost.Profit = (order.ActualProductAmount ?? 0M) - orderCost.RefundAmount - orderCost.PurchaseAmount - orderCost.DeliveryExpressFreight - @@ -33,14 +33,15 @@ namespace BBWY.Server.Business.Extensions } - public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal orderPayment, decimal preferentialAmount, decimal freightPrice, IList afterSaleOrders) + public static void CalculationOrderProfitAndCost(this OrderCost orderCost, decimal actualAmountProduct, decimal orderSellerPrice, decimal pingtaichengdanyouhuiquan, IList afterSaleOrders) { 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.RefundPurchaseAmount = afterSaleOrders == null || afterSaleOrders.Count == 0M ? 0M : afterSaleOrders.Sum(aso => aso.RefundPurchaseAmount ?? 0); //退款之后平台扣点 - orderCost.PlatformCommissionAmount = (orderPayment - freightPrice - 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 - @@ -49,8 +50,7 @@ namespace BBWY.Server.Business.Extensions // orderCost.AfterTotalCost + // orderCost.RefundPurchaseAmount; - orderCost.Profit = orderPayment + - preferentialAmount - + orderCost.Profit = actualAmountProduct - orderCost.RefundAmount - orderCost.PurchaseAmount - orderCost.DeliveryExpressFreight - @@ -77,13 +77,22 @@ namespace BBWY.Server.Business.Extensions /// /// /// - /// + /// + /// + /// /// /// - public static void CalculationSkuGrossProfit(this OrderCostDetail ocd, decimal skuShouldPay, decimal skuPingtaibutie, decimal skuVenderFee, decimal platformCommissionRatio) + public static void CalculationSkuGrossProfit(this OrderCostDetail ocd, + decimal skuShouldPay, + decimal pingTaiChengDanYouHuiQuan, + decimal superRedEnvelope, + decimal xianPinLeiDongQuan, + decimal skuVenderFee, + decimal platformCommissionRatio) { - var koudian = (skuShouldPay - skuVenderFee) * ocd.DeductionQuantity * platformCommissionRatio; - ocd.SkuGrossProfit = (skuShouldPay + skuPingtaibutie) * ocd.DeductionQuantity - + var pingTaiBuTie = pingTaiChengDanYouHuiQuan + superRedEnvelope + xianPinLeiDongQuan; + var koudian = (skuShouldPay + pingTaiBuTie - skuVenderFee) * ocd.DeductionQuantity * platformCommissionRatio; + ocd.SkuGrossProfit = (skuShouldPay + pingTaiBuTie) * ocd.DeductionQuantity - ocd.TotalCost - ocd.DeliveryExpressFreight - koudian; } } diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index ef2e1597..a01dbbb8 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -131,6 +131,7 @@ namespace BBWY.Server.Business IsAfterSaleOrder = o.IsAfterSaleOrder, SellerPreferentialAmount = o.SellerPreferentialAmount, PreferentialAmount = o.PreferentialAmount, + PingTaiChengDanYouHuiQuan = o.PingTaiChengDanYouHuiQuan, ContactName = ocs.ContactName, Address = ocs.Address, @@ -603,8 +604,11 @@ namespace BBWY.Server.Business //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); @@ -678,6 +682,8 @@ namespace BBWY.Server.Business osku.ItemTotal, osku.ShouldPay, osku.PingTaiChengDanYouHuiQuan, + osku.SuperRedEnvelope, + osku.XianPinLeiDongQuan, osku.VenderFee }); var avgPreferential = dbOrder.PreferentialAmount / orderSkuList.Count(); @@ -708,6 +714,8 @@ namespace BBWY.Server.Business orderCostDetail.CalculationSkuGrossProfit(osku.ShouldPay ?? 0M, osku.PingTaiChengDanYouHuiQuan ?? 0M, + osku.SuperRedEnvelope ?? 0M, + osku.XianPinLeiDongQuan ?? 0M, osku.VenderFee ?? 0M, manualCalculationCostRequest.PlatformCommissionRatio); } @@ -971,6 +979,8 @@ namespace BBWY.Server.Business //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); } diff --git a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs index b7a49e64..923740e4 100644 --- a/BBWY.Server.Business/PlatformSDK/JDBusiness.cs +++ b/BBWY.Server.Business/PlatformSDK/JDBusiness.cs @@ -1712,10 +1712,10 @@ namespace BBWY.Server.Business public override JToken GetOrderCouponDetail(QueryOrderCouponDetailRequest request) { var jdClient = GetJdClient(request.AppKey, request.AppSecret); - var req = new PopOrderCoupondetailRequest(); - - req.orderId = Convert.ToInt64(request.OrderId); + //var req = new PopOrderCoupondetailRequest(); + var req = new PopOrderQueryCouponDetaiRequest(); + req.orderId = request.OrderId; var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime()); if (res.Json == null) diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index 42be525b..a67ca7fb 100644 --- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -269,6 +269,8 @@ namespace BBWY.Server.Business orderCostDetail.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M, orderSku.PingTaiChengDanYouHuiQuan ?? 0M, + orderSku.SuperRedEnvelope ?? 0M, + orderSku.XianPinLeiDongQuan ?? 0M, orderSku.VenderFee ?? 0M, createOnlinePurchaseOrderRequest.PlatformCommissionRatio); insertOrderCostDetails.Add(orderCostDetail); diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index 387ecad6..bb5a54ee 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs @@ -305,7 +305,7 @@ namespace BBWY.Server.Business var orderCouponDetailResponse = JsonConvert.DeserializeObject>(orderCouponDetailHttpResult.Content); if (orderCouponDetailResponse.Success) { - var jtoken = orderCouponDetailResponse.Data["jingdong_pop_order_coupondetail_responce"]["couponDetailExternal"]["couponDetailVo"]; + var jtoken = orderCouponDetailResponse.Data["jingdong_pop_order_queryCouponDetai_responce"]["couponDetailExternal"]["couponDetailVo"]; #region 订单合计信息 var orderTotal = new OrderTotalInfo() @@ -392,6 +392,27 @@ namespace BBWY.Server.Business { foreach (var oskuJtoken in skuJArray) { + var skuDiscountInfoList = oskuJtoken["skuDiscountInfoList"] as JArray; + decimal? xianPinLeiDongQuan = 0M; + if (skuDiscountInfoList != null && skuDiscountInfoList.Count > 0) + { + foreach (var item1 in skuDiscountInfoList) + { + var discountTypeList = item1["discountTypeList"] as JArray; + if (discountTypeList != null && discountTypeList.Count() > 0) + { + foreach (var discountType in discountTypeList) + { + if (discountType.Value("type") == 6) + xianPinLeiDongQuan += discountType.Value("amount"); + } + } + } + } + + if (xianPinLeiDongQuan == 0M) + xianPinLeiDongQuan = oskuJtoken.Value("xianPinLeiDongQuan"); + var oskuCF = new OrderSkuCFDetail() { OrderId = orderId, @@ -420,7 +441,7 @@ namespace BBWY.Server.Business TaxFee = oskuJtoken.Value("taxFee"), TuiHuanHuoWuYou = oskuJtoken.Value("tuiHuanHuoWuYou"), VenderFee = oskuJtoken.Value("venderFee"), - XianPinLeiDongQuan = oskuJtoken.Value("xianPinLeiDongQuan"), + XianPinLeiDongQuan = xianPinLeiDongQuan, //数据不齐 XianPinLeiJingQuan = oskuJtoken.Value("xianPinLeiJingQuan"), ZhiFuYingXiaoYouHui = oskuJtoken.Value("zhiFuYingXiaoYouHui") }; @@ -448,9 +469,18 @@ namespace BBWY.Server.Business var storeOrder = orderJToken.Value("storeOrder") ?? string.Empty; var storeId = orderJToken.Value("storeId"); var storageType = ConvertStoreOrder(storeOrder); + + decimal? actualProductAmount = 0M; + decimal? preferentialAmount = 0M; + decimal? pingtaiChengDanYouHuiQuan = 0M; + if (dbOrder == null) { var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == orderId); + //actualProductAmount = orderPayment - freightPrice + pingtaibutie; + pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); + actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; + preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; dbOrder = new Order() { Id = orderId, @@ -473,7 +503,10 @@ namespace BBWY.Server.Business StoreId = storeId, IsGift = orderSellerPrice == 0M, StorageType = storageType, - PreferentialAmount = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan) ?? 0M + //PreferentialAmount = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan) ?? 0M, + ActualProductAmount = actualProductAmount ?? 0M, + PreferentialAmount = preferentialAmount ?? 0M, + PingTaiChengDanYouHuiQuan = pingtaiChengDanYouHuiQuan ?? 0M }; if (memoryCache.TryGetValue(orderId, out sDCalculationCostRequest)) @@ -556,6 +589,14 @@ namespace BBWY.Server.Business } else { + var orderTotalInfo = insertOrderTotalInfoList.FirstOrDefault(x => x.Id == orderId); + if (orderTotalInfo == null) + orderTotalInfo = dbOrderTotalList.FirstOrDefault(x => x.Id == orderId); + + pingtaiChengDanYouHuiQuan = (orderTotalInfo?.TotalPingTaiChengDanYouHuiQuan ?? 0M); + actualProductAmount = orderSellerPrice + pingtaiChengDanYouHuiQuan; + preferentialAmount = orderTotalPrice - (actualProductAmount ?? 0M) - freightPrice; + //preferentialAmount = dbOrder.PreferentialAmount; if (storageType != null && dbOrder.StorageType != storageType) dbOrder.StorageType = storageType; @@ -738,19 +779,33 @@ namespace BBWY.Server.Business skuShouldPay = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.ShouldPay; - decimal? pingtaiCoupon = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && + decimal? skuPingTaiChengDanYouHuiQuan = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.PingTaiChengDanYouHuiQuan; - if (pingtaiCoupon == null) - pingtaiCoupon = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.PingTaiChengDanYouHuiQuan; - if (pingtaiCoupon == null) - pingtaiCoupon = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.PingTaiChengDanYouHuiQuan; - - decimal? venderFee = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && + if (skuPingTaiChengDanYouHuiQuan == null) + skuPingTaiChengDanYouHuiQuan = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.PingTaiChengDanYouHuiQuan; + if (skuPingTaiChengDanYouHuiQuan == null) + skuPingTaiChengDanYouHuiQuan = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.PingTaiChengDanYouHuiQuan; + + decimal? skuSuperRedEnvelope = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && + x.SkuId == orderSkuId)?.SuperRedEnvelope; + if (skuSuperRedEnvelope == null) + skuSuperRedEnvelope = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.SuperRedEnvelope; + if (skuSuperRedEnvelope == null) + skuSuperRedEnvelope = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.SuperRedEnvelope; + + decimal? skuXianPinLeiDongQuan = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && + x.SkuId == orderSkuId)?.XianPinLeiDongQuan; + if (skuXianPinLeiDongQuan == null) + skuXianPinLeiDongQuan = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.XianPinLeiDongQuan; + if (skuXianPinLeiDongQuan == null) + skuXianPinLeiDongQuan = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.XianPinLeiDongQuan; + + decimal? skuVenderFee = orderSkuCFDetailList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.VenderFee; - if (venderFee == null) - venderFee = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.VenderFee; - if (venderFee == null) - venderFee = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.VenderFee; + if (skuVenderFee == null) + skuVenderFee = insertOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.VenderFee; + if (skuVenderFee == null) + skuVenderFee = dbOrderSkuList.FirstOrDefault(x => x.OrderId == orderId && x.SkuId == orderSkuId)?.VenderFee; #endregion //var itemPrice = orderSkuJToken.Value("jdPrice"); //sku单价 @@ -817,7 +872,11 @@ namespace BBWY.Server.Business // orderCostDetail.TotalCost - orderCostDetail.DeliveryExpressFreight - // koudian; - orderCostDetail.CalculationSkuGrossProfit(skuShouldPay ?? 0M, pingtaiCoupon ?? 0M, venderFee ?? 0M, platformCommissionRatio); + orderCostDetail.CalculationSkuGrossProfit(skuShouldPay ?? 0M, + skuPingTaiChengDanYouHuiQuan ?? 0M, + skuSuperRedEnvelope ?? 0M, + skuXianPinLeiDongQuan ?? 0M, + skuVenderFee ?? 0M, platformCommissionRatio); insertOrderCostDetailList.Add(orderCostDetail); } } @@ -837,7 +896,7 @@ namespace BBWY.Server.Business if (dbOrder.OrderTotalPrice != 0) orderCost.CalculationOrderProfitAndCost(dbOrder, null); else - orderCost.CalculationOrderProfitAndCost(dbOrder.OrderPayment, dbOrder.PreferentialAmount, dbOrder.FreightPrice, null); + orderCost.CalculationOrderProfitAndCost(actualProductAmount ?? 0M, orderSellerPrice, pingtaiChengDanYouHuiQuan ?? 0M, null); insertOrderCostList.Add(orderCost); #endregion @@ -867,7 +926,9 @@ namespace BBWY.Server.Business orderTotalPrice != dbOrder.OrderTotalPrice || storeOrder != dbOrder.StoreOrder || storeId != dbOrder.StoreId || - (dbOrderTotal != null && dbOrderTotal.TotalPingTaiChengDanYouHuiQuan != dbOrder.PreferentialAmount)) + actualProductAmount != dbOrder.ActualProductAmount || + preferentialAmount != dbOrder.PreferentialAmount || + pingtaiChengDanYouHuiQuan != dbOrder.PingTaiChengDanYouHuiQuan) { var updateSql = fsql.Update(orderId).SetIf(orderState != null && orderState != dbOrder.OrderState, o => o.OrderState, orderState) .SetIf(buyerRemark != dbOrder.BuyerRemark, o => o.BuyerRemark, buyerRemark) @@ -883,8 +944,10 @@ namespace BBWY.Server.Business .SetIf(orderSellerPrice > 0M && dbOrder.IsGift == true, o => o.IsGift, false) .SetIf(storeOrder != dbOrder.StoreOrder, o => o.StoreOrder, storeOrder) .SetIf(storeOrder != dbOrder.StoreOrder, o => o.StorageType, storageType) - .SetIf(dbOrderTotal != null && dbOrderTotal.TotalPingTaiChengDanYouHuiQuan != dbOrder.PreferentialAmount, o => o.PreferentialAmount, dbOrderTotal?.TotalPingTaiChengDanYouHuiQuan) - .SetIf(storeId != dbOrder.StoreId, o => o.StoreId, storeId); + .SetIf(storeId != dbOrder.StoreId, o => o.StoreId, storeId) + .SetIf(actualProductAmount != dbOrder.ActualProductAmount, o => o.ActualProductAmount, actualProductAmount) + .SetIf(preferentialAmount != dbOrder.PreferentialAmount, o => o.PreferentialAmount, preferentialAmount) + .SetIf(pingtaiChengDanYouHuiQuan != dbOrder.PingTaiChengDanYouHuiQuan, o => o.PingTaiChengDanYouHuiQuan, pingtaiChengDanYouHuiQuan); updateOrderList.Add(updateSql); } #endregion diff --git a/BBWY.Server.Business/TestBusiness.cs b/BBWY.Server.Business/TestBusiness.cs index 6c79201e..3069f8bd 100644 --- a/BBWY.Server.Business/TestBusiness.cs +++ b/BBWY.Server.Business/TestBusiness.cs @@ -187,6 +187,7 @@ namespace BBWY.Server.Business fsql.Delete(orderIdList).ExecuteAffrows(); fsql.Delete().Where(on => orderIdList.Contains(on.OrderId)).ExecuteAffrows(); fsql.Delete().Where(op => orderIdList.Contains(op.OrderId)).ExecuteAffrows(); + fsql.Update().Set(osku => osku.ShouldPay, 0).Where(osku => orderIdList.Contains(osku.OrderId)).ExecuteAffrows(); }); foreach (var orderId in orderIdList) @@ -216,15 +217,20 @@ namespace BBWY.Server.Business foreach (var orderSku in currentOrderSkuList) { var ocd = currentOrderCostDetailList.FirstOrDefault(x => x.SkuId == orderSku.SkuId); - //ocd.SkuGrossProfit = ((orderSku.ShouldPay ?? 0M) + (orderSku.Coupon ?? 0M)) * ocd.DeductionQuantity - ocd.TotalCost - ocd.DeliveryExpressFreight; - ocd.CalculationSkuGrossProfit(orderSku.ShouldPay ?? 0M, orderSku.PingTaiChengDanYouHuiQuan ?? 0M, orderSku.VenderFee ?? 0M, shop.PlatformCommissionRatio ?? 0.05M); + + 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(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); - orderCost.CalculationOrderProfitAndCost(order.OrderPayment, + orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M, orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M, orderTotal.TotalVenderFee ?? 0M, currentAfterOrderList); diff --git a/BBWY.Server.Model/Db/Order/Order.cs b/BBWY.Server.Model/Db/Order/Order.cs index e6649953..0fc9fbd0 100644 --- a/BBWY.Server.Model/Db/Order/Order.cs +++ b/BBWY.Server.Model/Db/Order/Order.cs @@ -52,13 +52,13 @@ namespace BBWY.Server.Model.Db public decimal OrderSellerPrice { get; set; } = 0.00M; /// - /// 平台补贴 + /// 优惠金额(订单总价-订单实收货款-用户支付运费) /// [Column(DbType = "decimal(20,2)")] public decimal PreferentialAmount { get; set; } = 0.00M; /// - /// 商家优惠金额(商家承担) + /// 商家优惠金额(商家承担)(废弃) /// [Column(DbType = "decimal(20,2)")] public decimal SellerPreferentialAmount { get; set; } = 0.00M; @@ -185,6 +185,18 @@ namespace BBWY.Server.Model.Db [Column(DbType = "bit")] public bool IsGift { get; set; } = false; + /// + /// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan) + /// + [Column(DbType = "decimal(18, 2)")] + public decimal? ActualProductAmount { get; set; } = 0.00M; + + /// + /// 平台承担优惠券 + /// + [Column(DbType = "decimal(18, 2)")] + public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M; + #region 订单成本 /// /// 平台扣点金额 diff --git a/BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs b/BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs index 6cd6bf12..5e732835 100644 --- a/BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs @@ -72,13 +72,23 @@ namespace BBWY.Server.Model.Dto /// public decimal OrderPayment { get; set; } + /// + /// 订单实收货款 (orderSellerPrice)+平台承担优惠券(PingTaiChengDanYouHuiQuan) + /// + public decimal? ActualProductAmount { get; set; } = 0.00M; + + /// + /// 平台承担优惠券 + /// + public decimal? PingTaiChengDanYouHuiQuan { get; set; } = 0.00M; + /// /// 商品运费(用户付) /// public decimal FreightPrice { get; set; } /// - /// 平台补贴 + /// 优惠金额 订单总价-订单实收货款-用户支付运费 /// public decimal PreferentialAmount { get; set; }