|
1
|
package domain
|
1
|
package domain
|
|
2
|
|
2
|
|
|
3
|
-import (
|
|
|
|
4
|
- "errors"
|
|
|
|
5
|
- "fmt"
|
|
|
|
6
|
-)
|
|
|
|
7
|
-
|
|
|
|
8
|
//类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红
|
3
|
//类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红
|
|
9
|
//因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来
|
4
|
//因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来
|
|
10
|
|
5
|
|
|
11
|
// OrderGoodWithBestshopBonusStatus 支付状态
|
6
|
// OrderGoodWithBestshopBonusStatus 支付状态
|
|
12
|
-type OrderGoodWithBestshopBonusStatus interface {
|
|
|
|
13
|
- OrderGoodBonusStatus
|
|
|
|
14
|
- UpdateOrderGoodNumber(good *OrderGood, number int) error
|
|
|
|
15
|
- UpdatePertnerBonusPercent(good *OrderGood, percent float64) error
|
|
|
|
16
|
-}
|
|
|
|
17
|
-
|
|
|
|
18
|
-//OrderGoodWithBestshop 处理订单中商品的分红相关数据
|
|
|
|
19
|
-type OrderGoodWithBestshop struct {
|
|
|
|
20
|
- currentBonusStatus OrderGoodWithBestshopBonusStatus
|
|
|
|
21
|
-}
|
|
|
|
22
|
-
|
|
|
|
23
|
-func (o *OrderGoodWithBestshop) UpdateBonusByGoodNumber(good *OrderGood, number int) error {
|
|
|
|
24
|
- o.reset(good)
|
|
|
|
25
|
- if good.PlanGoodNumber < number {
|
|
|
|
26
|
- return fmt.Errorf("修改商品数量的值不能大于初始值%d", good.PlanGoodNumber)
|
|
|
|
27
|
- }
|
|
|
|
28
|
- err := o.currentBonusStatus.UpdateOrderGoodNumber(good, number)
|
|
|
|
29
|
- return err
|
|
|
|
30
|
-}
|
|
|
|
31
|
-
|
|
|
|
32
|
-func (o *OrderGoodWithBestshop) UpdateBonusByPertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
33
|
- o.reset(good)
|
|
|
|
34
|
- err := o.currentBonusStatus.UpdatePertnerBonusPercent(good, percent)
|
|
|
|
35
|
- return err
|
|
|
|
36
|
-}
|
|
|
|
37
|
-
|
|
|
|
38
|
-func (o *OrderGoodWithBestshop) PayPartnerBonus(good *OrderGood) error {
|
|
|
|
39
|
- o.currentBonusStatus = OrderGoodBonusBestshopHasPay{}
|
|
|
|
40
|
- err := good.Compute()
|
|
|
|
41
|
- if err != nil {
|
|
|
|
42
|
- return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
43
|
- }
|
|
|
|
44
|
- err = good.CurrentBonusStatus.PayPartnerBonus(good)
|
|
|
|
45
|
- return err
|
|
|
|
46
|
-}
|
|
|
|
47
|
-
|
|
|
|
48
|
-func (o *OrderGoodWithBestshop) reset(good *OrderGood) {
|
|
|
|
49
|
- switch good.BonusStatus {
|
|
|
|
50
|
- case OrderGoodWaitPay:
|
|
|
|
51
|
- o.currentBonusStatus = OrderGoodBonusBestshopWaitPay{}
|
|
|
|
52
|
- case OrderGoodHasPay:
|
|
|
|
53
|
- o.currentBonusStatus = OrderGoodBonusBestshopHasPay{}
|
|
|
|
54
|
- }
|
|
|
|
55
|
- return
|
|
|
|
56
|
-}
|
|
|
|
57
|
-
|
|
|
|
58
|
-//OrderGoodBonusBestshopWaitPay 货品支付状态:待支付
|
|
|
|
59
|
-type OrderGoodBonusBestshopWaitPay struct {
|
|
|
|
60
|
- OrderGoodBonusWaitPay
|
|
|
|
61
|
-}
|
|
|
|
62
|
-
|
|
|
|
63
|
-var _ OrderGoodWithBestshopBonusStatus = (*OrderGoodBonusBestshopWaitPay)(nil)
|
|
|
|
64
|
-
|
|
|
|
65
|
-func (waitPay OrderGoodBonusBestshopWaitPay) UpdateOrderGoodNumber(good *OrderGood, number int) error {
|
|
|
|
66
|
- good.UseGoodNumber = number
|
|
|
|
67
|
- //待支付状态计算
|
|
|
|
68
|
- err := good.Compute()
|
|
|
|
69
|
- if err != nil {
|
|
|
|
70
|
- return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
71
|
- }
|
|
|
|
72
|
- err = good.CurrentBonusStatus.WartPayPartnerBonus(good)
|
|
|
|
73
|
- return err
|
|
|
|
74
|
-}
|
|
|
|
75
|
-
|
|
|
|
76
|
-func (waitPay OrderGoodBonusBestshopWaitPay) UpdatePertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
77
|
- good.PartnerBonusPercent = percent
|
|
|
|
78
|
- //待支付状态计算
|
|
|
|
79
|
- err := good.Compute()
|
|
|
|
80
|
- if err != nil {
|
|
|
|
81
|
- return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
82
|
- }
|
|
|
|
83
|
- err = good.CurrentBonusStatus.WartPayPartnerBonus(good)
|
|
|
|
84
|
- return err
|
|
|
|
85
|
-}
|
|
|
|
86
|
-
|
|
|
|
87
|
-//OrderGoodBonusBestshopHasPay 货品支付状态:已支付
|
|
|
|
88
|
-type OrderGoodBonusBestshopHasPay struct {
|
|
|
|
89
|
- OrderGoodBonusHasPay
|
|
|
|
90
|
-}
|
|
|
|
91
|
-
|
|
|
|
92
|
-var _ OrderGoodWithBestshopBonusStatus = (*OrderGoodBonusBestshopHasPay)(nil)
|
|
|
|
93
|
-
|
|
|
|
94
|
-func (hasPay OrderGoodBonusBestshopHasPay) UpdateOrderGoodNumber(good *OrderGood, number int) error {
|
|
|
|
95
|
- return errors.New("已支付分红的货品订单,不能修改货品数量")
|
|
|
|
96
|
-}
|
|
|
|
97
|
-
|
|
|
|
98
|
-func (hasPay OrderGoodBonusBestshopHasPay) UpdatePertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
99
|
- return errors.New("已支付分红的货品订单,不能修改合伙人分红比例")
|
|
|
|
100
|
-} |
7
|
+// type OrderGoodWithBestshopBonusStatus interface {
|
|
|
|
8
|
+// OrderGoodBonusStatus
|
|
|
|
9
|
+// UpdateOrderGoodNumber(good *OrderGood, number int) error
|
|
|
|
10
|
+// UpdatePertnerBonusPercent(good *OrderGood, percent float64) error
|
|
|
|
11
|
+// }
|
|
|
|
12
|
+
|
|
|
|
13
|
+// //OrderGoodWithBestshop 处理订单中商品的分红相关数据
|
|
|
|
14
|
+// type OrderGoodWithBestshop struct {
|
|
|
|
15
|
+// currentBonusStatus OrderGoodWithBestshopBonusStatus
|
|
|
|
16
|
+// }
|
|
|
|
17
|
+
|
|
|
|
18
|
+// func (o *OrderGoodWithBestshop) UpdateBonusByGoodNumber(good *OrderGood, number int) error {
|
|
|
|
19
|
+// o.reset(good)
|
|
|
|
20
|
+// if good.PlanGoodNumber < number {
|
|
|
|
21
|
+// return fmt.Errorf("修改商品数量的值不能大于初始值%d", good.PlanGoodNumber)
|
|
|
|
22
|
+// }
|
|
|
|
23
|
+// err := o.currentBonusStatus.UpdateOrderGoodNumber(good, number)
|
|
|
|
24
|
+// return err
|
|
|
|
25
|
+// }
|
|
|
|
26
|
+
|
|
|
|
27
|
+// func (o *OrderGoodWithBestshop) UpdateBonusByPertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
28
|
+// o.reset(good)
|
|
|
|
29
|
+// err := o.currentBonusStatus.UpdatePertnerBonusPercent(good, percent)
|
|
|
|
30
|
+// return err
|
|
|
|
31
|
+// }
|
|
|
|
32
|
+
|
|
|
|
33
|
+// func (o *OrderGoodWithBestshop) PayPartnerBonus(good *OrderGood) error {
|
|
|
|
34
|
+// o.currentBonusStatus = OrderGoodBonusBestshopHasPay{}
|
|
|
|
35
|
+// err := good.Compute()
|
|
|
|
36
|
+// if err != nil {
|
|
|
|
37
|
+// return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
38
|
+// }
|
|
|
|
39
|
+// err = good.CurrentBonusStatus.PayPartnerBonus(good)
|
|
|
|
40
|
+// return err
|
|
|
|
41
|
+// }
|
|
|
|
42
|
+
|
|
|
|
43
|
+// func (o *OrderGoodWithBestshop) reset(good *OrderGood) {
|
|
|
|
44
|
+// switch good.BonusStatus {
|
|
|
|
45
|
+// case OrderGoodWaitPay:
|
|
|
|
46
|
+// o.currentBonusStatus = OrderGoodBonusBestshopWaitPay{}
|
|
|
|
47
|
+// case OrderGoodHasPay:
|
|
|
|
48
|
+// o.currentBonusStatus = OrderGoodBonusBestshopHasPay{}
|
|
|
|
49
|
+// }
|
|
|
|
50
|
+// return
|
|
|
|
51
|
+// }
|
|
|
|
52
|
+
|
|
|
|
53
|
+// //OrderGoodBonusBestshopWaitPay 货品支付状态:待支付
|
|
|
|
54
|
+// type OrderGoodBonusBestshopWaitPay struct {
|
|
|
|
55
|
+// OrderGoodBonusWaitPay
|
|
|
|
56
|
+// }
|
|
|
|
57
|
+
|
|
|
|
58
|
+// var _ OrderGoodWithBestshopBonusStatus = (*OrderGoodBonusBestshopWaitPay)(nil)
|
|
|
|
59
|
+
|
|
|
|
60
|
+// func (waitPay OrderGoodBonusBestshopWaitPay) UpdateOrderGoodNumber(good *OrderGood, number int) error {
|
|
|
|
61
|
+// good.UseGoodNumber = number
|
|
|
|
62
|
+// //待支付状态计算
|
|
|
|
63
|
+// err := good.Compute()
|
|
|
|
64
|
+// if err != nil {
|
|
|
|
65
|
+// return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
66
|
+// }
|
|
|
|
67
|
+// err = good.CurrentBonusStatus.WartPayPartnerBonus(good)
|
|
|
|
68
|
+// return err
|
|
|
|
69
|
+// }
|
|
|
|
70
|
+
|
|
|
|
71
|
+// func (waitPay OrderGoodBonusBestshopWaitPay) UpdatePertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
72
|
+// good.PartnerBonusPercent = percent
|
|
|
|
73
|
+// //待支付状态计算
|
|
|
|
74
|
+// err := good.Compute()
|
|
|
|
75
|
+// if err != nil {
|
|
|
|
76
|
+// return errors.New("核算商品数据失败" + err.Error())
|
|
|
|
77
|
+// }
|
|
|
|
78
|
+// err = good.CurrentBonusStatus.WartPayPartnerBonus(good)
|
|
|
|
79
|
+// return err
|
|
|
|
80
|
+// }
|
|
|
|
81
|
+
|
|
|
|
82
|
+// //OrderGoodBonusBestshopHasPay 货品支付状态:已支付
|
|
|
|
83
|
+// type OrderGoodBonusBestshopHasPay struct {
|
|
|
|
84
|
+// OrderGoodBonusHasPay
|
|
|
|
85
|
+// }
|
|
|
|
86
|
+
|
|
|
|
87
|
+// var _ OrderGoodWithBestshopBonusStatus = (*OrderGoodBonusBestshopHasPay)(nil)
|
|
|
|
88
|
+
|
|
|
|
89
|
+// func (hasPay OrderGoodBonusBestshopHasPay) UpdateOrderGoodNumber(good *OrderGood, number int) error {
|
|
|
|
90
|
+// return errors.New("已支付分红的货品订单,不能修改货品数量")
|
|
|
|
91
|
+// }
|
|
|
|
92
|
+
|
|
|
|
93
|
+// func (hasPay OrderGoodBonusBestshopHasPay) UpdatePertnerBonusPercent(good *OrderGood, percent float64) error {
|
|
|
|
94
|
+// return errors.New("已支付分红的货品订单,不能修改合伙人分红比例")
|
|
|
|
95
|
+// } |