|
|
@ -744,21 +744,27 @@ namespace BBWYB.Server.Business |
|
|
|
throw new BusinessException("未查询到订单"); |
|
|
|
if (order.OrderState != Enums.OrderState.待核算) |
|
|
|
throw new BusinessException("订单状态不正确,只有待核算的订单才允许核算"); |
|
|
|
var orderCost = fsql.Select<OrderCost>(orderId).ToOne(); |
|
|
|
if (orderCost == null) |
|
|
|
throw new BusinessException("未查询到订单成本"); |
|
|
|
if (Math.Abs(orderCost.Profit ?? 0) > 1M) |
|
|
|
throw new BusinessException("订单利润绝对值不能大于1"); |
|
|
|
//var orderCost = fsql.Select<OrderCost>(orderId).ToOne();
|
|
|
|
//if (orderCost == null)
|
|
|
|
// throw new BusinessException("未查询到订单成本");
|
|
|
|
//if (Math.Abs(orderCost.Profit ?? 0) > 1M)
|
|
|
|
// throw new BusinessException("订单利润绝对值不能大于1");
|
|
|
|
|
|
|
|
var orderSkuCostList = fsql.Select<OrderSkuCost>().Where(o => o.OrderId == orderId).ToList(); |
|
|
|
if (orderSkuCostList.Count() == 0) |
|
|
|
throw new BusinessException("未查询到订单sku成本"); |
|
|
|
if (orderSkuCostList.Any(osc => Math.Abs(osc.Profit ?? 0) > 1)) |
|
|
|
throw new BusinessException("订单sku利润绝对值不能大于1"); |
|
|
|
|
|
|
|
fsql.Transaction(() => |
|
|
|
{ |
|
|
|
fsql.Update<Order>(orderId).Set(o => o.OrderState, Enums.OrderState.已完成).ExecuteAffrows(); |
|
|
|
fsql.Update<TimeLimitTask>().Set(t => t.CompletionTime, DateTime.Now) |
|
|
|
.Set(t => t.IsTimely == (DateTime.Now < t.ExpirationTime ? true : false)) |
|
|
|
.Where(t => t.OrderId == orderId) |
|
|
|
.Where(t => t.CompletionTime == null) |
|
|
|
.Where(t => t.TaskType == Enums.TimeLimitTaskType.待核算任务).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
{ |
|
|
|
fsql.Update<Order>(orderId).Set(o => o.OrderState, Enums.OrderState.已完成).ExecuteAffrows(); |
|
|
|
fsql.Update<TimeLimitTask>().Set(t => t.CompletionTime, DateTime.Now) |
|
|
|
.Set(t => t.IsTimely == (DateTime.Now < t.ExpirationTime ? true : false)) |
|
|
|
.Where(t => t.OrderId == orderId) |
|
|
|
.Where(t => t.CompletionTime == null) |
|
|
|
.Where(t => t.TaskType == Enums.TimeLimitTaskType.待核算任务).ExecuteAffrows(); |
|
|
|
}); |
|
|
|
|
|
|
|
SendPurchaseOrderStateToC(orderId, Enums.OrderState.已完成); |
|
|
|
} |
|
|
|