fix: 没有收益拆单报错3

master
howell 3 years ago
parent 29436ce5e1
commit f354e4dcfa

@ -521,7 +521,9 @@ func orderCreate() {
goodsTotalCommission := decimal.Zero
actualAmount := decimal.Zero
for _, v := range orderSku {
actualAmount = actualAmount.Add(v.GoodsAmount).Add(unitMap[v.SkuId])
actualAmount = actualAmount.Add(v.GoodsAmount).Add(unitMap[v.SkuId]).Sub(v.CoinAmount)
coinTotal = coinTotal.Add(v.CoinAmount)
goodsTotalAmount = v.GoodsAmount
}
orderNew := manage.RecookOrderInfoModel{

@ -2,6 +2,7 @@ package manage
import (
"recook/internal/define"
"recook/internal/model/order"
"recook/internal/model/user"
"recook/internal/v2/lib/db"
"recook/internal/v2/model/gys/enterprise"
@ -124,6 +125,29 @@ func (r *RecookOrderGoodsDetailModel) TableName() string {
return "recook_order_goods_detail"
}
func (r *RecookOrderGoodsDetailModel) GetSelfProfit(level int) decimal.Decimal {
base := r.GetBase()
switch level {
case 0:
return decimal.Zero
case 1:
self := base.Mul(order.Self.GetProfit()).Round(2)
brand := base.Mul(order.Brand.GetProfit()).Round(2)
return self.Add(brand)
case 2:
// 店铺买
self := base.Mul(order.Self.GetProfit()).Round(2)
brand := base.Mul(order.Brand.GetProfit()).Round(2)
shop := base.Mul(order.Shop.GetProfit()).Round(2)
return self.Add(brand).Add(shop)
case 10:
// 子公司 100%自购
return base.Mul(order.All.GetProfit())
default:
return decimal.Zero
}
}
func (r *RecookOrderGoodsDetailModel) GetBase() decimal.Decimal {
cost := r.PurchasePrice.Mul(decimal.NewFromFloat(1.03))
base := r.UnitPrice.Sub(cost).Mul(decimal.NewFromFloat32(define.Coefficient))

Loading…
Cancel
Save