作者 唐旭辉

更新

@@ -901,8 +901,8 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde @@ -901,8 +901,8 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde
901 return resp, cnt, nil 901 return resp, cnt, nil
902 } 902 }
903 903
904 -//PayPartnerBonusWithOrderBestshop 支付分红,海鲜干货的订单 (orderType=domain.OrderTypeBestShop)  
905 -func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, goodId int64, adminId int64) error { 904 +//PayPartnerBonusWithOrderBestshop 支付分红
  905 +func (service OrderInfoService) PayPartnerBonus(orderId int64, goodId int64, adminId int64) error {
906 var ( 906 var (
907 transactionContext, _ = factory.CreateTransactionContext(nil) 907 transactionContext, _ = factory.CreateTransactionContext(nil)
908 err error 908 err error
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 +// }
@@ -230,18 +230,18 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par @@ -230,18 +230,18 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par
230 230
231 //CustomOrderListForExcel 导出实际订单列表所用的结构 231 //CustomOrderListForExcel 导出实际订单列表所用的结构
232 type CustomOrderListForExcel struct { 232 type CustomOrderListForExcel struct {
233 - OrderCode string //订单编号  
234 - DeliveryCode string //发货编号  
235 - UpdateTime string //更新时间  
236 - CreateTime string //创建时间  
237 - PlanOrderCount int64 //货品总数  
238 - UseOrderCount int64 //货品总数调整  
239 - RegionName string //订单区域  
240 - PlanOrderAmount int64 //订单金额  
241 - UseOrderAmount int64 //订单金额调整  
242 - PartnerCategory string //合伙人类型  
243 - BuyerName string //买家  
244 - PartnerName string //合伙人 233 + OrderCode string //订单编号
  234 + DeliveryCode string //发货编号
  235 + UpdateTime string //更新时间
  236 + CreateTime string //创建时间
  237 + PlanOrderCount int64 //货品总数
  238 + UseOrderCount int64 //货品总数调整
  239 + RegionName string //订单区域
  240 + PlanOrderAmount float64 //订单金额
  241 + UseOrderAmount float64 //订单金额调整
  242 + PartnerCategory string //合伙人类型
  243 + BuyerName string //买家
  244 + PartnerName string //合伙人
245 } 245 }
246 246
247 //OrderListForExcel 获取实际订单列表用于excel导出 247 //OrderListForExcel 获取实际订单列表用于excel导出
@@ -230,7 +230,6 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, @@ -230,7 +230,6 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64,
230 } 230 }
231 231
232 //PayOrderGoodBonus 支付订单中货品的分红 232 //PayOrderGoodBonus 支付订单中货品的分红
233 -//目前只处理 海鲜干货的订单 即 order_type = OrderTypeBestShop (3)  
234 func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, adminId int64) error { 233 func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, adminId int64) error {
235 var ( 234 var (
236 userRepository domain.UsersRepository 235 userRepository domain.UsersRepository
@@ -254,9 +253,6 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a @@ -254,9 +253,6 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a
254 e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) 253 e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err)
255 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 254 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
256 } 255 }
257 - if oldOrder.OrderType != domain.OrderTypeBestShop {  
258 - return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型错误")  
259 - }  
260 oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) 256 oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId})
261 if err != nil { 257 if err != nil {
262 e := fmt.Sprintf("获取订单中(id=%d)的货品数据失败,%s", orderId, err) 258 e := fmt.Sprintf("获取订单中(id=%d)的货品数据失败,%s", orderId, err)
@@ -279,7 +275,7 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a @@ -279,7 +275,7 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a
279 continue 275 continue
280 } 276 }
281 updateGood = oldOrder.Goods[i] 277 updateGood = oldOrder.Goods[i]
282 - err := new(domain.OrderGoodWithBestshop).PayPartnerBonus(&updateGood) 278 + err = updateGood.CurrentBonusStatus.PayPartnerBonus(&updateGood)
283 if err != nil { 279 if err != nil {
284 return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) 280 return lib.ThrowError(lib.BUSINESS_ERROR, err.Error())
285 } 281 }
@@ -395,8 +395,8 @@ func (c *OrderDividendController) EditOrderDividend() { @@ -395,8 +395,8 @@ func (c *OrderDividendController) EditOrderDividend() {
395 return 395 return
396 } 396 }
397 397
398 -//PayOrderGoodBonusForBestshop 支付海鲜干货订单中的分红  
399 -func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { 398 +//PayOrderGoodBonus 支付订单中的分红
  399 +func (c *OrderDividendController) PayOrderGoodBonus() {
400 type Parameter struct { 400 type Parameter struct {
401 OrderId string `json:"orderId"` 401 OrderId string `json:"orderId"`
402 ProductId string `json:"productId"` 402 ProductId string `json:"productId"`
@@ -422,7 +422,7 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { @@ -422,7 +422,7 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() {
422 } 422 }
423 adminId := c.GetUserId() 423 adminId := c.GetUserId()
424 orderSrv := orderService.NewOrderInfoService(nil) 424 orderSrv := orderService.NewOrderInfoService(nil)
425 - err = orderSrv.PayPartnerBonusWithOrderBestshop(orderid, productId, adminId) 425 + err = orderSrv.PayPartnerBonus(orderid, productId, adminId)
426 if err != nil { 426 if err != nil {
427 c.ResponseError(err) 427 c.ResponseError(err)
428 return 428 return
@@ -31,7 +31,7 @@ func init() { @@ -31,7 +31,7 @@ func init() {
31 beego.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"), 31 beego.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"),
32 // beego.NSRouter("/mini-program/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetailForBestshop"), 32 // beego.NSRouter("/mini-program/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetailForBestshop"),
33 //beego.NSRouter("/mini-program/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividendForBestshop"), 33 //beego.NSRouter("/mini-program/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividendForBestshop"),
34 - beego.NSRouter("/mini-program/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonusForBestshop"), 34 + beego.NSRouter("/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonus"),
35 beego.NSRouter("/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonus"), 35 beego.NSRouter("/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonus"),
36 beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"), 36 beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"),
37 // beego.NSRouter("/business/detail", &controllers.BusinessBonusController{}, "POST:GetBusinessBonus"), 37 // beego.NSRouter("/business/detail", &controllers.BusinessBonusController{}, "POST:GetBusinessBonus"),