...
|
...
|
@@ -15,8 +15,8 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide |
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
OrderResponsitory, _ = factory.CreateOrderRepository(transactionContext)
|
|
|
beginTime = time.Unix(request.StartTime/1000, 0)
|
|
|
endTime = time.Unix(request.EndTime/1000, 0)
|
|
|
//beginTime = time.Unix(request.StartTime/1000, 0)
|
|
|
//endTime = time.Unix(request.EndTime/1000, 0)
|
|
|
)
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -26,16 +26,16 @@ func DividendStatistics(header *protocol.RequestHeader, request *protocol.Divide |
|
|
}()
|
|
|
_, orderAll, e := OrderResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: header.UserId, EndTime: time.Now(), SortByCreateTime: domain.DESC}))
|
|
|
if e != nil {
|
|
|
log.Error(e, beginTime, endTime)
|
|
|
log.Error(e)
|
|
|
}
|
|
|
var orderBetween []*domain.Order
|
|
|
for i := range orderAll {
|
|
|
if orderAll[i].CreateAt.After(beginTime) && orderAll[i].CreateAt.Before(endTime) {
|
|
|
if orderAll[i].CreateAt.Unix() >= (request.StartTime/1000) && orderAll[i].CreateAt.Unix() < (request.EndTime/1000) {
|
|
|
orderBetween = append(orderBetween, orderAll[i])
|
|
|
}
|
|
|
}
|
|
|
bonusAll := AllBonusStatics(orderAll, request.DividendAction)
|
|
|
bonusQuarters := QuartersBonusStatics(orderBetween, request.DividendAction)
|
|
|
bonusAll := AllBonusStatics(orderAll, 0)
|
|
|
bonusQuarters := QuartersBonusStatics(orderBetween, 0)
|
|
|
rsp = &protocol.DividendStatisticsResponse{}
|
|
|
rsp.Statistics = protocol.DividendStatistics{
|
|
|
Received: bonusAll.Received,
|
...
|
...
|
@@ -51,13 +51,13 @@ func AllBonusStatics(orders []*domain.Order, action int) (bonus protocol.Bonus) |
|
|
bonus = protocol.Bonus{}
|
|
|
for i := range orders {
|
|
|
o := orders[i]
|
|
|
if action == protocol.BonusTotal {
|
|
|
bonus.Received += o.OrderBonusReceive()
|
|
|
bonus.Outstanding += o.OrderBonusWait()
|
|
|
}
|
|
|
if action == protocol.BonusOutstanding {
|
|
|
bonus.Outstanding += o.OrderBonusOutstanding()
|
|
|
}
|
|
|
//if action == protocol.BonusTotal {
|
|
|
bonus.Received += o.OrderBonusReceive()
|
|
|
bonus.Outstanding += o.OrderBonusWait()
|
|
|
//}
|
|
|
//if action == protocol.BonusOutstanding {
|
|
|
// bonus.Outstanding += o.OrderBonusOutstanding()
|
|
|
//}
|
|
|
}
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -68,13 +68,16 @@ func QuartersBonusStatics(orders []*domain.Order, action int) (bonus []protocol. |
|
|
for i := range orders {
|
|
|
o := orders[i]
|
|
|
quarter := o.CreateAt.Month() / 4
|
|
|
if action == protocol.BonusTotal {
|
|
|
bonus[quarter].Received += o.OrderBonusReceive()
|
|
|
bonus[quarter].Outstanding += o.OrderBonusWait()
|
|
|
}
|
|
|
if action == protocol.BonusOutstanding {
|
|
|
bonus[quarter].Expend += o.OrderBonusOutstanding()
|
|
|
}
|
|
|
bonus[quarter].Received += o.OrderBonusReceive()
|
|
|
bonus[quarter].Outstanding += o.OrderBonusWait()
|
|
|
bonus[quarter].Expend += o.OrderBonusOutstanding()
|
|
|
//if action == protocol.BonusTotal {
|
|
|
//bonus[quarter].Received += o.OrderBonusReceive()
|
|
|
//bonus[quarter].Outstanding += o.OrderBonusWait()
|
|
|
//}
|
|
|
//if action == protocol.BonusOutstanding {
|
|
|
//bonus[quarter].Expend += o.OrderBonusOutstanding()
|
|
|
//}
|
|
|
}
|
|
|
return
|
|
|
}
|
...
|
...
|
|