Merge branch 'test' into master
正在显示
36 个修改的文件
包含
1607 行增加
和
1406 行删除
| 1 | package command | 1 | package command |
| 2 | 2 | ||
| 3 | -type UpdateBusinessBonusCommand struct { | ||
| 4 | - Id int64 `json:"id"` | ||
| 5 | - Bonus float64 `json:"bonus"` | ||
| 6 | - BonusStatus int8 `json:"bonusStatus"` | ||
| 7 | - CompanyId int64 `json:"companyId"` | ||
| 8 | -} | 3 | +// type UpdateBusinessBonusCommand struct { |
| 4 | +// Id int64 `json:"id"` | ||
| 5 | +// Bonus float64 `json:"bonus"` | ||
| 6 | +// BonusStatus int8 `json:"bonusStatus"` | ||
| 7 | +// CompanyId int64 `json:"companyId"` | ||
| 8 | +// } | ||
| 9 | 9 | ||
| 10 | -func (cmd UpdateBusinessBonusCommand) ValidateCommand() error { | ||
| 11 | - return nil | ||
| 12 | -} | 10 | +// func (cmd UpdateBusinessBonusCommand) ValidateCommand() error { |
| 11 | +// return nil | ||
| 12 | +// } |
| 1 | package query | 1 | package query |
| 2 | 2 | ||
| 3 | -type ListBusinessBonusQuery struct { | 3 | +// type ListBusinessBonusQuery struct { |
| 4 | 4 | ||
| 5 | - //用户名称匹配 | ||
| 6 | - PartnerNameMatch string `json:"userNameMatch" ` | ||
| 7 | - // 查询偏离量 | ||
| 8 | - Offset int `json:"offset" ` | ||
| 9 | - // 查询限制 | ||
| 10 | - Limit int `json:"limit"` | ||
| 11 | - PartnerId int64 `json:"partnerId"` | ||
| 12 | - CompanyId int64 `json:"companyId"` | ||
| 13 | -} | 5 | +// //用户名称匹配 |
| 6 | +// PartnerNameMatch string `json:"userNameMatch" ` | ||
| 7 | +// // 查询偏离量 | ||
| 8 | +// Offset int `json:"offset" ` | ||
| 9 | +// // 查询限制 | ||
| 10 | +// Limit int `json:"limit"` | ||
| 11 | +// PartnerId int64 `json:"partnerId"` | ||
| 12 | +// CompanyId int64 `json:"companyId"` | ||
| 13 | +// } |
| 1 | package service | 1 | package service |
| 2 | 2 | ||
| 3 | -type BusinessBonusService struct { | ||
| 4 | -} | 3 | +// type BusinessBonusService struct { |
| 4 | +// } | ||
| 5 | 5 | ||
| 6 | -func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusService { | ||
| 7 | - newService := new(BusinessBonusService) | ||
| 8 | - return newService | ||
| 9 | -} | 6 | +// func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusService { |
| 7 | +// newService := new(BusinessBonusService) | ||
| 8 | +// return newService | ||
| 9 | +// } | ||
| 10 | 10 | ||
| 11 | // ListBusinessBonus 列表 | 11 | // ListBusinessBonus 列表 |
| 12 | // func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusinessBonusQuery) (int, interface{}, error) { | 12 | // func (srv BusinessBonusService) ListBusinessBonus(queryOption query.ListBusinessBonusQuery) (int, interface{}, error) { |
| @@ -166,3 +166,4 @@ func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusServic | @@ -166,3 +166,4 @@ func NewBusinessBonusService(option map[string]interface{}) *BusinessBonusServic | ||
| 166 | 166 | ||
| 167 | // return returnData, nil | 167 | // return returnData, nil |
| 168 | // } | 168 | // } |
| 169 | +// } |
| @@ -111,6 +111,7 @@ func (subscriber *OrderLogSubscriber) HandleEvent(domainEvent coreDomain.DomainE | @@ -111,6 +111,7 @@ func (subscriber *OrderLogSubscriber) HandleEvent(domainEvent coreDomain.DomainE | ||
| 111 | GoodId: 0, | 111 | GoodId: 0, |
| 112 | Descript: []domain.OrderLogDescript{ | 112 | Descript: []domain.OrderLogDescript{ |
| 113 | domain.OrderLogDescript{ | 113 | domain.OrderLogDescript{ |
| 114 | + GoodId: currentEvent.OrderId, | ||
| 114 | Title: "编辑备注", | 115 | Title: "编辑备注", |
| 115 | Item: currentEvent.NewRemark, | 116 | Item: currentEvent.NewRemark, |
| 116 | Action: []string{}, | 117 | Action: []string{}, |
| @@ -119,34 +120,59 @@ func (subscriber *OrderLogSubscriber) HandleEvent(domainEvent coreDomain.DomainE | @@ -119,34 +120,59 @@ func (subscriber *OrderLogSubscriber) HandleEvent(domainEvent coreDomain.DomainE | ||
| 119 | } | 120 | } |
| 120 | err = orderLogRepository.Add(&orderLog) | 121 | err = orderLogRepository.Add(&orderLog) |
| 121 | break | 122 | break |
| 122 | - // 支付订单中货品的分红 | ||
| 123 | case event.PAY_ORDER_GOOD_BONUS_EVENT: | 123 | case event.PAY_ORDER_GOOD_BONUS_EVENT: |
| 124 | currentEvent := domainEvent.(event.PayOrderGoodBonus) | 124 | currentEvent := domainEvent.(event.PayOrderGoodBonus) |
| 125 | - adminUser, err = userRepository.FindOne(domain.UsersFindOneQuery{Id: currentEvent.AdminId}) | ||
| 126 | - if err != nil { | ||
| 127 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 128 | - } | ||
| 129 | orderLog := domain.OrderLog{ | 125 | orderLog := domain.OrderLog{ |
| 130 | OperatorType: domain.ORDER_LOG_OPERATOR_ADMIN, | 126 | OperatorType: domain.ORDER_LOG_OPERATOR_ADMIN, |
| 131 | - OperatorId: currentEvent.AdminId, | 127 | + OperatorId: currentEvent.Admin.Id, |
| 132 | Operator: adminUser.Name, | 128 | Operator: adminUser.Name, |
| 133 | AlterTime: time.Now(), | 129 | AlterTime: time.Now(), |
| 134 | DataFrom: domain.ORDER_LOG_FROM, | 130 | DataFrom: domain.ORDER_LOG_FROM, |
| 135 | LogAction: "支付", | 131 | LogAction: "支付", |
| 136 | - OrderId: currentEvent.OrderId, | ||
| 137 | - GoodId: currentEvent.GoodId, | ||
| 138 | - Descript: []domain.OrderLogDescript{ | ||
| 139 | - domain.OrderLogDescript{ | ||
| 140 | - Title: "支付分红", | ||
| 141 | - Item: currentEvent.GoodName, | ||
| 142 | - Action: []string{ | ||
| 143 | - fmt.Sprintf(`支付分红"¥%.2f"`, currentEvent.PartnerBonus), | ||
| 144 | - }, | 132 | + OrderId: currentEvent.OrderBase.Id, |
| 133 | + Descript: []domain.OrderLogDescript{}, | ||
| 134 | + } | ||
| 135 | + for i := range currentEvent.Goods { | ||
| 136 | + m := domain.OrderLogDescript{ | ||
| 137 | + GoodId: currentEvent.Goods[i].Id, | ||
| 138 | + Title: "支付分红", | ||
| 139 | + Item: currentEvent.Goods[i].GoodName, | ||
| 140 | + Action: []string{ | ||
| 141 | + fmt.Sprintf(`支付分红"¥%.2f"`, currentEvent.Goods[i].GetCurrentPartnerBonus()), | ||
| 145 | }, | 142 | }, |
| 146 | - }, | 143 | + } |
| 144 | + orderLog.Descript = append(orderLog.Descript, m) | ||
| 147 | } | 145 | } |
| 148 | err = orderLogRepository.Add(&orderLog) | 146 | err = orderLogRepository.Add(&orderLog) |
| 149 | break | 147 | break |
| 148 | + case event.BATCH_PAY_ORDER_GOOD_BONUS_EVENT: | ||
| 149 | + currentEvent := domainEvent.(event.BatchPayOrderGoodBonus) | ||
| 150 | + for i := range currentEvent { | ||
| 151 | + orderLog := domain.OrderLog{ | ||
| 152 | + OperatorType: domain.ORDER_LOG_OPERATOR_ADMIN, | ||
| 153 | + OperatorId: currentEvent[i].Admin.Id, | ||
| 154 | + Operator: adminUser.Name, | ||
| 155 | + AlterTime: time.Now(), | ||
| 156 | + DataFrom: domain.ORDER_LOG_FROM, | ||
| 157 | + LogAction: "支付", | ||
| 158 | + OrderId: currentEvent[i].OrderBase.Id, | ||
| 159 | + Descript: []domain.OrderLogDescript{}, | ||
| 160 | + } | ||
| 161 | + for ii := range currentEvent[i].Goods { | ||
| 162 | + m := domain.OrderLogDescript{ | ||
| 163 | + GoodId: currentEvent[i].Goods[ii].Id, | ||
| 164 | + Title: "支付分红", | ||
| 165 | + Item: currentEvent[i].Goods[ii].GoodName, | ||
| 166 | + Action: []string{ | ||
| 167 | + fmt.Sprintf(`支付分红"¥%.2f"`, currentEvent[i].Goods[ii].GetCurrentPartnerBonus()), | ||
| 168 | + }, | ||
| 169 | + } | ||
| 170 | + orderLog.Descript = append(orderLog.Descript, m) | ||
| 171 | + } | ||
| 172 | + err = orderLogRepository.Add(&orderLog) | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + break | ||
| 150 | } | 176 | } |
| 151 | return err | 177 | return err |
| 152 | } | 178 | } |
| @@ -156,6 +182,7 @@ func (subscriber *OrderLogSubscriber) SubscribedToEventTypes() []string { | @@ -156,6 +182,7 @@ func (subscriber *OrderLogSubscriber) SubscribedToEventTypes() []string { | ||
| 156 | event.UPDATE_BONUS_BY_GOOD_NUMBER_EVENT, | 182 | event.UPDATE_BONUS_BY_GOOD_NUMBER_EVENT, |
| 157 | event.UPDATE_BONUS_BY_PARTENT_BONUS_PERCENT_EVENT, | 183 | event.UPDATE_BONUS_BY_PARTENT_BONUS_PERCENT_EVENT, |
| 158 | event.UPDATE_ORDER_REMARK, | 184 | event.UPDATE_ORDER_REMARK, |
| 185 | + event.BATCH_PAY_ORDER_GOOD_BONUS_EVENT, | ||
| 159 | event.PAY_ORDER_GOOD_BONUS_EVENT, | 186 | event.PAY_ORDER_GOOD_BONUS_EVENT, |
| 160 | } | 187 | } |
| 161 | } | 188 | } |
| @@ -6,14 +6,6 @@ import ( | @@ -6,14 +6,6 @@ import ( | ||
| 6 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" |
| 7 | ) | 7 | ) |
| 8 | 8 | ||
| 9 | -func CreateBusinessBonusService(options map[string]interface{}) (service.BusinessBonusService, error) { | ||
| 10 | - var transactionContext *transaction.TransactionContext | ||
| 11 | - if value, ok := options["transactionContext"]; ok { | ||
| 12 | - transactionContext = value.(*transaction.TransactionContext) | ||
| 13 | - } | ||
| 14 | - return domainService.NewBusinessBonusService(transactionContext), nil | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | func CreateOrderBonusService(options map[string]interface{}) (service.OrderBonusService, error) { | 9 | func CreateOrderBonusService(options map[string]interface{}) (service.OrderBonusService, error) { |
| 18 | var transactionContext *transaction.TransactionContext | 10 | var transactionContext *transaction.TransactionContext |
| 19 | if value, ok := options["transactionContext"]; ok { | 11 | if value, ok := options["transactionContext"]; ok { |
| @@ -15,4 +15,6 @@ type ListOrderBaseQuery struct { | @@ -15,4 +15,6 @@ type ListOrderBaseQuery struct { | ||
| 15 | PartnerCategory int `json:"partnerCategory"` | 15 | PartnerCategory int `json:"partnerCategory"` |
| 16 | UpdateTimeBegin string `json:"updateTimeBegin"` | 16 | UpdateTimeBegin string `json:"updateTimeBegin"` |
| 17 | UpdateTimeEnd string `json:"updateTimeEnd"` | 17 | UpdateTimeEnd string `json:"updateTimeEnd"` |
| 18 | + CreateTimeBegin string `json:"createTimeBegin"` | ||
| 19 | + CreateTimeEnd string `json:"createTimeEnd"` | ||
| 18 | } | 20 | } |
| @@ -8,6 +8,8 @@ type ListOrderBonusQuery struct { | @@ -8,6 +8,8 @@ type ListOrderBonusQuery struct { | ||
| 8 | CompanyId int64 `json:"companyId"` | 8 | CompanyId int64 `json:"companyId"` |
| 9 | PartnerCategory int `json:"partnerCategory"` | 9 | PartnerCategory int `json:"partnerCategory"` |
| 10 | //订单类型 | 10 | //订单类型 |
| 11 | - OrderType int `json:"orderType"` | ||
| 12 | - PartnerOrCode string `json:"partnerOrCode"` | 11 | + OrderType int `json:"orderType"` |
| 12 | + PartnerOrCode string `json:"partnerOrCode"` | ||
| 13 | + CreateTimeBegin string `json:"createTimeBegin"` | ||
| 14 | + CreateTimeEnd string `json:"createTimeEnd"` | ||
| 13 | } | 15 | } |
| @@ -2,8 +2,6 @@ package service | @@ -2,8 +2,6 @@ package service | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | - "strings" | ||
| 6 | - "time" | ||
| 7 | 5 | ||
| 8 | "github.com/astaxie/beego/logs" | 6 | "github.com/astaxie/beego/logs" |
| 9 | 7 | ||
| @@ -57,6 +55,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | @@ -57,6 +55,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | ||
| 57 | listOrderQuery.OrderType, | 55 | listOrderQuery.OrderType, |
| 58 | listOrderQuery.PartnerOrCode, | 56 | listOrderQuery.PartnerOrCode, |
| 59 | [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, | 57 | [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, |
| 58 | + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, | ||
| 60 | listOrderQuery.PartnerCategory, | 59 | listOrderQuery.PartnerCategory, |
| 61 | listOrderQuery.Limit, listOrderQuery.Offset, | 60 | listOrderQuery.Limit, listOrderQuery.Offset, |
| 62 | ) | 61 | ) |
| @@ -78,6 +77,8 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | @@ -78,6 +77,8 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | ||
| 78 | UserId: orders[i].PartnerId, | 77 | UserId: orders[i].PartnerId, |
| 79 | }) | 78 | }) |
| 80 | if err != nil { | 79 | if err != nil { |
| 80 | + //防崩溃 | ||
| 81 | + partnerData = &domain.PartnerInfo{} | ||
| 81 | logs.Error("获取合伙(id=%d)失败%s", orders[i].PartnerId, err) | 82 | logs.Error("获取合伙(id=%d)失败%s", orders[i].PartnerId, err) |
| 82 | } | 83 | } |
| 83 | listIndex := listOrderQuery.Offset + (1 + i) | 84 | listIndex := listOrderQuery.Offset + (1 + i) |
| @@ -86,7 +87,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | @@ -86,7 +87,7 @@ func (service OrderInfoService) PageListOrderBase(listOrderQuery query.ListOrder | ||
| 86 | "createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"), | 87 | "createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"), |
| 87 | "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"), | 88 | "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"), |
| 88 | "buyer": orders[i].Buyer.BuyerName, | 89 | "buyer": orders[i].Buyer.BuyerName, |
| 89 | - "id": orders[i].Id, | 90 | + "id": fmt.Sprint(orders[i].Id), |
| 90 | "orderId": orders[i].OrderCode, | 91 | "orderId": orders[i].OrderCode, |
| 91 | "shipmentsId": orders[i].DeliveryCode, | 92 | "shipmentsId": orders[i].DeliveryCode, |
| 92 | "partner": partnerData.Partner.PartnerName, | 93 | "partner": partnerData.Partner.PartnerName, |
| @@ -533,110 +534,6 @@ func (service OrderInfoService) deleteOldOrderGoods(newGoods []domain.OrderGood, | @@ -533,110 +534,6 @@ func (service OrderInfoService) deleteOldOrderGoods(newGoods []domain.OrderGood, | ||
| 533 | return | 534 | return |
| 534 | } | 535 | } |
| 535 | 536 | ||
| 536 | -//Delivery 发货 | ||
| 537 | -func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error { | ||
| 538 | - var ( | ||
| 539 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 540 | - err error | ||
| 541 | - ) | ||
| 542 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 543 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 544 | - } | ||
| 545 | - defer func() { | ||
| 546 | - transactionContext.RollbackTransaction() | ||
| 547 | - }() | ||
| 548 | - var ( | ||
| 549 | - orderBaseRepository domain.OrderBaseRepository | ||
| 550 | - orderGoodRepository domain.OrderGoodRepository | ||
| 551 | - oldOrderData *domain.OrderBase | ||
| 552 | - oldOrderGoods []domain.OrderGood | ||
| 553 | - orderBaseDao *dao.OrderBaseDao | ||
| 554 | - ) | ||
| 555 | - | ||
| 556 | - if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 557 | - "transactionContext": transactionContext, | ||
| 558 | - }); err != nil { | ||
| 559 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 560 | - } | ||
| 561 | - if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
| 562 | - "transactionContext": transactionContext, | ||
| 563 | - }); err != nil { | ||
| 564 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 565 | - } | ||
| 566 | - //获取旧的订单 | ||
| 567 | - oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 568 | - CompanyId: cmd.CompanyId, | ||
| 569 | - OrderId: cmd.OrderId, | ||
| 570 | - }) | ||
| 571 | - if err != nil { | ||
| 572 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) | ||
| 573 | - } | ||
| 574 | - if oldOrderData.OrderType != domain.OrderIntention { | ||
| 575 | - return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型已发生变更") | ||
| 576 | - } | ||
| 577 | - if orderBaseDao, err = factory.CreateOrderBaseDao(map[string]interface{}{ | ||
| 578 | - "transactionContext": transactionContext, | ||
| 579 | - }); err != nil { | ||
| 580 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 581 | - } | ||
| 582 | - //检查delivery_code是否重复 | ||
| 583 | - if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.OrderId); err != nil { | ||
| 584 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 585 | - } else if ok { | ||
| 586 | - return lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在") | ||
| 587 | - } | ||
| 588 | - //获取旧的订单中的商品 | ||
| 589 | - oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ | ||
| 590 | - OrderId: cmd.OrderId, | ||
| 591 | - CompanyId: cmd.CompanyId, | ||
| 592 | - }) | ||
| 593 | - if err != nil { | ||
| 594 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err)) | ||
| 595 | - } | ||
| 596 | - for _, newGood := range cmd.Goods { | ||
| 597 | - for i := range oldOrderGoods { | ||
| 598 | - if newGood.Id != oldOrderGoods[i].Id { | ||
| 599 | - continue | ||
| 600 | - } | ||
| 601 | - oldOrderGoods[i].GoodName = newGood.GoodName | ||
| 602 | - oldOrderGoods[i].PlanGoodNumber = newGood.PlanGoodNumber | ||
| 603 | - oldOrderGoods[i].Price = newGood.Price | ||
| 604 | - oldOrderGoods[i].PartnerBonusPercent = newGood.PartnerBonusPercent | ||
| 605 | - oldOrderGoods[i].Remark = newGood.Remark | ||
| 606 | - err = oldOrderGoods[i].Compute() | ||
| 607 | - if err != nil { | ||
| 608 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err)) | ||
| 609 | - } | ||
| 610 | - err = oldOrderGoods[i].CurrentBonusStatus.WartPayPartnerBonus(&oldOrderGoods[i]) | ||
| 611 | - if err != nil { | ||
| 612 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err)) | ||
| 613 | - } | ||
| 614 | - } | ||
| 615 | - } | ||
| 616 | - oldOrderData.DeliveryCode = cmd.DeliveryCode | ||
| 617 | - oldOrderData.DeliveryTime = time.Now() | ||
| 618 | - oldOrderData.Goods = oldOrderGoods | ||
| 619 | - //变更订单类型 | ||
| 620 | - oldOrderData.OrderType = domain.OrderReal | ||
| 621 | - err = oldOrderData.Compute() | ||
| 622 | - if err != nil { | ||
| 623 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中合计的数值失败:%s", err)) | ||
| 624 | - } | ||
| 625 | - err = orderBaseRepository.Save(oldOrderData) | ||
| 626 | - if err != nil { | ||
| 627 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)) | ||
| 628 | - } | ||
| 629 | - err = orderGoodRepository.Save(oldOrderGoods) | ||
| 630 | - if err != nil { | ||
| 631 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单中的商品数据失败:%s", err)) | ||
| 632 | - } | ||
| 633 | - err = transactionContext.CommitTransaction() | ||
| 634 | - if err != nil { | ||
| 635 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 636 | - } | ||
| 637 | - return nil | ||
| 638 | -} | ||
| 639 | - | ||
| 640 | //DisableOrEnable 开启关闭订单 | 537 | //DisableOrEnable 开启关闭订单 |
| 641 | func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) error { | 538 | func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) error { |
| 642 | var ( | 539 | var ( |
| @@ -681,102 +578,6 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) | @@ -681,102 +578,6 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) | ||
| 681 | return nil | 578 | return nil |
| 682 | } | 579 | } |
| 683 | 580 | ||
| 684 | -//UpdateGoodBouns 分红时,更新货品的分红相关的数值 | ||
| 685 | -func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) error { | ||
| 686 | - var ( | ||
| 687 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 688 | - err error | ||
| 689 | - ) | ||
| 690 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 691 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 692 | - } | ||
| 693 | - defer func() { | ||
| 694 | - transactionContext.RollbackTransaction() | ||
| 695 | - }() | ||
| 696 | - var ( | ||
| 697 | - orderBaseRepository domain.OrderBaseRepository | ||
| 698 | - orderGoodRepository domain.OrderGoodRepository | ||
| 699 | - oldOrderData *domain.OrderBase | ||
| 700 | - oldOrderGoods []domain.OrderGood | ||
| 701 | - ) | ||
| 702 | - if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 703 | - "transactionContext": transactionContext, | ||
| 704 | - }); err != nil { | ||
| 705 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 706 | - } | ||
| 707 | - if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
| 708 | - "transactionContext": transactionContext, | ||
| 709 | - }); err != nil { | ||
| 710 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 711 | - } | ||
| 712 | - //获取旧的订单 | ||
| 713 | - oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 714 | - OrderId: cmd.Id, | ||
| 715 | - CompanyId: cmd.CompanyId, | ||
| 716 | - }) | ||
| 717 | - if err != nil { | ||
| 718 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err)) | ||
| 719 | - } | ||
| 720 | - if oldOrderData.OrderType != domain.OrderReal { | ||
| 721 | - return lib.ThrowError(lib.BUSINESS_ERROR, fmt.Sprintf("指定的订单的订单类型发生变更")) | ||
| 722 | - } | ||
| 723 | - //获取旧的订单中的商品 | ||
| 724 | - oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ | ||
| 725 | - OrderId: cmd.Id, | ||
| 726 | - }) | ||
| 727 | - if err != nil { | ||
| 728 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err)) | ||
| 729 | - } | ||
| 730 | - for _, newGood := range cmd.GoodBouns { | ||
| 731 | - for i := range oldOrderGoods { | ||
| 732 | - if newGood.GoodId != oldOrderGoods[i].Id { | ||
| 733 | - continue | ||
| 734 | - } | ||
| 735 | - oldOrderGoods[i].UseGoodNumber = newGood.UseGoodNumber | ||
| 736 | - oldOrderGoods[i].Remark = newGood.Remark | ||
| 737 | - oldOrderGoods[i].BonusStatus = newGood.BounsStatus | ||
| 738 | - err = oldOrderGoods[i].Compute() | ||
| 739 | - if err != nil { | ||
| 740 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err)) | ||
| 741 | - } | ||
| 742 | - switch newGood.BounsStatus { | ||
| 743 | - case domain.OrderGoodWaitPay: | ||
| 744 | - err = oldOrderGoods[i].CurrentBonusStatus.WartPayPartnerBonus(&oldOrderGoods[i]) | ||
| 745 | - if err != nil { | ||
| 746 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err)) | ||
| 747 | - } | ||
| 748 | - case domain.OrderGoodHasPay: | ||
| 749 | - err = oldOrderGoods[i].CurrentBonusStatus.PayPartnerBonus(&oldOrderGoods[i]) | ||
| 750 | - if err != nil { | ||
| 751 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err)) | ||
| 752 | - } | ||
| 753 | - default: | ||
| 754 | - return lib.ThrowError(lib.ARG_ERROR, fmt.Sprintf("货品的支付状态错误")) | ||
| 755 | - } | ||
| 756 | - } | ||
| 757 | - } | ||
| 758 | - oldOrderData.Goods = oldOrderGoods | ||
| 759 | - | ||
| 760 | - err = oldOrderData.Compute() | ||
| 761 | - if err != nil { | ||
| 762 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中合计的数值失败:%s", err)) | ||
| 763 | - } | ||
| 764 | - err = orderBaseRepository.Save(oldOrderData) | ||
| 765 | - if err != nil { | ||
| 766 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)) | ||
| 767 | - } | ||
| 768 | - err = orderGoodRepository.Save(oldOrderGoods) | ||
| 769 | - if err != nil { | ||
| 770 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单中的商品数据失败:%s", err)) | ||
| 771 | - } | ||
| 772 | - err = transactionContext.CommitTransaction() | ||
| 773 | - if err != nil { | ||
| 774 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 775 | - } | ||
| 776 | - return nil | ||
| 777 | - | ||
| 778 | -} | ||
| 779 | - | ||
| 780 | //PageListOrderBouns 获取订单的分红列表 | 581 | //PageListOrderBouns 获取订单的分红列表 |
| 781 | func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) { | 582 | func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) { |
| 782 | transactionContext, err := factory.CreateTransactionContext(nil) | 583 | transactionContext, err := factory.CreateTransactionContext(nil) |
| @@ -806,6 +607,7 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | @@ -806,6 +607,7 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | ||
| 806 | listOrderQuery.OrderType, | 607 | listOrderQuery.OrderType, |
| 807 | listOrderQuery.PartnerOrCode, | 608 | listOrderQuery.PartnerOrCode, |
| 808 | listOrderQuery.PartnerCategory, | 609 | listOrderQuery.PartnerCategory, |
| 610 | + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, | ||
| 809 | listOrderQuery.Limit, | 611 | listOrderQuery.Limit, |
| 810 | listOrderQuery.Offset, | 612 | listOrderQuery.Offset, |
| 811 | ) | 613 | ) |
| @@ -862,15 +664,16 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | @@ -862,15 +664,16 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | ||
| 862 | ) | 664 | ) |
| 863 | goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id}) | 665 | goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orders[i].Id}) |
| 864 | for ii := range goods { | 666 | for ii := range goods { |
| 865 | - if goods[ii].PartnerBonusPercent > 0 { | 667 | + if goods[ii].PartnerBonusPercent >= 0 { |
| 866 | hasBonusPercent = true | 668 | hasBonusPercent = true |
| 867 | } | 669 | } |
| 868 | } | 670 | } |
| 869 | listIndex := listOrderQuery.Offset + (1 + i) | 671 | listIndex := listOrderQuery.Offset + (1 + i) |
| 870 | listItem := map[string]interface{}{ | 672 | listItem := map[string]interface{}{ |
| 871 | "index": listIndex, | 673 | "index": listIndex, |
| 674 | + "createTime": orders[i].CreateTime.Local().Format("2006-01-02 15:04:05"), | ||
| 872 | "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"), | 675 | "updateTime": orders[i].UpdateTime.Local().Format("2006-01-02 15:04:05"), |
| 873 | - "id": orders[i].Id, | 676 | + "id": fmt.Sprint(orders[i].Id), |
| 874 | "shipmentsId": orders[i].DeliveryCode, | 677 | "shipmentsId": orders[i].DeliveryCode, |
| 875 | "partner": orders[i].PartnerInfo.PartnerName, | 678 | "partner": orders[i].PartnerInfo.PartnerName, |
| 876 | "dividendsReceivable": fmt.Sprint(orders[i].GetCurrentPartnerBonus()), | 679 | "dividendsReceivable": fmt.Sprint(orders[i].GetCurrentPartnerBonus()), |
| @@ -897,284 +700,8 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | @@ -897,284 +700,8 @@ func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrde | ||
| 897 | return resp, cnt, nil | 700 | return resp, cnt, nil |
| 898 | } | 701 | } |
| 899 | 702 | ||
| 900 | -//GetOrderBestshopInfo 获取来源于xiangmi订单的详情以及分红数据 | ||
| 901 | -func (service OrderInfoService) GetOrderBestshopInfoWithBonus(orderBaseId int64, companyId int64) (interface{}, error) { | ||
| 902 | - var ( | ||
| 903 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 904 | - err error | ||
| 905 | - ) | ||
| 906 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 907 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 908 | - } | ||
| 909 | - defer func() { | ||
| 910 | - transactionContext.RollbackTransaction() | ||
| 911 | - }() | ||
| 912 | - var ( | ||
| 913 | - orderBaseRepository domain.OrderBaseRepository | ||
| 914 | - orderGoodRepository domain.OrderGoodRepository | ||
| 915 | - orderBestshopRepository domain.OrderBestshopRepository | ||
| 916 | - orderGoodBestshopRepository domain.OrderGoodBestshopRepository | ||
| 917 | - orderLogRepository domain.OrderLogRepository | ||
| 918 | - partnerRepository domain.PartnerInfoRepository | ||
| 919 | - ) | ||
| 920 | - if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 921 | - "transactionContext": transactionContext, | ||
| 922 | - }); err != nil { | ||
| 923 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 924 | - } | ||
| 925 | - if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
| 926 | - "transactionContext": transactionContext, | ||
| 927 | - }); err != nil { | ||
| 928 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 929 | - } | ||
| 930 | - if orderBestshopRepository, err = factory.CreateOrderBestshopRepository(map[string]interface{}{ | ||
| 931 | - "transactionContext": transactionContext, | ||
| 932 | - }); err != nil { | ||
| 933 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 934 | - } | ||
| 935 | - if orderGoodBestshopRepository, err = factory.CreateOrderGoodBestshopRepository(map[string]interface{}{ | ||
| 936 | - "transactionContext": transactionContext, | ||
| 937 | - }); err != nil { | ||
| 938 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 939 | - } | ||
| 940 | - if orderLogRepository, err = factory.CreateOrderLogRepository(map[string]interface{}{ | ||
| 941 | - "transactionContext": transactionContext, | ||
| 942 | - }); err != nil { | ||
| 943 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 944 | - } | ||
| 945 | - if partnerRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | ||
| 946 | - "transactionContext": transactionContext, | ||
| 947 | - }); err != nil { | ||
| 948 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 949 | - } | ||
| 950 | - var ( | ||
| 951 | - orderData *domain.OrderBase | ||
| 952 | - orderGoods []domain.OrderGood | ||
| 953 | - orderBestshopData *domain.OrderBestShop | ||
| 954 | - orderGoodBestshop []domain.OrderGoodBestShop | ||
| 955 | - orderLogs []domain.OrderLog | ||
| 956 | - partnerInfo *domain.PartnerInfo | ||
| 957 | - ) | ||
| 958 | - | ||
| 959 | - orderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 960 | - OrderId: orderBaseId, | ||
| 961 | - CompanyId: companyId, | ||
| 962 | - }) | ||
| 963 | - if err != nil { | ||
| 964 | - e := fmt.Sprintf("获取订单(order_base)数据失败,id=%d,company_id=%d,err=%s", orderBaseId, companyId, err) | ||
| 965 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 966 | - } | ||
| 967 | - if orderData.OrderType != domain.OrderTypeBestShop { | ||
| 968 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取的订单数据失败,OrderType err") | ||
| 969 | - } | ||
| 970 | - orderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderData.Id}) | ||
| 971 | - if err != nil { | ||
| 972 | - e := fmt.Sprintf("获取订单的商品(order_good)数据失败,order_id=%d,err=%s", orderData.Id, err) | ||
| 973 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 974 | - } | ||
| 975 | - orderData.Goods = orderGoods | ||
| 976 | - partnerInfo, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderData.PartnerId}) | ||
| 977 | - if err != nil { | ||
| 978 | - e := fmt.Sprintf("获取订单中的合伙人(partner)数据失败,id=%d,order_id=%d,err=%s", orderData.PartnerId, orderData.Id, err) | ||
| 979 | - logs.Error(e) | ||
| 980 | - } | ||
| 981 | - orderData.PartnerInfo = partnerInfo.Partner | ||
| 982 | - orderBestshopData, err = orderBestshopRepository.FindOne(domain.OrderBestshopFindOneQuery{OrderId: orderData.DataFrom.DataId}) | ||
| 983 | - if err != nil { | ||
| 984 | - e := fmt.Sprintf("获取xiangmi订单(order_bestshop)数据失败,id=%d,err=%s", orderData.DataFrom.DataId, err) | ||
| 985 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 986 | - } | ||
| 987 | - orderGoodBestshop, err = orderGoodBestshopRepository.Find(domain.OrderGoodBestshopFindQuery{OrderId: orderBestshopData.Id}) | ||
| 988 | - if err != nil { | ||
| 989 | - e := fmt.Sprintf("获取xiangmi订单货品(order_good_bestshop)数据失败,order_id=%d,err=%s", orderBestshopData.Id, err) | ||
| 990 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 991 | - } | ||
| 992 | - orderBestshopData.Goods = orderGoodBestshop | ||
| 993 | - orderLogs, err = orderLogRepository.Find(domain.OrderLogFindQuery{OrderId: orderData.Id}) | ||
| 994 | - if err != nil { | ||
| 995 | - e := fmt.Sprintf("获取订单的修改记录(order_log)失败,err=%s", err) | ||
| 996 | - logs.Error(e) | ||
| 997 | - } | ||
| 998 | - err = transactionContext.CommitTransaction() | ||
| 999 | - if err != nil { | ||
| 1000 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1001 | - } | ||
| 1002 | - result := service.buildOrderBestshopInfoData(orderData, orderBestshopData, orderLogs) | ||
| 1003 | - return result, nil | ||
| 1004 | -} | ||
| 1005 | - | ||
| 1006 | -//BuildOrderBestshopInfoData 构建前端需要的数据结构 | ||
| 1007 | -func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.OrderBase, | ||
| 1008 | - orderBestshop *domain.OrderBestShop, orderLogs []domain.OrderLog) interface{} { | ||
| 1009 | - orderGoodBestshopMap := map[int64]*domain.OrderGoodBestShop{} | ||
| 1010 | - for i := range orderBestshop.Goods { | ||
| 1011 | - goodid := orderBestshop.Goods[i].Id | ||
| 1012 | - orderGoodBestshopMap[goodid] = &orderBestshop.Goods[i] | ||
| 1013 | - } | ||
| 1014 | - //订单中的商品 | ||
| 1015 | - productDetail := []map[string]interface{}{} | ||
| 1016 | - var hasPartnerBonusPercent bool | ||
| 1017 | - for i := range orderBase.Goods { | ||
| 1018 | - detail := map[string]interface{}{ | ||
| 1019 | - "commodityName": orderBase.Goods[i].GoodName, | ||
| 1020 | - "productCodes": "", | ||
| 1021 | - "commodityCode": "", | ||
| 1022 | - "univalence": orderBase.Goods[i].Price, | ||
| 1023 | - "orderNum": orderBase.Goods[i].GetCurrentGoodNumber(), | ||
| 1024 | - "commodityPrice": orderBase.Goods[i].GetCurrentAmount(), | ||
| 1025 | - "partnerDividends": "", | ||
| 1026 | - "productId": orderBase.Goods[i].Id, | ||
| 1027 | - "paymentStatus": orderBase.Goods[i].BonusStatus, | ||
| 1028 | - "partnerRatio": orderBase.Goods[i].PartnerBonusPercent, | ||
| 1029 | - } | ||
| 1030 | - if orderBase.Goods[i].PartnerBonusPercent >= 0 { | ||
| 1031 | - hasPartnerBonusPercent = true | ||
| 1032 | - detail["partnerDividends"] = fmt.Sprint(orderBase.Goods[i].GetCurrentPartnerBonus()) | ||
| 1033 | - } | ||
| 1034 | - goodBestshopId := orderBase.Goods[i].DataFrom.DataId | ||
| 1035 | - if v, ok := orderGoodBestshopMap[goodBestshopId]; ok { | ||
| 1036 | - detail["productCodes"] = v.Sn | ||
| 1037 | - detail["commodityCode"] = v.Bn | ||
| 1038 | - } | ||
| 1039 | - productDetail = append(productDetail, detail) | ||
| 1040 | - } | ||
| 1041 | - product := map[string]interface{}{ | ||
| 1042 | - "orderNumCount": orderBase.GetCurrentOrderCount(), | ||
| 1043 | - "partnerDividendsCount": "", | ||
| 1044 | - "orderAmountAdjustmentCount": orderBase.GetCurrentOrderAmount(), | ||
| 1045 | - "detail": productDetail, | ||
| 1046 | - } | ||
| 1047 | - if hasPartnerBonusPercent { | ||
| 1048 | - product["partnerDividendsCount"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 1049 | - } | ||
| 1050 | - //订单描述 | ||
| 1051 | - order := map[string]interface{}{ | ||
| 1052 | - "orderId": orderBase.Id, | ||
| 1053 | - "orderState": orderBestshop.OrderState, | ||
| 1054 | - "customers": orderBestshop.BuyerName, | ||
| 1055 | - "address": orderBestshop.BuyerAddress, | ||
| 1056 | - "remarks": orderBestshop.BuyerRemark, | ||
| 1057 | - "partner": orderBase.PartnerInfo.PartnerName, | ||
| 1058 | - "phone": orderBestshop.BuyerPhone, | ||
| 1059 | - "orderTime": orderBestshop.OrderTime, | ||
| 1060 | - "shippingStatus": orderBestshop.DeliveryState, | ||
| 1061 | - "partnerDividends": "", | ||
| 1062 | - "receivedDividends": "", | ||
| 1063 | - "notReceivedDividend": "", | ||
| 1064 | - "dividendSpending": "", | ||
| 1065 | - "orderNumber": orderBase.OrderCode, | ||
| 1066 | - } | ||
| 1067 | - if hasPartnerBonusPercent { | ||
| 1068 | - order["partnerDividends"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 1069 | - order["receivedDividends"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusHas) | ||
| 1070 | - order["notReceivedDividend"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusNot) | ||
| 1071 | - order["dividendSpending"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusExpense) | ||
| 1072 | - } | ||
| 1073 | - modifyLog := []map[string]interface{}{} | ||
| 1074 | - for i := range orderLogs { | ||
| 1075 | - m := map[string]interface{}{ | ||
| 1076 | - "title": orderLogs[i].LogAction, | ||
| 1077 | - "time": orderLogs[i].AlterTime.Local().Format("2006-01-02 15:04:05"), | ||
| 1078 | - "userName": orderLogs[i].Operator, | ||
| 1079 | - "id": orderLogs[i].Id, | ||
| 1080 | - } | ||
| 1081 | - detail := []map[string]string{} | ||
| 1082 | - for ii, vv := range orderLogs[i].Descript { | ||
| 1083 | - d := map[string]string{ | ||
| 1084 | - "updateTitle": vv.Title, | ||
| 1085 | - "id": fmt.Sprint(ii), | ||
| 1086 | - "content": vv.Item, | ||
| 1087 | - } | ||
| 1088 | - if len(vv.Action) > 0 { | ||
| 1089 | - d["content"] = vv.Item + ":" + strings.Join(vv.Action, ";") | ||
| 1090 | - } | ||
| 1091 | - detail = append(detail, d) | ||
| 1092 | - } | ||
| 1093 | - m["updateList"] = detail | ||
| 1094 | - modifyLog = append(modifyLog, m) | ||
| 1095 | - } | ||
| 1096 | - | ||
| 1097 | - result := map[string]interface{}{ | ||
| 1098 | - "order": order, | ||
| 1099 | - "product": product, | ||
| 1100 | - "modify": modifyLog, | ||
| 1101 | - "remark": orderBase.Remark.RemarkBonus, | ||
| 1102 | - } | ||
| 1103 | - return result | ||
| 1104 | -} | ||
| 1105 | - | ||
| 1106 | -//UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 | ||
| 1107 | -func (service OrderInfoService) UpdateBonusByGoodNumber(orderId int64, goodId int64, adminId int64, goodNumber int, reason string) error { | ||
| 1108 | - var ( | ||
| 1109 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 1110 | - err error | ||
| 1111 | - ) | ||
| 1112 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 1113 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 1114 | - } | ||
| 1115 | - defer func() { | ||
| 1116 | - transactionContext.RollbackTransaction() | ||
| 1117 | - }() | ||
| 1118 | - var ( | ||
| 1119 | - orderBonuSrv domainService.OrderBonusService | ||
| 1120 | - ) | ||
| 1121 | - orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 1122 | - "transactionContext": transactionContext, | ||
| 1123 | - }) | ||
| 1124 | - if err != nil { | ||
| 1125 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1126 | - } | ||
| 1127 | - orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 1128 | - TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 1129 | - }) | ||
| 1130 | - err = orderBonuSrv.UpdateBounsByGoodNumber(orderId, adminId, goodId, goodNumber, reason) | ||
| 1131 | - if err != nil { | ||
| 1132 | - return err | ||
| 1133 | - } | ||
| 1134 | - err = transactionContext.CommitTransaction() | ||
| 1135 | - if err != nil { | ||
| 1136 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1137 | - } | ||
| 1138 | - return nil | ||
| 1139 | -} | ||
| 1140 | - | ||
| 1141 | -//UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 | ||
| 1142 | -func (service OrderInfoService) UpdateBonusByPartnerBonusPercent(orderId int64, goodId int64, adminId int64, percent float64, reason string) error { | ||
| 1143 | - var ( | ||
| 1144 | - transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 1145 | - err error | ||
| 1146 | - ) | ||
| 1147 | - if err = transactionContext.StartTransaction(); err != nil { | ||
| 1148 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 1149 | - } | ||
| 1150 | - defer func() { | ||
| 1151 | - transactionContext.RollbackTransaction() | ||
| 1152 | - }() | ||
| 1153 | - var ( | ||
| 1154 | - orderBonuSrv domainService.OrderBonusService | ||
| 1155 | - ) | ||
| 1156 | - orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 1157 | - "transactionContext": transactionContext, | ||
| 1158 | - }) | ||
| 1159 | - if err != nil { | ||
| 1160 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1161 | - } | ||
| 1162 | - orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 1163 | - TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 1164 | - }) | ||
| 1165 | - err = orderBonuSrv.UpdateBounsByPartnerBonusPercent(orderId, adminId, goodId, percent, reason) | ||
| 1166 | - if err != nil { | ||
| 1167 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1168 | - } | ||
| 1169 | - err = transactionContext.CommitTransaction() | ||
| 1170 | - if err != nil { | ||
| 1171 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 1172 | - } | ||
| 1173 | - return nil | ||
| 1174 | -} | ||
| 1175 | - | ||
| 1176 | -//PayPartnerBonusWithOrderBestshop 支付分红,海鲜干货的订单 (orderType=domain.OrderTypeBestShop) | ||
| 1177 | -func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, goodId int64, adminId int64) error { | 703 | +//PayPartnerBonusWithOrderBestshop 支付分红 |
| 704 | +func (service OrderInfoService) PayPartnerBonus(orderId int64, goodId int64, adminId int64) error { | ||
| 1178 | var ( | 705 | var ( |
| 1179 | transactionContext, _ = factory.CreateTransactionContext(nil) | 706 | transactionContext, _ = factory.CreateTransactionContext(nil) |
| 1180 | err error | 707 | err error |
| @@ -1208,7 +735,7 @@ func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, | @@ -1208,7 +735,7 @@ func (service OrderInfoService) PayPartnerBonusWithOrderBestshop(orderId int64, | ||
| 1208 | return nil | 735 | return nil |
| 1209 | } | 736 | } |
| 1210 | 737 | ||
| 1211 | -//PayPartnerBonusWithOrderBestshop 支付分红,海鲜干货的订单 (orderType=domain.OrderTypeBestShop) | 738 | +//UpdateOrderRemarkBonus 订单分红详情,更新备注 |
| 1212 | func (service OrderInfoService) UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error { | 739 | func (service OrderInfoService) UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error { |
| 1213 | var ( | 740 | var ( |
| 1214 | transactionContext, _ = factory.CreateTransactionContext(nil) | 741 | transactionContext, _ = factory.CreateTransactionContext(nil) |
| @@ -1268,6 +795,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | @@ -1268,6 +795,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | ||
| 1268 | listOrderQuery.OrderType, | 795 | listOrderQuery.OrderType, |
| 1269 | listOrderQuery.PartnerOrCode, | 796 | listOrderQuery.PartnerOrCode, |
| 1270 | listOrderQuery.PartnerCategory, | 797 | listOrderQuery.PartnerCategory, |
| 798 | + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, | ||
| 1271 | ) | 799 | ) |
| 1272 | if err != nil { | 800 | if err != nil { |
| 1273 | return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 801 | return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -1287,10 +815,14 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | @@ -1287,10 +815,14 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | ||
| 1287 | "partner_name": result[i].PartnerName, | 815 | "partner_name": result[i].PartnerName, |
| 1288 | "bonus_status": "", | 816 | "bonus_status": "", |
| 1289 | "update_time": result[i].UpdateTime, | 817 | "update_time": result[i].UpdateTime, |
| 1290 | - "partner_bonus": fmt.Sprint(result[i].PartnerBonus), | ||
| 1291 | - "partner_bonus_has": fmt.Sprint(result[i].PartnerBonusHas), | ||
| 1292 | - "partner_bonus_not": fmt.Sprint(result[i].PartnerBonusNot), | ||
| 1293 | - "partner_bonus_expense": fmt.Sprint(result[i].PartnerBonusExpense), | 818 | + "create_time": result[i].CreateTime, |
| 819 | + "partner_bonus": fmt.Sprintf("%10.2f", result[i].PartnerBonus), | ||
| 820 | + "partner_bonus_has": fmt.Sprintf("%10.2f", result[i].PartnerBonusHas), | ||
| 821 | + "partner_bonus_not": fmt.Sprintf("%10.2f", result[i].PartnerBonusNot), | ||
| 822 | + "partner_bonus_expense": fmt.Sprintf("%10.2f", result[i].PartnerBonusExpense), | ||
| 823 | + } | ||
| 824 | + if len(result[i].DeliveryCode) == 0 { | ||
| 825 | + m["delivery_code"] = "-" | ||
| 1294 | } | 826 | } |
| 1295 | if result[i].HasBonusPercent == 0 { | 827 | if result[i].HasBonusPercent == 0 { |
| 1296 | m["partner_bonus"] = "-" | 828 | m["partner_bonus"] = "-" |
| @@ -1313,7 +845,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | @@ -1313,7 +845,7 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | ||
| 1313 | [2]string{"delivery_code", "发货单号"}, | 845 | [2]string{"delivery_code", "发货单号"}, |
| 1314 | [2]string{"partner_name", "合伙人"}, | 846 | [2]string{"partner_name", "合伙人"}, |
| 1315 | [2]string{"bonus_status", "支付状态"}, | 847 | [2]string{"bonus_status", "支付状态"}, |
| 1316 | - [2]string{"update_time", "最后操作时间"}, | 848 | + [2]string{"create_time", "创建时间"}, |
| 1317 | [2]string{"partner_bonus", "应收分红"}, | 849 | [2]string{"partner_bonus", "应收分红"}, |
| 1318 | [2]string{"partner_bonus_has", "已收分红"}, | 850 | [2]string{"partner_bonus_has", "已收分红"}, |
| 1319 | [2]string{"partner_bonus_not", "未收分红"}, | 851 | [2]string{"partner_bonus_not", "未收分红"}, |
| @@ -1321,3 +853,80 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | @@ -1321,3 +853,80 @@ func (service OrderInfoService) ListOrderBonusForExcel(listOrderQuery query.List | ||
| 1321 | } | 853 | } |
| 1322 | return resultMaps, column, nil | 854 | return resultMaps, column, nil |
| 1323 | } | 855 | } |
| 856 | + | ||
| 857 | +func (service OrderInfoService) ListOrderForExcel(listOrderQuery query.ListOrderBaseQuery) ([]map[string]string, [][2]string, error) { | ||
| 858 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 859 | + if err != nil { | ||
| 860 | + return nil, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 861 | + } | ||
| 862 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 863 | + return nil, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 864 | + } | ||
| 865 | + defer func() { | ||
| 866 | + transactionContext.RollbackTransaction() | ||
| 867 | + }() | ||
| 868 | + var ( | ||
| 869 | + orderBaseDao *dao.OrderBaseDao | ||
| 870 | + ) | ||
| 871 | + | ||
| 872 | + if orderBaseDao, err = factory.CreateOrderBaseDao(map[string]interface{}{ | ||
| 873 | + "transactionContext": transactionContext, | ||
| 874 | + }); err != nil { | ||
| 875 | + return nil, nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 876 | + } | ||
| 877 | + ordersData, err := orderBaseDao.OrderListForExcel( | ||
| 878 | + listOrderQuery.CompanyId, | ||
| 879 | + listOrderQuery.PartnerOrCode, | ||
| 880 | + [2]string{listOrderQuery.UpdateTimeBegin, listOrderQuery.UpdateTimeEnd}, | ||
| 881 | + [2]string{listOrderQuery.CreateTimeBegin, listOrderQuery.CreateTimeEnd}, | ||
| 882 | + listOrderQuery.PartnerCategory, | ||
| 883 | + ) | ||
| 884 | + if err != nil { | ||
| 885 | + return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 886 | + } | ||
| 887 | + err = transactionContext.CommitTransaction() | ||
| 888 | + if err != nil { | ||
| 889 | + return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 890 | + } | ||
| 891 | + var resultMaps []map[string]string | ||
| 892 | + for i := range ordersData { | ||
| 893 | + m := map[string]string{ | ||
| 894 | + "num": fmt.Sprint(i + 1), | ||
| 895 | + "order_code": ordersData[i].OrderCode, | ||
| 896 | + "delivery_code": ordersData[i].DeliveryCode, | ||
| 897 | + "partner_name": ordersData[i].PartnerName, | ||
| 898 | + "update_time": ordersData[i].UpdateTime, | ||
| 899 | + "create_time": ordersData[i].CreateTime, | ||
| 900 | + "plan_order_count": fmt.Sprint(ordersData[i].PlanOrderCount), | ||
| 901 | + "use_order_count": "", | ||
| 902 | + "region_name": fmt.Sprint(ordersData[i].RegionName), | ||
| 903 | + "plan_order_amount": fmt.Sprintf("%10.2f", ordersData[i].PlanOrderAmount), | ||
| 904 | + "use_order_amount": "", | ||
| 905 | + "partner_category": ordersData[i].PartnerCategory, | ||
| 906 | + "buyer_name": ordersData[i].BuyerName, | ||
| 907 | + } | ||
| 908 | + if ordersData[i].UseOrderCount >= 0 { | ||
| 909 | + m["use_order_count"] = fmt.Sprint(ordersData[i].UseOrderCount) | ||
| 910 | + } | ||
| 911 | + if ordersData[i].UseOrderAmount >= 0 { | ||
| 912 | + m["use_order_amount"] = fmt.Sprintf("%10.2f", ordersData[i].UseOrderAmount) | ||
| 913 | + } | ||
| 914 | + resultMaps = append(resultMaps, m) | ||
| 915 | + } | ||
| 916 | + column := [][2]string{ | ||
| 917 | + [2]string{"num", "序号"}, | ||
| 918 | + [2]string{"order_code", "订单号"}, | ||
| 919 | + [2]string{"delivery_code", "发货单号"}, | ||
| 920 | + [2]string{"create_time", "创建时间"}, | ||
| 921 | + [2]string{"update_time", "更新时间"}, | ||
| 922 | + [2]string{"plan_order_count", "订单数量"}, | ||
| 923 | + [2]string{"use_order_count", "数量调整"}, | ||
| 924 | + [2]string{"plan_order_amount", "订单金额"}, | ||
| 925 | + [2]string{"use_order_amount", "金额调整"}, | ||
| 926 | + [2]string{"region_name", "订单区域"}, | ||
| 927 | + [2]string{"partner_category", "合伙人类型"}, | ||
| 928 | + [2]string{"buyer_name", "客户"}, | ||
| 929 | + [2]string{"partner_name", "合伙人"}, | ||
| 930 | + } | ||
| 931 | + return resultMaps, column, nil | ||
| 932 | +} |
| 1 | +package service | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "strings" | ||
| 6 | + | ||
| 7 | + "github.com/astaxie/beego/logs" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/event/subscriber" | ||
| 9 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory" | ||
| 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" | ||
| 13 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +//GetOrderInfoWithBonus 获取订单的分红详情 | ||
| 17 | +func (service OrderInfoService) GetOrderInfoWithBonus(orderBaseId int64, companyId int64) (interface{}, error) { | ||
| 18 | + var err error | ||
| 19 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 20 | + if err != nil { | ||
| 21 | + return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 22 | + } | ||
| 23 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 24 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 25 | + } | ||
| 26 | + defer func() { | ||
| 27 | + transactionContext.RollbackTransaction() | ||
| 28 | + }() | ||
| 29 | + var ( | ||
| 30 | + orderBaseRepository domain.OrderBaseRepository | ||
| 31 | + order *domain.OrderBase | ||
| 32 | + ) | ||
| 33 | + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 34 | + "transactionContext": transactionContext, | ||
| 35 | + }); err != nil { | ||
| 36 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 37 | + } | ||
| 38 | + order, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 39 | + OrderId: orderBaseId, | ||
| 40 | + CompanyId: companyId, | ||
| 41 | + }) | ||
| 42 | + if err != nil { | ||
| 43 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单数据失败:%s", err)) | ||
| 44 | + } | ||
| 45 | + _ = transactionContext.CommitTransaction() | ||
| 46 | + var ( | ||
| 47 | + returnData interface{} | ||
| 48 | + ) | ||
| 49 | + switch order.OrderType { | ||
| 50 | + case domain.OrderReal: | ||
| 51 | + returnData, err = service.GetOrderBaseDetailWithBonus(orderBaseId, companyId) | ||
| 52 | + case domain.OrderTypeBestShop: | ||
| 53 | + returnData, err = service.GetOrderBestshopInfoWithBonus(orderBaseId, companyId) | ||
| 54 | + } | ||
| 55 | + return returnData, err | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +//GetOrderBaseDetailWithBonus 获取实际订单分红详情 | ||
| 59 | +func (service OrderInfoService) GetOrderBaseDetailWithBonus(orderBaseId int64, companyId int64) (interface{}, error) { | ||
| 60 | + //实际业务 | ||
| 61 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 62 | + if err != nil { | ||
| 63 | + return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 64 | + } | ||
| 65 | + var ( | ||
| 66 | + orderBaseRepository domain.OrderBaseRepository | ||
| 67 | + partnerInfoRepository domain.PartnerInfoRepository | ||
| 68 | + orderGoodRepository domain.OrderGoodRepository | ||
| 69 | + orderLogRepository domain.OrderLogRepository | ||
| 70 | + order *domain.OrderBase | ||
| 71 | + ) | ||
| 72 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 73 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 74 | + } | ||
| 75 | + defer func() { | ||
| 76 | + transactionContext.RollbackTransaction() | ||
| 77 | + }() | ||
| 78 | + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 79 | + "transactionContext": transactionContext, | ||
| 80 | + }); err != nil { | ||
| 81 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 82 | + } | ||
| 83 | + if orderLogRepository, err = factory.CreateOrderLogRepository(map[string]interface{}{ | ||
| 84 | + "transactionContext": transactionContext, | ||
| 85 | + }); err != nil { | ||
| 86 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 87 | + } | ||
| 88 | + if partnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | ||
| 89 | + "transactionContext": transactionContext, | ||
| 90 | + }); err != nil { | ||
| 91 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 92 | + } | ||
| 93 | + if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
| 94 | + "transactionContext": transactionContext, | ||
| 95 | + }); err != nil { | ||
| 96 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 97 | + } | ||
| 98 | + order, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 99 | + OrderId: orderBaseId, | ||
| 100 | + CompanyId: companyId, | ||
| 101 | + }) | ||
| 102 | + if err != nil { | ||
| 103 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单数据失败:%s", err)) | ||
| 104 | + } | ||
| 105 | + var ( | ||
| 106 | + partnerData *domain.PartnerInfo | ||
| 107 | + goods []domain.OrderGood | ||
| 108 | + orderLogs []domain.OrderLog | ||
| 109 | + ) | ||
| 110 | + | ||
| 111 | + partnerData, err = partnerInfoRepository.FindOne(domain.PartnerFindOneQuery{ | ||
| 112 | + UserId: order.PartnerId, | ||
| 113 | + CompanyId: companyId, | ||
| 114 | + }) | ||
| 115 | + if err != nil { | ||
| 116 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("检索合伙人数据失败:%s", err)) | ||
| 117 | + } | ||
| 118 | + order.PartnerInfo = partnerData.Partner | ||
| 119 | + goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{ | ||
| 120 | + OrderId: order.Id, | ||
| 121 | + CompanyId: companyId, | ||
| 122 | + }) | ||
| 123 | + if err != nil { | ||
| 124 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("获取订单中的商品列表失败:%s", err)) | ||
| 125 | + } | ||
| 126 | + order.Goods = goods | ||
| 127 | + orderLogs, err = orderLogRepository.Find(domain.OrderLogFindQuery{OrderId: order.Id}) | ||
| 128 | + if err != nil { | ||
| 129 | + e := fmt.Sprintf("获取订单的修改记录(order_log)失败,err=%s", err) | ||
| 130 | + logs.Error(e) | ||
| 131 | + } | ||
| 132 | + err = transactionContext.CommitTransaction() | ||
| 133 | + if err != nil { | ||
| 134 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 135 | + } | ||
| 136 | + result := service.buildOrderBaseInfoData(order, orderLogs) | ||
| 137 | + return result, nil | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +//BuildOrderBestshopInfoData 构建前端需要的数据结构 | ||
| 141 | +func (service OrderInfoService) buildOrderBaseInfoData(orderBase *domain.OrderBase, orderLogs []domain.OrderLog) interface{} { | ||
| 142 | + //订单中的商品 | ||
| 143 | + productDetail := []map[string]interface{}{} | ||
| 144 | + var hasPartnerBonusPercent bool | ||
| 145 | + for i := range orderBase.Goods { | ||
| 146 | + detail := map[string]interface{}{ | ||
| 147 | + "commodityName": orderBase.Goods[i].GoodName, | ||
| 148 | + "productCodes": "", | ||
| 149 | + "commodityCode": "", | ||
| 150 | + "univalence": orderBase.Goods[i].Price, | ||
| 151 | + "orderNum": orderBase.Goods[i].GetCurrentGoodNumber(), | ||
| 152 | + "commodityPrice": orderBase.Goods[i].GetCurrentAmount(), | ||
| 153 | + "partnerDividends": "", | ||
| 154 | + "productId": orderBase.Goods[i].Id, | ||
| 155 | + "paymentStatus": orderBase.Goods[i].BonusStatus, | ||
| 156 | + "partnerRatio": orderBase.Goods[i].PartnerBonusPercent, | ||
| 157 | + } | ||
| 158 | + if orderBase.Goods[i].PartnerBonusPercent >= 0 { | ||
| 159 | + hasPartnerBonusPercent = true | ||
| 160 | + detail["partnerDividends"] = fmt.Sprint(orderBase.Goods[i].GetCurrentPartnerBonus()) | ||
| 161 | + } | ||
| 162 | + productDetail = append(productDetail, detail) | ||
| 163 | + } | ||
| 164 | + product := map[string]interface{}{ | ||
| 165 | + "orderNumCount": orderBase.GetCurrentOrderCount(), | ||
| 166 | + "partnerDividendsCount": "", | ||
| 167 | + "orderAmountAdjustmentCount": orderBase.GetCurrentOrderAmount(), | ||
| 168 | + "detail": productDetail, | ||
| 169 | + } | ||
| 170 | + if hasPartnerBonusPercent { | ||
| 171 | + product["partnerDividendsCount"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 172 | + } | ||
| 173 | + //订单描述 | ||
| 174 | + order := map[string]interface{}{ | ||
| 175 | + "orderId": fmt.Sprint(orderBase.Id), | ||
| 176 | + "orderType": orderBase.OrderType, | ||
| 177 | + "orderTypeName": domain.GetOrderBaseTypeName(orderBase.OrderType), | ||
| 178 | + "orderState": "", | ||
| 179 | + "customers": orderBase.Buyer.BuyerName, | ||
| 180 | + "address": "", | ||
| 181 | + "remarks": "", | ||
| 182 | + "partner": orderBase.PartnerInfo.PartnerName, | ||
| 183 | + "phone": "", | ||
| 184 | + "orderTime": "", | ||
| 185 | + "shippingStatus": "", | ||
| 186 | + "partnerDividends": "", | ||
| 187 | + "receivedDividends": "", | ||
| 188 | + "notReceivedDividend": "", | ||
| 189 | + "dividendSpending": "", | ||
| 190 | + "orderNumber": orderBase.OrderCode, | ||
| 191 | + "shipmentsId": orderBase.DeliveryCode, | ||
| 192 | + "orderArea": orderBase.RegionInfo.RegionName, | ||
| 193 | + "partnerCategory": orderBase.PartnerCategory.Name, | ||
| 194 | + } | ||
| 195 | + if hasPartnerBonusPercent { | ||
| 196 | + order["partnerDividends"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 197 | + order["receivedDividends"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusHas) | ||
| 198 | + order["notReceivedDividend"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusNot) | ||
| 199 | + order["dividendSpending"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusExpense) | ||
| 200 | + } | ||
| 201 | + modifyLog := []map[string]interface{}{} | ||
| 202 | + for i := range orderLogs { | ||
| 203 | + m := map[string]interface{}{ | ||
| 204 | + "title": orderLogs[i].LogAction, | ||
| 205 | + "time": orderLogs[i].AlterTime.Local().Format("2006-01-02 15:04:05"), | ||
| 206 | + "userName": orderLogs[i].Operator, | ||
| 207 | + "id": orderLogs[i].Id, | ||
| 208 | + } | ||
| 209 | + detail := []map[string]string{} | ||
| 210 | + for ii, vv := range orderLogs[i].Descript { | ||
| 211 | + d := map[string]string{ | ||
| 212 | + "updateTitle": vv.Title, | ||
| 213 | + "id": fmt.Sprint(ii), | ||
| 214 | + "content": vv.Item, | ||
| 215 | + } | ||
| 216 | + if len(vv.Action) > 0 { | ||
| 217 | + d["content"] = vv.Item + ":" + strings.Join(vv.Action, ";") | ||
| 218 | + } | ||
| 219 | + detail = append(detail, d) | ||
| 220 | + } | ||
| 221 | + m["updateList"] = detail | ||
| 222 | + modifyLog = append(modifyLog, m) | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + result := map[string]interface{}{ | ||
| 226 | + "order": order, | ||
| 227 | + "product": product, | ||
| 228 | + "modify": modifyLog, | ||
| 229 | + "remark": orderBase.Remark.RemarkBonus, | ||
| 230 | + } | ||
| 231 | + return result | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +//GetOrderBestshopInfo 获取来源于xiangmi订单的详情以及分红数据 | ||
| 235 | +func (service OrderInfoService) GetOrderBestshopInfoWithBonus(orderBaseId int64, companyId int64) (interface{}, error) { | ||
| 236 | + var ( | ||
| 237 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 238 | + err error | ||
| 239 | + ) | ||
| 240 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 241 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 242 | + } | ||
| 243 | + defer func() { | ||
| 244 | + transactionContext.RollbackTransaction() | ||
| 245 | + }() | ||
| 246 | + var ( | ||
| 247 | + orderBaseRepository domain.OrderBaseRepository | ||
| 248 | + orderGoodRepository domain.OrderGoodRepository | ||
| 249 | + orderBestshopRepository domain.OrderBestshopRepository | ||
| 250 | + orderGoodBestshopRepository domain.OrderGoodBestshopRepository | ||
| 251 | + orderLogRepository domain.OrderLogRepository | ||
| 252 | + partnerRepository domain.PartnerInfoRepository | ||
| 253 | + ) | ||
| 254 | + if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{ | ||
| 255 | + "transactionContext": transactionContext, | ||
| 256 | + }); err != nil { | ||
| 257 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 258 | + } | ||
| 259 | + if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{ | ||
| 260 | + "transactionContext": transactionContext, | ||
| 261 | + }); err != nil { | ||
| 262 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 263 | + } | ||
| 264 | + if orderBestshopRepository, err = factory.CreateOrderBestshopRepository(map[string]interface{}{ | ||
| 265 | + "transactionContext": transactionContext, | ||
| 266 | + }); err != nil { | ||
| 267 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 268 | + } | ||
| 269 | + if orderGoodBestshopRepository, err = factory.CreateOrderGoodBestshopRepository(map[string]interface{}{ | ||
| 270 | + "transactionContext": transactionContext, | ||
| 271 | + }); err != nil { | ||
| 272 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 273 | + } | ||
| 274 | + if orderLogRepository, err = factory.CreateOrderLogRepository(map[string]interface{}{ | ||
| 275 | + "transactionContext": transactionContext, | ||
| 276 | + }); err != nil { | ||
| 277 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 278 | + } | ||
| 279 | + if partnerRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{ | ||
| 280 | + "transactionContext": transactionContext, | ||
| 281 | + }); err != nil { | ||
| 282 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 283 | + } | ||
| 284 | + var ( | ||
| 285 | + orderData *domain.OrderBase | ||
| 286 | + orderGoods []domain.OrderGood | ||
| 287 | + orderBestshopData *domain.OrderBestShop | ||
| 288 | + orderGoodBestshop []domain.OrderGoodBestShop | ||
| 289 | + orderLogs []domain.OrderLog | ||
| 290 | + partnerInfo *domain.PartnerInfo | ||
| 291 | + ) | ||
| 292 | + | ||
| 293 | + orderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{ | ||
| 294 | + OrderId: orderBaseId, | ||
| 295 | + CompanyId: companyId, | ||
| 296 | + }) | ||
| 297 | + if err != nil { | ||
| 298 | + e := fmt.Sprintf("获取订单(order_base)数据失败,id=%d,company_id=%d,err=%s", orderBaseId, companyId, err) | ||
| 299 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 300 | + } | ||
| 301 | + if orderData.OrderType != domain.OrderTypeBestShop { | ||
| 302 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取的订单数据失败,OrderType err") | ||
| 303 | + } | ||
| 304 | + orderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderData.Id}) | ||
| 305 | + if err != nil { | ||
| 306 | + e := fmt.Sprintf("获取订单的商品(order_good)数据失败,order_id=%d,err=%s", orderData.Id, err) | ||
| 307 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 308 | + } | ||
| 309 | + orderData.Goods = orderGoods | ||
| 310 | + partnerInfo, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderData.PartnerId}) | ||
| 311 | + if err != nil { | ||
| 312 | + e := fmt.Sprintf("获取订单中的合伙人(partner)数据失败,id=%d,order_id=%d,err=%s", orderData.PartnerId, orderData.Id, err) | ||
| 313 | + logs.Error(e) | ||
| 314 | + } | ||
| 315 | + orderData.PartnerInfo = partnerInfo.Partner | ||
| 316 | + orderBestshopData, err = orderBestshopRepository.FindOne(domain.OrderBestshopFindOneQuery{OrderId: orderData.DataFrom.DataId}) | ||
| 317 | + if err != nil { | ||
| 318 | + e := fmt.Sprintf("获取xiangmi订单(order_bestshop)数据失败,id=%d,err=%s", orderData.DataFrom.DataId, err) | ||
| 319 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 320 | + } | ||
| 321 | + orderGoodBestshop, err = orderGoodBestshopRepository.Find(domain.OrderGoodBestshopFindQuery{OrderId: orderBestshopData.Id}) | ||
| 322 | + if err != nil { | ||
| 323 | + e := fmt.Sprintf("获取xiangmi订单货品(order_good_bestshop)数据失败,order_id=%d,err=%s", orderBestshopData.Id, err) | ||
| 324 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 325 | + } | ||
| 326 | + orderBestshopData.Goods = orderGoodBestshop | ||
| 327 | + orderLogs, err = orderLogRepository.Find(domain.OrderLogFindQuery{OrderId: orderData.Id}) | ||
| 328 | + if err != nil { | ||
| 329 | + e := fmt.Sprintf("获取订单的修改记录(order_log)失败,err=%s", err) | ||
| 330 | + logs.Error(e) | ||
| 331 | + } | ||
| 332 | + err = transactionContext.CommitTransaction() | ||
| 333 | + if err != nil { | ||
| 334 | + return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 335 | + } | ||
| 336 | + result := service.buildOrderBestshopInfoData(orderData, orderBestshopData, orderLogs) | ||
| 337 | + return result, nil | ||
| 338 | + | ||
| 339 | +} | ||
| 340 | + | ||
| 341 | +//BuildOrderBestshopInfoData 构建前端需要的数据结构 | ||
| 342 | +func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.OrderBase, | ||
| 343 | + orderBestshop *domain.OrderBestShop, orderLogs []domain.OrderLog) interface{} { | ||
| 344 | + orderGoodBestshopMap := map[int64]*domain.OrderGoodBestShop{} | ||
| 345 | + for i := range orderBestshop.Goods { | ||
| 346 | + goodid := orderBestshop.Goods[i].Id | ||
| 347 | + orderGoodBestshopMap[goodid] = &orderBestshop.Goods[i] | ||
| 348 | + } | ||
| 349 | + //订单中的商品 | ||
| 350 | + productDetail := []map[string]interface{}{} | ||
| 351 | + var hasPartnerBonusPercent bool | ||
| 352 | + for i := range orderBase.Goods { | ||
| 353 | + detail := map[string]interface{}{ | ||
| 354 | + "commodityName": orderBase.Goods[i].GoodName, | ||
| 355 | + "productCodes": "", | ||
| 356 | + "commodityCode": "", | ||
| 357 | + "univalence": orderBase.Goods[i].Price, | ||
| 358 | + "orderNum": orderBase.Goods[i].GetCurrentGoodNumber(), | ||
| 359 | + "commodityPrice": orderBase.Goods[i].GetCurrentAmount(), | ||
| 360 | + "partnerDividends": "", | ||
| 361 | + "productId": orderBase.Goods[i].Id, | ||
| 362 | + "paymentStatus": orderBase.Goods[i].BonusStatus, | ||
| 363 | + "partnerRatio": orderBase.Goods[i].PartnerBonusPercent, | ||
| 364 | + } | ||
| 365 | + if orderBase.Goods[i].PartnerBonusPercent >= 0 { | ||
| 366 | + hasPartnerBonusPercent = true | ||
| 367 | + detail["partnerDividends"] = fmt.Sprint(orderBase.Goods[i].GetCurrentPartnerBonus()) | ||
| 368 | + } | ||
| 369 | + goodBestshopId := orderBase.Goods[i].DataFrom.DataId | ||
| 370 | + if v, ok := orderGoodBestshopMap[goodBestshopId]; ok { | ||
| 371 | + detail["productCodes"] = v.Sn | ||
| 372 | + detail["commodityCode"] = v.Bn | ||
| 373 | + } | ||
| 374 | + productDetail = append(productDetail, detail) | ||
| 375 | + } | ||
| 376 | + product := map[string]interface{}{ | ||
| 377 | + "orderNumCount": orderBase.GetCurrentOrderCount(), | ||
| 378 | + "partnerDividendsCount": "", | ||
| 379 | + "orderAmountAdjustmentCount": orderBase.GetCurrentOrderAmount(), | ||
| 380 | + "detail": productDetail, | ||
| 381 | + } | ||
| 382 | + if hasPartnerBonusPercent { | ||
| 383 | + product["partnerDividendsCount"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 384 | + } | ||
| 385 | + //订单描述 | ||
| 386 | + order := map[string]interface{}{ | ||
| 387 | + "orderId": fmt.Sprint(orderBase.Id), | ||
| 388 | + "orderType": orderBase.OrderType, | ||
| 389 | + "orderTypeName": domain.GetOrderBaseTypeName(orderBase.OrderType), | ||
| 390 | + "orderState": orderBestshop.OrderState, | ||
| 391 | + "customers": orderBase.Buyer.BuyerName, | ||
| 392 | + "address": orderBestshop.BuyerAddress, | ||
| 393 | + "remarks": orderBestshop.BuyerRemark, | ||
| 394 | + "partner": orderBase.PartnerInfo.PartnerName, | ||
| 395 | + "phone": orderBestshop.BuyerPhone, | ||
| 396 | + "orderTime": orderBestshop.OrderTime, | ||
| 397 | + "shippingStatus": orderBestshop.DeliveryState, | ||
| 398 | + "partnerDividends": "", | ||
| 399 | + "receivedDividends": "", | ||
| 400 | + "notReceivedDividend": "", | ||
| 401 | + "dividendSpending": "", | ||
| 402 | + "orderNumber": orderBase.OrderCode, | ||
| 403 | + "orderArea": orderBase.RegionInfo.RegionName, | ||
| 404 | + "partnerCategory": orderBase.PartnerCategory.Name, | ||
| 405 | + "shipmentsId": orderBase.DeliveryCode, | ||
| 406 | + } | ||
| 407 | + if hasPartnerBonusPercent { | ||
| 408 | + order["partnerDividends"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus()) | ||
| 409 | + order["receivedDividends"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusHas) | ||
| 410 | + order["notReceivedDividend"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusNot) | ||
| 411 | + order["dividendSpending"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusExpense) | ||
| 412 | + } | ||
| 413 | + modifyLog := []map[string]interface{}{} | ||
| 414 | + for i := range orderLogs { | ||
| 415 | + m := map[string]interface{}{ | ||
| 416 | + "title": orderLogs[i].LogAction, | ||
| 417 | + "time": orderLogs[i].AlterTime.Local().Format("2006-01-02 15:04:05"), | ||
| 418 | + "userName": orderLogs[i].Operator, | ||
| 419 | + "id": orderLogs[i].Id, | ||
| 420 | + } | ||
| 421 | + detail := []map[string]string{} | ||
| 422 | + for ii, vv := range orderLogs[i].Descript { | ||
| 423 | + d := map[string]string{ | ||
| 424 | + "updateTitle": vv.Title, | ||
| 425 | + "id": fmt.Sprint(ii), | ||
| 426 | + "content": vv.Item, | ||
| 427 | + } | ||
| 428 | + if len(vv.Action) > 0 { | ||
| 429 | + d["content"] = vv.Item + ":" + strings.Join(vv.Action, ";") | ||
| 430 | + } | ||
| 431 | + detail = append(detail, d) | ||
| 432 | + } | ||
| 433 | + m["updateList"] = detail | ||
| 434 | + modifyLog = append(modifyLog, m) | ||
| 435 | + } | ||
| 436 | + | ||
| 437 | + result := map[string]interface{}{ | ||
| 438 | + "order": order, | ||
| 439 | + "product": product, | ||
| 440 | + "modify": modifyLog, | ||
| 441 | + "remark": orderBase.Remark.RemarkBonus, | ||
| 442 | + } | ||
| 443 | + return result | ||
| 444 | +} | ||
| 445 | + | ||
| 446 | +//UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动 | ||
| 447 | +func (service OrderInfoService) UpdateBonusByGoodNumber(orderId int64, goodId int64, adminId int64, goodNumber int, reason string) error { | ||
| 448 | + var ( | ||
| 449 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 450 | + err error | ||
| 451 | + ) | ||
| 452 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 453 | + return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 454 | + } | ||
| 455 | + defer func() { | ||
| 456 | + transactionContext.RollbackTransaction() | ||
| 457 | + }() | ||
| 458 | + var ( | ||
| 459 | + orderBonuSrv domainService.OrderBonusService | ||
| 460 | + ) | ||
| 461 | + orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 462 | + "transactionContext": transactionContext, | ||
| 463 | + }) | ||
| 464 | + if err != nil { | ||
| 465 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 466 | + } | ||
| 467 | + orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 468 | + TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 469 | + }) | ||
| 470 | + err = orderBonuSrv.UpdateBounsByGoodNumber(orderId, adminId, goodId, goodNumber, reason) | ||
| 471 | + if err != nil { | ||
| 472 | + return err | ||
| 473 | + } | ||
| 474 | + err = transactionContext.CommitTransaction() | ||
| 475 | + if err != nil { | ||
| 476 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 477 | + } | ||
| 478 | + return nil | ||
| 479 | +} | ||
| 480 | + | ||
| 481 | +//UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动 | ||
| 482 | +func (service OrderInfoService) UpdateBonusByPartnerBonusPercent(orderId int64, goodId int64, adminId int64, percent float64, reason string) error { | ||
| 483 | + var ( | ||
| 484 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 485 | + err error | ||
| 486 | + ) | ||
| 487 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 488 | + return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 489 | + } | ||
| 490 | + defer func() { | ||
| 491 | + transactionContext.RollbackTransaction() | ||
| 492 | + }() | ||
| 493 | + var ( | ||
| 494 | + orderBonuSrv domainService.OrderBonusService | ||
| 495 | + ) | ||
| 496 | + orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 497 | + "transactionContext": transactionContext, | ||
| 498 | + }) | ||
| 499 | + if err != nil { | ||
| 500 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 501 | + } | ||
| 502 | + orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 503 | + TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 504 | + }) | ||
| 505 | + err = orderBonuSrv.UpdateBounsByPartnerBonusPercent(orderId, adminId, goodId, percent, reason) | ||
| 506 | + if err != nil { | ||
| 507 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 508 | + } | ||
| 509 | + err = transactionContext.CommitTransaction() | ||
| 510 | + if err != nil { | ||
| 511 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 512 | + } | ||
| 513 | + return nil | ||
| 514 | +} | ||
| 515 | + | ||
| 516 | +//BatchPayPartnerBonus 批量支付分红 | ||
| 517 | +func (service OrderInfoService) BatchPayPartnerBonus(orderId []int64, adminId int64) error { | ||
| 518 | + var ( | ||
| 519 | + transactionContext, _ = factory.CreateTransactionContext(nil) | ||
| 520 | + err error | ||
| 521 | + ) | ||
| 522 | + if err = transactionContext.StartTransaction(); err != nil { | ||
| 523 | + return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | ||
| 524 | + } | ||
| 525 | + defer func() { | ||
| 526 | + transactionContext.RollbackTransaction() | ||
| 527 | + }() | ||
| 528 | + var ( | ||
| 529 | + orderBonuSrv domainService.OrderBonusService | ||
| 530 | + ) | ||
| 531 | + orderBonuSrv, err = factory.CreateOrderBonusService(map[string]interface{}{ | ||
| 532 | + "transactionContext": transactionContext, | ||
| 533 | + }) | ||
| 534 | + if err != nil { | ||
| 535 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 536 | + } | ||
| 537 | + orderBonuSrv.Subscribe(&subscriber.OrderLogSubscriber{ | ||
| 538 | + TransactionContext: transactionContext.(*transaction.TransactionContext), | ||
| 539 | + }) | ||
| 540 | + err = orderBonuSrv.BatchPayPartnerBonus(orderId, adminId) | ||
| 541 | + if err != nil { | ||
| 542 | + return err | ||
| 543 | + } | ||
| 544 | + err = transactionContext.CommitTransaction() | ||
| 545 | + if err != nil { | ||
| 546 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 547 | + } | ||
| 548 | + return nil | ||
| 549 | +} |
| @@ -8,7 +8,6 @@ import ( | @@ -8,7 +8,6 @@ import ( | ||
| 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/command" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/command" |
| 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query" |
| 10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
| 11 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain/service" | ||
| 12 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/dao" | 11 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/dao" |
| 13 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 12 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" |
| 14 | ) | 13 | ) |
| @@ -23,7 +22,7 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService { | @@ -23,7 +22,7 @@ func NewPartnerInfoService(options map[string]interface{}) *PartnerInfoService { | ||
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | // CreatePartnerInfo 创建合伙人 | 24 | // CreatePartnerInfo 创建合伙人 |
| 26 | -func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.CreatePartnerInfoCommand) (data interface{}, err error) { | 25 | +func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.CreatePartnerInfoCommand) (data *domain.PartnerInfo, err error) { |
| 27 | var ( | 26 | var ( |
| 28 | transactionContext, _ = factory.CreateTransactionContext(nil) | 27 | transactionContext, _ = factory.CreateTransactionContext(nil) |
| 29 | ) | 28 | ) |
| @@ -92,19 +91,19 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | @@ -92,19 +91,19 @@ func (PartnerInfoService *PartnerInfoService) CreatePartnerInfo(cmd *command.Cre | ||
| 92 | if err = partnerInfoRepository.Save(&newPartnerInfo); err != nil { | 91 | if err = partnerInfoRepository.Save(&newPartnerInfo); err != nil { |
| 93 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 92 | return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
| 94 | } | 93 | } |
| 95 | - var businessBonusSrv service.BusinessBonusService | ||
| 96 | - if businessBonusSrv, err = factory.CreateBusinessBonusService(map[string]interface{}{ | ||
| 97 | - "transactionContext": transactionContext, | ||
| 98 | - }); err != nil { | ||
| 99 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 100 | - } | ||
| 101 | - err = businessBonusSrv.EnableOrDisable(newPartnerInfo.Partner.Id) | ||
| 102 | - if err != nil { | ||
| 103 | - e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", newPartnerInfo.Partner.Id, err) | ||
| 104 | - return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 105 | - } | 94 | + //var businessBonusSrv service.BusinessBonusService |
| 95 | + // if businessBonusSrv, err = factory.CreateBusinessBonusService(map[string]interface{}{ | ||
| 96 | + // "transactionContext": transactionContext, | ||
| 97 | + // }); err != nil { | ||
| 98 | + // return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 99 | + // } | ||
| 100 | + // err = businessBonusSrv.EnableOrDisable(newPartnerInfo.Partner.Id) | ||
| 101 | + // if err != nil { | ||
| 102 | + // e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", newPartnerInfo.Partner.Id, err) | ||
| 103 | + // return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 104 | + // } | ||
| 106 | err = transactionContext.CommitTransaction() | 105 | err = transactionContext.CommitTransaction() |
| 107 | - return newPartnerInfo, nil | 106 | + return &newPartnerInfo, nil |
| 108 | } | 107 | } |
| 109 | 108 | ||
| 110 | // GetPartnerInfo 返回合伙人 | 109 | // GetPartnerInfo 返回合伙人 |
| @@ -216,18 +215,18 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | @@ -216,18 +215,18 @@ func (PartnerInfoService *PartnerInfoService) UpdatePartnerInfo(cmd *command.Upd | ||
| 216 | if err = partnerInfoRepository.Save(partnerInfo); err != nil { | 215 | if err = partnerInfoRepository.Save(partnerInfo); err != nil { |
| 217 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | 216 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) |
| 218 | } | 217 | } |
| 219 | - var businessBonusSrv service.BusinessBonusService | ||
| 220 | - if businessBonusSrv, err = factory.CreateBusinessBonusService(map[string]interface{}{ | ||
| 221 | - "transactionContext": transactionContext, | ||
| 222 | - }); err != nil { | ||
| 223 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 224 | - } | ||
| 225 | - //TODO 修改为本地消息订阅 | ||
| 226 | - err = businessBonusSrv.EnableOrDisable(partnerInfo.Partner.Id) | ||
| 227 | - if err != nil { | ||
| 228 | - e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err) | ||
| 229 | - return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 230 | - } | 218 | + //到0.6.0 彻底删除 |
| 219 | + // var businessBonusSrv service.BusinessBonusService | ||
| 220 | + // if businessBonusSrv, err = factory.CreateBusinessBonusService(map[string]interface{}{ | ||
| 221 | + // "transactionContext": transactionContext, | ||
| 222 | + // }); err != nil { | ||
| 223 | + // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 224 | + // } | ||
| 225 | + // err = businessBonusSrv.EnableOrDisable(partnerInfo.Partner.Id) | ||
| 226 | + // if err != nil { | ||
| 227 | + // e := fmt.Sprintf("更新业务分红(partner_id=%d)数据失败:%s", partnerInfo.Partner.Id, err) | ||
| 228 | + // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 229 | + // } | ||
| 231 | transactionContext.CommitTransaction() | 230 | transactionContext.CommitTransaction() |
| 232 | return | 231 | return |
| 233 | } | 232 | } |
| @@ -28,6 +28,7 @@ type CreateOrderFromBestshop struct { | @@ -28,6 +28,7 @@ type CreateOrderFromBestshop struct { | ||
| 28 | //发货时间 | 28 | //发货时间 |
| 29 | DeliveryTime string `json:"deliveryTime"` | 29 | DeliveryTime string `json:"deliveryTime"` |
| 30 | PartnerId int64 `json:"partnerId"` | 30 | PartnerId int64 `json:"partnerId"` |
| 31 | + OrderArea string `json:"orderArea"` | ||
| 31 | Goods []struct { | 32 | Goods []struct { |
| 32 | Id int64 `json:"id"` | 33 | Id int64 `json:"id"` |
| 33 | //货品编号 | 34 | //货品编号 |
| @@ -126,6 +126,7 @@ func (s SyncOrderService) CreateOrderFromBestshop(cmd command.CreateOrderFromBes | @@ -126,6 +126,7 @@ func (s SyncOrderService) CreateOrderFromBestshop(cmd command.CreateOrderFromBes | ||
| 126 | DeliveryTime: cmd.DeliveryTime, | 126 | DeliveryTime: cmd.DeliveryTime, |
| 127 | IsCopy: false, | 127 | IsCopy: false, |
| 128 | CompanyId: cmd.CompanyId, | 128 | CompanyId: cmd.CompanyId, |
| 129 | + OrderArea: cmd.OrderArea, | ||
| 129 | } | 130 | } |
| 130 | err = orderBestshopRepository.Add(&order) | 131 | err = orderBestshopRepository.Add(&order) |
| 131 | if err != nil { | 132 | if err != nil { |
| @@ -224,7 +225,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord | @@ -224,7 +225,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord | ||
| 224 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | 225 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) |
| 225 | } | 226 | } |
| 226 | for _, v := range companyData.Applets { | 227 | for _, v := range companyData.Applets { |
| 227 | - if v.Id == BEST_SHOP_UNIONID { | 228 | + if len(v.Id) > 0 { |
| 228 | canCopyOrder = true | 229 | canCopyOrder = true |
| 229 | } | 230 | } |
| 230 | } | 231 | } |
| @@ -501,9 +501,9 @@ func (service UsersService) EditUserPermission(cmd command.EditUserPermissionCom | @@ -501,9 +501,9 @@ func (service UsersService) EditUserPermission(cmd command.EditUserPermissionCom | ||
| 501 | partners = append(partners, p) | 501 | partners = append(partners, p) |
| 502 | } | 502 | } |
| 503 | for i := range permissionList { | 503 | for i := range permissionList { |
| 504 | - if permissionList[i].Code == domain.PERMINSSION_ADMIN_USER && !usersData.IsSuperAdmin() { | ||
| 505 | - return lib.ThrowError(lib.BUSINESS_ERROR, "操作异常") | ||
| 506 | - } | 504 | + // if permissionList[i].Code == domain.PERMINSSION_ADMIN_USER && !usersData.IsSuperAdmin() { |
| 505 | + // return lib.ThrowError(lib.BUSINESS_ERROR, "操作异常") | ||
| 506 | + // } | ||
| 507 | p := domain.AdminPermissionBase{ | 507 | p := domain.AdminPermissionBase{ |
| 508 | Id: permissionList[i].Id, | 508 | Id: permissionList[i].Id, |
| 509 | Code: permissionList[i].Code, | 509 | Code: permissionList[i].Code, |
| 1 | package event | 1 | package event |
| 2 | 2 | ||
| 3 | +import "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 4 | + | ||
| 3 | const ( | 5 | const ( |
| 4 | //支付订单中货品的分红 | 6 | //支付订单中货品的分红 |
| 5 | - PAY_ORDER_GOOD_BONUS_EVENT string = "PayOrderGoodBonus" | 7 | + PAY_ORDER_GOOD_BONUS_EVENT string = "PayOrderGoodBonus" |
| 8 | + BATCH_PAY_ORDER_GOOD_BONUS_EVENT string = "BatchPayOrderGoodBonus" | ||
| 6 | ) | 9 | ) |
| 7 | 10 | ||
| 11 | +//BatchPayOrderGoodBonus | ||
| 12 | +//事件:批量支付一个订单中货品的分红 | ||
| 13 | +type BatchPayOrderGoodBonus []PayOrderGoodBonus | ||
| 14 | + | ||
| 15 | +func (p BatchPayOrderGoodBonus) EventType() string { | ||
| 16 | + return BATCH_PAY_ORDER_GOOD_BONUS_EVENT | ||
| 17 | +} | ||
| 18 | + | ||
| 8 | //PayOrderGoodBonus | 19 | //PayOrderGoodBonus |
| 9 | -//事件:支付订单中货品的分红 | 20 | +//事件:支付一个订单中货品的分红 |
| 10 | type PayOrderGoodBonus struct { | 21 | type PayOrderGoodBonus struct { |
| 11 | - //订单id | ||
| 12 | - OrderId int64 | ||
| 13 | - //货品名称 | ||
| 14 | - GoodName string | ||
| 15 | - //订单中的货品id | ||
| 16 | - GoodId int64 | ||
| 17 | - //管理员id | ||
| 18 | - AdminId int64 | ||
| 19 | - // | ||
| 20 | - PartnerBonus float64 | 22 | + OrderBase *domain.OrderBase |
| 23 | + Goods []domain.OrderGood | ||
| 24 | + Admin *domain.Users | ||
| 21 | } | 25 | } |
| 22 | 26 | ||
| 23 | func (p PayOrderGoodBonus) EventType() string { | 27 | func (p PayOrderGoodBonus) EventType() string { |
| @@ -182,16 +182,14 @@ func (order *OrderBase) AddGoods(goods []OrderGood) { | @@ -182,16 +182,14 @@ 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 | 185 | +func (order *OrderBase) ModifyGoodNumber(goodid int64, number int64) { |
| 187 | for i := range order.Goods { | 186 | for i := range order.Goods { |
| 188 | - for _, goodId := range goodIds { | ||
| 189 | - order.Goods[i].Id = goodId | 187 | + if order.Goods[i].Id != goodid { |
| 190 | continue | 188 | continue |
| 191 | } | 189 | } |
| 192 | - newGoods = append(newGoods, order.Goods[i]) | 190 | + // thisGood := order.Goods[i] |
| 191 | + | ||
| 193 | } | 192 | } |
| 194 | - order.Goods = newGoods | ||
| 195 | order.Compute() | 193 | order.Compute() |
| 196 | } | 194 | } |
| 197 | 195 |
| @@ -34,8 +34,9 @@ type OrderBestShop struct { | @@ -34,8 +34,9 @@ type OrderBestShop struct { | ||
| 34 | PartnerId int64 `json:"partnerId"` | 34 | PartnerId int64 `json:"partnerId"` |
| 35 | Goods []OrderGoodBestShop `json:"goods"` | 35 | Goods []OrderGoodBestShop `json:"goods"` |
| 36 | //是否将数据同步到 order_base ,order_good | 36 | //是否将数据同步到 order_base ,order_good |
| 37 | - IsCopy bool `json:"isCopy"` | ||
| 38 | - CompanyId int64 `json:"companyId"` | 37 | + IsCopy bool `json:"isCopy"` |
| 38 | + CompanyId int64 `json:"companyId"` | ||
| 39 | + OrderArea string `json:"orderArea"` | ||
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | 42 | func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { |
| @@ -54,6 +55,7 @@ func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | @@ -54,6 +55,7 @@ func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | ||
| 54 | o.OrderCompute.PlanOrderAmount = order.OrderAmount | 55 | o.OrderCompute.PlanOrderAmount = order.OrderAmount |
| 55 | o.OrderCompute.PlanOrderCount = order.OrderCount | 56 | o.OrderCompute.PlanOrderCount = order.OrderCount |
| 56 | o.DeliveryTime, _ = time.Parse("2006-01-02 15:04:05", order.DeliveryTime) | 57 | o.DeliveryTime, _ = time.Parse("2006-01-02 15:04:05", order.DeliveryTime) |
| 58 | + o.RegionInfo.RegionName = order.OrderArea | ||
| 57 | return | 59 | return |
| 58 | } | 60 | } |
| 59 | 61 |
| @@ -2,6 +2,7 @@ package domain | @@ -2,6 +2,7 @@ package domain | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "errors" | 4 | "errors" |
| 5 | + "fmt" | ||
| 5 | 6 | ||
| 6 | "github.com/shopspring/decimal" | 7 | "github.com/shopspring/decimal" |
| 7 | ) | 8 | ) |
| @@ -12,6 +13,10 @@ type OrderGoodBonusStatus interface { | @@ -12,6 +13,10 @@ type OrderGoodBonusStatus interface { | ||
| 12 | WartPayPartnerBonus(orderGood *OrderGood) error | 13 | WartPayPartnerBonus(orderGood *OrderGood) error |
| 13 | //状态变更为已支付 | 14 | //状态变更为已支付 |
| 14 | PayPartnerBonus(orderGood *OrderGood) error | 15 | PayPartnerBonus(orderGood *OrderGood) error |
| 16 | + //变更货品数量 | ||
| 17 | + ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error | ||
| 18 | + //变更合伙人分红比例 | ||
| 19 | + ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error | ||
| 15 | } | 20 | } |
| 16 | 21 | ||
| 17 | //货单的支付状态 | 22 | //货单的支付状态 |
| @@ -43,6 +48,7 @@ type GoodCompute struct { | @@ -43,6 +48,7 @@ type GoodCompute struct { | ||
| 43 | //合伙人分红支出 | 48 | //合伙人分红支出 |
| 44 | PartnerBonusExpense float64 `json:"partnerBonusExpense"` | 49 | PartnerBonusExpense float64 `json:"partnerBonusExpense"` |
| 45 | } | 50 | } |
| 51 | + | ||
| 46 | type OrderGoodRemarkReason struct { | 52 | type OrderGoodRemarkReason struct { |
| 47 | ModifyGoodNumber string `json:"modifyGoodNumber"` //货品数量变更的理由 | 53 | ModifyGoodNumber string `json:"modifyGoodNumber"` //货品数量变更的理由 |
| 48 | ModifyPartnerBonusPercent string `json:"modifyPartnerBonusPercent"` //合伙人分红比例变更的理由 | 54 | ModifyPartnerBonusPercent string `json:"modifyPartnerBonusPercent"` //合伙人分红比例变更的理由 |
| @@ -105,6 +111,20 @@ func (good OrderGood) GetCurrentPartnerBonus() float64 { | @@ -105,6 +111,20 @@ func (good OrderGood) GetCurrentPartnerBonus() float64 { | ||
| 105 | return good.GoodCompute.PlanPartnerBonus | 111 | return good.GoodCompute.PlanPartnerBonus |
| 106 | } | 112 | } |
| 107 | 113 | ||
| 114 | +//GetCurrentAmount 获取当前的商品合伙人分红 | ||
| 115 | +func (good *OrderGood) ModifyOrderGoodNumber(number int, orderType int) error { | ||
| 116 | + if good.PlanGoodNumber < number { | ||
| 117 | + return fmt.Errorf("修改数量不能大于初始值:%d", good.PlanGoodNumber) | ||
| 118 | + } | ||
| 119 | + err := good.CurrentBonusStatus.ModifyOrderGoodNumber(good, number, orderType) | ||
| 120 | + return err | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +func (good *OrderGood) ModifyPertnerBonusPercent(percent float64, orderType int) error { | ||
| 124 | + err := good.CurrentBonusStatus.ModifyPertnerBonusPercent(good, percent, orderType) | ||
| 125 | + return err | ||
| 126 | +} | ||
| 127 | + | ||
| 108 | //Update 更新商品相关的数据 | 128 | //Update 更新商品相关的数据 |
| 109 | func (good *OrderGood) Update(m map[string]interface{}) error { | 129 | func (good *OrderGood) Update(m map[string]interface{}) error { |
| 110 | if v, ok := m["GoodName"]; ok { | 130 | if v, ok := m["GoodName"]; ok { |
| @@ -194,6 +214,68 @@ func (hasPay OrderGoodBonusHasPay) WartPayPartnerBonus(good *OrderGood) error { | @@ -194,6 +214,68 @@ func (hasPay OrderGoodBonusHasPay) WartPayPartnerBonus(good *OrderGood) error { | ||
| 194 | return errors.New("已支付的货单不能将状态回退为待支付") | 214 | return errors.New("已支付的货单不能将状态回退为待支付") |
| 195 | } | 215 | } |
| 196 | 216 | ||
| 217 | +func (hasPay OrderGoodBonusHasPay) ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error { | ||
| 218 | + //规则描述: | ||
| 219 | + //实际自建订单(orderType==1),已支付分红状态下“可以”修改货品数量 | ||
| 220 | + //香米小程序订单(orderType==3),已支付分红状态下“不可以”修改货品数量 | ||
| 221 | + switch orderType { | ||
| 222 | + case OrderReal: | ||
| 223 | + good.UseGoodNumber = number | ||
| 224 | + //待支付状态计算 | ||
| 225 | + err := good.Compute() | ||
| 226 | + if err != nil { | ||
| 227 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 228 | + } | ||
| 229 | + case OrderTypeBestShop: | ||
| 230 | + return errors.New("小程序订单里已支付分红的货品订单,不能修改货品数量") | ||
| 231 | + } | ||
| 232 | + good.CurrentBonusStatus.PayPartnerBonus(good) | ||
| 233 | + return nil | ||
| 234 | +} | ||
| 235 | + | ||
| 236 | +func (waitPay OrderGoodBonusWaitPay) ModifyOrderGoodNumber(good *OrderGood, number int, orderType int) error { | ||
| 237 | + //规则描述: | ||
| 238 | + //实际自建订单(orderType==1),未支付分红状态下“可以”修改货品数量 | ||
| 239 | + //香米小程序订单(orderType==3),未支付分红状态下“可以”修改货品数量 | ||
| 240 | + good.UseGoodNumber = number | ||
| 241 | + //待支付状态计算 | ||
| 242 | + err := good.Compute() | ||
| 243 | + if err != nil { | ||
| 244 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 245 | + } | ||
| 246 | + good.CurrentBonusStatus.WartPayPartnerBonus(good) | ||
| 247 | + return nil | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | +func (waitPay OrderGoodBonusWaitPay) ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error { | ||
| 251 | + //规则描述: | ||
| 252 | + //实际自建订单(orderType==1),未支付分红状态下“不可以”修改合伙人分红比例 | ||
| 253 | + //香米小程序订单(orderType==3),未支付分红状态下“可以”修改合伙人分红比例 | ||
| 254 | + switch orderType { | ||
| 255 | + case OrderReal: | ||
| 256 | + return errors.New("自建订单不能修改合伙人分红比例") | ||
| 257 | + case OrderTypeBestShop: | ||
| 258 | + good.PartnerBonusPercent = percent | ||
| 259 | + //待支付状态计算 | ||
| 260 | + err := good.Compute() | ||
| 261 | + if err != nil { | ||
| 262 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 263 | + } | ||
| 264 | + err = good.CurrentBonusStatus.WartPayPartnerBonus(good) | ||
| 265 | + if err != nil { | ||
| 266 | + return errors.New("核算商品数据失败" + err.Error()) | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + return nil | ||
| 270 | +} | ||
| 271 | + | ||
| 272 | +func (hasPay OrderGoodBonusHasPay) ModifyPertnerBonusPercent(good *OrderGood, percent float64, orderType int) error { | ||
| 273 | + //规则描述: | ||
| 274 | + //实际自建订单(orderType==1),已支付分红状态下“不可以”修改合伙人分红比例 | ||
| 275 | + //香米小程序订单(orderType==3),已支付分红状态下“不可以”修改合伙人分红比例 | ||
| 276 | + return errors.New("已支付分红的货品订单,不能修改合伙人分红比例") | ||
| 277 | +} | ||
| 278 | + | ||
| 197 | //NewOrderGood 初始值设定 | 279 | //NewOrderGood 初始值设定 |
| 198 | func NewOrderGood() OrderGood { | 280 | func NewOrderGood() OrderGood { |
| 199 | return OrderGood{ | 281 | return OrderGood{ |
| @@ -16,6 +16,7 @@ const ( | @@ -16,6 +16,7 @@ const ( | ||
| 16 | 16 | ||
| 17 | //OrderLogDescript 描述日志内容 | 17 | //OrderLogDescript 描述日志内容 |
| 18 | type OrderLogDescript struct { | 18 | type OrderLogDescript struct { |
| 19 | + GoodId int64 `json:"goodId"` | ||
| 19 | Title string `json:"title"` //标题 | 20 | Title string `json:"title"` //标题 |
| 20 | Item string `json:"item"` //修改的项目 | 21 | Item string `json:"item"` //修改的项目 |
| 21 | Action []string `json:"action"` //执行的操作 | 22 | Action []string `json:"action"` //执行的操作 |
pkg/domain/order_with_bestshop.go
已删除
100644 → 0
| 1 | -package domain | ||
| 2 | - | ||
| 3 | -import ( | ||
| 4 | - "errors" | ||
| 5 | - "fmt" | ||
| 6 | -) | ||
| 7 | - | ||
| 8 | -//类型为(orderType=OrderTypeBestShop) 海鲜干货的订单分红 | ||
| 9 | -//因页面上的对于该类型的订单分红状态处理方式 有别于原有的其他类型(OrderReal),所以单独提取出来 | ||
| 10 | - | ||
| 11 | -// 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 | -} |
| @@ -10,4 +10,5 @@ type OrderBonusService interface { | @@ -10,4 +10,5 @@ type OrderBonusService interface { | ||
| 10 | UpdateBounsByPartnerBonusPercent(orderId int64, adminId int64, goodId int64, partnerPercent float64, reason string) error | 10 | UpdateBounsByPartnerBonusPercent(orderId int64, adminId int64, goodId int64, partnerPercent float64, reason string) error |
| 11 | UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error | 11 | UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error |
| 12 | PayOrderGoodBonus(orderId int64, goodId int64, adminId int64) error | 12 | PayOrderGoodBonus(orderId int64, goodId int64, adminId int64) error |
| 13 | + BatchPayPartnerBonus(orderIds []int64, adminId int64) error | ||
| 13 | } | 14 | } |
| @@ -2,11 +2,7 @@ package dao | @@ -2,11 +2,7 @@ package dao | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | - "strings" | ||
| 6 | - "time" | ||
| 7 | 5 | ||
| 8 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 9 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models" | ||
| 10 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" |
| 11 | ) | 7 | ) |
| 12 | 8 | ||
| @@ -24,81 +20,81 @@ func NewBusinessBonusDao(transactionContext *transaction.TransactionContext) (*B | @@ -24,81 +20,81 @@ func NewBusinessBonusDao(transactionContext *transaction.TransactionContext) (*B | ||
| 24 | } | 20 | } |
| 25 | } | 21 | } |
| 26 | 22 | ||
| 27 | -type CustomBusinessBonus struct { | ||
| 28 | - Id int64 | ||
| 29 | - Bonus string | ||
| 30 | - BonusNot string | ||
| 31 | - BonusExpense string | ||
| 32 | - BonusHas string | ||
| 33 | - BonusStatus int8 | ||
| 34 | - PartnerName string | ||
| 35 | - UpdateAt time.Time | ||
| 36 | -} | 23 | +// type CustomBusinessBonus struct { |
| 24 | +// Id int64 | ||
| 25 | +// Bonus string | ||
| 26 | +// BonusNot string | ||
| 27 | +// BonusExpense string | ||
| 28 | +// BonusHas string | ||
| 29 | +// BonusStatus int8 | ||
| 30 | +// PartnerName string | ||
| 31 | +// UpdateAt time.Time | ||
| 32 | +// } | ||
| 37 | 33 | ||
| 38 | -func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatch string, | ||
| 39 | - companyId int64, limit int, offset int) ([]CustomBusinessBonus, error) { | ||
| 40 | - sql := `SELECT business_bonus.id, business_bonus.bonus,business_bonus.bonus_not | ||
| 41 | - ,business_bonus.bonus_expense,business_bonus.bonus_status,business_bonus.update_at | ||
| 42 | - ,partner_info.partner_name,business_bonus.bonus_has | ||
| 43 | - FROM business_bonus | ||
| 44 | - JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | ||
| 45 | - WHERE business_bonus.is_disable=? AND business_bonus.company_id = ? ` | ||
| 46 | - partnerCondition := []string{} | ||
| 47 | - allParam := []interface{}{domain.BUSINESS_BONUS_ENABLE, companyId} | ||
| 48 | - if partnerId > 0 { | ||
| 49 | - partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `) | ||
| 50 | - allParam = append(allParam, partnerId) | ||
| 51 | - } | ||
| 52 | - if len(partnerNameMatch) > 0 { | ||
| 53 | - allParam = append(allParam, "%"+partnerNameMatch+"%") | ||
| 54 | - partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `) | ||
| 55 | - } | ||
| 56 | - if len(partnerCondition) > 0 { | ||
| 57 | - sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR ")) | ||
| 58 | - } | ||
| 59 | - sql += `ORDER BY business_bonus.id DESC limit ? OFFSET ? ` | ||
| 60 | - allParam = append(allParam, limit, offset) | ||
| 61 | - tx := dao.transactionContext.PgTx | ||
| 62 | - var ( | ||
| 63 | - result []CustomBusinessBonus | ||
| 64 | - err error | ||
| 65 | - ) | ||
| 66 | - _, err = tx.Query(&result, sql, allParam...) | ||
| 67 | - return result, err | ||
| 68 | -} | 34 | +// func (dao BusinessBonusDao) SearchBusinessBonus(partnerId int64, partnerNameMatch string, |
| 35 | +// companyId int64, limit int, offset int) ([]CustomBusinessBonus, error) { | ||
| 36 | +// sql := `SELECT business_bonus.id, business_bonus.bonus,business_bonus.bonus_not | ||
| 37 | +// ,business_bonus.bonus_expense,business_bonus.bonus_status,business_bonus.update_at | ||
| 38 | +// ,partner_info.partner_name,business_bonus.bonus_has | ||
| 39 | +// FROM business_bonus | ||
| 40 | +// JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | ||
| 41 | +// WHERE business_bonus.is_disable=? AND business_bonus.company_id = ? ` | ||
| 42 | +// partnerCondition := []string{} | ||
| 43 | +// allParam := []interface{}{domain.BUSINESS_BONUS_ENABLE, companyId} | ||
| 44 | +// if partnerId > 0 { | ||
| 45 | +// partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `) | ||
| 46 | +// allParam = append(allParam, partnerId) | ||
| 47 | +// } | ||
| 48 | +// if len(partnerNameMatch) > 0 { | ||
| 49 | +// allParam = append(allParam, "%"+partnerNameMatch+"%") | ||
| 50 | +// partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `) | ||
| 51 | +// } | ||
| 52 | +// if len(partnerCondition) > 0 { | ||
| 53 | +// sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR ")) | ||
| 54 | +// } | ||
| 55 | +// sql += `ORDER BY business_bonus.id DESC limit ? OFFSET ? ` | ||
| 56 | +// allParam = append(allParam, limit, offset) | ||
| 57 | +// tx := dao.transactionContext.PgTx | ||
| 58 | +// var ( | ||
| 59 | +// result []CustomBusinessBonus | ||
| 60 | +// err error | ||
| 61 | +// ) | ||
| 62 | +// _, err = tx.Query(&result, sql, allParam...) | ||
| 63 | +// return result, err | ||
| 64 | +// } | ||
| 69 | 65 | ||
| 70 | -func (dao BusinessBonusDao) CountBusinessBonus(partnerId int64, partnerNameMatch string, | ||
| 71 | - companyId int64, limit int, offset int) (int, error) { | ||
| 72 | - sql := `SELECT count(*) | ||
| 73 | - FROM business_bonus | ||
| 74 | - JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | ||
| 75 | - WHERE business_bonus.is_disable=? AND business_bonus.company_id = ? ` | ||
| 76 | - partnerCondition := []string{} | ||
| 77 | - allParam := []interface{}{domain.BUSINESS_BONUS_ENABLE, companyId} | ||
| 78 | - if partnerId > 0 { | ||
| 79 | - partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `) | ||
| 80 | - allParam = append(allParam, partnerId) | ||
| 81 | - } | ||
| 82 | - if len(partnerNameMatch) > 0 { | ||
| 83 | - allParam = append(allParam, "%"+partnerNameMatch+"%") | ||
| 84 | - partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `) | ||
| 85 | - } | ||
| 86 | - if len(partnerCondition) > 0 { | ||
| 87 | - sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR ")) | ||
| 88 | - } | ||
| 89 | - tx := dao.transactionContext.PgTx | ||
| 90 | - var ( | ||
| 91 | - result int | ||
| 92 | - err error | ||
| 93 | - ) | ||
| 94 | - _, err = tx.Query(&result, sql, allParam...) | ||
| 95 | - return result, err | ||
| 96 | -} | 66 | +// func (dao BusinessBonusDao) CountBusinessBonus(partnerId int64, partnerNameMatch string, |
| 67 | +// companyId int64, limit int, offset int) (int, error) { | ||
| 68 | +// sql := `SELECT count(*) | ||
| 69 | +// FROM business_bonus | ||
| 70 | +// JOIN partner_info ON business_bonus.partner_info_id=partner_info.id | ||
| 71 | +// WHERE business_bonus.is_disable=? AND business_bonus.company_id = ? ` | ||
| 72 | +// partnerCondition := []string{} | ||
| 73 | +// allParam := []interface{}{domain.BUSINESS_BONUS_ENABLE, companyId} | ||
| 74 | +// if partnerId > 0 { | ||
| 75 | +// partnerCondition = append(partnerCondition, ` business_bonus.partner_info_id=? `) | ||
| 76 | +// allParam = append(allParam, partnerId) | ||
| 77 | +// } | ||
| 78 | +// if len(partnerNameMatch) > 0 { | ||
| 79 | +// allParam = append(allParam, "%"+partnerNameMatch+"%") | ||
| 80 | +// partnerCondition = append(partnerCondition, ` partner_info.partner_name like ? `) | ||
| 81 | +// } | ||
| 82 | +// if len(partnerCondition) > 0 { | ||
| 83 | +// sql += fmt.Sprintf(" AND (%s)", strings.Join(partnerCondition, " OR ")) | ||
| 84 | +// } | ||
| 85 | +// tx := dao.transactionContext.PgTx | ||
| 86 | +// var ( | ||
| 87 | +// result int | ||
| 88 | +// err error | ||
| 89 | +// ) | ||
| 90 | +// _, err = tx.Query(&result, sql, allParam...) | ||
| 91 | +// return result, err | ||
| 92 | +// } | ||
| 97 | 93 | ||
| 98 | -func (dao BusinessBonusDao) ExistBusinessBonus(userId int64) (bool, error) { | ||
| 99 | - tx := dao.transactionContext.PgTx | ||
| 100 | - ok, err := tx.Model(&models.BusinessBonus{}). | ||
| 101 | - Where("partner_info_id=?", userId). | ||
| 102 | - Exists() | ||
| 103 | - return ok, err | ||
| 104 | -} | 94 | +// func (dao BusinessBonusDao) ExistBusinessBonus(userId int64) (bool, error) { |
| 95 | +// tx := dao.transactionContext.PgTx | ||
| 96 | +// ok, err := tx.Model(&models.BusinessBonus{}). | ||
| 97 | +// Where("partner_info_id=?", userId). | ||
| 98 | +// Exists() | ||
| 99 | +// return ok, err | ||
| 100 | +// } |
| @@ -47,11 +47,14 @@ func (dao OrderBaseDao) DeliveryCodeExist(code string, companyId int64, notId .. | @@ -47,11 +47,14 @@ func (dao OrderBaseDao) DeliveryCodeExist(code string, companyId int64, notId .. | ||
| 47 | return ok, err | 47 | return ok, err |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | -//OrderListByCondition 根据条件获取订单分红列表 | ||
| 51 | -//orderType 订单类型 | ||
| 52 | -//partnerOrCode 合伙人姓名或订单号或发货单号 | 50 | +//OrderBonusListByCondition 根据条件获取订单分红列表 |
| 51 | +//@param orderType 订单类型 | ||
| 52 | +//@param partnerOrCode 合伙人姓名或订单号或发货单号 | ||
| 53 | +//@param companyId 公司id | ||
| 54 | +//@param partnerCategory 合伙人类型 | ||
| 55 | +//@param createTime 创建时间 | ||
| 53 | func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int, partnerOrCode string, | 56 | func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int, partnerOrCode string, |
| 54 | - partnerCategory int, limit, offset int) ([]models.OrderBase, int, error) { | 57 | + partnerCategory int, createTime [2]string, limit, offset int) ([]models.OrderBase, int, error) { |
| 55 | tx := dao.transactionContext.GetDB() | 58 | tx := dao.transactionContext.GetDB() |
| 56 | var orders []models.OrderBase | 59 | var orders []models.OrderBase |
| 57 | query := tx.Model(&orders).Where("order_base.company_id=?", companyId) | 60 | query := tx.Model(&orders).Where("order_base.company_id=?", companyId) |
| @@ -63,6 +66,15 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int | @@ -63,6 +66,15 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int | ||
| 63 | if partnerCategory > 0 { | 66 | if partnerCategory > 0 { |
| 64 | query = query.Where(`order_base.partner_category@>'{"id":?}'`, partnerCategory) | 67 | query = query.Where(`order_base.partner_category@>'{"id":?}'`, partnerCategory) |
| 65 | } | 68 | } |
| 69 | + | ||
| 70 | + if len(createTime[0]) > 0 { | ||
| 71 | + query = query.Where(`order_base.create_time>=?`, createTime[0]) | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + if len(createTime[1]) > 0 { | ||
| 75 | + query = query.Where(`order_base.create_time<=?`, createTime[1]) | ||
| 76 | + } | ||
| 77 | + | ||
| 66 | if len(partnerOrCode) > 0 { | 78 | if len(partnerOrCode) > 0 { |
| 67 | query = query.Join("LEFT JOIN partner_info as p ON order_base.partner_id=p.id"). | 79 | query = query.Join("LEFT JOIN partner_info as p ON order_base.partner_id=p.id"). |
| 68 | WhereGroup(func(q *orm.Query) (*orm.Query, error) { | 80 | WhereGroup(func(q *orm.Query) (*orm.Query, error) { |
| @@ -72,7 +84,7 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int | @@ -72,7 +84,7 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int | ||
| 72 | return q, nil | 84 | return q, nil |
| 73 | }) | 85 | }) |
| 74 | } | 86 | } |
| 75 | - query = query.Order("order_base.update_time DESC"). | 87 | + query = query.Order("order_base.create_time DESC"). |
| 76 | Offset(offset). | 88 | Offset(offset). |
| 77 | Limit(limit) | 89 | Limit(limit) |
| 78 | 90 | ||
| @@ -88,6 +100,7 @@ type CustomOrderBonusForExcel struct { | @@ -88,6 +100,7 @@ type CustomOrderBonusForExcel struct { | ||
| 88 | BonusStatus int | 100 | BonusStatus int |
| 89 | DeliveryCode string | 101 | DeliveryCode string |
| 90 | UpdateTime string | 102 | UpdateTime string |
| 103 | + CreateTime string | ||
| 91 | PartnerBonus float64 | 104 | PartnerBonus float64 |
| 92 | PartnerBonusHas float64 | 105 | PartnerBonusHas float64 |
| 93 | PartnerBonusNot float64 | 106 | PartnerBonusNot float64 |
| @@ -101,9 +114,10 @@ type CustomOrderBonusForExcel struct { | @@ -101,9 +114,10 @@ type CustomOrderBonusForExcel struct { | ||
| 101 | //@param orderType 订单类型 | 114 | //@param orderType 订单类型 |
| 102 | //@param partnerOrCode 合伙人姓名或订单号或发货单号 | 115 | //@param partnerOrCode 合伙人姓名或订单号或发货单号 |
| 103 | //@param partnerCategory 合伙人类型id | 116 | //@param partnerCategory 合伙人类型id |
| 117 | +//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" | ||
| 104 | //@return result 查询结果数据 | 118 | //@return result 查询结果数据 |
| 105 | func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string, | 119 | func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, partnerOrCode string, |
| 106 | - partnerCategory int) (result []CustomOrderBonusForExcel, err error) { | 120 | + partnerCategory int, createTime [2]string) (result []CustomOrderBonusForExcel, err error) { |
| 107 | //导出分红列表所用的sql | 121 | //导出分红列表所用的sql |
| 108 | sqlStr := `SELECT | 122 | sqlStr := `SELECT |
| 109 | t1.ID AS order_id, | 123 | t1.ID AS order_id, |
| @@ -112,6 +126,7 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | @@ -112,6 +126,7 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | ||
| 112 | t1.delivery_code, | 126 | t1.delivery_code, |
| 113 | t1.bonus_status, | 127 | t1.bonus_status, |
| 114 | to_char(t1.update_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS update_time, | 128 | to_char(t1.update_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS update_time, |
| 129 | + to_char(t1.create_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS create_time, | ||
| 115 | (CASE | 130 | (CASE |
| 116 | WHEN t1.use_partner_bonus>0 | 131 | WHEN t1.use_partner_bonus>0 |
| 117 | THEN | 132 | THEN |
| @@ -152,7 +167,15 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | @@ -152,7 +167,15 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | ||
| 152 | sqlStr += ` AND t1.partner_category @>'{"id":?}'` | 167 | sqlStr += ` AND t1.partner_category @>'{"id":?}'` |
| 153 | param = append(param, partnerCategory) | 168 | param = append(param, partnerCategory) |
| 154 | } | 169 | } |
| 155 | - sqlStr += ` ORDER BY t1.update_time DESC limit 10000 ` | 170 | + if len(createTime[0]) > 0 { |
| 171 | + param = append(param, createTime[0]) | ||
| 172 | + sqlStr += ` AND t1.create_time>=? ` | ||
| 173 | + } | ||
| 174 | + if len(createTime[1]) > 0 { | ||
| 175 | + param = append(param, createTime[1]) | ||
| 176 | + sqlStr += ` AND t1.create_time<=? ` | ||
| 177 | + } | ||
| 178 | + sqlStr += ` ORDER BY t1.create_time DESC limit 10000 ` | ||
| 156 | tx := dao.transactionContext.GetDB() | 179 | tx := dao.transactionContext.GetDB() |
| 157 | _, err = tx.Query(&result, sqlStr, param...) | 180 | _, err = tx.Query(&result, sqlStr, param...) |
| 158 | 181 | ||
| @@ -168,8 +191,9 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | @@ -168,8 +191,9 @@ func (dao OrderBaseDao) OrderBonusListForExcel(companyId int64, orderType int, p | ||
| 168 | //@param partnerOrCode 合伙人姓名或订单号或发货单号 | 191 | //@param partnerOrCode 合伙人姓名或订单号或发货单号 |
| 169 | //@param partnerCategory 合伙人类型id | 192 | //@param partnerCategory 合伙人类型id |
| 170 | //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" | 193 | //@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" |
| 194 | +//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" | ||
| 171 | func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, partnerOrCode string, | 195 | func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, partnerOrCode string, |
| 172 | - updateTime [2]string, partnerCategory int, limit, offset int) ([]models.OrderBase, int, error) { | 196 | + updateTime [2]string, createTime [2]string, partnerCategory int, limit, offset int) ([]models.OrderBase, int, error) { |
| 173 | tx := dao.transactionContext.GetDB() | 197 | tx := dao.transactionContext.GetDB() |
| 174 | var orders []models.OrderBase | 198 | var orders []models.OrderBase |
| 175 | query := tx.Model(&orders).Where("order_base.company_id=?", companyId) | 199 | query := tx.Model(&orders).Where("order_base.company_id=?", companyId) |
| @@ -187,6 +211,13 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | @@ -187,6 +211,13 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | ||
| 187 | if len(updateTime[1]) > 0 { | 211 | if len(updateTime[1]) > 0 { |
| 188 | query = query.Where(`order_base.update_time<=?`, updateTime[1]) | 212 | query = query.Where(`order_base.update_time<=?`, updateTime[1]) |
| 189 | } | 213 | } |
| 214 | + if len(createTime[0]) > 0 { | ||
| 215 | + query = query.Where(`order_base.create_time>=?`, createTime[0]) | ||
| 216 | + } | ||
| 217 | + if len(createTime[1]) > 0 { | ||
| 218 | + query = query.Where(`order_base.create_time<=?`, createTime[1]) | ||
| 219 | + } | ||
| 220 | + | ||
| 190 | if len(partnerOrCode) > 0 { | 221 | if len(partnerOrCode) > 0 { |
| 191 | query = query.Join("LEFT JOIN partner_info as p ON order_base.partner_id=p.id"). | 222 | query = query.Join("LEFT JOIN partner_info as p ON order_base.partner_id=p.id"). |
| 192 | WhereGroup(func(q *orm.Query) (*orm.Query, error) { | 223 | WhereGroup(func(q *orm.Query) (*orm.Query, error) { |
| @@ -196,7 +227,7 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | @@ -196,7 +227,7 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | ||
| 196 | return q, nil | 227 | return q, nil |
| 197 | }) | 228 | }) |
| 198 | } | 229 | } |
| 199 | - query = query.Order("order_base.update_time DESC"). | 230 | + query = query.Order("order_base.create_time DESC"). |
| 200 | Offset(offset). | 231 | Offset(offset). |
| 201 | Limit(limit) | 232 | Limit(limit) |
| 202 | 233 | ||
| @@ -204,3 +235,80 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | @@ -204,3 +235,80 @@ func (dao OrderBaseDao) OrderListByCondition(companyId int64, orderType int, par | ||
| 204 | return orders, cnt, err | 235 | return orders, cnt, err |
| 205 | 236 | ||
| 206 | } | 237 | } |
| 238 | + | ||
| 239 | +//CustomOrderListForExcel 导出实际订单列表所用的结构 | ||
| 240 | +type CustomOrderListForExcel struct { | ||
| 241 | + OrderCode string //订单编号 | ||
| 242 | + DeliveryCode string //发货编号 | ||
| 243 | + UpdateTime string //更新时间 | ||
| 244 | + CreateTime string //创建时间 | ||
| 245 | + PlanOrderCount int64 //货品总数 | ||
| 246 | + UseOrderCount int64 //货品总数调整 | ||
| 247 | + RegionName string //订单区域 | ||
| 248 | + PlanOrderAmount float64 //订单金额 | ||
| 249 | + UseOrderAmount float64 //订单金额调整 | ||
| 250 | + PartnerCategory string //合伙人类型 | ||
| 251 | + BuyerName string //买家 | ||
| 252 | + PartnerName string //合伙人 | ||
| 253 | +} | ||
| 254 | + | ||
| 255 | +//OrderListForExcel 获取实际订单列表用于excel导出 | ||
| 256 | +//@param companyId 公司id | ||
| 257 | +//@param orderType 订单类型 | ||
| 258 | +//@param partnerOrCode 合伙人姓名或订单号或发货单号 | ||
| 259 | +//@param partnerCategory 合伙人类型id | ||
| 260 | +//@param updateTime 订单更新时间范围"[开始时间,结束时间]",时间格式"2006-01-02 15:04:05+07" | ||
| 261 | +//@param createTime 订单的创建时间范围"[开始时间,结束时间]" 时间格式"2006-01-02 15:04:05+07" | ||
| 262 | +func (dao OrderBaseDao) OrderListForExcel(companyId int64, partnerOrCode string, | ||
| 263 | + updateTime [2]string, createTime [2]string, partnerCategory int) ( | ||
| 264 | + result []CustomOrderListForExcel, err error) { | ||
| 265 | + sqlstr := ` | ||
| 266 | + SELECT t1.order_code,t1.delivery_code | ||
| 267 | + ,to_char(t1.create_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS create_time | ||
| 268 | + ,to_char(t1.update_time AT TIME ZONE 'CCT' ,'YYYY-MM-DD HH24:MI:SS') AS update_time | ||
| 269 | + ,t1.plan_order_count,t1.use_order_count,t1.plan_order_amount,t1.use_order_amount | ||
| 270 | + ,t1.region_info->'regionName' AS region_name,t1.buyer->'buyerName' AS buyer_name | ||
| 271 | + ,t1.partner_category->'name' AS partner_category | ||
| 272 | + ,t2.partner_name | ||
| 273 | + FROM "order_base" AS t1 | ||
| 274 | + LEFT JOIN partner_info as t2 ON t1.partner_id=t2.id | ||
| 275 | + WHERE 1=1 AND t1.order_type = 1 AND t1.company_id=? | ||
| 276 | + ` | ||
| 277 | + params := []interface{}{companyId} | ||
| 278 | + if len(partnerOrCode) > 0 { | ||
| 279 | + like := "%" + partnerOrCode + "%" | ||
| 280 | + params = append(params, like, like, like) | ||
| 281 | + sqlstr += " AND (t1.order_code like ? OR t1.delivery_code like ? OR t2.partner_name like ? ) " | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + if partnerCategory > 0 { | ||
| 285 | + params = append(params, partnerCategory) | ||
| 286 | + sqlstr += ` AND t1.partner_category@>'{"id":?}' ` | ||
| 287 | + } | ||
| 288 | + | ||
| 289 | + if len(updateTime[0]) > 0 { | ||
| 290 | + params = append(params, updateTime[0]) | ||
| 291 | + sqlstr += ` AND t1.update_time>=? ` | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + if len(updateTime[1]) > 0 { | ||
| 295 | + params = append(params, updateTime[1]) | ||
| 296 | + sqlstr += ` AND t1.update_time<=? ` | ||
| 297 | + } | ||
| 298 | + | ||
| 299 | + if len(createTime[0]) > 0 { | ||
| 300 | + params = append(params, createTime[0]) | ||
| 301 | + sqlstr += ` AND t1.create_time>=? ` | ||
| 302 | + } | ||
| 303 | + if len(createTime[1]) > 0 { | ||
| 304 | + params = append(params, createTime[1]) | ||
| 305 | + sqlstr += ` AND t1.create_time<=? ` | ||
| 306 | + } | ||
| 307 | + sqlstr += ` ORDER BY t1.create_time DESC limit 10000 ` | ||
| 308 | + tx := dao.transactionContext.GetDB() | ||
| 309 | + _, err = tx.Query(&result, sqlstr, params...) | ||
| 310 | + if err != nil { | ||
| 311 | + return result, err | ||
| 312 | + } | ||
| 313 | + return result, nil | ||
| 314 | +} |
| 1 | package domainService | 1 | package domainService |
| 2 | 2 | ||
| 3 | -import ( | ||
| 4 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 5 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/dao" | ||
| 6 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/transaction" | ||
| 7 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/repository" | ||
| 8 | -) | 3 | +// type BusinessBonusService struct { |
| 4 | +// transactionContext *transaction.TransactionContext | ||
| 5 | +// } | ||
| 9 | 6 | ||
| 10 | -type BusinessBonusService struct { | ||
| 11 | - transactionContext *transaction.TransactionContext | ||
| 12 | -} | 7 | +// func NewBusinessBonusService(tcx *transaction.TransactionContext) *BusinessBonusService { |
| 8 | +// return &BusinessBonusService{ | ||
| 9 | +// transactionContext: tcx, | ||
| 10 | +// } | ||
| 11 | +// } | ||
| 13 | 12 | ||
| 14 | -func NewBusinessBonusService(tcx *transaction.TransactionContext) *BusinessBonusService { | ||
| 15 | - return &BusinessBonusService{ | ||
| 16 | - transactionContext: tcx, | ||
| 17 | - } | ||
| 18 | -} | 13 | +// func (srv BusinessBonusService) EnableOrDisable(parntnerId int64) error { |
| 14 | +// var ( | ||
| 15 | +// bonusDao, _ = dao.NewBusinessBonusDao(srv.transactionContext) | ||
| 16 | +// bonusReponsitory, _ = repository.NewBusinessBonusRepository(srv.transactionContext) | ||
| 17 | +// partnerReponsitory, _ = repository.NewPartnerInfoRepository(srv.transactionContext) | ||
| 19 | 18 | ||
| 20 | -func (srv BusinessBonusService) EnableOrDisable(parntnerId int64) error { | ||
| 21 | - var ( | ||
| 22 | - bonusDao, _ = dao.NewBusinessBonusDao(srv.transactionContext) | ||
| 23 | - bonusReponsitory, _ = repository.NewBusinessBonusRepository(srv.transactionContext) | ||
| 24 | - partnerReponsitory, _ = repository.NewPartnerInfoRepository(srv.transactionContext) | 19 | +// err error |
| 20 | +// partnerHasInBonus bool | ||
| 21 | +// partnerData *domain.PartnerInfo | ||
| 22 | +// partnerHasBusinessCategory bool | ||
| 23 | +// ) | ||
| 24 | +// partnerHasInBonus, err = bonusDao.ExistBusinessBonus(parntnerId) | ||
| 25 | +// if err != nil { | ||
| 26 | +// return err | ||
| 27 | +// } | ||
| 28 | +// partnerData, err = partnerReponsitory.FindOne(domain.PartnerFindOneQuery{UserId: parntnerId}) | ||
| 29 | +// if err != nil { | ||
| 30 | +// return err | ||
| 31 | +// } | ||
| 32 | +// for _, v := range partnerData.PartnerCategoryInfos { | ||
| 33 | +// if v.Id == 2 { | ||
| 34 | +// partnerHasBusinessCategory = true | ||
| 35 | +// break | ||
| 36 | +// } | ||
| 37 | +// } | ||
| 38 | +// if partnerHasInBonus && partnerHasBusinessCategory { | ||
| 39 | +// //已存在业务分红数据况 && 是业务合伙人类型 | ||
| 40 | +// var bonusData *domain.BusinessBonus | ||
| 41 | +// bonusData, err = bonusReponsitory.FindOne(domain.BusinessBonusFindOneQuery{ | ||
| 42 | +// PartnerId: parntnerId, | ||
| 43 | +// }) | ||
| 44 | +// if bonusData.IsDisable == domain.BUSINESS_BONUS_ENABLE { | ||
| 45 | +// return nil | ||
| 46 | +// } | ||
| 47 | +// bonusData.IsDisable = domain.BUSINESS_BONUS_ENABLE | ||
| 48 | +// err = bonusReponsitory.Edit(bonusData) | ||
| 49 | +// return err | ||
| 50 | +// } | ||
| 51 | +// if partnerHasInBonus && !partnerHasBusinessCategory { | ||
| 52 | +// //已存在业务分红数据况 && 不是业务合伙人类型 | ||
| 53 | +// var bonusData *domain.BusinessBonus | ||
| 54 | +// bonusData, err = bonusReponsitory.FindOne(domain.BusinessBonusFindOneQuery{ | ||
| 55 | +// PartnerId: parntnerId, | ||
| 56 | +// }) | ||
| 57 | +// if bonusData.IsDisable == domain.BUSINESS_BONUS_DISABLE { | ||
| 58 | +// return nil | ||
| 59 | +// } | ||
| 60 | +// bonusData.IsDisable = domain.BUSINESS_BONUS_DISABLE | ||
| 61 | +// err = bonusReponsitory.Edit(bonusData) | ||
| 62 | +// return err | ||
| 63 | +// } | ||
| 25 | 64 | ||
| 26 | - err error | ||
| 27 | - partnerHasInBonus bool | ||
| 28 | - partnerData *domain.PartnerInfo | ||
| 29 | - partnerHasBusinessCategory bool | ||
| 30 | - ) | ||
| 31 | - partnerHasInBonus, err = bonusDao.ExistBusinessBonus(parntnerId) | ||
| 32 | - if err != nil { | ||
| 33 | - return err | ||
| 34 | - } | ||
| 35 | - partnerData, err = partnerReponsitory.FindOne(domain.PartnerFindOneQuery{UserId: parntnerId}) | ||
| 36 | - if err != nil { | ||
| 37 | - return err | ||
| 38 | - } | ||
| 39 | - for _, v := range partnerData.PartnerCategoryInfos { | ||
| 40 | - if v.Id == 2 { | ||
| 41 | - partnerHasBusinessCategory = true | ||
| 42 | - break | ||
| 43 | - } | ||
| 44 | - } | ||
| 45 | - if partnerHasInBonus && partnerHasBusinessCategory { | ||
| 46 | - //已存在业务分红数据况 && 是业务合伙人类型 | ||
| 47 | - var bonusData *domain.BusinessBonus | ||
| 48 | - bonusData, err = bonusReponsitory.FindOne(domain.BusinessBonusFindOneQuery{ | ||
| 49 | - PartnerId: parntnerId, | ||
| 50 | - }) | ||
| 51 | - if bonusData.IsDisable == domain.BUSINESS_BONUS_ENABLE { | ||
| 52 | - return nil | ||
| 53 | - } | ||
| 54 | - bonusData.IsDisable = domain.BUSINESS_BONUS_ENABLE | ||
| 55 | - err = bonusReponsitory.Edit(bonusData) | ||
| 56 | - return err | ||
| 57 | - } | ||
| 58 | - if partnerHasInBonus && !partnerHasBusinessCategory { | ||
| 59 | - //已存在业务分红数据况 && 不是业务合伙人类型 | ||
| 60 | - var bonusData *domain.BusinessBonus | ||
| 61 | - bonusData, err = bonusReponsitory.FindOne(domain.BusinessBonusFindOneQuery{ | ||
| 62 | - PartnerId: parntnerId, | ||
| 63 | - }) | ||
| 64 | - if bonusData.IsDisable == domain.BUSINESS_BONUS_DISABLE { | ||
| 65 | - return nil | ||
| 66 | - } | ||
| 67 | - bonusData.IsDisable = domain.BUSINESS_BONUS_DISABLE | ||
| 68 | - err = bonusReponsitory.Edit(bonusData) | ||
| 69 | - return err | ||
| 70 | - } | 65 | +// if !partnerHasInBonus && partnerHasBusinessCategory { |
| 66 | +// //不存在业务分红数据况 && 是业务合伙人类型 | ||
| 67 | +// newBonus := &domain.BusinessBonus{ | ||
| 68 | +// PartnerInfoId: partnerData.Partner.Id, | ||
| 69 | +// IsDisable: domain.BUSINESS_BONUS_ENABLE, | ||
| 70 | +// CompanyId: partnerData.CompanyId, | ||
| 71 | +// Bonus: 0, | ||
| 72 | +// } | ||
| 73 | +// err = bonusReponsitory.Add(newBonus) | ||
| 74 | +// return err | ||
| 75 | +// } | ||
| 71 | 76 | ||
| 72 | - if !partnerHasInBonus && partnerHasBusinessCategory { | ||
| 73 | - //不存在业务分红数据况 && 是业务合伙人类型 | ||
| 74 | - newBonus := &domain.BusinessBonus{ | ||
| 75 | - PartnerInfoId: partnerData.Partner.Id, | ||
| 76 | - IsDisable: domain.BUSINESS_BONUS_ENABLE, | ||
| 77 | - CompanyId: partnerData.CompanyId, | ||
| 78 | - Bonus: 0, | ||
| 79 | - } | ||
| 80 | - err = bonusReponsitory.Add(newBonus) | ||
| 81 | - return err | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - return nil | ||
| 85 | -} | 77 | +// return nil |
| 78 | +// } | ||
| 79 | +// } |
| @@ -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 | } |
| @@ -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,13 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a | @@ -279,7 +275,13 @@ 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 | + if updateGood.PartnerBonusPercent < 0 { |
| 279 | + return nil | ||
| 280 | + } | ||
| 281 | + if updateGood.BonusStatus == domain.OrderGoodHasPay { | ||
| 282 | + return nil | ||
| 283 | + } | ||
| 284 | + err = updateGood.CurrentBonusStatus.PayPartnerBonus(&updateGood) | ||
| 283 | if err != nil { | 285 | if err != nil { |
| 284 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) | 286 | return lib.ThrowError(lib.BUSINESS_ERROR, err.Error()) |
| 285 | } | 287 | } |
| @@ -305,11 +307,11 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a | @@ -305,11 +307,11 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a | ||
| 305 | } | 307 | } |
| 306 | // | 308 | // |
| 307 | payEvent := event.PayOrderGoodBonus{ | 309 | payEvent := event.PayOrderGoodBonus{ |
| 308 | - OrderId: orderId, | ||
| 309 | - GoodId: goodId, | ||
| 310 | - AdminId: adminId, | ||
| 311 | - GoodName: updateGood.GoodName, | ||
| 312 | - PartnerBonus: updateGood.GetCurrentPartnerBonus(), | 310 | + OrderBase: oldOrder, |
| 311 | + Goods: []domain.OrderGood{ | ||
| 312 | + updateGood, | ||
| 313 | + }, | ||
| 314 | + Admin: &adminUser, | ||
| 313 | } | 315 | } |
| 314 | if err = serve.Publish(payEvent); err != nil { | 316 | if err = serve.Publish(payEvent); err != nil { |
| 315 | return err | 317 | return err |
| @@ -318,7 +320,6 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a | @@ -318,7 +320,6 @@ func (serve *OrderBonusService) PayOrderGoodBonus(orderId int64, goodId int64, a | ||
| 318 | } | 320 | } |
| 319 | 321 | ||
| 320 | //UpdateOrderRemarkBonus 更新备注 | 322 | //UpdateOrderRemarkBonus 更新备注 |
| 321 | -//目前只处理 海鲜干货的订单 即 order_type = OrderTypeBestShop (3) | ||
| 322 | func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error { | 323 | func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId int64, remark string) error { |
| 323 | var ( | 324 | var ( |
| 324 | userRepository domain.UsersRepository | 325 | userRepository domain.UsersRepository |
| @@ -338,9 +339,6 @@ func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId in | @@ -338,9 +339,6 @@ func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId in | ||
| 338 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) | 339 | e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) |
| 339 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | 340 | return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) |
| 340 | } | 341 | } |
| 341 | - if oldOrder.OrderType != domain.OrderTypeBestShop { | ||
| 342 | - return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型错误") | ||
| 343 | - } | ||
| 344 | adminUser, err = userRepository.FindOne(domain.UsersFindOneQuery{Id: adminId}) | 342 | adminUser, err = userRepository.FindOne(domain.UsersFindOneQuery{Id: adminId}) |
| 345 | if err != nil { | 343 | if err != nil { |
| 346 | e := fmt.Sprintf("获取管理员用户(id=%d)数据失败,%s", adminId, err) | 344 | e := fmt.Sprintf("获取管理员用户(id=%d)数据失败,%s", adminId, err) |
| @@ -368,6 +366,95 @@ func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId in | @@ -368,6 +366,95 @@ func (serve *OrderBonusService) UpdateOrderRemarkBonus(orderId int64, adminId in | ||
| 368 | return err | 366 | return err |
| 369 | } | 367 | } |
| 370 | } | 368 | } |
| 369 | + return nil | ||
| 370 | +} | ||
| 371 | + | ||
| 372 | +//BatchPayPartnerBonus 批量支付订单中货品的分红 | ||
| 373 | +func (serve *OrderBonusService) BatchPayPartnerBonus(orderIds []int64, adminId int64) error { | ||
| 374 | + var ( | ||
| 375 | + userRepository domain.UsersRepository | ||
| 376 | + orderBaseReponsitory domain.OrderBaseRepository | ||
| 377 | + orderGoodRepository domain.OrderGoodRepository | ||
| 378 | + | ||
| 379 | + adminUser domain.Users | ||
| 380 | + err error | ||
| 381 | + ) | ||
| 382 | + if orderGoodRepository, err = repository.NewOrderGoodRepository(serve.transactionContext); err != nil { | ||
| 383 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 384 | + } | ||
| 385 | + if orderBaseReponsitory, err = repository.NewOrderBaseRepository(serve.transactionContext); err != nil { | ||
| 386 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 387 | + } | ||
| 388 | + if userRepository, err = repository.NewUsersRepository(serve.transactionContext); err != nil { | ||
| 389 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 390 | + } | ||
| 391 | + adminUser, err = userRepository.FindOne(domain.UsersFindOneQuery{Id: adminId}) | ||
| 392 | + if err != nil { | ||
| 393 | + e := fmt.Sprintf("获取管理员用户(id=%d)数据失败,%s", adminId, err) | ||
| 394 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 395 | + } | ||
| 396 | + var ( | ||
| 397 | + payEvents []event.PayOrderGoodBonus | ||
| 398 | + ) | ||
| 399 | + for _, orderId := range orderIds { | ||
| 400 | + var oldOrder *domain.OrderBase | ||
| 401 | + oldOrder, err = orderBaseReponsitory.FindOne(domain.OrderBaseFindOneQuery{OrderId: orderId}) | ||
| 402 | + if err != nil { | ||
| 403 | + e := fmt.Sprintf("获取订单(id=%d)数据失败,%s", orderId, err) | ||
| 404 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 405 | + } | ||
| 406 | + oldOrder.Goods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{OrderId: orderId}) | ||
| 407 | + if err != nil { | ||
| 408 | + e := fmt.Sprintf("获取订单中(id=%d)的货品数据失败,%s", orderId, err) | ||
| 409 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) | ||
| 410 | + } | ||
| 371 | 411 | ||
| 412 | + if ok := adminUser.InCompany(oldOrder.CompanyId); !ok { | ||
| 413 | + return lib.ThrowError(lib.BUSINESS_ERROR, "用户不能更新非自己公司的订单") | ||
| 414 | + } | ||
| 415 | + var updateGoods []domain.OrderGood | ||
| 416 | + for i := range oldOrder.Goods { | ||
| 417 | + thisGood := oldOrder.Goods[i] | ||
| 418 | + if thisGood.BonusStatus == domain.OrderGoodHasPay { | ||
| 419 | + //已支付 | ||
| 420 | + continue | ||
| 421 | + } | ||
| 422 | + if thisGood.PartnerBonusPercent < 0 { | ||
| 423 | + //未设置合伙人分红比例 | ||
| 424 | + continue | ||
| 425 | + } | ||
| 426 | + thisGood.CurrentBonusStatus.PayPartnerBonus(&thisGood) | ||
| 427 | + oldOrder.Goods[i] = thisGood | ||
| 428 | + //货品更新 | ||
| 429 | + updateGoods = append(updateGoods, thisGood) | ||
| 430 | + } | ||
| 431 | + err = oldOrder.Compute() | ||
| 432 | + if err != nil { | ||
| 433 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "核算订单数据失败") | ||
| 434 | + } | ||
| 435 | + //更新订单货品 | ||
| 436 | + if len(updateGoods) > 0 { | ||
| 437 | + err = orderBaseReponsitory.Save(oldOrder) | ||
| 438 | + if err != nil { | ||
| 439 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 440 | + } | ||
| 441 | + err = orderGoodRepository.Save(updateGoods) | ||
| 442 | + if err != nil { | ||
| 443 | + return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 444 | + } | ||
| 445 | + //构建事件 | ||
| 446 | + payEvent := event.PayOrderGoodBonus{ | ||
| 447 | + OrderBase: oldOrder, | ||
| 448 | + Goods: updateGoods, | ||
| 449 | + Admin: &adminUser, | ||
| 450 | + } | ||
| 451 | + payEvents = append(payEvents, payEvent) | ||
| 452 | + } | ||
| 453 | + } | ||
| 454 | + if len(payEvents) > 0 { | ||
| 455 | + if err = serve.Publish(event.BatchPayOrderGoodBonus(payEvents)); err != nil { | ||
| 456 | + return err | ||
| 457 | + } | ||
| 458 | + } | ||
| 372 | return nil | 459 | return nil |
| 373 | } | 460 | } |
| @@ -116,7 +116,7 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery | @@ -116,7 +116,7 @@ func (repository OrderBaseRepository) Find(queryOption domain.OrderBaseFindQuery | ||
| 116 | err error | 116 | err error |
| 117 | ordersReturn = make([]domain.OrderBase, 0) | 117 | ordersReturn = make([]domain.OrderBase, 0) |
| 118 | ) | 118 | ) |
| 119 | - query = query.Order("order_base.id DESC") | 119 | + query = query.Order("order_base.create_time DESC") |
| 120 | count, err := query.SelectAndCount() | 120 | count, err := query.SelectAndCount() |
| 121 | if err != nil { | 121 | if err != nil { |
| 122 | return ordersReturn, 0, err | 122 | return ordersReturn, 0, err |
| @@ -106,7 +106,7 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery | @@ -106,7 +106,7 @@ func (repository OrderGoodRepository) Find(queryOption domain.OrderGoodFindQuery | ||
| 106 | if queryOption.Limit > 0 { | 106 | if queryOption.Limit > 0 { |
| 107 | query = query.Limit(queryOption.Limit) | 107 | query = query.Limit(queryOption.Limit) |
| 108 | } else { | 108 | } else { |
| 109 | - query = query.Limit(100) | 109 | + query = query.Limit(1000) |
| 110 | } | 110 | } |
| 111 | var ( | 111 | var ( |
| 112 | err error | 112 | err error |
| 1 | package controllers | 1 | package controllers |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "encoding/json" | ||
| 5 | "errors" | 4 | "errors" |
| 6 | "fmt" | 5 | "fmt" |
| 7 | - "time" | ||
| 8 | 6 | ||
| 9 | - "github.com/GeeTeam/gt3-golang-sdk/geetest" | ||
| 10 | "github.com/astaxie/beego/logs" | 7 | "github.com/astaxie/beego/logs" |
| 11 | userCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/command" | 8 | userCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/command" |
| 12 | userService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/service" | 9 | userService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/service" |
| @@ -54,27 +51,26 @@ func (c *AdminLoginController) Login() { | @@ -54,27 +51,26 @@ func (c *AdminLoginController) Login() { | ||
| 54 | } | 51 | } |
| 55 | 52 | ||
| 56 | //CaptchaInit 极验初始化 | 53 | //CaptchaInit 极验初始化 |
| 57 | -func (c *AdminLoginController) CaptchaInit() { | ||
| 58 | - const ( | ||
| 59 | - captchaID = "33a2abf9c5df0d6bc3b89fb39280114b" | ||
| 60 | - privateKey = "13320fd2b10199e9a2440a4fbb4d46f7" | ||
| 61 | - ) | ||
| 62 | - newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second) | ||
| 63 | - userip := c.Ctx.Input.IP() | ||
| 64 | - _, responseBt := newGeetest.PreProcess("", userip) | ||
| 65 | - // c.SetSession("geetest_status", status) | ||
| 66 | - var geetestRsp geetest.FailbackRegisterRespnse | ||
| 67 | - json.Unmarshal(responseBt, &geetestRsp) | ||
| 68 | - //对前端定义的数据格式进行适配。。。 | ||
| 69 | - rspData := map[string]interface{}{ | ||
| 70 | - "success": geetestRsp.Success, | ||
| 71 | - "gt": geetestRsp.GT, | ||
| 72 | - "challenge": geetestRsp.Challenge, | ||
| 73 | - "newCaptcha": geetestRsp.NewCaptcha, | ||
| 74 | - } | ||
| 75 | - c.ResponseData(rspData) | ||
| 76 | - return | ||
| 77 | -} | 54 | +// func (c *AdminLoginController) CaptchaInit() { |
| 55 | +// const ( | ||
| 56 | +// captchaID = "33a2abf9c5df0d6bc3b89fb39280114b" | ||
| 57 | +// privateKey = "13320fd2b10199e9a2440a4fbb4d46f7" | ||
| 58 | +// ) | ||
| 59 | +// newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second) | ||
| 60 | +// userip := c.Ctx.Input.IP() | ||
| 61 | +// _, responseBt := newGeetest.PreProcess("", userip) | ||
| 62 | +// var geetestRsp geetest.FailbackRegisterRespnse | ||
| 63 | +// json.Unmarshal(responseBt, &geetestRsp) | ||
| 64 | +// //对前端定义的数据格式进行适配。。。 | ||
| 65 | +// rspData := map[string]interface{}{ | ||
| 66 | +// "success": geetestRsp.Success, | ||
| 67 | +// "gt": geetestRsp.GT, | ||
| 68 | +// "challenge": geetestRsp.Challenge, | ||
| 69 | +// "newCaptcha": geetestRsp.NewCaptcha, | ||
| 70 | +// } | ||
| 71 | +// c.ResponseData(rspData) | ||
| 72 | +// return | ||
| 73 | +// } | ||
| 78 | 74 | ||
| 79 | //AdminpPofile 获取登录用户的权限配置 | 75 | //AdminpPofile 获取登录用户的权限配置 |
| 80 | func (c *AdminLoginController) AdminpPofile() { | 76 | func (c *AdminLoginController) AdminpPofile() { |
| 1 | package controllers | 1 | package controllers |
| 2 | 2 | ||
| 3 | -import ( | ||
| 4 | - "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | ||
| 5 | -) | ||
| 6 | - | ||
| 7 | -type BusinessBonusController struct { | ||
| 8 | - BaseController | ||
| 9 | -} | 3 | +// type BusinessBonusController struct { |
| 4 | +// BaseController | ||
| 5 | +// } | ||
| 10 | 6 | ||
| 11 | -func (c *BusinessBonusController) Prepare() { | ||
| 12 | - c.BaseController.Prepare() | ||
| 13 | - if ok := c.ValidJWTToken(); !ok { | ||
| 14 | - return | ||
| 15 | - } | ||
| 16 | - if ok := c.ValidAdminPermission(domain.PERMISSION_DIVIDEND); !ok { | ||
| 17 | - return | ||
| 18 | - } | ||
| 19 | -} | 7 | +// func (c *BusinessBonusController) Prepare() { |
| 8 | +// c.BaseController.Prepare() | ||
| 9 | +// if ok := c.ValidJWTToken(); !ok { | ||
| 10 | +// return | ||
| 11 | +// } | ||
| 12 | +// if ok := c.ValidAdminPermission(domain.PERMISSION_DIVIDEND); !ok { | ||
| 13 | +// return | ||
| 14 | +// } | ||
| 15 | +// } | ||
| 20 | 16 | ||
| 21 | // func (c *BusinessBonusController) ListBusinessBonus() { | 17 | // func (c *BusinessBonusController) ListBusinessBonus() { |
| 22 | // type Parameter struct { | 18 | // type Parameter struct { |
| @@ -110,3 +106,27 @@ func (c *BusinessBonusController) Prepare() { | @@ -110,3 +106,27 @@ func (c *BusinessBonusController) Prepare() { | ||
| 110 | // } | 106 | // } |
| 111 | // c.ResponseData(data) | 107 | // c.ResponseData(data) |
| 112 | // } | 108 | // } |
| 109 | +// type Parameter struct { | ||
| 110 | +// Id int64 `json:"id"` | ||
| 111 | +// } | ||
| 112 | +// var ( | ||
| 113 | +// param Parameter | ||
| 114 | +// err error | ||
| 115 | +// ) | ||
| 116 | +// if err = c.BindJsonData(¶m); err != nil { | ||
| 117 | +// logs.Error(err) | ||
| 118 | +// c.ResponseError(errors.New("json数据解析失败")) | ||
| 119 | +// return | ||
| 120 | +// } | ||
| 121 | +// companyId := c.GetUserCompany() | ||
| 122 | +// srv := businessService.NewBusinessBonusService(nil) | ||
| 123 | +// data, err := srv.GetBusinessBonus(businessQuery.GetBusinessBonusQuery{ | ||
| 124 | +// Id: param.Id, | ||
| 125 | +// CompanyId: companyId, | ||
| 126 | +// }) | ||
| 127 | +// if err != nil { | ||
| 128 | +// c.ResponseError(err) | ||
| 129 | +// return | ||
| 130 | +// } | ||
| 131 | +// c.ResponseData(data) | ||
| 132 | +// } |
| @@ -2,11 +2,10 @@ package controllers | @@ -2,11 +2,10 @@ package controllers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "errors" | 4 | "errors" |
| 5 | - "fmt" | ||
| 6 | "strconv" | 5 | "strconv" |
| 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" |
| @@ -32,11 +31,12 @@ func (c *OrderDividendController) Prepare() { | @@ -32,11 +31,12 @@ func (c *OrderDividendController) Prepare() { | ||
| 32 | //PageListOrderDividend 获取实发订单分红列表 | 31 | //PageListOrderDividend 获取实发订单分红列表 |
| 33 | func (c *OrderDividendController) PageListOrderDividend() { | 32 | func (c *OrderDividendController) PageListOrderDividend() { |
| 34 | type Parameter struct { | 33 | type Parameter struct { |
| 35 | - SearchWord string `json:"searchWord"` | ||
| 36 | - OrderType int `json:"orderType"` | ||
| 37 | - PageSize int `json:"pageSize"` | ||
| 38 | - PageNumber int `json:"pageNumber"` | ||
| 39 | - PartnerCategoryId int `json:"partnerCategoryId"` | 34 | + SearchWord string `json:"searchWord"` |
| 35 | + OrderType int `json:"orderType"` | ||
| 36 | + PageSize int `json:"pageSize"` | ||
| 37 | + PageNumber int `json:"pageNumber"` | ||
| 38 | + PartnerCategoryId int `json:"partnerCategoryId"` | ||
| 39 | + CreateTime []string `json:"createTime"` | ||
| 40 | } | 40 | } |
| 41 | var ( | 41 | var ( |
| 42 | param Parameter | 42 | param Parameter |
| @@ -59,6 +59,33 @@ func (c *OrderDividendController) PageListOrderDividend() { | @@ -59,6 +59,33 @@ func (c *OrderDividendController) PageListOrderDividend() { | ||
| 59 | if param.PageSize == 0 { | 59 | if param.PageSize == 0 { |
| 60 | param.PageSize = 20 | 60 | param.PageSize = 20 |
| 61 | } | 61 | } |
| 62 | + | ||
| 63 | + var ( | ||
| 64 | + createTimeBegin string | ||
| 65 | + createTimeEnd string | ||
| 66 | + ) | ||
| 67 | + if len(param.CreateTime) > 0 { | ||
| 68 | + if len(param.CreateTime[0]) > 0 { | ||
| 69 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local) | ||
| 70 | + if err != nil { | ||
| 71 | + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) | ||
| 72 | + return | ||
| 73 | + } | ||
| 74 | + createTimeBegin = t.Format("2006-01-02 15:04:05-07") | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + if len(param.CreateTime) > 1 { | ||
| 78 | + if len(param.CreateTime[1]) > 0 { | ||
| 79 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local) | ||
| 80 | + if err != nil { | ||
| 81 | + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) | ||
| 82 | + return | ||
| 83 | + } | ||
| 84 | + //设定时间边界 | ||
| 85 | + t = t.Add(86399 * time.Second) | ||
| 86 | + createTimeEnd = t.Format("2006-01-02 15:04:05-07") | ||
| 87 | + } | ||
| 88 | + } | ||
| 62 | companyId := c.GetUserCompany() | 89 | companyId := c.GetUserCompany() |
| 63 | orderSrv := orderService.NewOrderInfoService(nil) | 90 | orderSrv := orderService.NewOrderInfoService(nil) |
| 64 | resp, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{ | 91 | resp, cnt, err := orderSrv.PageListOrderBonus(orderQuery.ListOrderBonusQuery{ |
| @@ -68,6 +95,8 @@ func (c *OrderDividendController) PageListOrderDividend() { | @@ -68,6 +95,8 @@ func (c *OrderDividendController) PageListOrderDividend() { | ||
| 68 | Offset: (param.PageNumber - 1) * param.PageSize, | 95 | Offset: (param.PageNumber - 1) * param.PageSize, |
| 69 | CompanyId: companyId, | 96 | CompanyId: companyId, |
| 70 | PartnerCategory: param.PartnerCategoryId, | 97 | PartnerCategory: param.PartnerCategoryId, |
| 98 | + CreateTimeBegin: createTimeBegin, | ||
| 99 | + CreateTimeEnd: createTimeEnd, | ||
| 71 | }) | 100 | }) |
| 72 | if err != nil { | 101 | if err != nil { |
| 73 | c.ResponseError(err) | 102 | c.ResponseError(err) |
| @@ -77,7 +106,6 @@ func (c *OrderDividendController) PageListOrderDividend() { | @@ -77,7 +106,6 @@ func (c *OrderDividendController) PageListOrderDividend() { | ||
| 77 | return | 106 | return |
| 78 | } | 107 | } |
| 79 | 108 | ||
| 80 | -//OrderDividendDetail 订单的分红详情 | ||
| 81 | func (c *OrderDividendController) OrderDividendDetail() { | 109 | func (c *OrderDividendController) OrderDividendDetail() { |
| 82 | type Parameter struct { | 110 | type Parameter struct { |
| 83 | Id string `json:"id"` | 111 | Id string `json:"id"` |
| @@ -98,168 +126,26 @@ func (c *OrderDividendController) OrderDividendDetail() { | @@ -98,168 +126,26 @@ func (c *OrderDividendController) OrderDividendDetail() { | ||
| 98 | } | 126 | } |
| 99 | companyId := c.GetUserCompany() | 127 | companyId := c.GetUserCompany() |
| 100 | orderSrv := orderService.NewOrderInfoService(nil) | 128 | orderSrv := orderService.NewOrderInfoService(nil) |
| 101 | - orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{ | ||
| 102 | - OrderId: orderid, | ||
| 103 | - CompanyId: companyId, | ||
| 104 | - }) | 129 | + orderinfo, err := orderSrv.GetOrderInfoWithBonus(orderid, companyId) |
| 105 | if err != nil { | 130 | if err != nil { |
| 106 | c.ResponseError(err) | 131 | c.ResponseError(err) |
| 107 | return | 132 | return |
| 108 | } | 133 | } |
| 109 | - if orderinfo.OrderType != domain.OrderReal { | ||
| 110 | - c.ResponseError(errors.New("参数错误")) | ||
| 111 | - return | ||
| 112 | - } | ||
| 113 | - allGoods := []map[string]interface{}{} | ||
| 114 | - for _, v := range orderinfo.Goods { | ||
| 115 | - detail := map[string]interface{}{ | ||
| 116 | - "productName": v.GoodName, | ||
| 117 | - "orderNum": v.PlanGoodNumber, | ||
| 118 | - "univalence": v.Price, | ||
| 119 | - "partnerRatio": v.PartnerBonusPercent, | ||
| 120 | - "orderPrice": v.GoodCompute.PlanAmount, | ||
| 121 | - "partnerDividendsReceivable": v.GoodCompute.PlanPartnerBonus, | ||
| 122 | - } | ||
| 123 | - m := map[string]interface{}{ | ||
| 124 | - "detail": detail, | ||
| 125 | - "quantityControl": "", | ||
| 126 | - "id": v.Id, | ||
| 127 | - "stateOfPayment": v.BonusStatus, | ||
| 128 | - "remark": v.Remark, | ||
| 129 | - "amountControl": "", | ||
| 130 | - "partnerDividendControl": "", | ||
| 131 | - "receivedDividends": v.GoodCompute.PartnerBonusHas, | ||
| 132 | - "notReceivedDividend": v.GoodCompute.PartnerBonusNot, | ||
| 133 | - "dividendSpending": v.GoodCompute.PartnerBonusExpense, | ||
| 134 | - } | ||
| 135 | - if v.GoodCompute.UseAmount >= 0 { | ||
| 136 | - m["amountControl"] = fmt.Sprint(v.GoodCompute.UseAmount) | ||
| 137 | - } | ||
| 138 | - if v.UseGoodNumber >= 0 { | ||
| 139 | - m["quantityControl"] = fmt.Sprint(v.UseGoodNumber) | ||
| 140 | - } | ||
| 141 | - if v.GoodCompute.UsePartnerBonus >= 0 { | ||
| 142 | - m["partnerDividendControl"] = fmt.Sprint(v.GoodCompute.UsePartnerBonus) | ||
| 143 | - } | ||
| 144 | - allGoods = append(allGoods, m) | ||
| 145 | - } | ||
| 146 | - orderData := map[string]interface{}{ | ||
| 147 | - "buyer": orderinfo.Buyer.BuyerName, | ||
| 148 | - "shipmentsId": orderinfo.DeliveryCode, | ||
| 149 | - "orderDist": orderinfo.RegionInfo.RegionName, | ||
| 150 | - "partner": orderinfo.PartnerInfo.PartnerName, | ||
| 151 | - "id": orderinfo.Id, | ||
| 152 | - "orderId": orderinfo.OrderCode, | ||
| 153 | - "partnerCategoryId": orderinfo.PartnerCategory.Id, | ||
| 154 | - "partnerCategoryName": orderinfo.PartnerCategory.Name, | ||
| 155 | - } | ||
| 156 | - dividendCount := map[string]interface{}{ | ||
| 157 | - "orderNum": orderinfo.OrderCompute.PlanOrderCount, | ||
| 158 | - "orderAmountAdjustment": orderinfo.OrderCompute.PlanOrderAmount, | ||
| 159 | - "orderNumControl": "", | ||
| 160 | - "orderAmountAdjustmentControl": "", | ||
| 161 | - "partnerDividends": orderinfo.OrderCompute.PlanPartnerBonus, | ||
| 162 | - "partnerDividendsControl": "", | ||
| 163 | - "receivedDividends": orderinfo.OrderCompute.PartnerBonusHas, | ||
| 164 | - "notReceivedDividend": orderinfo.OrderCompute.PartnerBonusNot, | ||
| 165 | - "dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense, | ||
| 166 | - "commissionProportion": orderinfo.SalesmanBonusPercent, | ||
| 167 | - "expectedCommission": orderinfo.OrderCompute.SalesmanBonus, | ||
| 168 | - } | ||
| 169 | - if orderinfo.OrderCompute.UseOrderAmount >= 0 { | ||
| 170 | - dividendCount["orderAmountAdjustmentControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount) | ||
| 171 | - } | ||
| 172 | - if orderinfo.OrderCompute.UsePartnerBonus >= 0 { | ||
| 173 | - dividendCount["partnerDividendsControl"] = fmt.Sprint(orderinfo.OrderCompute.UsePartnerBonus) | ||
| 174 | - } | ||
| 175 | - if orderinfo.OrderCompute.UseOrderCount >= 0 { | ||
| 176 | - dividendCount["orderNumControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount) | ||
| 177 | - } | ||
| 178 | - rsp := map[string]interface{}{ | ||
| 179 | - "order": orderData, | ||
| 180 | - "product": allGoods, | ||
| 181 | - "dividendCount": dividendCount, | ||
| 182 | - "operationTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"), | ||
| 183 | - } | ||
| 184 | - if orderinfo.OrderCompute.UseOrderAmount >= 0 { | ||
| 185 | - rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount) | ||
| 186 | - } | ||
| 187 | - if orderinfo.OrderCompute.UseOrderCount >= 0 { | ||
| 188 | - rsp["orderAmountAdjustmentCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount) | ||
| 189 | - } | ||
| 190 | - c.ResponseData(rsp) | 134 | + c.ResponseData(orderinfo) |
| 191 | return | 135 | return |
| 192 | } | 136 | } |
| 193 | 137 | ||
| 194 | -type postOrderDividend struct { | ||
| 195 | - Id int64 `json:"id"` | ||
| 196 | - DividendPayments []postDividendPayment `json:"dividendPayment"` | ||
| 197 | -} | 138 | +// type postOrderDividend struct { |
| 139 | +// Id int64 `json:"id"` | ||
| 140 | +// DividendPayments []postDividendPayment `json:"dividendPayment"` | ||
| 141 | +// } | ||
| 198 | 142 | ||
| 199 | -type postDividendPayment struct { | ||
| 200 | - QuantityControl string `json:"quantityControl"` | ||
| 201 | - StateOfPayment int `json:"stateOfPayment"` | ||
| 202 | - ProductId int64 `json:"productId"` | ||
| 203 | - Remark string `json:"remark"` | ||
| 204 | -} | ||
| 205 | - | ||
| 206 | -func (c *OrderDividendController) EditOrderDividend() { | ||
| 207 | - var ( | ||
| 208 | - param postOrderDividend | ||
| 209 | - err error | ||
| 210 | - ) | ||
| 211 | - if err = c.BindJsonData(¶m); err != nil { | ||
| 212 | - logs.Error(err) | ||
| 213 | - c.ResponseError(errors.New("json数据解析失败")) | ||
| 214 | - return | ||
| 215 | - } | ||
| 216 | - | ||
| 217 | - if param.Id == 0 { | ||
| 218 | - c.ResponseError(errors.New("参数错误")) | ||
| 219 | - return | ||
| 220 | - } | ||
| 221 | - goodbouns := []orderCmd.GoodBouns{} | ||
| 222 | - for _, v := range param.DividendPayments { | ||
| 223 | - if v.ProductId == 0 { | ||
| 224 | - c.ResponseError(errors.New("参数错误")) | ||
| 225 | - return | ||
| 226 | - } | ||
| 227 | - if !(v.StateOfPayment == domain.OrderGoodWaitPay || v.StateOfPayment == domain.OrderGoodHasPay) { | ||
| 228 | - c.ResponseError(errors.New("参数错误")) | ||
| 229 | - return | ||
| 230 | - } | ||
| 231 | - g := orderCmd.GoodBouns{ | ||
| 232 | - GoodId: v.ProductId, | ||
| 233 | - Remark: v.Remark, | ||
| 234 | - BounsStatus: v.StateOfPayment, | ||
| 235 | - } | ||
| 236 | - if len(v.QuantityControl) == 0 { | ||
| 237 | - g.UseGoodNumber = -1 | ||
| 238 | - } else { | ||
| 239 | - num, err := strconv.Atoi(v.QuantityControl) | ||
| 240 | - if err != nil { | ||
| 241 | - c.ResponseError(errors.New("参数错误")) | ||
| 242 | - return | ||
| 243 | - } | ||
| 244 | - g.UseGoodNumber = num | ||
| 245 | - } | ||
| 246 | - goodbouns = append(goodbouns, g) | ||
| 247 | - } | ||
| 248 | - companyId := c.GetUserCompany() | ||
| 249 | - cmd := orderCmd.UpdateGoodBouns{ | ||
| 250 | - Id: param.Id, | ||
| 251 | - GoodBouns: goodbouns, | ||
| 252 | - CompanyId: companyId, | ||
| 253 | - } | ||
| 254 | - orderSrv := orderService.NewOrderInfoService(nil) | ||
| 255 | - err = orderSrv.UpdateGoodBouns(cmd) | ||
| 256 | - if err != nil { | ||
| 257 | - c.ResponseError(err) | ||
| 258 | - return | ||
| 259 | - } | ||
| 260 | - c.ResponseData(nil) | ||
| 261 | - return | ||
| 262 | -} | 143 | +// type postDividendPayment struct { |
| 144 | +// QuantityControl string `json:"quantityControl"` | ||
| 145 | +// StateOfPayment int `json:"stateOfPayment"` | ||
| 146 | +// ProductId int64 `json:"productId"` | ||
| 147 | +// Remark string `json:"remark"` | ||
| 148 | +// } | ||
| 263 | 149 | ||
| 264 | //OrderDividendDetailForBestshop 海鲜干货的订单分红详情 | 150 | //OrderDividendDetailForBestshop 海鲜干货的订单分红详情 |
| 265 | func (c *OrderDividendController) OrderDividendDetailForBestshop() { | 151 | func (c *OrderDividendController) OrderDividendDetailForBestshop() { |
| @@ -291,8 +177,8 @@ func (c *OrderDividendController) OrderDividendDetailForBestshop() { | @@ -291,8 +177,8 @@ func (c *OrderDividendController) OrderDividendDetailForBestshop() { | ||
| 291 | return | 177 | return |
| 292 | } | 178 | } |
| 293 | 179 | ||
| 294 | -//EditOrderForBestshop 编辑海鲜干货的订单 中的 货品数量和分红比例 | ||
| 295 | -func (c *OrderDividendController) EditOrderDividendForBestshop() { | 180 | +//EditOrderForBestshop 编辑订单分红详情中的 货品数量和分红比例 |
| 181 | +func (c *OrderDividendController) EditOrderDividend() { | ||
| 296 | type Parameter struct { | 182 | type Parameter struct { |
| 297 | State int `json:"state"` | 183 | State int `json:"state"` |
| 298 | OrderId string `json:"orderId"` | 184 | OrderId string `json:"orderId"` |
| @@ -337,8 +223,8 @@ func (c *OrderDividendController) EditOrderDividendForBestshop() { | @@ -337,8 +223,8 @@ func (c *OrderDividendController) EditOrderDividendForBestshop() { | ||
| 337 | return | 223 | return |
| 338 | } | 224 | } |
| 339 | 225 | ||
| 340 | -//PayOrderGoodBonusForBestshop 支付海鲜干货订单中的分红 | ||
| 341 | -func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { | 226 | +//PayOrderGoodBonus 支付订单中的分红 |
| 227 | +func (c *OrderDividendController) PayOrderGoodBonus() { | ||
| 342 | type Parameter struct { | 228 | type Parameter struct { |
| 343 | OrderId string `json:"orderId"` | 229 | OrderId string `json:"orderId"` |
| 344 | ProductId string `json:"productId"` | 230 | ProductId string `json:"productId"` |
| @@ -364,7 +250,7 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { | @@ -364,7 +250,7 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { | ||
| 364 | } | 250 | } |
| 365 | adminId := c.GetUserId() | 251 | adminId := c.GetUserId() |
| 366 | orderSrv := orderService.NewOrderInfoService(nil) | 252 | orderSrv := orderService.NewOrderInfoService(nil) |
| 367 | - err = orderSrv.PayPartnerBonusWithOrderBestshop(orderid, productId, adminId) | 253 | + err = orderSrv.PayPartnerBonus(orderid, productId, adminId) |
| 368 | if err != nil { | 254 | if err != nil { |
| 369 | c.ResponseError(err) | 255 | c.ResponseError(err) |
| 370 | return | 256 | return |
| @@ -373,8 +259,8 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { | @@ -373,8 +259,8 @@ func (c *OrderDividendController) PayOrderGoodBonusForBestshop() { | ||
| 373 | return | 259 | return |
| 374 | } | 260 | } |
| 375 | 261 | ||
| 376 | -//EditOrderRemarkBonusForBestshop 编辑海鲜干货订单中的备注 | ||
| 377 | -func (c *OrderDividendController) EditOrderRemarkBonusForBestshop() { | 262 | +//EditOrderRemarkBonus 编辑订单分红详情中的备注 |
| 263 | +func (c *OrderDividendController) EditOrderRemarkBonus() { | ||
| 378 | type Parameter struct { | 264 | type Parameter struct { |
| 379 | OrderId string `json:"orderId"` | 265 | OrderId string `json:"orderId"` |
| 380 | Remark string `json:"remark"` | 266 | Remark string `json:"remark"` |
| @@ -407,11 +293,12 @@ func (c *OrderDividendController) EditOrderRemarkBonusForBestshop() { | @@ -407,11 +293,12 @@ func (c *OrderDividendController) EditOrderRemarkBonusForBestshop() { | ||
| 407 | 293 | ||
| 408 | func (c *OrderDividendController) ListOrderBonusForExcel() { | 294 | func (c *OrderDividendController) ListOrderBonusForExcel() { |
| 409 | type Parameter struct { | 295 | type Parameter struct { |
| 410 | - SearchWord string `json:"searchWord"` | ||
| 411 | - OrderType int `json:"orderType"` | ||
| 412 | - PageSize int `json:"pageSize"` | ||
| 413 | - PageNumber int `json:"pageNumber"` | ||
| 414 | - PartnerCategoryId int `json:"partnerCategoryId"` | 296 | + SearchWord string `json:"searchWord"` |
| 297 | + OrderType int `json:"orderType"` | ||
| 298 | + PageSize int `json:"pageSize"` | ||
| 299 | + PageNumber int `json:"pageNumber"` | ||
| 300 | + PartnerCategoryId int `json:"partnerCategoryId"` | ||
| 301 | + CreateTime []string `json:"createTime"` | ||
| 415 | } | 302 | } |
| 416 | var ( | 303 | var ( |
| 417 | param Parameter | 304 | param Parameter |
| @@ -428,7 +315,32 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | @@ -428,7 +315,32 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | ||
| 428 | c.ResponseError(errors.New("参数异常")) | 315 | c.ResponseError(errors.New("参数异常")) |
| 429 | return | 316 | return |
| 430 | } | 317 | } |
| 431 | - | 318 | + var ( |
| 319 | + createTimeBegin string | ||
| 320 | + createTimeEnd string | ||
| 321 | + ) | ||
| 322 | + if len(param.CreateTime) > 0 { | ||
| 323 | + if len(param.CreateTime[0]) > 0 { | ||
| 324 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local) | ||
| 325 | + if err != nil { | ||
| 326 | + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) | ||
| 327 | + return | ||
| 328 | + } | ||
| 329 | + createTimeBegin = t.Format("2006-01-02 15:04:05-07") | ||
| 330 | + } | ||
| 331 | + } | ||
| 332 | + if len(param.CreateTime) > 1 { | ||
| 333 | + if len(param.CreateTime[1]) > 0 { | ||
| 334 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local) | ||
| 335 | + if err != nil { | ||
| 336 | + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) | ||
| 337 | + return | ||
| 338 | + } | ||
| 339 | + //设定时间边界 | ||
| 340 | + t = t.Add(86399 * time.Second) | ||
| 341 | + createTimeEnd = t.Format("2006-01-02 15:04:05-07") | ||
| 342 | + } | ||
| 343 | + } | ||
| 432 | companyId := c.GetUserCompany() | 344 | companyId := c.GetUserCompany() |
| 433 | orderSrv := orderService.NewOrderInfoService(nil) | 345 | orderSrv := orderService.NewOrderInfoService(nil) |
| 434 | dataResult, column, err := orderSrv.ListOrderBonusForExcel( | 346 | dataResult, column, err := orderSrv.ListOrderBonusForExcel( |
| @@ -437,6 +349,8 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | @@ -437,6 +349,8 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | ||
| 437 | PartnerOrCode: param.SearchWord, | 349 | PartnerOrCode: param.SearchWord, |
| 438 | CompanyId: companyId, | 350 | CompanyId: companyId, |
| 439 | PartnerCategory: param.PartnerCategoryId, | 351 | PartnerCategory: param.PartnerCategoryId, |
| 352 | + CreateTimeBegin: createTimeBegin, | ||
| 353 | + CreateTimeEnd: createTimeEnd, | ||
| 440 | }) | 354 | }) |
| 441 | if err != nil { | 355 | if err != nil { |
| 442 | c.ResponseError(err) | 356 | c.ResponseError(err) |
| @@ -456,3 +370,34 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | @@ -456,3 +370,34 @@ func (c *OrderDividendController) ListOrderBonusForExcel() { | ||
| 456 | c.ResponseExcelByFile(c.Ctx, excelMaker) | 370 | c.ResponseExcelByFile(c.Ctx, excelMaker) |
| 457 | return | 371 | return |
| 458 | } | 372 | } |
| 373 | + | ||
| 374 | +//BatchPayOrderGoodBonus 批量支付订单中的分红 | ||
| 375 | +func (c *OrderDividendController) BatchPayOrderGoodBonus() { | ||
| 376 | + type Parameter struct { | ||
| 377 | + OrderIds []string `json:"orderIds"` | ||
| 378 | + } | ||
| 379 | + var ( | ||
| 380 | + param Parameter | ||
| 381 | + err error | ||
| 382 | + ) | ||
| 383 | + if err = c.BindJsonData(¶m); err != nil { | ||
| 384 | + logs.Error(err) | ||
| 385 | + c.ResponseError(errors.New("json数据解析失败")) | ||
| 386 | + return | ||
| 387 | + } | ||
| 388 | + orderIds := []int64{} | ||
| 389 | + for _, v := range param.OrderIds { | ||
| 390 | + id, _ := strconv.ParseInt(v, 10, 64) | ||
| 391 | + orderIds = append(orderIds, id) | ||
| 392 | + } | ||
| 393 | + adminId := c.GetUserId() | ||
| 394 | + orderSrv := orderService.NewOrderInfoService(nil) | ||
| 395 | + | ||
| 396 | + err = orderSrv.BatchPayPartnerBonus(orderIds, adminId) | ||
| 397 | + if err != nil { | ||
| 398 | + c.ResponseError(err) | ||
| 399 | + return | ||
| 400 | + } | ||
| 401 | + c.ResponseData(nil) | ||
| 402 | + return | ||
| 403 | +} |
| @@ -15,6 +15,7 @@ import ( | @@ -15,6 +15,7 @@ import ( | ||
| 15 | orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service" | 15 | orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service" |
| 16 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" | 16 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" |
| 17 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" | 17 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib" |
| 18 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib/exceltool" | ||
| 18 | ) | 19 | ) |
| 19 | 20 | ||
| 20 | type OrderInfoController struct { | 21 | type OrderInfoController struct { |
| @@ -32,142 +33,6 @@ func (c *OrderInfoController) Prepare() { | @@ -32,142 +33,6 @@ func (c *OrderInfoController) Prepare() { | ||
| 32 | } | 33 | } |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | -//PageListOrderPurpose 分页获取意向订单列表 | ||
| 36 | -// func (c *OrderInfoController) PageListOrderPurpose() { | ||
| 37 | -// type Parameter struct { | ||
| 38 | -// SearchText string `json:"searchText"` | ||
| 39 | -// Partner int64 `json:"partner"` | ||
| 40 | -// PageSize int `json:"pageSize"` | ||
| 41 | -// PageNumber int `json:"pageNumber"` | ||
| 42 | -// } | ||
| 43 | -// var ( | ||
| 44 | -// param Parameter | ||
| 45 | -// err error | ||
| 46 | -// ) | ||
| 47 | -// if err = c.BindJsonData(¶m); err != nil { | ||
| 48 | -// logs.Error(err) | ||
| 49 | -// c.ResponseError(errors.New("json数据解析失败")) | ||
| 50 | -// return | ||
| 51 | -// } | ||
| 52 | -// if param.PageNumber == 0 { | ||
| 53 | -// param.PageNumber = 1 | ||
| 54 | -// } | ||
| 55 | -// if param.PageSize == 0 { | ||
| 56 | -// param.PageSize = 20 | ||
| 57 | -// } | ||
| 58 | -// companyId := c.GetUserCompany() | ||
| 59 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 60 | -// orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{ | ||
| 61 | -// PartnerId: param.Partner, | ||
| 62 | -// OrderCode: param.SearchText, | ||
| 63 | -// OrderType: domain.OrderIntention, | ||
| 64 | -// Limit: param.PageSize, | ||
| 65 | -// Offset: (param.PageNumber - 1) * param.PageSize, | ||
| 66 | -// CompanyId: companyId, | ||
| 67 | -// }) | ||
| 68 | -// if err != nil { | ||
| 69 | -// c.ResponseError(err) | ||
| 70 | -// return | ||
| 71 | -// } | ||
| 72 | -// rsp := []map[string]interface{}{} | ||
| 73 | -// for i := range orderinfos { | ||
| 74 | -// orderinfo := orderinfos[i] | ||
| 75 | -// m := map[string]interface{}{ | ||
| 76 | -// "createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"), | ||
| 77 | -// "updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"), | ||
| 78 | -// "buyer": orderinfo.Buyer.BuyerName, | ||
| 79 | -// "id": orderinfo.Id, | ||
| 80 | -// "orderId": orderinfo.OrderCode, | ||
| 81 | -// "partner": orderinfo.PartnerInfo.PartnerName, | ||
| 82 | -// "orderNum": orderinfo.OrderCompute.PlanOrderCount, | ||
| 83 | -// "orderPrice": orderinfo.OrderCompute.PlanOrderAmount, | ||
| 84 | -// "orderDist": orderinfo.RegionInfo.RegionName, | ||
| 85 | -// } | ||
| 86 | -// rsp = append(rsp, m) | ||
| 87 | -// } | ||
| 88 | -// c.ResponsePageList(rsp, cnt, param.PageNumber) | ||
| 89 | -// } | ||
| 90 | - | ||
| 91 | -//GetOrderPurpose 获取意向订单详情 | ||
| 92 | -// func (c *OrderInfoController) GetOrderPurpose() { | ||
| 93 | -// type Parameter struct { | ||
| 94 | -// Id string `json:"id"` | ||
| 95 | -// } | ||
| 96 | -// var ( | ||
| 97 | -// param Parameter | ||
| 98 | -// err error | ||
| 99 | -// ) | ||
| 100 | -// if err = c.BindJsonData(¶m); err != nil { | ||
| 101 | -// logs.Error(err) | ||
| 102 | -// c.ResponseError(errors.New("json数据解析失败")) | ||
| 103 | -// return | ||
| 104 | -// } | ||
| 105 | -// orderid, _ := strconv.ParseInt(param.Id, 10, 64) | ||
| 106 | -// companyId := c.GetUserCompany() | ||
| 107 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 108 | -// orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{ | ||
| 109 | -// OrderId: orderid, | ||
| 110 | -// CompanyId: companyId, | ||
| 111 | -// }) | ||
| 112 | -// if err != nil { | ||
| 113 | -// c.ResponseError(err) | ||
| 114 | -// return | ||
| 115 | -// } | ||
| 116 | -// if orderinfo.OrderType != domain.OrderIntention { | ||
| 117 | -// c.ResponseError(errors.New("参数错误")) | ||
| 118 | -// return | ||
| 119 | -// } | ||
| 120 | -// allGoods := []map[string]interface{}{} | ||
| 121 | -// for _, v := range orderinfo.Goods { | ||
| 122 | -// m := map[string]interface{}{ | ||
| 123 | -// "id": v.Id, | ||
| 124 | -// "productName": v.GoodName, | ||
| 125 | -// "orderNum": v.PlanGoodNumber, | ||
| 126 | -// "univalence": v.Price, | ||
| 127 | -// "partnerRatio": v.PartnerBonusPercent, | ||
| 128 | -// "orderPrice": v.GoodCompute.PlanAmount, | ||
| 129 | -// } | ||
| 130 | -// allGoods = append(allGoods, m) | ||
| 131 | -// } | ||
| 132 | -// rsp := map[string]interface{}{ | ||
| 133 | -// "buyer": orderinfo.Buyer.BuyerName, | ||
| 134 | -// "id": orderinfo.Id, | ||
| 135 | -// "partnerID": orderinfo.PartnerInfo.Id, | ||
| 136 | -// "partner": orderinfo.PartnerInfo.PartnerName, | ||
| 137 | -// "orderDist": orderinfo.RegionInfo.RegionName, | ||
| 138 | -// "orderId": orderinfo.OrderCode, | ||
| 139 | -// "product": allGoods, | ||
| 140 | -// "commissionProportion": orderinfo.SalesmanBonusPercent, | ||
| 141 | -// "orderNumCount": orderinfo.OrderCompute.PlanOrderCount, | ||
| 142 | -// "orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount, | ||
| 143 | -// } | ||
| 144 | -// c.ResponseData(rsp) | ||
| 145 | -// } | ||
| 146 | - | ||
| 147 | -//RemoveOrderPurpose 删除意向订单 | ||
| 148 | -// func (c *OrderInfoController) RemoveOrderPurpose() { | ||
| 149 | -// type Parameter struct { | ||
| 150 | -// Id int64 `json:"id"` | ||
| 151 | -// } | ||
| 152 | -// var ( | ||
| 153 | -// param Parameter | ||
| 154 | -// err error | ||
| 155 | -// ) | ||
| 156 | -// if err = c.BindJsonData(¶m); err != nil { | ||
| 157 | -// logs.Error(err) | ||
| 158 | -// c.ResponseError(errors.New("json数据解析失败")) | ||
| 159 | -// return | ||
| 160 | -// } | ||
| 161 | -// companyId := c.GetUserCompany() | ||
| 162 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 163 | -// err = orderSrv.DeleteOrder(param.Id, companyId) | ||
| 164 | -// if err != nil { | ||
| 165 | -// c.ResponseError(err) | ||
| 166 | -// return | ||
| 167 | -// } | ||
| 168 | -// c.ResponseData(nil) | ||
| 169 | -// } | ||
| 170 | - | ||
| 171 | //postPurposeOrderDetail 请求添加/更新的订单数据 | 36 | //postPurposeOrderDetail 请求添加/更新的订单数据 |
| 172 | type postPurposeOrderDetail struct { | 37 | type postPurposeOrderDetail struct { |
| 173 | Id int64 `json:"id"` | 38 | Id int64 `json:"id"` |
| @@ -252,93 +117,6 @@ func (postData *postOrderGood) Valid() error { | @@ -252,93 +117,6 @@ func (postData *postOrderGood) Valid() error { | ||
| 252 | return nil | 117 | return nil |
| 253 | } | 118 | } |
| 254 | 119 | ||
| 255 | -// //UpdateOrderPurpose 更新意向订单 | ||
| 256 | -// func (c *OrderInfoController) UpdateOrderPurpose() { | ||
| 257 | -// //用与适配前端定义的数据结构 | ||
| 258 | -// var ( | ||
| 259 | -// param postPurposeOrderDetail | ||
| 260 | -// err error | ||
| 261 | -// ) | ||
| 262 | -// if err = c.BindJsonData(¶m); err != nil { | ||
| 263 | -// logs.Error(err) | ||
| 264 | -// c.ResponseError(errors.New("json数据解析失败")) | ||
| 265 | -// return | ||
| 266 | -// } | ||
| 267 | - | ||
| 268 | -// if err := param.Valid(); err != nil { | ||
| 269 | -// c.ResponseError(err) | ||
| 270 | -// return | ||
| 271 | -// } | ||
| 272 | -// if param.Id == 0 { | ||
| 273 | -// err = c.addOrderPurpose(param) | ||
| 274 | -// } else { | ||
| 275 | -// err = c.editOrderPurpose(param) | ||
| 276 | -// } | ||
| 277 | -// if err != nil { | ||
| 278 | -// c.ResponseError(err) | ||
| 279 | -// } | ||
| 280 | -// c.ResponseData(nil) | ||
| 281 | -// return | ||
| 282 | -// } | ||
| 283 | - | ||
| 284 | -// func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error { | ||
| 285 | - | ||
| 286 | -// newGoods := []orderCmd.OrderGoodData{} | ||
| 287 | -// for _, v := range param.Product { | ||
| 288 | -// g := orderCmd.OrderGoodData{ | ||
| 289 | -// GoodName: v.ProductName, | ||
| 290 | -// PlanGoodNumber: v.OrderNum, | ||
| 291 | -// Price: v.Univalence, | ||
| 292 | -// PartnerBonusPercent: v.PartnerRatio, | ||
| 293 | -// } | ||
| 294 | -// newGoods = append(newGoods, g) | ||
| 295 | -// } | ||
| 296 | -// companyId := c.GetUserCompany() | ||
| 297 | -// createcmd := orderCmd.CreateOrderCommand{ | ||
| 298 | -// OrderType: domain.OrderIntention, | ||
| 299 | -// OrderCode: param.OrderId, | ||
| 300 | -// DeliveryCode: "", | ||
| 301 | -// BuyerName: param.BuyerName, | ||
| 302 | -// OrderRegion: param.OrderDist, | ||
| 303 | -// PartnerId: param.PartnerId, | ||
| 304 | -// SalesmanBonusPercent: param.CommissionProportion, | ||
| 305 | -// Goods: newGoods, | ||
| 306 | -// CompanyId: companyId, | ||
| 307 | -// } | ||
| 308 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 309 | -// _, err := orderSrv.CreateNewOrder(createcmd) | ||
| 310 | -// return err | ||
| 311 | -// } | ||
| 312 | - | ||
| 313 | -// func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error { | ||
| 314 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 315 | -// newGoods := []orderCmd.OrderGoodData{} | ||
| 316 | -// for _, v := range param.Product { | ||
| 317 | -// g := orderCmd.OrderGoodData{ | ||
| 318 | -// GoodName: v.ProductName, | ||
| 319 | -// PlanGoodNumber: v.OrderNum, | ||
| 320 | -// Price: v.Univalence, | ||
| 321 | -// PartnerBonusPercent: v.PartnerRatio, | ||
| 322 | -// } | ||
| 323 | -// newGoods = append(newGoods, g) | ||
| 324 | -// } | ||
| 325 | -// companyId := c.GetUserCompany() | ||
| 326 | -// updatecmd := orderCmd.UpdateOrderCommand{ | ||
| 327 | -// Id: param.Id, | ||
| 328 | -// OrderType: domain.OrderIntention, | ||
| 329 | -// OrderCode: param.OrderId, | ||
| 330 | -// DeliveryCode: "", | ||
| 331 | -// BuyerName: param.BuyerName, | ||
| 332 | -// OrderRegion: param.OrderDist, | ||
| 333 | -// PartnerId: param.PartnerId, | ||
| 334 | -// SalesmanBonusPercent: param.CommissionProportion, | ||
| 335 | -// Goods: newGoods, | ||
| 336 | -// CompanyId: companyId, | ||
| 337 | -// } | ||
| 338 | -// _, err := orderSrv.UpdateOrderData(updatecmd) | ||
| 339 | -// return err | ||
| 340 | -// } | ||
| 341 | - | ||
| 342 | type postOrderPurposeDelivery struct { | 120 | type postOrderPurposeDelivery struct { |
| 343 | ShipmentsId string `json:"shipmentsId"` //发货单号 | 121 | ShipmentsId string `json:"shipmentsId"` //发货单号 |
| 344 | Id string `json:"id"` //订单id | 122 | Id string `json:"id"` //订单id |
| @@ -363,51 +141,6 @@ func (postData *postOrderPurposeDelivery) Valid() error { | @@ -363,51 +141,6 @@ func (postData *postOrderPurposeDelivery) Valid() error { | ||
| 363 | return nil | 141 | return nil |
| 364 | } | 142 | } |
| 365 | 143 | ||
| 366 | -//OrderPurposeDelivery 发货 意向订单转实发单 | ||
| 367 | -// func (c *OrderInfoController) OrderPurposeDelivery() { | ||
| 368 | -// //用与适配前端定义的数据结构 | ||
| 369 | - | ||
| 370 | -// var ( | ||
| 371 | -// param postOrderPurposeDelivery | ||
| 372 | -// err error | ||
| 373 | -// ) | ||
| 374 | -// if err = c.BindJsonData(¶m); err != nil { | ||
| 375 | -// logs.Error(err) | ||
| 376 | -// c.ResponseError(errors.New("json数据解析失败")) | ||
| 377 | -// return | ||
| 378 | -// } | ||
| 379 | -// param.ShipmentsId = strings.TrimSpace(param.ShipmentsId) | ||
| 380 | -// orderid, _ := strconv.ParseInt(param.Id, 10, 64) | ||
| 381 | -// if orderid <= 0 { | ||
| 382 | -// c.ResponseError(errors.New("参数错误")) | ||
| 383 | -// return | ||
| 384 | -// } | ||
| 385 | -// if err = param.Valid(); err != nil { | ||
| 386 | -// c.ResponseError(err) | ||
| 387 | -// return | ||
| 388 | -// } | ||
| 389 | -// goods := []orderCmd.OrderGoodData{} | ||
| 390 | -// for _, v := range param.ProductDetail { | ||
| 391 | -// g := orderCmd.OrderGoodData{ | ||
| 392 | -// Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum, | ||
| 393 | -// Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio, | ||
| 394 | -// } | ||
| 395 | -// goods = append(goods, g) | ||
| 396 | -// } | ||
| 397 | -// companyId := c.GetUserCompany() | ||
| 398 | -// deliveryCommand := orderCmd.OrderDeliveryCommand{ | ||
| 399 | -// OrderId: orderid, DeliveryCode: param.ShipmentsId, | ||
| 400 | -// DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId, | ||
| 401 | -// } | ||
| 402 | -// orderSrv := orderService.NewOrderInfoService(nil) | ||
| 403 | -// err = orderSrv.Delivery(deliveryCommand) | ||
| 404 | -// if err != nil { | ||
| 405 | -// c.ResponseError(err) | ||
| 406 | -// } | ||
| 407 | -// c.ResponseData(nil) | ||
| 408 | -// return | ||
| 409 | -// } | ||
| 410 | - | ||
| 411 | //PageListOrderReal 获取实发订单列表 | 144 | //PageListOrderReal 获取实发订单列表 |
| 412 | func (c *OrderInfoController) PageListOrderReal() { | 145 | func (c *OrderInfoController) PageListOrderReal() { |
| 413 | type Parameter struct { | 146 | type Parameter struct { |
| @@ -416,6 +149,7 @@ func (c *OrderInfoController) PageListOrderReal() { | @@ -416,6 +149,7 @@ func (c *OrderInfoController) PageListOrderReal() { | ||
| 416 | PageSize int `json:"pageSize"` | 149 | PageSize int `json:"pageSize"` |
| 417 | PageNumber int `json:"pageNumber"` | 150 | PageNumber int `json:"pageNumber"` |
| 418 | UpdateTime []string `json:"updateTime"` | 151 | UpdateTime []string `json:"updateTime"` |
| 152 | + CreateTime []string `json:"createTime"` | ||
| 419 | } | 153 | } |
| 420 | var ( | 154 | var ( |
| 421 | param Parameter | 155 | param Parameter |
| @@ -458,6 +192,33 @@ func (c *OrderInfoController) PageListOrderReal() { | @@ -458,6 +192,33 @@ func (c *OrderInfoController) PageListOrderReal() { | ||
| 458 | updateTimeEnd = t.Format("2006-01-02 15:04:05-07") | 192 | updateTimeEnd = t.Format("2006-01-02 15:04:05-07") |
| 459 | } | 193 | } |
| 460 | } | 194 | } |
| 195 | + var ( | ||
| 196 | + createTimeBegin string | ||
| 197 | + createTimeEnd string | ||
| 198 | + ) | ||
| 199 | + if len(param.CreateTime) > 0 { | ||
| 200 | + if len(param.CreateTime[0]) > 0 { | ||
| 201 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local) | ||
| 202 | + if err != nil { | ||
| 203 | + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) | ||
| 204 | + return | ||
| 205 | + } | ||
| 206 | + createTimeBegin = t.Format("2006-01-02 15:04:05-07") | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + if len(param.CreateTime) > 1 { | ||
| 210 | + if len(param.CreateTime[1]) > 0 { | ||
| 211 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local) | ||
| 212 | + if err != nil { | ||
| 213 | + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) | ||
| 214 | + return | ||
| 215 | + } | ||
| 216 | + //设定时间边界 | ||
| 217 | + t = t.Add(86399 * time.Second) | ||
| 218 | + createTimeEnd = t.Format("2006-01-02 15:04:05-07") | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + | ||
| 461 | companyId := c.GetUserCompany() | 222 | companyId := c.GetUserCompany() |
| 462 | orderSrv := orderService.NewOrderInfoService(nil) | 223 | orderSrv := orderService.NewOrderInfoService(nil) |
| 463 | orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{ | 224 | orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{ |
| @@ -469,6 +230,8 @@ func (c *OrderInfoController) PageListOrderReal() { | @@ -469,6 +230,8 @@ func (c *OrderInfoController) PageListOrderReal() { | ||
| 469 | PartnerCategory: param.PartnerCategory, | 230 | PartnerCategory: param.PartnerCategory, |
| 470 | UpdateTimeBegin: updateTimeBegin, | 231 | UpdateTimeBegin: updateTimeBegin, |
| 471 | UpdateTimeEnd: updateTimeEnd, | 232 | UpdateTimeEnd: updateTimeEnd, |
| 233 | + CreateTimeBegin: createTimeBegin, | ||
| 234 | + CreateTimeEnd: createTimeEnd, | ||
| 472 | }) | 235 | }) |
| 473 | if err != nil { | 236 | if err != nil { |
| 474 | c.ResponseError(err) | 237 | c.ResponseError(err) |
| @@ -514,7 +277,7 @@ func (c *OrderInfoController) GetOrderReal() { | @@ -514,7 +277,7 @@ func (c *OrderInfoController) GetOrderReal() { | ||
| 514 | allGoods := []map[string]interface{}{} | 277 | allGoods := []map[string]interface{}{} |
| 515 | for _, v := range orderinfo.Goods { | 278 | for _, v := range orderinfo.Goods { |
| 516 | m := map[string]interface{}{ | 279 | m := map[string]interface{}{ |
| 517 | - "id": v.Id, | 280 | + "id": fmt.Sprint(v.Id), |
| 518 | "productName": v.GoodName, | 281 | "productName": v.GoodName, |
| 519 | "orderNum": v.PlanGoodNumber, | 282 | "orderNum": v.PlanGoodNumber, |
| 520 | "univalence": v.Price, | 283 | "univalence": v.Price, |
| @@ -594,8 +357,9 @@ func (c *OrderInfoController) UpdateOrderReal() { | @@ -594,8 +357,9 @@ func (c *OrderInfoController) UpdateOrderReal() { | ||
| 594 | c.ResponseError(err) | 357 | c.ResponseError(err) |
| 595 | return | 358 | return |
| 596 | } | 359 | } |
| 360 | + var orderDataReturn *domain.OrderBase | ||
| 597 | if param.Id == 0 { | 361 | if param.Id == 0 { |
| 598 | - err = c.addOrderReal(param) | 362 | + orderDataReturn, err = c.addOrderReal(param) |
| 599 | } else { | 363 | } else { |
| 600 | err = c.editOrderReal(param) | 364 | err = c.editOrderReal(param) |
| 601 | } | 365 | } |
| @@ -603,11 +367,17 @@ func (c *OrderInfoController) UpdateOrderReal() { | @@ -603,11 +367,17 @@ func (c *OrderInfoController) UpdateOrderReal() { | ||
| 603 | c.ResponseError(err) | 367 | c.ResponseError(err) |
| 604 | return | 368 | return |
| 605 | } | 369 | } |
| 370 | + if orderDataReturn != nil { | ||
| 371 | + c.ResponseData(map[string]interface{}{ | ||
| 372 | + "id": orderDataReturn.Id, | ||
| 373 | + }) | ||
| 374 | + return | ||
| 375 | + } | ||
| 606 | c.ResponseData(nil) | 376 | c.ResponseData(nil) |
| 607 | return | 377 | return |
| 608 | } | 378 | } |
| 609 | 379 | ||
| 610 | -func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { | 380 | +func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) (*domain.OrderBase, error) { |
| 611 | orderSrv := orderService.NewOrderInfoService(nil) | 381 | orderSrv := orderService.NewOrderInfoService(nil) |
| 612 | newGoods := []orderCmd.OrderGoodData{} | 382 | newGoods := []orderCmd.OrderGoodData{} |
| 613 | for _, v := range param.Product { | 383 | for _, v := range param.Product { |
| @@ -632,8 +402,8 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { | @@ -632,8 +402,8 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error { | ||
| 632 | CompanyId: companyId, | 402 | CompanyId: companyId, |
| 633 | PartnerCategory: param.PartnerCategoryId, | 403 | PartnerCategory: param.PartnerCategoryId, |
| 634 | } | 404 | } |
| 635 | - _, err := orderSrv.CreateNewOrder(createcmd) | ||
| 636 | - return err | 405 | + orderData, err := orderSrv.CreateNewOrder(createcmd) |
| 406 | + return orderData, err | ||
| 637 | } | 407 | } |
| 638 | 408 | ||
| 639 | func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { | 409 | func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error { |
| @@ -711,7 +481,7 @@ func (c *OrderInfoController) OrderDisable() { | @@ -711,7 +481,7 @@ func (c *OrderInfoController) OrderDisable() { | ||
| 711 | //RemoveOrderReal 删除意向订单 | 481 | //RemoveOrderReal 删除意向订单 |
| 712 | func (c *OrderInfoController) RemoveOrderReal() { | 482 | func (c *OrderInfoController) RemoveOrderReal() { |
| 713 | type Parameter struct { | 483 | type Parameter struct { |
| 714 | - Id int64 `json:"id"` | 484 | + Id string `json:"id"` |
| 715 | } | 485 | } |
| 716 | var ( | 486 | var ( |
| 717 | param Parameter | 487 | param Parameter |
| @@ -723,11 +493,113 @@ func (c *OrderInfoController) RemoveOrderReal() { | @@ -723,11 +493,113 @@ func (c *OrderInfoController) RemoveOrderReal() { | ||
| 723 | return | 493 | return |
| 724 | } | 494 | } |
| 725 | companyId := c.GetUserCompany() | 495 | companyId := c.GetUserCompany() |
| 496 | + id, _ := strconv.ParseInt(param.Id, 10, 64) | ||
| 726 | orderSrv := orderService.NewOrderInfoService(nil) | 497 | orderSrv := orderService.NewOrderInfoService(nil) |
| 727 | - err = orderSrv.DeleteOrder(param.Id, companyId) | 498 | + err = orderSrv.DeleteOrder(id, companyId) |
| 728 | if err != nil { | 499 | if err != nil { |
| 729 | c.ResponseError(err) | 500 | c.ResponseError(err) |
| 730 | return | 501 | return |
| 731 | } | 502 | } |
| 732 | c.ResponseData(nil) | 503 | c.ResponseData(nil) |
| 733 | } | 504 | } |
| 505 | + | ||
| 506 | +//ListOrderForExcel excel 导出实际订单的列表 | ||
| 507 | +func (c *OrderInfoController) ListOrderForExcel() { | ||
| 508 | + type Parameter struct { | ||
| 509 | + SearchText string `json:"searchText"` | ||
| 510 | + PartnerCategory int `json:"PartnerCategory"` | ||
| 511 | + UpdateTime []string `json:"updateTime"` | ||
| 512 | + CreateTime []string `json:"createTime"` | ||
| 513 | + } | ||
| 514 | + var ( | ||
| 515 | + param Parameter | ||
| 516 | + err error | ||
| 517 | + ) | ||
| 518 | + if err = c.BindJsonData(¶m); err != nil { | ||
| 519 | + logs.Error(err) | ||
| 520 | + c.ResponseError(errors.New("json数据解析失败")) | ||
| 521 | + return | ||
| 522 | + } | ||
| 523 | + var ( | ||
| 524 | + updateTimeBegin string | ||
| 525 | + updateTimeEnd string | ||
| 526 | + ) | ||
| 527 | + if len(param.UpdateTime) > 0 { | ||
| 528 | + if len(param.UpdateTime[0]) > 0 { | ||
| 529 | + t, err := time.ParseInLocation("2006-01-02", param.UpdateTime[0], time.Local) | ||
| 530 | + if err != nil { | ||
| 531 | + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) | ||
| 532 | + return | ||
| 533 | + } | ||
| 534 | + updateTimeBegin = t.Format("2006-01-02 15:04:05-07") | ||
| 535 | + } | ||
| 536 | + } | ||
| 537 | + if len(param.UpdateTime) > 1 { | ||
| 538 | + if len(param.UpdateTime[1]) > 0 { | ||
| 539 | + t, err := time.ParseInLocation("2006-01-02", param.UpdateTime[1], time.Local) | ||
| 540 | + if err != nil { | ||
| 541 | + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) | ||
| 542 | + return | ||
| 543 | + } | ||
| 544 | + //设定时间边界 | ||
| 545 | + t = t.Add(86399 * time.Second) | ||
| 546 | + updateTimeEnd = t.Format("2006-01-02 15:04:05-07") | ||
| 547 | + } | ||
| 548 | + } | ||
| 549 | + var ( | ||
| 550 | + createTimeBegin string | ||
| 551 | + createTimeEnd string | ||
| 552 | + ) | ||
| 553 | + if len(param.CreateTime) > 0 { | ||
| 554 | + if len(param.CreateTime[0]) > 0 { | ||
| 555 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[0], time.Local) | ||
| 556 | + if err != nil { | ||
| 557 | + c.ResponseError(errors.New("UpdateTimeBegin 时间格式错误")) | ||
| 558 | + return | ||
| 559 | + } | ||
| 560 | + createTimeBegin = t.Format("2006-01-02 15:04:05-07") | ||
| 561 | + } | ||
| 562 | + } | ||
| 563 | + if len(param.CreateTime) > 1 { | ||
| 564 | + if len(param.CreateTime[1]) > 0 { | ||
| 565 | + t, err := time.ParseInLocation("2006-01-02", param.CreateTime[1], time.Local) | ||
| 566 | + if err != nil { | ||
| 567 | + c.ResponseError(errors.New("UpdateTimeEnd 时间格式错误")) | ||
| 568 | + return | ||
| 569 | + } | ||
| 570 | + //设定时间边界 | ||
| 571 | + t = t.Add(86399 * time.Second) | ||
| 572 | + createTimeEnd = t.Format("2006-01-02 15:04:05-07") | ||
| 573 | + } | ||
| 574 | + } | ||
| 575 | + | ||
| 576 | + companyId := c.GetUserCompany() | ||
| 577 | + orderSrv := orderService.NewOrderInfoService(nil) | ||
| 578 | + orderinfos, columns, err := orderSrv.ListOrderForExcel(orderQuery.ListOrderBaseQuery{ | ||
| 579 | + PartnerOrCode: param.SearchText, | ||
| 580 | + OrderType: domain.OrderReal, | ||
| 581 | + CompanyId: companyId, | ||
| 582 | + PartnerCategory: param.PartnerCategory, | ||
| 583 | + UpdateTimeBegin: updateTimeBegin, | ||
| 584 | + UpdateTimeEnd: updateTimeEnd, | ||
| 585 | + CreateTimeBegin: createTimeBegin, | ||
| 586 | + CreateTimeEnd: createTimeEnd, | ||
| 587 | + }) | ||
| 588 | + if err != nil { | ||
| 589 | + c.ResponseError(err) | ||
| 590 | + return | ||
| 591 | + } | ||
| 592 | + var excelHeaders []exceltool.ExcelHead | ||
| 593 | + for i := range columns { | ||
| 594 | + h := exceltool.ExcelHead{ | ||
| 595 | + Key: columns[i][0], | ||
| 596 | + Name: columns[i][1], | ||
| 597 | + } | ||
| 598 | + excelHeaders = append(excelHeaders, h) | ||
| 599 | + } | ||
| 600 | + excelMaker := exceltool.NewExcelMaker() | ||
| 601 | + excelMaker.SetListHead(excelHeaders) | ||
| 602 | + excelMaker.MakeListExcel(orderinfos) | ||
| 603 | + c.ResponseExcelByFile(c.Ctx, excelMaker) | ||
| 604 | + return | ||
| 605 | +} |
| @@ -84,11 +84,17 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | @@ -84,11 +84,17 @@ func (c *PartnerInfoController) CreatePartnerInfo() { | ||
| 84 | } | 84 | } |
| 85 | } | 85 | } |
| 86 | serve := partnerInfoService.NewPartnerInfoService(nil) | 86 | serve := partnerInfoService.NewPartnerInfoService(nil) |
| 87 | - _, err = serve.CreatePartnerInfo(&cmd) | 87 | + newPartner, err := serve.CreatePartnerInfo(&cmd) |
| 88 | if err != nil { | 88 | if err != nil { |
| 89 | c.ResponseError(err) | 89 | c.ResponseError(err) |
| 90 | return | 90 | return |
| 91 | } | 91 | } |
| 92 | + if newPartner != nil { | ||
| 93 | + c.ResponseData(map[string]interface{}{ | ||
| 94 | + "id": newPartner.Partner.Id, | ||
| 95 | + }) | ||
| 96 | + return | ||
| 97 | + } | ||
| 92 | c.ResponseData(nil) | 98 | c.ResponseData(nil) |
| 93 | return | 99 | return |
| 94 | } | 100 | } |
| @@ -202,11 +208,12 @@ func (c *PartnerInfoController) GetPartnerInfo() { | @@ -202,11 +208,12 @@ func (c *PartnerInfoController) GetPartnerInfo() { | ||
| 202 | return | 208 | return |
| 203 | } | 209 | } |
| 204 | 210 | ||
| 205 | -//PartnerInfoSetState 合伙人批量禁用 | 211 | +//PartnerInfoSetState 合伙人批量禁用.启用 |
| 206 | func (c *PartnerInfoController) PartnerInfoSetState() { | 212 | func (c *PartnerInfoController) PartnerInfoSetState() { |
| 207 | //用与适配前端定义的数据结构 | 213 | //用与适配前端定义的数据结构 |
| 208 | type Parameter struct { | 214 | type Parameter struct { |
| 209 | - Id []int64 `json:"id"` | 215 | + Id []int64 `json:"id"` |
| 216 | + Status int `json:"status"` | ||
| 210 | } | 217 | } |
| 211 | var ( | 218 | var ( |
| 212 | param Parameter | 219 | param Parameter |
| @@ -218,10 +225,23 @@ func (c *PartnerInfoController) PartnerInfoSetState() { | @@ -218,10 +225,23 @@ func (c *PartnerInfoController) PartnerInfoSetState() { | ||
| 218 | return | 225 | return |
| 219 | } | 226 | } |
| 220 | comanyId := c.GetUserCompany() | 227 | comanyId := c.GetUserCompany() |
| 221 | - cmd := partnerInfoCmd.StatusPartnerInfoCommand{ | ||
| 222 | - Ids: param.Id, | ||
| 223 | - CompanyId: comanyId, | ||
| 224 | - Status: domain.PARTNER_STATUS_NO, | 228 | + var cmd partnerInfoCmd.StatusPartnerInfoCommand |
| 229 | + switch param.Status { | ||
| 230 | + case 0: | ||
| 231 | + cmd = partnerInfoCmd.StatusPartnerInfoCommand{ | ||
| 232 | + Ids: param.Id, | ||
| 233 | + CompanyId: comanyId, | ||
| 234 | + Status: domain.PARTNER_STATUS_NO, | ||
| 235 | + } | ||
| 236 | + case 1: | ||
| 237 | + cmd = partnerInfoCmd.StatusPartnerInfoCommand{ | ||
| 238 | + Ids: param.Id, | ||
| 239 | + CompanyId: comanyId, | ||
| 240 | + Status: domain.PARTNER_STATUS_YES, | ||
| 241 | + } | ||
| 242 | + default: | ||
| 243 | + c.ResponseError(errors.New("参数错误")) | ||
| 244 | + return | ||
| 225 | } | 245 | } |
| 226 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) | 246 | newPartnerService := partnerInfoService.NewPartnerInfoService(nil) |
| 227 | err = newPartnerService.UpdateStatus(cmd) | 247 | err = newPartnerService.UpdateStatus(cmd) |
| @@ -80,9 +80,6 @@ func (c *UserController) BeforeEditUser() { | @@ -80,9 +80,6 @@ func (c *UserController) BeforeEditUser() { | ||
| 80 | } | 80 | } |
| 81 | var rspData []map[string]interface{} | 81 | var rspData []map[string]interface{} |
| 82 | for i := range allPermission { | 82 | for i := range allPermission { |
| 83 | - if allPermission[i].Code == domain.PERMINSSION_ADMIN_USER { | ||
| 84 | - continue | ||
| 85 | - } | ||
| 86 | m := map[string]interface{}{ | 83 | m := map[string]interface{}{ |
| 87 | "id": allPermission[i].Id, | 84 | "id": allPermission[i].Id, |
| 88 | "permissionName": allPermission[i].Name, | 85 | "permissionName": allPermission[i].Name, |
| @@ -22,29 +22,20 @@ func init() { | @@ -22,29 +22,20 @@ func init() { | ||
| 22 | beego.NSRouter("/add", &controllers.PartnerInfoController{}, "POST:CreatePartnerInfo"), | 22 | beego.NSRouter("/add", &controllers.PartnerInfoController{}, "POST:CreatePartnerInfo"), |
| 23 | beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"), | 23 | beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"), |
| 24 | beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"), | 24 | beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"), |
| 25 | - //beego.NSRouter("/set-status", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), | ||
| 26 | beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), | 25 | beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"), |
| 27 | ), | 26 | ), |
| 28 | beego.NSNamespace("/dividends", | 27 | beego.NSNamespace("/dividends", |
| 29 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), | 28 | beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"), |
| 30 | - beego.NSRouter("/edit", &controllers.OrderDividendController{}, "POST:EditOrderDividend"), | 29 | + beego.NSRouter("/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividend"), |
| 31 | beego.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"), | 30 | beego.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"), |
| 32 | - beego.NSRouter("/mini-program/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetailForBestshop"), | ||
| 33 | - beego.NSRouter("/mini-program/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividendForBestshop"), | ||
| 34 | - beego.NSRouter("/mini-program/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonusForBestshop"), | ||
| 35 | - beego.NSRouter("/mini-program/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonusForBestshop"), | 31 | + beego.NSRouter("/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonus"), |
| 32 | + beego.NSRouter("/payDividends/batch", &controllers.OrderDividendController{}, "POST:BatchPayOrderGoodBonus"), | ||
| 33 | + beego.NSRouter("/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonus"), | ||
| 36 | beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"), | 34 | beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"), |
| 37 | - // beego.NSRouter("/business/detail", &controllers.BusinessBonusController{}, "POST:GetBusinessBonus"), | ||
| 38 | - // beego.NSRouter("/business/edit", &controllers.BusinessBonusController{}, "POST:UpdateBusinessBonus"), | ||
| 39 | - // beego.NSRouter("/business/list", &controllers.BusinessBonusController{}, "POST:ListBusinessBonus"), | ||
| 40 | ), | 35 | ), |
| 41 | beego.NSNamespace("/order", | 36 | beego.NSNamespace("/order", |
| 42 | - // beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"), | ||
| 43 | - // beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"), | ||
| 44 | - // beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"), | ||
| 45 | - // beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"), | ||
| 46 | - // beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"), | ||
| 47 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), | 37 | beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"), |
| 38 | + beego.NSRouter("/actual/list/excel", &controllers.OrderInfoController{}, "POST:ListOrderForExcel"), | ||
| 48 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), | 39 | beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"), |
| 49 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), | 40 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), |
| 50 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), | 41 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), |
-
请 注册 或 登录 后发表评论