...
|
...
|
@@ -73,6 +73,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat |
|
|
orderBetween = append(orderBetween, orderAll[i])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//0:全部分类,
|
|
|
//Career int = 1 //事业
|
|
|
//Business int = 2 //业务
|
...
|
...
|
@@ -86,31 +87,33 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat |
|
|
bonusAllDevelop protocol.Bonus
|
|
|
bonusAllApp protocol.Bonus
|
|
|
)
|
|
|
for _, val := range orderAll {
|
|
|
static := val.OrderBonusStatic()
|
|
|
bonusAll.Received = utils.Decimal(bonusAll.Received + static.OrderBonusReceive())
|
|
|
bonusAll.Outstanding = utils.Decimal(bonusAll.Outstanding + static.OrderBonusWait())
|
|
|
bonusAll.Receivable = utils.Decimal(bonusAll.Receivable + static.OrderTotalReceivable())
|
|
|
if val.PartnerCategory == nil {
|
|
|
continue
|
|
|
}
|
|
|
switch val.PartnerCategory.Id {
|
|
|
case int64(domain.Career):
|
|
|
bonusAllCareer.Received = utils.Decimal(bonusAllCareer.Received + static.OrderBonusReceive())
|
|
|
bonusAllCareer.Outstanding = utils.Decimal(bonusAllCareer.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllCareer.Receivable = utils.Decimal(bonusAllCareer.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.Business):
|
|
|
bonusAllBusiness.Received = utils.Decimal(bonusAllBusiness.Received + static.OrderBonusReceive())
|
|
|
bonusAllBusiness.Outstanding = utils.Decimal(bonusAllBusiness.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllBusiness.Receivable = utils.Decimal(bonusAllBusiness.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.App):
|
|
|
bonusAllApp.Received = utils.Decimal(bonusAllApp.Received + static.OrderBonusReceive())
|
|
|
bonusAllApp.Outstanding = utils.Decimal(bonusAllApp.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllApp.Receivable = utils.Decimal(bonusAllApp.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.Develop):
|
|
|
bonusAllDevelop.Received = utils.Decimal(bonusAllDevelop.Received + static.OrderBonusReceive())
|
|
|
bonusAllDevelop.Outstanding = utils.Decimal(bonusAllDevelop.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllDevelop.Receivable = utils.Decimal(bonusAllDevelop.Receivable + static.OrderTotalReceivable())
|
|
|
{
|
|
|
for _, val := range orderAll {
|
|
|
static := val.OrderBonusStatic()
|
|
|
bonusAll.Received = utils.Decimal(bonusAll.Received + static.OrderBonusReceive())
|
|
|
bonusAll.Outstanding = utils.Decimal(bonusAll.Outstanding + static.OrderBonusWait())
|
|
|
bonusAll.Receivable = utils.Decimal(bonusAll.Receivable + static.OrderTotalReceivable())
|
|
|
if val.PartnerCategory == nil {
|
|
|
continue
|
|
|
}
|
|
|
switch val.PartnerCategory.Id {
|
|
|
case int64(domain.Career):
|
|
|
bonusAllCareer.Received = utils.Decimal(bonusAllCareer.Received + static.OrderBonusReceive())
|
|
|
bonusAllCareer.Outstanding = utils.Decimal(bonusAllCareer.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllCareer.Receivable = utils.Decimal(bonusAllCareer.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.Business):
|
|
|
bonusAllBusiness.Received = utils.Decimal(bonusAllBusiness.Received + static.OrderBonusReceive())
|
|
|
bonusAllBusiness.Outstanding = utils.Decimal(bonusAllBusiness.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllBusiness.Receivable = utils.Decimal(bonusAllBusiness.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.App):
|
|
|
bonusAllApp.Received = utils.Decimal(bonusAllApp.Received + static.OrderBonusReceive())
|
|
|
bonusAllApp.Outstanding = utils.Decimal(bonusAllApp.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllApp.Receivable = utils.Decimal(bonusAllApp.Receivable + static.OrderTotalReceivable())
|
|
|
case int64(domain.Develop):
|
|
|
bonusAllDevelop.Received = utils.Decimal(bonusAllDevelop.Received + static.OrderBonusReceive())
|
|
|
bonusAllDevelop.Outstanding = utils.Decimal(bonusAllDevelop.Outstanding + static.OrderBonusWait())
|
|
|
bonusAllDevelop.Receivable = utils.Decimal(bonusAllDevelop.Receivable + static.OrderTotalReceivable())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//0:全部分类,
|
...
|
...
|
@@ -126,6 +129,46 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat |
|
|
bonusQuartersDevelop = [4]protocol.Bonus{}
|
|
|
bonusQuartersApp = [4]protocol.Bonus{}
|
|
|
)
|
|
|
{
|
|
|
var (
|
|
|
quarterNum int // 对应季度在数组中的位置
|
|
|
)
|
|
|
for _, val := range orderBetween {
|
|
|
quarterNum = quarter(val.SaleDate)
|
|
|
static := val.OrderBonusStatic()
|
|
|
bonusQuarters[quarterNum].Receivable = utils.Decimal(bonusQuarters[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuarters[quarterNum].Received = utils.Decimal(bonusQuarters[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuarters[quarterNum].Outstanding = utils.Decimal(bonusQuarters[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
if val.PartnerCategory == nil {
|
|
|
continue
|
|
|
}
|
|
|
// 分类合并计数
|
|
|
switch val.PartnerCategory.Id {
|
|
|
case int64(domain.Career):
|
|
|
bonusQuartersCareer[quarterNum].Receivable = utils.Decimal(bonusQuartersCareer[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersCareer[quarterNum].Received = utils.Decimal(bonusQuartersCareer[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersCareer[quarterNum].Outstanding = utils.Decimal(bonusQuartersCareer[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
case int64(domain.Business):
|
|
|
bonusQuartersBusiness[quarterNum].Receivable = utils.Decimal(bonusQuartersBusiness[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersBusiness[quarterNum].Received = utils.Decimal(bonusQuartersBusiness[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersBusiness[quarterNum].Outstanding = utils.Decimal(bonusQuartersBusiness[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
case int64(domain.App):
|
|
|
bonusQuartersApp[quarterNum].Receivable = utils.Decimal(bonusQuartersApp[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersApp[quarterNum].Received = utils.Decimal(bonusQuartersApp[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersApp[quarterNum].Outstanding = utils.Decimal(bonusQuartersApp[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
case int64(domain.Develop):
|
|
|
bonusQuartersDevelop[quarterNum].Receivable = utils.Decimal(bonusQuartersDevelop[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersDevelop[quarterNum].Received = utils.Decimal(bonusQuartersDevelop[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersDevelop[quarterNum].Outstanding = utils.Decimal(bonusQuartersDevelop[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 处理分月份的
|
|
|
//月度分红
|
|
|
var (
|
|
|
bonusMonths = [12]protocol.Bonus{}
|
...
|
...
|
@@ -134,58 +177,42 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat |
|
|
bonusMonthsDevelop = [12]protocol.Bonus{}
|
|
|
bonusMonthsApp = [12]protocol.Bonus{}
|
|
|
)
|
|
|
var (
|
|
|
quarterNum int // 对应季度在数组中的位置
|
|
|
monthNum int //对应月份在数组中的位置
|
|
|
)
|
|
|
for _, val := range orderBetween {
|
|
|
quarterNum = quarter(val.SaleDate)
|
|
|
monthNum = int(val.SaleDate.Month()) - 1
|
|
|
static := val.OrderBonusStatic()
|
|
|
bonusQuarters[quarterNum].Receivable = utils.Decimal(bonusQuarters[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuarters[quarterNum].Received = utils.Decimal(bonusQuarters[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuarters[quarterNum].Outstanding = utils.Decimal(bonusQuarters[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
bonusMonths[monthNum].Receivable = utils.Decimal(bonusMonths[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonths[monthNum].Received = utils.Decimal(bonusMonths[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonths[monthNum].Outstanding = utils.Decimal(bonusMonths[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
if val.PartnerCategory == nil {
|
|
|
continue
|
|
|
}
|
|
|
// 分类合并计数
|
|
|
switch val.PartnerCategory.Id {
|
|
|
case int64(domain.Career):
|
|
|
bonusQuartersCareer[quarterNum].Receivable = utils.Decimal(bonusQuartersCareer[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersCareer[quarterNum].Received = utils.Decimal(bonusQuartersCareer[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersCareer[quarterNum].Outstanding = utils.Decimal(bonusQuartersCareer[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
bonusMonthsCareer[monthNum].Receivable = utils.Decimal(bonusMonthsCareer[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsCareer[monthNum].Received = utils.Decimal(bonusMonthsCareer[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsCareer[monthNum].Outstanding = utils.Decimal(bonusMonthsCareer[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.Business):
|
|
|
bonusQuartersBusiness[quarterNum].Receivable = utils.Decimal(bonusQuartersBusiness[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersBusiness[quarterNum].Received = utils.Decimal(bonusQuartersBusiness[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersBusiness[quarterNum].Outstanding = utils.Decimal(bonusQuartersBusiness[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
bonusMonthsBusiness[monthNum].Receivable = utils.Decimal(bonusMonthsBusiness[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsBusiness[monthNum].Received = utils.Decimal(bonusMonthsBusiness[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsBusiness[monthNum].Outstanding = utils.Decimal(bonusMonthsBusiness[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.App):
|
|
|
bonusQuartersApp[quarterNum].Receivable = utils.Decimal(bonusQuartersApp[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersApp[quarterNum].Received = utils.Decimal(bonusQuartersApp[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersApp[quarterNum].Outstanding = utils.Decimal(bonusQuartersApp[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
bonusMonthsApp[monthNum].Receivable = utils.Decimal(bonusMonthsApp[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsApp[monthNum].Received = utils.Decimal(bonusMonthsApp[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsApp[monthNum].Outstanding = utils.Decimal(bonusMonthsApp[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.Develop):
|
|
|
bonusQuartersDevelop[quarterNum].Receivable = utils.Decimal(bonusQuartersDevelop[quarterNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusQuartersDevelop[quarterNum].Received = utils.Decimal(bonusQuartersDevelop[quarterNum].Received + static.OrderBonusReceive())
|
|
|
bonusQuartersDevelop[quarterNum].Outstanding = utils.Decimal(bonusQuartersDevelop[quarterNum].Outstanding + static.OrderBonusWait())
|
|
|
|
|
|
bonusMonthsDevelop[monthNum].Receivable = utils.Decimal(bonusMonthsDevelop[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsDevelop[monthNum].Received = utils.Decimal(bonusMonthsDevelop[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsDevelop[monthNum].Outstanding = utils.Decimal(bonusMonthsDevelop[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
{
|
|
|
//按照自然年过滤数据
|
|
|
yearNum := time.Unix(request.StartTime/1000, 0).Local().Year()
|
|
|
var monthNum int //对应月份在数组中的位置
|
|
|
for i, val := range orderAll {
|
|
|
if orderAll[i].SaleDate.Year() != yearNum {
|
|
|
continue
|
|
|
}
|
|
|
monthNum = int(val.SaleDate.Month()) - 1
|
|
|
static := val.OrderBonusStatic()
|
|
|
bonusMonths[monthNum].Receivable = utils.Decimal(bonusMonths[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonths[monthNum].Received = utils.Decimal(bonusMonths[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonths[monthNum].Outstanding = utils.Decimal(bonusMonths[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
if val.PartnerCategory == nil {
|
|
|
continue
|
|
|
}
|
|
|
// 分类合并计数
|
|
|
switch val.PartnerCategory.Id {
|
|
|
case int64(domain.Career):
|
|
|
bonusMonthsCareer[monthNum].Receivable = utils.Decimal(bonusMonthsCareer[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsCareer[monthNum].Received = utils.Decimal(bonusMonthsCareer[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsCareer[monthNum].Outstanding = utils.Decimal(bonusMonthsCareer[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.Business):
|
|
|
bonusMonthsBusiness[monthNum].Receivable = utils.Decimal(bonusMonthsBusiness[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsBusiness[monthNum].Received = utils.Decimal(bonusMonthsBusiness[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsBusiness[monthNum].Outstanding = utils.Decimal(bonusMonthsBusiness[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.App):
|
|
|
bonusMonthsApp[monthNum].Receivable = utils.Decimal(bonusMonthsApp[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsApp[monthNum].Received = utils.Decimal(bonusMonthsApp[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsApp[monthNum].Outstanding = utils.Decimal(bonusMonthsApp[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
case int64(domain.Develop):
|
|
|
bonusMonthsDevelop[monthNum].Receivable = utils.Decimal(bonusMonthsDevelop[monthNum].Receivable + static.OrderTotalReceivable())
|
|
|
bonusMonthsDevelop[monthNum].Received = utils.Decimal(bonusMonthsDevelop[monthNum].Received + static.OrderBonusReceive())
|
|
|
bonusMonthsDevelop[monthNum].Outstanding = utils.Decimal(bonusMonthsDevelop[monthNum].Outstanding + static.OrderBonusWait())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// 整理输出数据
|
...
|
...
|
|