作者 tangxvhui

更新

... ... @@ -203,6 +203,10 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
}
err = m.CurrentBonusStatus.WartPayPartnerBonus(&m)
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err))
}
orderGoods = append(orderGoods, m)
}
newOrder.Goods = orderGoods
... ...
... ... @@ -125,20 +125,23 @@ func (order *OrderBase) Compute() error {
order.OrderCompute.PartnerBonusExpense, _ = partnerBonusExpense.Round(2).Float64()
order.OrderCompute.PartnerBonusHas, _ = partnerBonusHas.Round(2).Float64()
order.OrderCompute.PartnerBonusNot, _ = partnerBonusNot.Round(2).Float64()
order.OrderCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
order.OrderCompute.PlanOrderAmount, _ = planOrderAmount.Round(2).Float64()
order.OrderCompute.PlanOrderCount = planOrderCount
if hasUsePartnerBonus {
order.OrderCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
} else {
order.OrderCompute.UsePartnerBonus = -1
}
if hasUseOrderAmount {
order.OrderCompute.UseOrderAmount, _ = useOrderAmount.Round(2).Float64()
} else {
order.OrderCompute.UseOrderAmount = -1
}
if HasUseOrderCount {
order.OrderCompute.UseOrderCount = useOrderCount
} else {
order.OrderCompute.UseOrderCount = -1
}
return nil
}
... ...
... ... @@ -81,7 +81,7 @@ type OrderGoodBonusHasPay struct{}
var _ OrderGoodBonusStatus = (*OrderGoodBonusHasPay)(nil)
func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error {
func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error {
good.GoodCompute.PartnerBonusExpense = 0
good.GoodCompute.PartnerBonusHas = 0
//初始状态为待支付时 ,合伙人未收分红等于合伙人应收分红(或者调整的)
... ... @@ -93,7 +93,7 @@ func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error {
return nil
}
func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error {
func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error {
//待支付状态转支付时 ,合伙人已收收分红等于合伙人应收分红(或者调整的)
if good.GoodCompute.UsePartnerBonus < 0 {
good.GoodCompute.PartnerBonusHas = good.GoodCompute.PlanPartnerBonus
... ... @@ -101,6 +101,7 @@ func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error
good.GoodCompute.PartnerBonusHas = good.GoodCompute.UsePartnerBonus
}
good.GoodCompute.PartnerBonusExpense = 0
good.GoodCompute.PartnerBonusNot = 0
return nil
}
... ...
... ... @@ -56,6 +56,8 @@ type OrderBase struct {
PartnerBonusNot float64
//合伙人分红支出
PartnerBonusExpense float64
//上一次查看时间 已读情况
LastViewTime time.Time
}
var _ pg.BeforeUpdateHook = (*OrderBase)(nil)
... ...
... ... @@ -17,6 +17,7 @@ type OrderInfoController struct {
////Prepare 重写 BaseController 的Prepare方法
func (c *OrderInfoController) Prepare() {
return
c.BaseController.Prepare()
if ok := c.ValidJWTToken(); !ok {
return
... ...