This commit is contained in:
苏尹岚
2021-03-11 14:42:12 +08:00
parent a391a7b86d
commit a2978a94e5

View File

@@ -1934,8 +1934,8 @@ func UpdateOrderInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID int,
func RefreshOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID, skuID int) (num int64, err error) {
var (
db = dao.GetDB()
shopPrice int64
db = dao.GetDB()
shopPrice, earningPrice int64
)
order, err := partner.CurOrderManager.LoadOrder(vendorOrderID, vendorID)
if order.EarningType != model.EarningTypeQuote {
@@ -1947,8 +1947,11 @@ func RefreshOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID,
return fmt.Errorf("未找到此门店商品!")
}
storeSku := storeSkus[0]
if v.ShopPrice == v.EarningPrice {
v.EarningPrice = int64(math.Round(float64(storeSku.Price) * float64(order.OrderPayPercentage) / 100))
}
v.ShopPrice = int64(storeSku.Price)
dao.UpdateEntity(db, v, "ShopPrice")
dao.UpdateEntity(db, v, "ShopPrice", "EarningPrice")
return err
}
dao.Begin(db)
@@ -1974,9 +1977,11 @@ func RefreshOrderSkuInfo(ctx *jxcontext.Context, vendorOrderID string, vendorID,
}
for _, v := range order.Skus {
shopPrice += v.ShopPrice * int64(v.Count)
earningPrice += v.EarningPrice * int64(v.Count)
}
order.ShopPrice = shopPrice
num, err = dao.UpdateEntity(db, order, "ShopPrice")
order.EarningPrice = earningPrice
num, err = dao.UpdateEntity(db, order, "ShopPrice", "EarningPrice")
dao.Commit(db)
return num, err
}