正在显示
1 个修改的文件
包含
103 行增加
和
76 行删除
| @@ -73,6 +73,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | @@ -73,6 +73,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | ||
| 73 | orderBetween = append(orderBetween, orderAll[i]) | 73 | orderBetween = append(orderBetween, orderAll[i]) |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
| 76 | + | ||
| 76 | //0:全部分类, | 77 | //0:全部分类, |
| 77 | //Career int = 1 //事业 | 78 | //Career int = 1 //事业 |
| 78 | //Business int = 2 //业务 | 79 | //Business int = 2 //业务 |
| @@ -86,31 +87,33 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | @@ -86,31 +87,33 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | ||
| 86 | bonusAllDevelop protocol.Bonus | 87 | bonusAllDevelop protocol.Bonus |
| 87 | bonusAllApp protocol.Bonus | 88 | bonusAllApp protocol.Bonus |
| 88 | ) | 89 | ) |
| 89 | - for _, val := range orderAll { | ||
| 90 | - static := val.OrderBonusStatic() | ||
| 91 | - bonusAll.Received = utils.Decimal(bonusAll.Received + static.OrderBonusReceive()) | ||
| 92 | - bonusAll.Outstanding = utils.Decimal(bonusAll.Outstanding + static.OrderBonusWait()) | ||
| 93 | - bonusAll.Receivable = utils.Decimal(bonusAll.Receivable + static.OrderTotalReceivable()) | ||
| 94 | - if val.PartnerCategory == nil { | ||
| 95 | - continue | ||
| 96 | - } | ||
| 97 | - switch val.PartnerCategory.Id { | ||
| 98 | - case int64(domain.Career): | ||
| 99 | - bonusAllCareer.Received = utils.Decimal(bonusAllCareer.Received + static.OrderBonusReceive()) | ||
| 100 | - bonusAllCareer.Outstanding = utils.Decimal(bonusAllCareer.Outstanding + static.OrderBonusWait()) | ||
| 101 | - bonusAllCareer.Receivable = utils.Decimal(bonusAllCareer.Receivable + static.OrderTotalReceivable()) | ||
| 102 | - case int64(domain.Business): | ||
| 103 | - bonusAllBusiness.Received = utils.Decimal(bonusAllBusiness.Received + static.OrderBonusReceive()) | ||
| 104 | - bonusAllBusiness.Outstanding = utils.Decimal(bonusAllBusiness.Outstanding + static.OrderBonusWait()) | ||
| 105 | - bonusAllBusiness.Receivable = utils.Decimal(bonusAllBusiness.Receivable + static.OrderTotalReceivable()) | ||
| 106 | - case int64(domain.App): | ||
| 107 | - bonusAllApp.Received = utils.Decimal(bonusAllApp.Received + static.OrderBonusReceive()) | ||
| 108 | - bonusAllApp.Outstanding = utils.Decimal(bonusAllApp.Outstanding + static.OrderBonusWait()) | ||
| 109 | - bonusAllApp.Receivable = utils.Decimal(bonusAllApp.Receivable + static.OrderTotalReceivable()) | ||
| 110 | - case int64(domain.Develop): | ||
| 111 | - bonusAllDevelop.Received = utils.Decimal(bonusAllDevelop.Received + static.OrderBonusReceive()) | ||
| 112 | - bonusAllDevelop.Outstanding = utils.Decimal(bonusAllDevelop.Outstanding + static.OrderBonusWait()) | ||
| 113 | - bonusAllDevelop.Receivable = utils.Decimal(bonusAllDevelop.Receivable + static.OrderTotalReceivable()) | 90 | + { |
| 91 | + for _, val := range orderAll { | ||
| 92 | + static := val.OrderBonusStatic() | ||
| 93 | + bonusAll.Received = utils.Decimal(bonusAll.Received + static.OrderBonusReceive()) | ||
| 94 | + bonusAll.Outstanding = utils.Decimal(bonusAll.Outstanding + static.OrderBonusWait()) | ||
| 95 | + bonusAll.Receivable = utils.Decimal(bonusAll.Receivable + static.OrderTotalReceivable()) | ||
| 96 | + if val.PartnerCategory == nil { | ||
| 97 | + continue | ||
| 98 | + } | ||
| 99 | + switch val.PartnerCategory.Id { | ||
| 100 | + case int64(domain.Career): | ||
| 101 | + bonusAllCareer.Received = utils.Decimal(bonusAllCareer.Received + static.OrderBonusReceive()) | ||
| 102 | + bonusAllCareer.Outstanding = utils.Decimal(bonusAllCareer.Outstanding + static.OrderBonusWait()) | ||
| 103 | + bonusAllCareer.Receivable = utils.Decimal(bonusAllCareer.Receivable + static.OrderTotalReceivable()) | ||
| 104 | + case int64(domain.Business): | ||
| 105 | + bonusAllBusiness.Received = utils.Decimal(bonusAllBusiness.Received + static.OrderBonusReceive()) | ||
| 106 | + bonusAllBusiness.Outstanding = utils.Decimal(bonusAllBusiness.Outstanding + static.OrderBonusWait()) | ||
| 107 | + bonusAllBusiness.Receivable = utils.Decimal(bonusAllBusiness.Receivable + static.OrderTotalReceivable()) | ||
| 108 | + case int64(domain.App): | ||
| 109 | + bonusAllApp.Received = utils.Decimal(bonusAllApp.Received + static.OrderBonusReceive()) | ||
| 110 | + bonusAllApp.Outstanding = utils.Decimal(bonusAllApp.Outstanding + static.OrderBonusWait()) | ||
| 111 | + bonusAllApp.Receivable = utils.Decimal(bonusAllApp.Receivable + static.OrderTotalReceivable()) | ||
| 112 | + case int64(domain.Develop): | ||
| 113 | + bonusAllDevelop.Received = utils.Decimal(bonusAllDevelop.Received + static.OrderBonusReceive()) | ||
| 114 | + bonusAllDevelop.Outstanding = utils.Decimal(bonusAllDevelop.Outstanding + static.OrderBonusWait()) | ||
| 115 | + bonusAllDevelop.Receivable = utils.Decimal(bonusAllDevelop.Receivable + static.OrderTotalReceivable()) | ||
| 116 | + } | ||
| 114 | } | 117 | } |
| 115 | } | 118 | } |
| 116 | //0:全部分类, | 119 | //0:全部分类, |
| @@ -126,6 +129,46 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | @@ -126,6 +129,46 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | ||
| 126 | bonusQuartersDevelop = [4]protocol.Bonus{} | 129 | bonusQuartersDevelop = [4]protocol.Bonus{} |
| 127 | bonusQuartersApp = [4]protocol.Bonus{} | 130 | bonusQuartersApp = [4]protocol.Bonus{} |
| 128 | ) | 131 | ) |
| 132 | + { | ||
| 133 | + var ( | ||
| 134 | + quarterNum int // 对应季度在数组中的位置 | ||
| 135 | + ) | ||
| 136 | + for _, val := range orderBetween { | ||
| 137 | + quarterNum = quarter(val.SaleDate) | ||
| 138 | + static := val.OrderBonusStatic() | ||
| 139 | + bonusQuarters[quarterNum].Receivable = utils.Decimal(bonusQuarters[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 140 | + bonusQuarters[quarterNum].Received = utils.Decimal(bonusQuarters[quarterNum].Received + static.OrderBonusReceive()) | ||
| 141 | + bonusQuarters[quarterNum].Outstanding = utils.Decimal(bonusQuarters[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 142 | + if val.PartnerCategory == nil { | ||
| 143 | + continue | ||
| 144 | + } | ||
| 145 | + // 分类合并计数 | ||
| 146 | + switch val.PartnerCategory.Id { | ||
| 147 | + case int64(domain.Career): | ||
| 148 | + bonusQuartersCareer[quarterNum].Receivable = utils.Decimal(bonusQuartersCareer[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 149 | + bonusQuartersCareer[quarterNum].Received = utils.Decimal(bonusQuartersCareer[quarterNum].Received + static.OrderBonusReceive()) | ||
| 150 | + bonusQuartersCareer[quarterNum].Outstanding = utils.Decimal(bonusQuartersCareer[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 151 | + | ||
| 152 | + case int64(domain.Business): | ||
| 153 | + bonusQuartersBusiness[quarterNum].Receivable = utils.Decimal(bonusQuartersBusiness[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 154 | + bonusQuartersBusiness[quarterNum].Received = utils.Decimal(bonusQuartersBusiness[quarterNum].Received + static.OrderBonusReceive()) | ||
| 155 | + bonusQuartersBusiness[quarterNum].Outstanding = utils.Decimal(bonusQuartersBusiness[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 156 | + | ||
| 157 | + case int64(domain.App): | ||
| 158 | + bonusQuartersApp[quarterNum].Receivable = utils.Decimal(bonusQuartersApp[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 159 | + bonusQuartersApp[quarterNum].Received = utils.Decimal(bonusQuartersApp[quarterNum].Received + static.OrderBonusReceive()) | ||
| 160 | + bonusQuartersApp[quarterNum].Outstanding = utils.Decimal(bonusQuartersApp[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 161 | + | ||
| 162 | + case int64(domain.Develop): | ||
| 163 | + bonusQuartersDevelop[quarterNum].Receivable = utils.Decimal(bonusQuartersDevelop[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 164 | + bonusQuartersDevelop[quarterNum].Received = utils.Decimal(bonusQuartersDevelop[quarterNum].Received + static.OrderBonusReceive()) | ||
| 165 | + bonusQuartersDevelop[quarterNum].Outstanding = utils.Decimal(bonusQuartersDevelop[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 166 | + | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + // 处理分月份的 | ||
| 129 | //月度分红 | 172 | //月度分红 |
| 130 | var ( | 173 | var ( |
| 131 | bonusMonths = [12]protocol.Bonus{} | 174 | bonusMonths = [12]protocol.Bonus{} |
| @@ -134,58 +177,42 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | @@ -134,58 +177,42 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStat | ||
| 134 | bonusMonthsDevelop = [12]protocol.Bonus{} | 177 | bonusMonthsDevelop = [12]protocol.Bonus{} |
| 135 | bonusMonthsApp = [12]protocol.Bonus{} | 178 | bonusMonthsApp = [12]protocol.Bonus{} |
| 136 | ) | 179 | ) |
| 137 | - var ( | ||
| 138 | - quarterNum int // 对应季度在数组中的位置 | ||
| 139 | - monthNum int //对应月份在数组中的位置 | ||
| 140 | - ) | ||
| 141 | - for _, val := range orderBetween { | ||
| 142 | - quarterNum = quarter(val.SaleDate) | ||
| 143 | - monthNum = int(val.SaleDate.Month()) - 1 | ||
| 144 | - static := val.OrderBonusStatic() | ||
| 145 | - bonusQuarters[quarterNum].Receivable = utils.Decimal(bonusQuarters[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 146 | - bonusQuarters[quarterNum].Received = utils.Decimal(bonusQuarters[quarterNum].Received + static.OrderBonusReceive()) | ||
| 147 | - bonusQuarters[quarterNum].Outstanding = utils.Decimal(bonusQuarters[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 148 | - | ||
| 149 | - bonusMonths[monthNum].Receivable = utils.Decimal(bonusMonths[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 150 | - bonusMonths[monthNum].Received = utils.Decimal(bonusMonths[monthNum].Received + static.OrderBonusReceive()) | ||
| 151 | - bonusMonths[monthNum].Outstanding = utils.Decimal(bonusMonths[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 152 | - if val.PartnerCategory == nil { | ||
| 153 | - continue | ||
| 154 | - } | ||
| 155 | - // 分类合并计数 | ||
| 156 | - switch val.PartnerCategory.Id { | ||
| 157 | - case int64(domain.Career): | ||
| 158 | - bonusQuartersCareer[quarterNum].Receivable = utils.Decimal(bonusQuartersCareer[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 159 | - bonusQuartersCareer[quarterNum].Received = utils.Decimal(bonusQuartersCareer[quarterNum].Received + static.OrderBonusReceive()) | ||
| 160 | - bonusQuartersCareer[quarterNum].Outstanding = utils.Decimal(bonusQuartersCareer[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 161 | - | ||
| 162 | - bonusMonthsCareer[monthNum].Receivable = utils.Decimal(bonusMonthsCareer[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 163 | - bonusMonthsCareer[monthNum].Received = utils.Decimal(bonusMonthsCareer[monthNum].Received + static.OrderBonusReceive()) | ||
| 164 | - bonusMonthsCareer[monthNum].Outstanding = utils.Decimal(bonusMonthsCareer[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 165 | - case int64(domain.Business): | ||
| 166 | - bonusQuartersBusiness[quarterNum].Receivable = utils.Decimal(bonusQuartersBusiness[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 167 | - bonusQuartersBusiness[quarterNum].Received = utils.Decimal(bonusQuartersBusiness[quarterNum].Received + static.OrderBonusReceive()) | ||
| 168 | - bonusQuartersBusiness[quarterNum].Outstanding = utils.Decimal(bonusQuartersBusiness[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 169 | - | ||
| 170 | - bonusMonthsBusiness[monthNum].Receivable = utils.Decimal(bonusMonthsBusiness[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 171 | - bonusMonthsBusiness[monthNum].Received = utils.Decimal(bonusMonthsBusiness[monthNum].Received + static.OrderBonusReceive()) | ||
| 172 | - bonusMonthsBusiness[monthNum].Outstanding = utils.Decimal(bonusMonthsBusiness[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 173 | - case int64(domain.App): | ||
| 174 | - bonusQuartersApp[quarterNum].Receivable = utils.Decimal(bonusQuartersApp[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 175 | - bonusQuartersApp[quarterNum].Received = utils.Decimal(bonusQuartersApp[quarterNum].Received + static.OrderBonusReceive()) | ||
| 176 | - bonusQuartersApp[quarterNum].Outstanding = utils.Decimal(bonusQuartersApp[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 177 | - | ||
| 178 | - bonusMonthsApp[monthNum].Receivable = utils.Decimal(bonusMonthsApp[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 179 | - bonusMonthsApp[monthNum].Received = utils.Decimal(bonusMonthsApp[monthNum].Received + static.OrderBonusReceive()) | ||
| 180 | - bonusMonthsApp[monthNum].Outstanding = utils.Decimal(bonusMonthsApp[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 181 | - case int64(domain.Develop): | ||
| 182 | - bonusQuartersDevelop[quarterNum].Receivable = utils.Decimal(bonusQuartersDevelop[quarterNum].Receivable + static.OrderTotalReceivable()) | ||
| 183 | - bonusQuartersDevelop[quarterNum].Received = utils.Decimal(bonusQuartersDevelop[quarterNum].Received + static.OrderBonusReceive()) | ||
| 184 | - bonusQuartersDevelop[quarterNum].Outstanding = utils.Decimal(bonusQuartersDevelop[quarterNum].Outstanding + static.OrderBonusWait()) | ||
| 185 | 180 | ||
| 186 | - bonusMonthsDevelop[monthNum].Receivable = utils.Decimal(bonusMonthsDevelop[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 187 | - bonusMonthsDevelop[monthNum].Received = utils.Decimal(bonusMonthsDevelop[monthNum].Received + static.OrderBonusReceive()) | ||
| 188 | - bonusMonthsDevelop[monthNum].Outstanding = utils.Decimal(bonusMonthsDevelop[monthNum].Outstanding + static.OrderBonusWait()) | 181 | + { |
| 182 | + //按照自然年过滤数据 | ||
| 183 | + yearNum := time.Unix(request.StartTime/1000, 0).Local().Year() | ||
| 184 | + var monthNum int //对应月份在数组中的位置 | ||
| 185 | + for i, val := range orderAll { | ||
| 186 | + if orderAll[i].SaleDate.Year() != yearNum { | ||
| 187 | + continue | ||
| 188 | + } | ||
| 189 | + monthNum = int(val.SaleDate.Month()) - 1 | ||
| 190 | + static := val.OrderBonusStatic() | ||
| 191 | + bonusMonths[monthNum].Receivable = utils.Decimal(bonusMonths[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 192 | + bonusMonths[monthNum].Received = utils.Decimal(bonusMonths[monthNum].Received + static.OrderBonusReceive()) | ||
| 193 | + bonusMonths[monthNum].Outstanding = utils.Decimal(bonusMonths[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 194 | + if val.PartnerCategory == nil { | ||
| 195 | + continue | ||
| 196 | + } | ||
| 197 | + // 分类合并计数 | ||
| 198 | + switch val.PartnerCategory.Id { | ||
| 199 | + case int64(domain.Career): | ||
| 200 | + bonusMonthsCareer[monthNum].Receivable = utils.Decimal(bonusMonthsCareer[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 201 | + bonusMonthsCareer[monthNum].Received = utils.Decimal(bonusMonthsCareer[monthNum].Received + static.OrderBonusReceive()) | ||
| 202 | + bonusMonthsCareer[monthNum].Outstanding = utils.Decimal(bonusMonthsCareer[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 203 | + case int64(domain.Business): | ||
| 204 | + bonusMonthsBusiness[monthNum].Receivable = utils.Decimal(bonusMonthsBusiness[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 205 | + bonusMonthsBusiness[monthNum].Received = utils.Decimal(bonusMonthsBusiness[monthNum].Received + static.OrderBonusReceive()) | ||
| 206 | + bonusMonthsBusiness[monthNum].Outstanding = utils.Decimal(bonusMonthsBusiness[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 207 | + case int64(domain.App): | ||
| 208 | + bonusMonthsApp[monthNum].Receivable = utils.Decimal(bonusMonthsApp[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 209 | + bonusMonthsApp[monthNum].Received = utils.Decimal(bonusMonthsApp[monthNum].Received + static.OrderBonusReceive()) | ||
| 210 | + bonusMonthsApp[monthNum].Outstanding = utils.Decimal(bonusMonthsApp[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 211 | + case int64(domain.Develop): | ||
| 212 | + bonusMonthsDevelop[monthNum].Receivable = utils.Decimal(bonusMonthsDevelop[monthNum].Receivable + static.OrderTotalReceivable()) | ||
| 213 | + bonusMonthsDevelop[monthNum].Received = utils.Decimal(bonusMonthsDevelop[monthNum].Received + static.OrderBonusReceive()) | ||
| 214 | + bonusMonthsDevelop[monthNum].Outstanding = utils.Decimal(bonusMonthsDevelop[monthNum].Outstanding + static.OrderBonusWait()) | ||
| 215 | + } | ||
| 189 | } | 216 | } |
| 190 | } | 217 | } |
| 191 | // 整理输出数据 | 218 | // 整理输出数据 |
-
请 注册 或 登录 后发表评论