正在显示
7 个修改的文件
包含
230 行增加
和
157 行删除
| @@ -901,76 +901,6 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | @@ -901,76 +901,6 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | ||
| 901 | return resp, cnt, nil | 901 | return resp, cnt, nil |
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | -//UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 | ||
| 905 | -func (service OrderInfoService) UpdateBonusByGoodNumber(orderId int64, goodId int64, adminId int64, goodNumber int, reason string) error { | ||
| 906 | - var ( | ||
| 907 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 908 | - err error | ||
| 909 | - ) | ||
| 910 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 911 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 912 | - } | ||
| 913 | - defer func() { | ||
| 914 | - transactionContext.RollbackTransaction() | ||
| 915 | - }() | ||
| 916 | - var ( | ||
| 917 | - orderBonuSrv domainService.OrderBonusService | ||
| 918 | - ) | ||
| 919 | - orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 920 | - "transactionContext": transactionContext, | ||
| 921 | - }) | ||
| 922 | - if err != nil { | ||
| 923 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 924 | - } | ||
| 925 | - orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 926 | - TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 927 | - }) | ||
| 928 | - err = orderBonuSrv.UpdateBounsByGoodNumber(orderId, adminId, goodId, goodNumber, reason) | ||
| 929 | - if err != nil { | ||
| 930 | - return err | ||
| 931 | - } | ||
| 932 | - err = transactionContext.CommitTransaction() | ||
| 933 | - if err != nil { | ||
| 934 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 935 | - } | ||
| 936 | - return nil | ||
| 937 | -} | ||
| 938 | - | ||
| 939 | -//UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 | ||
| 940 | -func (service OrderInfoService) UpdateBonusByPartnerBonusPercent(orderId int64, goodId int64, adminId int64, percent float64, reason string) error { | ||
| 941 | - var ( | ||
| 942 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 943 | - err error | ||
| 944 | - ) | ||
| 945 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 946 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 947 | - } | ||
| 948 | - defer func() { | ||
| 949 | - transactionContext.RollbackTransaction() | ||
| 950 | - }() | ||
| 951 | - var ( | ||
| 952 | - orderBonuSrv domainService.OrderBonusService | ||
| 953 | - ) | ||
| 954 | - orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 955 | - "transactionContext": transactionContext, | ||
| 956 | - }) | ||
| 957 | - if err != nil { | ||
| 958 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 959 | - } | ||
| 960 | - orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 961 | - TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 962 | - }) | ||
| 963 | - err = orderBonuSrv.UpdateBounsByPartnerBonusPercent(orderId, adminId, goodId, percent, reason) | ||
| 964 | - if err != nil { | ||
| 965 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 966 | - } | ||
| 967 | - err = transactionContext.CommitTransaction() | ||
| 968 | - if err != nil { | ||
| 969 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 970 | - } | ||
| 971 | - return nil | ||
| 972 | -} | ||
| 973 | - | ||
| 974 | //PayPartnerBonusWithOrderBestshop 支付分红,海鲜干货的订单 (orderType=domain.OrderTypeBestShop) | 904 | //PayPartnerBonusWithOrderBestshop 支付分红,海鲜干货的订单 (orderType=domain.OrderTypeBestShop) |
| 975 | func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, goodId int64, adminId int64) error { | 905 | func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, goodId int64, adminId int64) error { |
| 976 | var ( | 906 | var ( |
| @@ -5,8 +5,11 @@ import ( | @@ -5,8 +5,11 @@ import ( | ||
| 5 | "strings" | 5 | "strings" |
| 6 | 6 | ||
| 7 | "github.com/astaxie/beego/logs" | 7 | "github.com/astaxie/beego/logs" |
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/event/subscriber" | ||
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" |
| 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
| 11 | + domainService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain/service" | ||
| 12 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | ||
| 10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 13 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" |
| 11 | ) | 14 | ) |
| 12 | 15 | ||
| @@ -431,3 +434,73 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord | @@ -431,3 +434,73 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord | ||
| 431 | } | 434 | } |
| 432 | return result | 435 | return result |
| 433 | } | 436 | } |
| 437 | + | ||
| 438 | +//UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 | ||
| 439 | +func (service OrderInfoService) UpdateBonusByGoodNumber(orderId int64, goodId int64, adminId int64, goodNumber int, reason string) error { | ||
| 440 | + var ( | ||
| 441 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 442 | + err error | ||
| 443 | + ) | ||
| 444 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 445 | + return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 446 | + } | ||
| 447 | + defer func() { | ||
| 448 | + transactionContext.RollbackTransaction() | ||
| 449 | + }() | ||
| 450 | + var ( | ||
| 451 | + orderBonuSrv domainService.OrderBonusService | ||
| 452 | + ) | ||
| 453 | + orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 454 | + "transactionContext": transactionContext, | ||
| 455 | + }) | ||
| 456 | + if err != nil { | ||
| 457 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 458 | + } | ||
| 459 | + orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 460 | + TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 461 | + }) | ||
| 462 | + err = orderBonuSrv.UpdateBounsByGoodNumber(orderId, adminId, goodId, goodNumber, reason) | ||
| 463 | + if err != nil { | ||
| 464 | + return err | ||
| 465 | + } | ||
| 466 | + err = transactionContext.CommitTransaction() | ||
| 467 | + if err != nil { | ||
| 468 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 469 | + } | ||
| 470 | + return nil | ||
| 471 | +} | ||
| 472 | + | ||
| 473 | +//UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 | ||
| 474 | +func (service OrderInfoService) UpdateBonusByPartnerBonusPercent(orderId int64, goodId int64, adminId int64, percent float64, reason string) error { | ||
| 475 | + var ( | ||
| 476 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 477 | + err error | ||
| 478 | + ) | ||
| 479 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 480 | + return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 481 | + } | ||
| 482 | + defer func() { | ||
| 483 | + transactionContext.RollbackTransaction() | ||
| 484 | + }() | ||
| 485 | + var ( | ||
| 486 | + orderBonuSrv domainService.OrderBonusService | ||
| 487 | + ) | ||
| 488 | + orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 489 | + "transactionContext": transactionContext, | ||
| 490 | + }) | ||
| 491 | + if err != nil { | ||
| 492 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 493 | + } | ||
| 494 | + orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 495 | + TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 496 | + }) | ||
| 497 | + err = orderBonuSrv.UpdateBounsByPartnerBonusPercent(orderId, adminId, goodId, percent, reason) | ||
| 498 | + if err != nil { | ||
| 499 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 500 | + } | ||
| 501 | + err = transactionContext.CommitTransaction() | ||
| 502 | + if err != nil { | ||
| 503 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 504 | + } | ||
| 505 | + return nil | ||
| 506 | +} |
| @@ -182,18 +182,16 @@ func (order *OrderBase) AddGoods(goods []OrderGood) { | @@ -182,18 +182,16 @@ func (order *OrderBase) AddGoods(goods []OrderGood) { | ||
| 182 | order.Compute() | 182 | order.Compute() |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | -// func (order *OrderBase) DeleteGoods(goodIds []int64) { | ||
| 186 | -// var newGoods []OrderGood | ||
| 187 | -// for i := range order.Goods { | ||
| 188 | -// for _, goodId := range goodIds { | ||
| 189 | -// order.Goods[i].Id = goodId | ||
| 190 | -// continue | ||
| 191 | -// } | ||
| 192 | -// newGoods = append(newGoods, order.Goods[i]) | ||
| 193 | -// } | ||
| 194 | -// order.Goods = newGoods | ||
| 195 | -// order.Compute() | ||
| 196 | -// } | 185 | +func (order *OrderBase) ModifyGoodNumber(goodid int64, number int64) { |
| 186 | + for i := range order.Goods { | ||
| 187 | + if order.Goods[i].Id != goodid { | ||
| 188 | + continue | ||
| 189 | + } | ||
| 190 | + // thisGood := order.Goods[i] | ||
| 191 | + | ||
| 192 | + } | ||
| 193 | + order.Compute() | ||
| 194 | +} | ||
| 197 | 195 | ||
| 198 | //Compute 数据汇总核算 | 196 | //Compute 数据汇总核算 |
| 199 | func (order *OrderBase) Compute() error { | 197 | func (order *OrderBase) Compute() error { |
| @@ -13,9 +13,9 @@ type OrderGoodBonusStatus interface { | @@ -13,9 +13,9 @@ type OrderGoodBonusStatus interface { | ||
| 13 | //状态变更为已支付 | 13 | //状态变更为已支付 |
| 14 | PayPartnerBonus(orderGood *OrderGood) error | 14 | PayPartnerBonus(orderGood *OrderGood) error |
| 15 | //变更货品数量 | 15 | //变更货品数量 |
| 16 | - /// UpdateOrderGoodNumber(good *OrderGood, number int, orderType int) error | 16 | + ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error |
| 17 | //变更合伙人分红比例 | 17 | //变更合伙人分红比例 |
| 18 | - //UpdatePertnerBonusPercent(good *OrderGood, percent float64, orderType int) error | 18 | + ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | //货单的支付状态 | 21 | //货单的支付状态 |
| @@ -110,6 +110,17 @@ func (good OrderGood) GetCurrentPartnerBonus() float64 { | @@ -110,6 +110,17 @@ func (good OrderGood) GetCurrentPartnerBonus() float64 { | ||
| 110 | return good.GoodCompute.PlanPartnerBonus | 110 | return good.GoodCompute.PlanPartnerBonus |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | +//GetCurrentAmount 获取当前的商品合伙人分红 | ||
| 114 | +func (good *OrderGood) ModifyOrderGoodNumber(number int, orderType int) error { | ||
| 115 | + err := good.CurrentBonusStatus.ModifyOrderGoodNumber(good, number, orderType) | ||
| 116 | + return err | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +func (good *OrderGood) ModifyPertnerBonusPercent(percent float64, orderType int) error { | ||
| 120 | + err := good.CurrentBonusStatus.ModifyPertnerBonusPercent(good, percent, orderType) | ||
| 121 | + return err | ||
| 122 | +} | ||
| 123 | + | ||
| 113 | //Update 更新商品相关的数据 | 124 | //Update 更新商品相关的数据 |
| 114 | func (good *OrderGood) Update(m map[string]interface{}) error { | 125 | func (good *OrderGood) Update(m map[string]interface{}) error { |
| 115 | if v, ok := m["GoodName"]; ok { | 126 | if v, ok := m["GoodName"]; ok { |
| @@ -199,6 +210,68 @@ func (hasPay OrderGoodBonusHasPay) WartPayPartnerBonus(good *OrderGood) error { | @@ -199,6 +210,68 @@ func (hasPay OrderGoodBonusHasPay) WartPayPartnerBonus(good *OrderGood) error { | ||
| 199 | return errors.New("已支付的货单不能将状态回退为待支付") | 210 | return errors.New("已支付的货单不能将状态回退为待支付") |
| 200 | } | 211 | } |
| 201 | 212 | ||
| 213 | +func (hasPay OrderGoodBonusHasPay) ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error { | ||
| 214 | + //规则描述: | ||
| 215 | + //实际自建订单(orderType==1),已支付分红状态下“可以”修改货品数量 | ||
| 216 | + //香米小程序订单(orderType==3),已支付分红状态下“不可以”修改货品数量 | ||
| 217 | + switch orderType { | ||
| 218 | + case OrderReal: | ||
| 219 | + good.UseGoodNumber = number | ||
| 220 | + //待支付状态计算 | ||
| 221 | + err := good.Compute() | ||
| 222 | + if err != nil { | ||
| 223 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 224 | + } | ||
| 225 | + case OrderTypeBestShop: | ||
| 226 | + return errors.New("小程序订单里已支付分红的货品订单,不能修改货品数量") | ||
| 227 | + } | ||
| 228 | + good.CurrentBonusStatus.PayPartnerBonus(good) | ||
| 229 | + return nil | ||
| 230 | +} | ||
| 231 | + | ||
| 232 | +func (waitPay OrderGoodBonusWaitPay) ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error { | ||
| 233 | + //规则描述: | ||
| 234 | + //实际自建订单(orderType==1),未支付分红状态下“可以”修改货品数量 | ||
| 235 | + //香米小程序订单(orderType==3),未支付分红状态下“可以”修改货品数量 | ||
| 236 | + good.UseGoodNumber = number | ||
| 237 | + //待支付状态计算 | ||
| 238 | + err := good.Compute() | ||
| 239 | + if err != nil { | ||
| 240 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 241 | + } | ||
| 242 | + good.CurrentBonusStatus.WartPayPartnerBonus(good) | ||
| 243 | + return nil | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +func (waitPay OrderGoodBonusWaitPay) ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error { | ||
| 247 | + //规则描述: | ||
| 248 | + //实际自建订单(orderType==1),未支付分红状态下“不可以”修改合伙人分红比例 | ||
| 249 | + //香米小程序订单(orderType==3),未支付分红状态下“可以”修改合伙人分红比例 | ||
| 250 | + switch orderType { | ||
| 251 | + case OrderReal: | ||
| 252 | + return errors.New("自建订单不能修改合伙人分红比例") | ||
| 253 | + case OrderTypeBestShop: | ||
| 254 | + good.PartnerBonusPercent = percent | ||
| 255 | + //待支付状态计算 | ||
| 256 | + err := good.Compute() | ||
| 257 | + if err != nil { | ||
| 258 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 259 | + } | ||
| 260 | + err = good.CurrentBonusStatus.WartPayPartnerBonus(good) | ||
| 261 | + if err != nil { | ||
| 262 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | + return nil | ||
| 266 | +} | ||
| 267 | + | ||
| 268 | +func (hasPay OrderGoodBonusHasPay) ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error { | ||
| 269 | + //规则描述: | ||
| 270 | + //实际自建订单(orderType==1),已支付分红状态下“不可以”修改合伙人分红比例 | ||
| 271 | + //香米小程序订单(orderType==3),已支付分红状态下“不可以”修改合伙人分红比例 | ||
| 272 | + return errors.New("已支付分红的货品订单,不能修改合伙人分红比例") | ||
| 273 | +} | ||
| 274 | + | ||
| 202 | //NewOrderGood 初始值设定 | 275 | //NewOrderGood 初始值设定 |
| 203 | func NewOrderGood() OrderGood { | 276 | func NewOrderGood() OrderGood { |
| 204 | return OrderGood{ | 277 | return OrderGood{ |
| @@ -28,7 +28,6 @@ func NewOrderBonusService(tcx *transaction.TransactionContext) *OrderBonusServic | @@ -28,7 +28,6 @@ func NewOrderBonusService(tcx *transaction.TransactionContext) *OrderBonusServic | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | //UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 | 30 | //UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 |
| 31 | -//目前只处理 xiangmi的订单 即 order_type = OrderTypeBestShop (3) | ||
| 32 | func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId int64, goodId int64, goodWithNumber int, reason string) error { | 31 | func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId int64, goodId int64, goodWithNumber int, reason string) error { |
| 33 | var ( | 32 | var ( |
| 34 | userRepository domain.UsersRepository | 33 | userRepository domain.UsersRepository |
| @@ -52,9 +51,6 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | @@ -52,9 +51,6 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | ||
| 52 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) | 51 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) |
| 53 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | 52 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) |
| 54 | } | 53 | } |
| 55 | - if oldOrder.OrderType != domain.OrderTypeBestShop { | ||
| 56 | - return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型错误") | ||
| 57 | - } | ||
| 58 | oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) | 54 | oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) |
| 59 | if err != nil { | 55 | if err != nil { |
| 60 | e := fmt.Sprintf("获取订单(id=%d)中的货品数据失败,%s", orderId, err) | 56 | e := fmt.Sprintf("获取订单(id=%d)中的货品数据失败,%s", orderId, err) |
| @@ -82,8 +78,13 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | @@ -82,8 +78,13 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | ||
| 82 | updateGood = oldOrder.Goods[i] | 78 | updateGood = oldOrder.Goods[i] |
| 83 | formerNumber = updateGood.GetCurrentGoodNumber() | 79 | formerNumber = updateGood.GetCurrentGoodNumber() |
| 84 | formerAmount = updateGood.GetCurrentAmount() | 80 | formerAmount = updateGood.GetCurrentAmount() |
| 85 | - err := new(domain.OrderGoodWithBestshop). | ||
| 86 | - UpdateBonusByGoodNumber(&updateGood, goodWithNumber) | 81 | + //TODO |
| 82 | + // err := new(domain.OrderGoodWithBestshop). | ||
| 83 | + // UpdateBonusByGoodNumber(&updateGood, goodWithNumber) | ||
| 84 | + // if err != nil { | ||
| 85 | + // return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) | ||
| 86 | + // } | ||
| 87 | + err = updateGood.ModifyOrderGoodNumber(goodWithNumber, oldOrder.OrderType) | ||
| 87 | if err != nil { | 88 | if err != nil { |
| 88 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) | 89 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) |
| 89 | } | 90 | } |
| @@ -128,7 +129,6 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | @@ -128,7 +129,6 @@ func (serve *OrderBonusService) UpdateBounsByGoodNumber(orderId int64, adminId i | ||
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | //UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 | 131 | //UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 |
| 131 | -////目前只处理 xiangmi的订单 即 order_type = OrderTypeBestShop (3) | ||
| 132 | func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, adminId int64, goodId int64, partnerPercent float64, reason string) error { | 132 | func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, adminId int64, goodId int64, partnerPercent float64, reason string) error { |
| 133 | var ( | 133 | var ( |
| 134 | userRepository domain.UsersRepository | 134 | userRepository domain.UsersRepository |
| @@ -152,9 +152,7 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, | @@ -152,9 +152,7 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, | ||
| 152 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) | 152 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) |
| 153 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | 153 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) |
| 154 | } | 154 | } |
| 155 | - if oldOrder.OrderType != domain.OrderTypeBestShop { | ||
| 156 | - return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型错误") | ||
| 157 | - } | 155 | + |
| 158 | oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) | 156 | oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) |
| 159 | if err != nil { | 157 | if err != nil { |
| 160 | e := fmt.Sprintf("获取订单中(id=%d)的货品数据失败,%s", orderId, err) | 158 | e := fmt.Sprintf("获取订单中(id=%d)的货品数据失败,%s", orderId, err) |
| @@ -182,8 +180,10 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, | @@ -182,8 +180,10 @@ func (serve *OrderBonusService) UpdateBounsByPartnerBonusPercent(orderId int64, | ||
| 182 | updateGood = oldOrder.Goods[i] | 180 | updateGood = oldOrder.Goods[i] |
| 183 | formerPartnerBonusPercent = updateGood.PartnerBonusPercent | 181 | formerPartnerBonusPercent = updateGood.PartnerBonusPercent |
| 184 | formerPartnerBonus = updateGood.GetCurrentPartnerBonus() | 182 | formerPartnerBonus = updateGood.GetCurrentPartnerBonus() |
| 185 | - err := new(domain.OrderGoodWithBestshop). | ||
| 186 | - UpdateBonusByPertnerBonusPercent(&updateGood, partnerPercent) | 183 | + // err := new(domain.OrderGoodWithBestshop). |
| 184 | + // UpdateBonusByPertnerBonusPercent(&updateGood, partnerPercent) | ||
| 185 | + | ||
| 186 | + err = updateGood.ModifyPertnerBonusPercent(partnerPercent, oldOrder.OrderType) | ||
| 187 | if err != nil { | 187 | if err != nil { |
| 188 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) | 188 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) |
| 189 | } | 189 | } |
| @@ -6,7 +6,6 @@ import ( | @@ -6,7 +6,6 @@ import ( | ||
| 6 | "time" | 6 | "time" |
| 7 | 7 | ||
| 8 | "github.com/astaxie/beego/logs" | 8 | "github.com/astaxie/beego/logs" |
| 9 | - orderCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/command" | ||
| 10 | orderQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query" | 9 | orderQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query" |
| 11 | orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service" | 10 | orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service" |
| 12 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
| @@ -262,63 +261,63 @@ type postDividendPayment struct { | @@ -262,63 +261,63 @@ type postDividendPayment struct { | ||
| 262 | Remark string `json:"remark"` | 261 | Remark string `json:"remark"` |
| 263 | } | 262 | } |
| 264 | 263 | ||
| 265 | -func (c *OrderDividendController) EditOrderDividend() { | ||
| 266 | - var ( | ||
| 267 | - param postOrderDividend | ||
| 268 | - err error | ||
| 269 | - ) | ||
| 270 | - if err = c.BindJsonData(¶m); err != nil { | ||
| 271 | - logs.Error(err) | ||
| 272 | - c.ResponseError(errors.New("json数据解析失败")) | ||
| 273 | - return | ||
| 274 | - } | 264 | +// func (c *OrderDividendController) EditOrderDividend() { |
| 265 | +// var ( | ||
| 266 | +// param postOrderDividend | ||
| 267 | +// err error | ||
| 268 | +// ) | ||
| 269 | +// if err = c.BindJsonData(¶m); err != nil { | ||
| 270 | +// logs.Error(err) | ||
| 271 | +// c.ResponseError(errors.New("json数据解析失败")) | ||
| 272 | +// return | ||
| 273 | +// } | ||
| 275 | 274 | ||
| 276 | - if param.Id == 0 { | ||
| 277 | - c.ResponseError(errors.New("参数错误")) | ||
| 278 | - return | ||
| 279 | - } | ||
| 280 | - goodbouns := []orderCmd.GoodBouns{} | ||
| 281 | - for _, v := range param.DividendPayments { | ||
| 282 | - if v.ProductId == 0 { | ||
| 283 | - c.ResponseError(errors.New("参数错误")) | ||
| 284 | - return | ||
| 285 | - } | ||
| 286 | - if !(v.StateOfPayment == domain.OrderGoodWaitPay || v.StateOfPayment == domain.OrderGoodHasPay) { | ||
| 287 | - c.ResponseError(errors.New("参数错误")) | ||
| 288 | - return | ||
| 289 | - } | ||
| 290 | - g := orderCmd.GoodBouns{ | ||
| 291 | - GoodId: v.ProductId, | ||
| 292 | - Remark: v.Remark, | ||
| 293 | - BounsStatus: v.StateOfPayment, | ||
| 294 | - } | ||
| 295 | - if len(v.QuantityControl) == 0 { | ||
| 296 | - g.UseGoodNumber = -1 | ||
| 297 | - } else { | ||
| 298 | - num, err := strconv.Atoi(v.QuantityControl) | ||
| 299 | - if err != nil { | ||
| 300 | - c.ResponseError(errors.New("参数错误")) | ||
| 301 | - return | ||
| 302 | - } | ||
| 303 | - g.UseGoodNumber = num | ||
| 304 | - } | ||
| 305 | - goodbouns = append(goodbouns, g) | ||
| 306 | - } | ||
| 307 | - companyId := c.GetUserCompany() | ||
| 308 | - cmd := orderCmd.UpdateGoodBouns{ | ||
| 309 | - Id: param.Id, | ||
| 310 | - GoodBouns: goodbouns, | ||
| 311 | - CompanyId: companyId, | ||
| 312 | - } | ||
| 313 | - orderSrv := orderService.NewOrderInfoService(nil) | ||
| 314 | - err = orderSrv.UpdateGoodBouns(cmd) | ||
| 315 | - if err != nil { | ||
| 316 | - c.ResponseError(err) | ||
| 317 | - return | ||
| 318 | - } | ||
| 319 | - c.ResponseData(nil) | ||
| 320 | - return | ||
| 321 | -} | 275 | +// if param.Id == 0 { |
| 276 | +// c.ResponseError(errors.New("参数错误")) | ||
| 277 | +// return | ||
| 278 | +// } | ||
| 279 | +// goodbouns := []orderCmd.GoodBouns{} | ||
| 280 | +// for _, v := range param.DividendPayments { | ||
| 281 | +// if v.ProductId == 0 { | ||
| 282 | +// c.ResponseError(errors.New("参数错误")) | ||
| 283 | +// return | ||
| 284 | +// } | ||
| 285 | +// if !(v.StateOfPayment == domain.OrderGoodWaitPay || v.StateOfPayment == domain.OrderGoodHasPay) { | ||
| 286 | +// c.ResponseError(errors.New("参数错误")) | ||
| 287 | +// return | ||
| 288 | +// } | ||
| 289 | +// g := orderCmd.GoodBouns{ | ||
| 290 | +// GoodId: v.ProductId, | ||
| 291 | +// Remark: v.Remark, | ||
| 292 | +// BounsStatus: v.StateOfPayment, | ||
| 293 | +// } | ||
| 294 | +// if len(v.QuantityControl) == 0 { | ||
| 295 | +// g.UseGoodNumber = -1 | ||
| 296 | +// } else { | ||
| 297 | +// num, err := strconv.Atoi(v.QuantityControl) | ||
| 298 | +// if err != nil { | ||
| 299 | +// c.ResponseError(errors.New("参数错误")) | ||
| 300 | +// return | ||
| 301 | +// } | ||
| 302 | +// g.UseGoodNumber = num | ||
| 303 | +// } | ||
| 304 | +// goodbouns = append(goodbouns, g) | ||
| 305 | +// } | ||
| 306 | +// companyId := c.GetUserCompany() | ||
| 307 | +// cmd := orderCmd.UpdateGoodBouns{ | ||
| 308 | +// Id: param.Id, | ||
| 309 | +// GoodBouns: goodbouns, | ||
| 310 | +// CompanyId: companyId, | ||
| 311 | +// } | ||
| 312 | +// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 313 | +// err = orderSrv.UpdateGoodBouns(cmd) | ||
| 314 | +// if err != nil { | ||
| 315 | +// c.ResponseError(err) | ||
| 316 | +// return | ||
| 317 | +// } | ||
| 318 | +// c.ResponseData(nil) | ||
| 319 | +// return | ||
| 320 | +// } | ||
| 322 | 321 | ||
| 323 | //OrderDividendDetailForBestshop 海鲜干货的订单分红详情 | 322 | //OrderDividendDetailForBestshop 海鲜干货的订单分红详情 |
| 324 | func (c *OrderDividendController) OrderDividendDetailForBestshop() { | 323 | func (c *OrderDividendController) OrderDividendDetailForBestshop() { |
| @@ -350,8 +349,8 @@ func (c *OrderDividendController) OrderDividendDetailForBestshop() { | @@ -350,8 +349,8 @@ func (c *OrderDividendController) OrderDividendDetailForBestshop() { | ||
| 350 | return | 349 | return |
| 351 | } | 350 | } |
| 352 | 351 | ||
| 353 | -//EditOrderForBestshop 编辑海鲜干货的订单 中的 货品数量和分红比例 | ||
| 354 | -func (c *OrderDividendController) EditOrderDividendForBestshop() { | 352 | +//EditOrderForBestshop 编辑订单分红详情中的 货品数量和分红比例 |
| 353 | +func (c *OrderDividendController) EditOrderDividend() { | ||
| 355 | type Parameter struct { | 354 | type Parameter struct { |
| 356 | State int `json:"state"` | 355 | State int `json:"state"` |
| 357 | OrderId string `json:"orderId"` | 356 | OrderId string `json:"orderId"` |
| @@ -27,10 +27,10 @@ func init() { | @@ -27,10 +27,10 @@ func init() { | ||
| 27 | ), | 27 | ), |
| 28 | beego.NSNamespace("/dividends", | 28 | beego.NSNamespace("/dividends", |
| 29 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), | 29 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), |
| 30 | - beego.NSRouter("/edit", &controllers.OrderDividendController{}, "POST:EditOrderDividend"), | 30 | + beego.NSRouter("/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividend"), |
| 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("/mini-program/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonusForBestshop"), |
| 35 | beego.NSRouter("/mini-program/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonusForBestshop"), | 35 | beego.NSRouter("/mini-program/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonusForBestshop"), |
| 36 | beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"), | 36 | beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"), |
-
请 注册 或 登录 后发表评论