刷新结算价加上拆分

This commit is contained in:
苏尹岚
2020-05-06 17:02:29 +08:00
parent 81a27959ef
commit 6f266fdf23

View File

@@ -738,6 +738,26 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
}
}()
for _, value := range order.Skus {
storeID := 0
if order.StoreID == 0 {
storeID = order.JxStoreID
} else {
storeID = order.StoreID
}
result, _ := dao.GetEffectiveActStoreSkuInfo(db, 0, nil, 0, []int{storeID}, []int{value.SkuID}, order.OrderCreatedAt, order.OrderCreatedAt)
if len(result) > 0 {
if result[0].EarningPrice != 0 {
sku := value
sku.Count = value.Count - 1
value.Count = 1
if value.ShopPrice < value.SalePrice {
sku.EarningPrice = value.ShopPrice
} else {
sku.EarningPrice = value.SalePrice
}
order.Skus = append(order.Skus, sku)
}
}
if _, err = dao.UpdateEntity(db, value, "EarningPrice", "StoreSubID"); err != nil {
return nil, err
}