...
|
...
|
@@ -11,6 +11,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -711,8 +712,85 @@ func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) err |
|
|
|
|
|
}
|
|
|
|
|
|
//PageListOrderBouns 获取订单的分红列表
|
|
|
func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]domain.OrderBase, int, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, 0, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, 0, err
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var (
|
|
|
ordersM []models.OrderBase
|
|
|
orders []domain.OrderBase
|
|
|
cnt int
|
|
|
orderBaseDao *dao.OrderBaseDao
|
|
|
)
|
|
|
|
|
|
if orderBaseDao, err = factory.CreateOrderBaseDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, cnt, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
ordersM, cnt, err = orderBaseDao.OrderListByCondition(
|
|
|
listOrderQuery.CompanyId,
|
|
|
listOrderQuery.OrderType,
|
|
|
listOrderQuery.PartnerOrCode,
|
|
|
listOrderQuery.Limit,
|
|
|
listOrderQuery.Offset,
|
|
|
)
|
|
|
for _, orderModel := range ordersM {
|
|
|
order := domain.OrderBase{
|
|
|
Id: orderModel.Id, OrderType: orderModel.OrderType, OrderCode: orderModel.OrderCode,
|
|
|
DeliveryCode: orderModel.DeliveryCode, Buyer: orderModel.Buyer, RegionInfo: orderModel.RegionInfo,
|
|
|
PartnerId: orderModel.PartnerId, SalesmanBonusPercent: orderModel.SalesmanBonusPercent,
|
|
|
CreateTime: orderModel.CreateTime, DeliveryTime: orderModel.DeliveryTime, UpdateTime: orderModel.UpdateTime,
|
|
|
IsDisable: orderModel.IsDisable,
|
|
|
OrderCompute: domain.OrderCompute{
|
|
|
PlanPartnerBonus: orderModel.PlanPartnerBonus, UsePartnerBonus: orderModel.UsePartnerBonus,
|
|
|
PartnerBonusHas: orderModel.PartnerBonusHas, PartnerBonusNot: orderModel.PartnerBonusNot,
|
|
|
PartnerBonusExpense: orderModel.PartnerBonusExpense, SalesmanBonus: orderModel.SalesmanBonus,
|
|
|
PlanOrderCount: orderModel.PlanOrderCount, PlanOrderAmount: orderModel.PlanOrderAmount,
|
|
|
UseOrderCount: orderModel.UseOrderCount, UseOrderAmount: orderModel.UseOrderAmount,
|
|
|
},
|
|
|
PartnerInfo: domain.Partner{
|
|
|
Id: orderModel.PartnerId,
|
|
|
},
|
|
|
BonusStatus: orderModel.BonusStatus,
|
|
|
CompanyId: orderModel.CompanyId,
|
|
|
}
|
|
|
orders = append(orders, order)
|
|
|
}
|
|
|
var PartnerInfoRepository domain.PartnerInfoRepository
|
|
|
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, 0, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
for i := range orders {
|
|
|
partnerData := &domain.PartnerInfo{}
|
|
|
partnerData, err = PartnerInfoRepository.FindOne(domain.PartnerFindOneQuery{
|
|
|
UserId: orders[i].PartnerId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
logs.Error("获取合伙(id=%d)失败%s", orders[i].PartnerId, err)
|
|
|
} else {
|
|
|
orders[i].PartnerInfo = partnerData.Partner
|
|
|
}
|
|
|
}
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
if err != nil {
|
|
|
return orders, cnt, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return orders, cnt, nil
|
|
|
}
|
|
|
|
|
|
//UpdateBounsWithGoodNumber 分红时,因修改订单中商品的数量发生分红变动
|
|
|
func (service OrderInfoService) UpdateBounsByGoodNumber() error {
|
|
|
func (service OrderInfoService) UpdateBonusByGoodNumber() error {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
err error
|
...
|
...
|
@@ -732,7 +810,7 @@ func (service OrderInfoService) UpdateBounsByGoodNumber() error { |
|
|
}
|
|
|
|
|
|
//UpdateBounsByPartnerBonusPercent 分红时,因修改订单中商品的合伙人分行比例发生分红变动
|
|
|
func (service OrderInfoService) UpdateBounsByPartnerBonusPercent() error {
|
|
|
func (service OrderInfoService) UpdateBonusByPartnerBonusPercent() error {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
err error
|
...
|
...
|
|