|
|
@ -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
|
|
|
|