作者 tangxvhui

更新

@@ -86,18 +86,24 @@ func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error @@ -86,18 +86,24 @@ func (waitPay OrderGoodBonusWaitPay) WartPayPartnerBonus(good *OrderGood) error
86 good.GoodCompute.PartnerBonusHas = 0 86 good.GoodCompute.PartnerBonusHas = 0
87 //初始状态为待支付时 ,合伙人未收分红等于合伙人应收分红(或者调整的) 87 //初始状态为待支付时 ,合伙人未收分红等于合伙人应收分红(或者调整的)
88 if good.UseGoodNumber < 0 { 88 if good.UseGoodNumber < 0 {
  89 + //数量没有调整,未收等于预计应收分红
89 good.GoodCompute.PartnerBonusNot = good.GoodCompute.PlanPartnerBonus 90 good.GoodCompute.PartnerBonusNot = good.GoodCompute.PlanPartnerBonus
90 } else { 91 } else {
  92 + //数量有调整,未收等于调整后的应收分红
91 good.GoodCompute.PartnerBonusNot = good.GoodCompute.UsePartnerBonus 93 good.GoodCompute.PartnerBonusNot = good.GoodCompute.UsePartnerBonus
92 } 94 }
93 return nil 95 return nil
94 } 96 }
95 97
96 func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error { 98 func (waitPay OrderGoodBonusWaitPay) PayPartnerBonus(good *OrderGood) error {
97 - //待支付状态转支付时 ,合伙人已收收分红等于合伙人应收分红(或者调整的)  
98 - if good.GoodCompute.UsePartnerBonus < 0 { 99 + //待支付状态转支付时
  100 + //合伙人已收收分红等于合伙人应收分红(或者调整的)
  101 + //计算已支付
  102 + if good.UseGoodNumber < 0 {
  103 + //数量没有调整,已收等于预计应收分红
99 good.GoodCompute.PartnerBonusHas = good.GoodCompute.PlanPartnerBonus 104 good.GoodCompute.PartnerBonusHas = good.GoodCompute.PlanPartnerBonus
100 } else { 105 } else {
  106 + //数量有调整,已收等于调整后的应收分红
101 good.GoodCompute.PartnerBonusHas = good.GoodCompute.UsePartnerBonus 107 good.GoodCompute.PartnerBonusHas = good.GoodCompute.UsePartnerBonus
102 } 108 }
103 good.GoodCompute.PartnerBonusExpense = 0 109 good.GoodCompute.PartnerBonusExpense = 0
@@ -111,6 +117,7 @@ func (hasPay OrderGoodBonusHasPay) PayPartnerBonus(good *OrderGood) error { @@ -111,6 +117,7 @@ func (hasPay OrderGoodBonusHasPay) PayPartnerBonus(good *OrderGood) error {
111 //计算分红支出 117 //计算分红支出
112 //分红支出=应收分红(有出现调整,则取调整后的应收分红)和已收分红的差额 118 //分红支出=应收分红(有出现调整,则取调整后的应收分红)和已收分红的差额
113 if good.UseGoodNumber >= 0 { 119 if good.UseGoodNumber >= 0 {
  120 + //有数量调整,分红支出等于 已支付分红-调整后的已收分红
114 good.GoodCompute.PartnerBonusExpense = good.GoodCompute.PartnerBonusHas - good.GoodCompute.UsePartnerBonus 121 good.GoodCompute.PartnerBonusExpense = good.GoodCompute.PartnerBonusHas - good.GoodCompute.UsePartnerBonus
115 } 122 }
116 return nil 123 return nil
@@ -135,11 +142,12 @@ func NewOrderGood() OrderGood { @@ -135,11 +142,12 @@ func NewOrderGood() OrderGood {
135 142
136 //Compute 数据汇总核算 143 //Compute 数据汇总核算
137 func (good *OrderGood) Compute() error { 144 func (good *OrderGood) Compute() error {
  145 + //计算预计货品总值
  146 + //计算预计合伙人分红
138 price := decimal.NewFromFloat(good.Price) 147 price := decimal.NewFromFloat(good.Price)
139 planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber 148 planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber
140 //price*useGoodNumber 149 //price*useGoodNumber
141 planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*planGoodNumber*PartnerBonusPercent 150 planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*planGoodNumber*PartnerBonusPercent
142 -  
143 good.GoodCompute.PlanAmount, _ = planamount.Round(2).Float64() 151 good.GoodCompute.PlanAmount, _ = planamount.Round(2).Float64()
144 good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64() 152 good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).Float64()
145 if good.UseGoodNumber < 0 { 153 if good.UseGoodNumber < 0 {
@@ -147,6 +155,8 @@ func (good *OrderGood) Compute() error { @@ -147,6 +155,8 @@ func (good *OrderGood) Compute() error {
147 good.GoodCompute.UsePartnerBonus = -1 155 good.GoodCompute.UsePartnerBonus = -1
148 good.GoodCompute.UseAmount = -1 156 good.GoodCompute.UseAmount = -1
149 } else { 157 } else {
  158 + //计算调整后的货品总值
  159 + //计算调整后的合伙人分红
150 useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber 160 useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber
151 usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*useGoodNumber*PartnerBonusPercent 161 usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)) //price*useGoodNumber*PartnerBonusPercent
152 good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64() 162 good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).Float64()
@@ -635,3 +635,26 @@ func (c *OrderInfoController) OrderDisable() { @@ -635,3 +635,26 @@ func (c *OrderInfoController) OrderDisable() {
635 c.ResponseData(nil) 635 c.ResponseData(nil)
636 return 636 return
637 } 637 }
  638 +
  639 +//RemoveOrderReal 删除意向订单
  640 +func (c *OrderInfoController) RemoveOrderReal() {
  641 + type Parameter struct {
  642 + Id int64 `json:"id"`
  643 + }
  644 + var (
  645 + param Parameter
  646 + err error
  647 + )
  648 + if err = c.BindJsonData(&param); err != nil {
  649 + logs.Error(err)
  650 + c.ResponseError(errors.New("json数据解析失败"))
  651 + return
  652 + }
  653 + orderSrv := orderService.NewOrderInfoService(nil)
  654 + err = orderSrv.DeleteOrder(param.Id)
  655 + if err != nil {
  656 + c.ResponseError(err)
  657 + return
  658 + }
  659 + c.ResponseData(nil)
  660 +}
@@ -41,6 +41,8 @@ func init() { @@ -41,6 +41,8 @@ func init() {
41 beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"), 41 beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"),
42 beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), 42 beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"),
43 beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), 43 beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"),
  44 + beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"),
  45 +
44 beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), 46 beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"),
45 beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), 47 beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"),
46 ), 48 ),