Browse Source

C端改公式

AddValidOverTime
shanji 2 years ago
parent
commit
0d2de21239
  1. 2
      BBWY.Client/GlobalContext.cs
  2. 10
      BBWY.Client/Models/APIModel/Response/Order/OrderResponse.cs
  3. 14
      BBWY.Client/Models/Order/Order.cs
  4. 14
      BBWY.Client/Views/Order/OrderListControl.xaml
  5. 24
      BBWY.JDSDK/Request/PopOrderQueryCouponDetaiRequest.cs
  6. 8
      BBWY.JDSDK/Response/PopOrderQueryCouponDetaiResponse.cs
  7. 31
      BBWY.Server.Business/Extensions/OrderCostExtension.cs
  8. 10
      BBWY.Server.Business/Order/OrderBusiness.cs
  9. 6
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  10. 2
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  11. 101
      BBWY.Server.Business/Sync/OrderSyncBusiness.cs
  12. 12
      BBWY.Server.Business/TestBusiness.cs
  13. 16
      BBWY.Server.Model/Db/Order/Order.cs
  14. 12
      BBWY.Server.Model/Dto/Response/Order/OrderResponse.cs

2
BBWY.Client/GlobalContext.cs

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

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

@ -64,6 +64,16 @@ namespace BBWY.Client.Models
/// </summary>
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>

14
BBWY.Client/Models/Order/Order.cs

@ -82,6 +82,16 @@ namespace BBWY.Client.Models
/// </summary>
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>
@ -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.));
}
}

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

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

24
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<PopOrderQueryCouponDetaiResponse>
{
public override string ApiName => "jingdong.pop.order.queryCouponDetai";
public string orderId { get; set; }
public bool? queryPromoFlag { get; set; }
protected override void PrepareParam(IDictionary<string, object> paramters)
{
paramters.Add("orderId", orderId);
if (queryPromoFlag != null)
paramters.Add("queryPromoFlag", queryPromoFlag);
}
}
}

8
BBWY.JDSDK/Response/PopOrderQueryCouponDetaiResponse.cs

@ -0,0 +1,8 @@
using Jd.Api;
namespace BBWY.JDSDK.Response
{
public class PopOrderQueryCouponDetaiResponse : JdResponse
{
}
}

31
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<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.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
/// </summary>
/// <param name="ocd"></param>
/// <param name="skuShouldPay"></param>
/// <param name="skuPingtaibutie"></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 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;
}
}

10
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);
}

6
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)

2
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);

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

@ -305,7 +305,7 @@ namespace BBWY.Server.Business
var orderCouponDetailResponse = JsonConvert.DeserializeObject<ApiResponse<JToken>>(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<int>("type") == 6)
xianPinLeiDongQuan += discountType.Value<decimal>("amount");
}
}
}
}
if (xianPinLeiDongQuan == 0M)
xianPinLeiDongQuan = oskuJtoken.Value<decimal>("xianPinLeiDongQuan");
var oskuCF = new OrderSkuCFDetail()
{
OrderId = orderId,
@ -420,7 +441,7 @@ namespace BBWY.Server.Business
TaxFee = oskuJtoken.Value<decimal>("taxFee"),
TuiHuanHuoWuYou = oskuJtoken.Value<decimal>("tuiHuanHuoWuYou"),
VenderFee = oskuJtoken.Value<decimal>("venderFee"),
XianPinLeiDongQuan = oskuJtoken.Value<decimal>("xianPinLeiDongQuan"),
XianPinLeiDongQuan = xianPinLeiDongQuan, //数据不齐
XianPinLeiJingQuan = oskuJtoken.Value<decimal>("xianPinLeiJingQuan"),
ZhiFuYingXiaoYouHui = oskuJtoken.Value<decimal>("zhiFuYingXiaoYouHui")
};
@ -448,9 +469,18 @@ namespace BBWY.Server.Business
var storeOrder = orderJToken.Value<string>("storeOrder") ?? string.Empty;
var storeId = orderJToken.Value<string>("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<decimal>("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<Order>(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

12
BBWY.Server.Business/TestBusiness.cs

@ -187,6 +187,7 @@ namespace BBWY.Server.Business
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();
});
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<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);
orderCost.CalculationOrderProfitAndCost(order.OrderPayment,
orderCost.CalculationOrderProfitAndCost(order.ActualProductAmount ?? 0M,
orderTotal.TotalPingTaiChengDanYouHuiQuan ?? 0M,
orderTotal.TotalVenderFee ?? 0M,
currentAfterOrderList);

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

@ -52,13 +52,13 @@ namespace BBWY.Server.Model.Db
public decimal OrderSellerPrice { get; set; } = 0.00M;
/// <summary>
/// 平台补贴
/// 优惠金额(订单总价-订单实收货款-用户支付运费)
/// </summary>
[Column(DbType = "decimal(20,2)")]
public decimal PreferentialAmount { get; set; } = 0.00M;
/// <summary>
/// 商家优惠金额(商家承担)
/// 商家优惠金额(商家承担)(废弃)
/// </summary>
[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;
/// <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 订单成本
/// <summary>
/// 平台扣点金额

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

@ -72,13 +72,23 @@ namespace BBWY.Server.Model.Dto
/// </summary>
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>
public decimal FreightPrice { get; set; }
/// <summary>
/// 平台补贴
/// 优惠金额 订单总价-订单实收货款-用户支付运费
/// </summary>
public decimal PreferentialAmount { get; set; }

Loading…
Cancel
Save