|
@ -23,22 +23,31 @@ namespace BBWY.Server.Business |
|
|
{ |
|
|
{ |
|
|
private ILogger logger; |
|
|
private ILogger logger; |
|
|
private IFreeSql fsql; |
|
|
private IFreeSql fsql; |
|
|
private IDictionary<Enums.Platform, Action<JArray, long, string, string, string, string>> syncOrderMethodDic; |
|
|
private IDictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>> syncOrderMethodDic; |
|
|
private IIdGenerator idGenerator; |
|
|
private IIdGenerator idGenerator; |
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
private TaskSchedulerManager taskSchedulerManager; |
|
|
private MDSBusiness mdsBusiness; |
|
|
private MDSBusiness mdsBusiness; |
|
|
|
|
|
private FreeSqlMultiDBManager freeSqlMultiDBManager; |
|
|
public OrderBusiness(RestApiService restApiService, ILogger logger, IFreeSql fsql, IIdGenerator idGenerator, IOptions<GlobalConfig> options, TaskSchedulerManager taskSchedulerManager, MDSBusiness mdsBusiness) : base(restApiService, options) |
|
|
|
|
|
|
|
|
public OrderBusiness(RestApiService restApiService, |
|
|
|
|
|
ILogger logger, |
|
|
|
|
|
IFreeSql fsql, |
|
|
|
|
|
IIdGenerator idGenerator, |
|
|
|
|
|
IOptions<GlobalConfig> options, |
|
|
|
|
|
TaskSchedulerManager taskSchedulerManager, |
|
|
|
|
|
MDSBusiness mdsBusiness, |
|
|
|
|
|
FreeSqlMultiDBManager freeSqlMultiDBManager) : base(restApiService, options) |
|
|
{ |
|
|
{ |
|
|
this.logger = logger; |
|
|
this.logger = logger; |
|
|
this.fsql = fsql; |
|
|
this.fsql = fsql; |
|
|
this.idGenerator = idGenerator; |
|
|
this.idGenerator = idGenerator; |
|
|
this.taskSchedulerManager = taskSchedulerManager; |
|
|
this.taskSchedulerManager = taskSchedulerManager; |
|
|
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, long, string, string, string, string>>() |
|
|
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>>() |
|
|
{ |
|
|
{ |
|
|
{ Enums.Platform.京东, SyncJDOrder } |
|
|
{ Enums.Platform.京东, SyncJDOrder } |
|
|
}; |
|
|
}; |
|
|
this.mdsBusiness = mdsBusiness; |
|
|
this.mdsBusiness = mdsBusiness; |
|
|
|
|
|
this.freeSqlMultiDBManager = freeSqlMultiDBManager; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public OrderListResponse GetOrderList(SearchOrderRequest searchOrderRequest) |
|
|
public OrderListResponse GetOrderList(SearchOrderRequest searchOrderRequest) |
|
@ -457,11 +466,13 @@ namespace BBWY.Server.Business |
|
|
|
|
|
|
|
|
if (orderCost == null) |
|
|
if (orderCost == null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (autoCalculationCostRequest.PlatformCommissionRatio == 0M) |
|
|
|
|
|
autoCalculationCostRequest.PlatformCommissionRatio = 0.05M; |
|
|
#region 计算成本
|
|
|
#region 计算成本
|
|
|
orderCost = new OrderCost() |
|
|
orderCost = new OrderCost() |
|
|
{ |
|
|
{ |
|
|
OrderId = autoCalculationCostRequest.OrderId, |
|
|
OrderId = autoCalculationCostRequest.OrderId, |
|
|
PlatformCommissionRatio = 0.05M, |
|
|
PlatformCommissionRatio = autoCalculationCostRequest.PlatformCommissionRatio, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
Profit = 0, |
|
|
Profit = 0, |
|
|
PurchaseAmount = orderCostPurchaseAmount, |
|
|
PurchaseAmount = orderCostPurchaseAmount, |
|
@ -525,10 +536,12 @@ namespace BBWY.Server.Business |
|
|
var orderCost = fsql.Select<OrderCost>(manualCalculationCostRequest.OrderId).ToOne(); |
|
|
var orderCost = fsql.Select<OrderCost>(manualCalculationCostRequest.OrderId).ToOne(); |
|
|
if (orderCost == null) |
|
|
if (orderCost == null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (manualCalculationCostRequest.PlatformCommissionRatio == 0M) |
|
|
|
|
|
manualCalculationCostRequest.PlatformCommissionRatio = 0.05M; |
|
|
orderCost = new OrderCost() |
|
|
orderCost = new OrderCost() |
|
|
{ |
|
|
{ |
|
|
OrderId = manualCalculationCostRequest.OrderId, |
|
|
OrderId = manualCalculationCostRequest.OrderId, |
|
|
PlatformCommissionRatio = 0.05M, |
|
|
PlatformCommissionRatio = manualCalculationCostRequest.PlatformCommissionRatio, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
Profit = 0, |
|
|
Profit = 0, |
|
|
PurchaseAmount = manualCalculationCostRequest.PurchaseCost, |
|
|
PurchaseAmount = manualCalculationCostRequest.PurchaseCost, |
|
@ -607,10 +620,12 @@ namespace BBWY.Server.Business |
|
|
var orderCost = fsql.Select<OrderCost>(sdCalculationCostRequest.OrderId).ToOne(); |
|
|
var orderCost = fsql.Select<OrderCost>(sdCalculationCostRequest.OrderId).ToOne(); |
|
|
if (orderCost == null) |
|
|
if (orderCost == null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (sdCalculationCostRequest.PlatformCommissionRatio == 0M) |
|
|
|
|
|
sdCalculationCostRequest.PlatformCommissionRatio = 0.05M; |
|
|
orderCost = new OrderCost() |
|
|
orderCost = new OrderCost() |
|
|
{ |
|
|
{ |
|
|
OrderId = sdCalculationCostRequest.OrderId, |
|
|
OrderId = sdCalculationCostRequest.OrderId, |
|
|
PlatformCommissionRatio = 0.05M, |
|
|
PlatformCommissionRatio = sdCalculationCostRequest.PlatformCommissionRatio, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
Profit = 0, |
|
|
Profit = 0, |
|
|
DeliveryExpressFreight = sdCalculationCostRequest.DeliveryExpressFreight, |
|
|
DeliveryExpressFreight = sdCalculationCostRequest.DeliveryExpressFreight, |
|
@ -721,15 +736,18 @@ namespace BBWY.Server.Business |
|
|
{ |
|
|
{ |
|
|
var preferentialAmount = fsql.Select<OrderCoupon>().Where(oc => oc.OrderId == relationPurchaseOrderRequest.OrderDropShipping.OrderId) |
|
|
var preferentialAmount = fsql.Select<OrderCoupon>().Where(oc => oc.OrderId == relationPurchaseOrderRequest.OrderDropShipping.OrderId) |
|
|
.ToAggregate(g => g.Sum(g.Key.CouponPrice)); |
|
|
.ToAggregate(g => g.Sum(g.Key.CouponPrice)); |
|
|
|
|
|
|
|
|
|
|
|
if (relationPurchaseOrderRequest.PlatformCommissionRatio == 0M) |
|
|
|
|
|
relationPurchaseOrderRequest.PlatformCommissionRatio = 0.05M; |
|
|
orderCost = new OrderCost() |
|
|
orderCost = new OrderCost() |
|
|
{ |
|
|
{ |
|
|
OrderId = relationPurchaseOrderRequest.OrderDropShipping.OrderId, |
|
|
OrderId = relationPurchaseOrderRequest.OrderDropShipping.OrderId, |
|
|
CreateTime = DateTime.Now, |
|
|
CreateTime = DateTime.Now, |
|
|
DeliveryExpressFreight = relationPurchaseOrderRequest.OrderDropShipping.DeliveryFreight, |
|
|
DeliveryExpressFreight = relationPurchaseOrderRequest.OrderDropShipping.DeliveryFreight, |
|
|
PlatformCommissionRatio = 0.05M, |
|
|
PlatformCommissionRatio = relationPurchaseOrderRequest.PlatformCommissionRatio, |
|
|
SDCommissionAmount = 0, |
|
|
SDCommissionAmount = 0, |
|
|
PurchaseAmount = relationPurchaseOrderRequest.RelationPurchaseOrderSkuList.Sum(s => s.SingleSkuAmount * s.Quantity), |
|
|
PurchaseAmount = relationPurchaseOrderRequest.RelationPurchaseOrderSkuList.Sum(s => s.SingleSkuAmount * s.Quantity), |
|
|
PlatformCommissionAmount = dbOrder.OrderSellerPrice * 0.05M, |
|
|
PlatformCommissionAmount = dbOrder.OrderSellerPrice * relationPurchaseOrderRequest.PlatformCommissionRatio, |
|
|
PreferentialAmount = preferentialAmount, |
|
|
PreferentialAmount = preferentialAmount, |
|
|
IsManualEdited = true |
|
|
IsManualEdited = true |
|
|
}; |
|
|
}; |
|
@ -883,7 +901,7 @@ namespace BBWY.Server.Business |
|
|
if (orderListResponse.Data == null || orderListResponse.Data.Count == 0) |
|
|
if (orderListResponse.Data == null || orderListResponse.Data.Count == 0) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
syncOrderMethodDic[shop.Platform](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken); |
|
|
syncOrderMethodDic[shop.Platform](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M); |
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -948,8 +966,9 @@ namespace BBWY.Server.Business |
|
|
}, System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler); |
|
|
}, System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken) |
|
|
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken, decimal platformCommissionRatio) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var orderTokenList = orderTokenJArray.Where(o => o.Value<decimal>("orderTotalPrice") != 0); |
|
|
var orderTokenList = orderTokenJArray.Where(o => o.Value<decimal>("orderTotalPrice") != 0); |
|
|
|
|
|
|
|
|
var interfaceOrderIdList = orderTokenList.Select(orderJToken => orderJToken.Value<string>("orderId")); |
|
|
var interfaceOrderIdList = orderTokenList.Select(orderJToken => orderJToken.Value<string>("orderId")); |
|
@ -1274,7 +1293,7 @@ namespace BBWY.Server.Business |
|
|
orderCost = new OrderCost() |
|
|
orderCost = new OrderCost() |
|
|
{ |
|
|
{ |
|
|
OrderId = orderId, |
|
|
OrderId = orderId, |
|
|
PlatformCommissionRatio = 0.05M, |
|
|
PlatformCommissionRatio = platformCommissionRatio, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
PreferentialAmount = dbOrder.PreferentialAmount, |
|
|
Profit = 0, |
|
|
Profit = 0, |
|
|
PurchaseAmount = orderCostPurchaseAmount, |
|
|
PurchaseAmount = orderCostPurchaseAmount, |
|
|