作者 陈志颖

feat:增加个人贡献值收支

@@ -304,7 +304,7 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati @@ -304,7 +304,7 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati
304 } 304 }
305 } 305 }
306 306
307 -// 获取员工财富值分组统计 307 +// 获取公司员工财富值分组统计
308 func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) { 308 func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) {
309 if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil { 309 if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
310 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 310 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -344,7 +344,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees @@ -344,7 +344,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees
344 } 344 }
345 } 345 }
346 346
347 -// 获取员工贡献值分组统计 347 +// 获取公司员工贡献值分组统计
348 func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) { 348 func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) {
349 if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil { 349 if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil {
350 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 350 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -385,44 +385,44 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp @@ -385,44 +385,44 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp
385 } 385 }
386 386
387 // 员工排行榜统计 (弃用) 387 // 员工排行榜统计 (弃用)
388 -func (statisticsService *StatisticsService) EmployeesRankingListStatistics(employeesRankingListStatisticsCommand *command.EmployeesRankingListStatisticsCommand) (interface{}, error) {  
389 - if err := employeesRankingListStatisticsCommand.ValidateCommand(); err != nil {  
390 - return nil, application.ThrowError(application.ARG_ERROR, err.Error())  
391 - }  
392 - transactionContext, err := factory.CreateTransactionContext(nil)  
393 - if err != nil {  
394 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
395 - }  
396 - if err := transactionContext.StartTransaction(); err != nil {  
397 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
398 - }  
399 - defer func() {  
400 - transactionContext.RollbackTransaction()  
401 - }()  
402 -  
403 - var employeeDao *dao.EmployeeDao  
404 - if value, err := factory.CreateEmployeeDao(map[string]interface{}{  
405 - "transactionContext": transactionContext,  
406 - }); err != nil {  
407 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
408 - } else {  
409 - employeeDao = value  
410 - }  
411 -  
412 - if employeesRankingListStatisticsCommand.StartTime.IsZero() && employeesRankingListStatisticsCommand.EndTime.IsZero() {  
413 - employeesRankingListStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())  
414 - employeesRankingListStatisticsCommand.EndTime = time.Now().Local()  
415 - }  
416 -  
417 - if employeesRankingListStatistics, err := employeeDao.CalculateEmployeesRankingList(employeesRankingListStatisticsCommand.CompanyId, employeesRankingListStatisticsCommand.StartTime, employeesRankingListStatisticsCommand.EndTime, employeesRankingListStatisticsCommand.Offset, employeesRankingListStatisticsCommand.Limit); err != nil {  
418 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
419 - } else {  
420 - if err := transactionContext.CommitTransaction(); err != nil {  
421 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
422 - }  
423 - return employeesRankingListStatistics, nil  
424 - }  
425 -} 388 +//func (statisticsService *StatisticsService) EmployeesRankingListStatistics(employeesRankingListStatisticsCommand *command.EmployeesRankingListStatisticsCommand) (interface{}, error) {
  389 +// if err := employeesRankingListStatisticsCommand.ValidateCommand(); err != nil {
  390 +// return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  391 +// }
  392 +// transactionContext, err := factory.CreateTransactionContext(nil)
  393 +// if err != nil {
  394 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  395 +// }
  396 +// if err := transactionContext.StartTransaction(); err != nil {
  397 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  398 +// }
  399 +// defer func() {
  400 +// transactionContext.RollbackTransaction()
  401 +// }()
  402 +//
  403 +// var employeeDao *dao.EmployeeDao
  404 +// if value, err := factory.CreateEmployeeDao(map[string]interface{}{
  405 +// "transactionContext": transactionContext,
  406 +// }); err != nil {
  407 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  408 +// } else {
  409 +// employeeDao = value
  410 +// }
  411 +//
  412 +// if employeesRankingListStatisticsCommand.StartTime.IsZero() && employeesRankingListStatisticsCommand.EndTime.IsZero() {
  413 +// employeesRankingListStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
  414 +// employeesRankingListStatisticsCommand.EndTime = time.Now().Local()
  415 +// }
  416 +//
  417 +// if employeesRankingListStatistics, err := employeeDao.CalculateEmployeesRankingList(employeesRankingListStatisticsCommand.CompanyId, employeesRankingListStatisticsCommand.StartTime, employeesRankingListStatisticsCommand.EndTime, employeesRankingListStatisticsCommand.Offset, employeesRankingListStatisticsCommand.Limit); err != nil {
  418 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  419 +// } else {
  420 +// if err := transactionContext.CommitTransaction(); err != nil {
  421 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  422 +// }
  423 +// return employeesRankingListStatistics, nil
  424 +// }
  425 +//}
426 426
427 // 贡献值、财富值榜单 427 // 贡献值、财富值榜单
428 func (statisticsService *StatisticsService) ContributionsWealthRanking(contributionsWealthRankingQuery *query.ContributionsWealthRankingQuery) (interface{}, error) { 428 func (statisticsService *StatisticsService) ContributionsWealthRanking(contributionsWealthRankingQuery *query.ContributionsWealthRankingQuery) (interface{}, error) {
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 + "time"
  7 +)
  8 +
  9 +type ContributionsTransactionRecordStatisticsCommand struct {
  10 + // 统一用户UID
  11 + Uid int64 `json:"uid" valid:"Required"`
  12 + // 事务时间区间-开始时间
  13 + TransactionStartTime time.Time `json:"transactionStartTime,omitempty"`
  14 + // 事务时间区间-截止时间
  15 + TransactionEndTime time.Time `json:"transactionEndTime,omitempty"`
  16 +}
  17 +
  18 +func (contributionsTransactionRecordStatisticsCommand *ContributionsTransactionRecordStatisticsCommand) ValidateCommand() error {
  19 + valid := validation.Validation{}
  20 + b, err := valid.Valid(contributionsTransactionRecordStatisticsCommand)
  21 + if err != nil {
  22 + return err
  23 + }
  24 + if !b {
  25 + for _, validErr := range valid.Errors {
  26 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  27 + }
  28 + }
  29 + return nil
  30 +}
@@ -1055,12 +1055,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer @@ -1055,12 +1055,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer
1055 } 1055 }
1056 } 1056 }
1057 1057
1058 -// 返回素币兑换现金活动总清单  
1059 -//func (cashPoolService *CashPoolService) ListSystemExchangeCashPerson(listSystemExchangeCashPersonQuery *query.ListSystemExchangeCashPersonQuery) (interface{}, error) {  
1060 -//  
1061 -//}  
1062 -  
1063 -// TODO 返回兑换素币清单列表 1058 +// 返回兑换素币清单列表
1064 func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) { 1059 func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
1065 if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil { 1060 if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil {
1066 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 1061 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -1368,11 +1363,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1368,11 +1363,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1368 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId))) 1363 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
1369 } 1364 }
1370 1365
1371 - // TODO 更新兑换清单,个人已兑换现金计算  
1372 - if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {  
1373 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
1374 - }  
1375 -  
1376 var exchangeCashActivityRepository domain.ExchangeActivityRepository 1366 var exchangeCashActivityRepository domain.ExchangeActivityRepository
1377 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ 1367 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
1378 "transactionContext": transactionContext, 1368 "transactionContext": transactionContext,
@@ -1391,6 +1381,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1391,6 +1381,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1391 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(person.ExchangeCashActivityId))) 1381 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(person.ExchangeCashActivityId)))
1392 } 1382 }
1393 1383
  1384 + // 更新兑换清单,个人已兑换现金计算
  1385 + updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
  1386 +
  1387 + if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
  1388 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  1389 + }
  1390 +
1394 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1391 updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1395 ExchangeCashActivityId: person.ExchangeCashActivityId, 1392 ExchangeCashActivityId: person.ExchangeCashActivityId,
1396 ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney), 1393 ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
@@ -165,6 +165,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney @@ -165,6 +165,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
165 defer func() { 165 defer func() {
166 transactionContext.RollbackTransaction() 166 transactionContext.RollbackTransaction()
167 }() 167 }()
  168 +
168 var employeeDao *dao.EmployeeDao 169 var employeeDao *dao.EmployeeDao
169 if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 170 if value, err := factory.CreateEmployeeDao(map[string]interface{}{
170 "transactionContext": transactionContext, 171 "transactionContext": transactionContext,
@@ -173,6 +174,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney @@ -173,6 +174,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
173 } else { 174 } else {
174 employeeDao = value 175 employeeDao = value
175 } 176 }
  177 +
176 if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(suMoneyTransactionRecordStatisticsCommand.Uid, suMoneyTransactionRecordStatisticsCommand.TransactionStartTime, suMoneyTransactionRecordStatisticsCommand.TransactionEndTime); err != nil { 178 if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(suMoneyTransactionRecordStatisticsCommand.Uid, suMoneyTransactionRecordStatisticsCommand.TransactionStartTime, suMoneyTransactionRecordStatisticsCommand.TransactionEndTime); err != nil {
177 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 179 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
178 } else { 180 } else {
@@ -183,6 +185,42 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney @@ -183,6 +185,42 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
183 } 185 }
184 } 186 }
185 187
  188 +// 贡献值事务记录统计
  189 +func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(contributionsTransactionRecordStatisticsCommand *command.ContributionsTransactionRecordStatisticsCommand) (interface{}, error) {
  190 + if err := contributionsTransactionRecordStatisticsCommand.ValidateCommand(); err != nil {
  191 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  192 + }
  193 + transactionContext, err := factory.CreateTransactionContext(nil)
  194 + if err != nil {
  195 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  196 + }
  197 + if err := transactionContext.StartTransaction(); err != nil {
  198 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  199 + }
  200 + defer func() {
  201 + transactionContext.RollbackTransaction()
  202 + }()
  203 +
  204 + var employeeDao *dao.EmployeeDao
  205 + if value, err := factory.CreateEmployeeDao(map[string]interface{}{
  206 + "transactionContext": transactionContext,
  207 + }); err != nil {
  208 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  209 + } else {
  210 + employeeDao = value
  211 + }
  212 +
  213 + if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(contributionsTransactionRecordStatisticsCommand.Uid, contributionsTransactionRecordStatisticsCommand.TransactionStartTime, contributionsTransactionRecordStatisticsCommand.TransactionEndTime); err != nil {
  214 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  215 + } else {
  216 + if err := transactionContext.CommitTransaction(); err != nil {
  217 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  218 + }
  219 + return calculateResult, nil
  220 + }
  221 +}
  222 +
  223 +
186 func NewSuMoneyService(options map[string]interface{}) *SuMoneyService { 224 func NewSuMoneyService(options map[string]interface{}) *SuMoneyService {
187 newSuMoneyService := &SuMoneyService{} 225 newSuMoneyService := &SuMoneyService{}
188 return newSuMoneyService 226 return newSuMoneyService
@@ -31,6 +31,7 @@ func (dao *EmployeeDao) BatchSetStatus(uids []int64, status int) error { @@ -31,6 +31,7 @@ func (dao *EmployeeDao) BatchSetStatus(uids []int64, status int) error {
31 return err 31 return err
32 } 32 }
33 33
  34 +// 修改用户权限
34 func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string) error { 35 func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string) error {
35 tx := dao.transactionContext.PgTx 36 tx := dao.transactionContext.PgTx
36 if _, err := tx.Query( 37 if _, err := tx.Query(
@@ -48,6 +49,7 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string) @@ -48,6 +49,7 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string)
48 return nil 49 return nil
49 } 50 }
50 51
  52 +//
51 func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error { 53 func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
52 tx := dao.transactionContext.PgTx 54 tx := dao.transactionContext.PgTx
53 _, err := tx.QueryOne( 55 _, err := tx.QueryOne(
@@ -87,7 +89,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string @@ -87,7 +89,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
87 }, nil 89 }, nil
88 } 90 }
89 91
90 -// 计算个人素币情况,昨日收益:做任务验收获得的素币+额外增加-扣除素币-兑换物资-兑换现金 92 +// 计算个人素币收益,昨日收益:做任务验收获得的素币+额外增加-扣除素币-兑换物资-兑换现金
91 func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) { 93 func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) {
92 var incomeSuMoney float64 94 var incomeSuMoney float64
93 var expendSuMoney float64 95 var expendSuMoney float64
@@ -142,7 +144,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ @@ -142,7 +144,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
142 }, nil 144 }, nil
143 } 145 }
144 146
145 -// 系统已兑换素币、未兑换素币 147 +// 计算系统已兑换素币、未兑换素币
146 func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) { 148 func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) {
147 var systemUnExchangeSuMoney float64 149 var systemUnExchangeSuMoney float64
148 var systemExchangedSuMoney float64 150 var systemExchangedSuMoney float64
@@ -203,10 +205,12 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf @@ -203,10 +205,12 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
203 }, nil 205 }, nil
204 } 206 }
205 207
206 -// 个人收入支出素币统计 208 +// 计算个人素币收支
207 func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) { 209 func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
208 - var incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)  
209 - var expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除, 5: 兑换现金) 210 + var (
  211 + incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
  212 + expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除, 5: 兑换现金)
  213 + )
210 tx := dao.transactionContext.PgTx 214 tx := dao.transactionContext.PgTx
211 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 215 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
212 // 收入素币 216 // 收入素币
@@ -235,31 +239,37 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction @@ -235,31 +239,37 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
235 }, nil 239 }, nil
236 } 240 }
237 241
238 -// 员工财富值统计  
239 -func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {  
240 - var ret []struct {  
241 - Uid int  
242 - EmployeeName string  
243 - EmployeeSuMoney float64  
244 - } 242 +// 计算个人贡献值收支
  243 +func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
  244 + var (
  245 + incomeContributions float64 // 增加的贡献值(2:任务奖励,3:增加)
  246 + expendContributions float64 // 扣除的贡献值 (4: 扣除)
  247 + )
245 tx := dao.transactionContext.PgTx 248 tx := dao.transactionContext.PgTx
246 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 249 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
247 - if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").  
248 - ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").  
249 - ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").  
250 - ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").  
251 - Where(`e.company_id = ?`, companyId).  
252 - Where(`e.status = ?`, 1).  
253 - Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的  
254 - Where(`su_money_transaction_record.create_time > ?`, startTime).  
255 - Where(`su_money_transaction_record.create_time < ?`, endTime).  
256 - Group("su_money_transaction_record.employee").  
257 - Order("employee_su_money DESC").  
258 - Select(&ret); err != nil {  
259 - return nil, err 250 + // 增加的贡献值
  251 + if err := tx.Model(suMoneyTransactionRecordModel).
  252 + ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
  253 + Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
  254 + Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
  255 + Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
  256 + Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
  257 + Select(&incomeContributions); err != nil {
  258 + return nil, err
  259 + }
  260 + // 扣除的贡献值
  261 + if err := tx.Model(suMoneyTransactionRecordModel).
  262 + ColumnExpr("sum(su_money_transaction_record.su_money) AS expend_su_money").
  263 + Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
  264 + Where(`su_money_transaction_record.record_type =?`, 4).
  265 + Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
  266 + Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
  267 + Select(&expendContributions); err != nil {
  268 + return nil, err
260 } 269 }
261 return map[string]interface{}{ 270 return map[string]interface{}{
262 - "employeesSuMoney": ret, 271 + "incomeContributions": incomeContributions,
  272 + "expendContributions": expendContributions,
263 }, nil 273 }, nil
264 } 274 }
265 275
@@ -311,7 +321,7 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. @@ -311,7 +321,7 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.
311 // }, nil 321 // }, nil
312 //} 322 //}
313 323
314 -// 贡献值、财富值总榜和年榜 324 +// 贡献值、财富值总榜和年榜
315 func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) { 325 func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
316 var retWealth []struct { 326 var retWealth []struct {
317 Uid int 327 Uid int
@@ -337,10 +347,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -337,10 +347,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
337 EmployeesContributions float64 347 EmployeesContributions float64
338 Ranking int 348 Ranking int
339 } 349 }
340 -  
341 tx := dao.transactionContext.PgTx 350 tx := dao.transactionContext.PgTx
342 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 351 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
343 -  
344 // 财富值榜单 352 // 财富值榜单
345 queryWealth := tx.Model(suMoneyTransactionRecordModel) 353 queryWealth := tx.Model(suMoneyTransactionRecordModel)
346 queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint") 354 queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
@@ -432,24 +440,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -432,24 +440,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
432 } 440 }
433 contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee") 441 contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee")
434 442
435 - //if offset, ok := queryOptions["offset"]; ok {  
436 - // offset := offset.(int)  
437 - // if offset > -1 {  
438 - // queryContributionsDecrease = queryContributionsDecrease.Offset(offset)  
439 - // }  
440 - //} else {  
441 - // queryContributionsDecrease = queryContributionsDecrease.Offset(0)  
442 - //}  
443 - //if limit, ok := queryOptions["limit"]; ok {  
444 - // limit := limit.(int)  
445 - // if limit > -1 {  
446 - // queryContributionsDecrease = queryContributionsDecrease.Limit(limit)  
447 - // }  
448 - //} else {  
449 - // queryContributionsDecrease = queryContributionsDecrease.Limit(20)  
450 - //}  
451 - //contributionsDecrease := queryWealth.Order("employee_contributions_decrease DESC")  
452 -  
453 queryContributions := tx.Model() 443 queryContributions := tx.Model()
454 queryContributions = queryContributions.With("t", contributionsDecrease) 444 queryContributions = queryContributions.With("t", contributionsDecrease)
455 queryContributions = queryContributions.Table("t") 445 queryContributions = queryContributions.Table("t")
@@ -555,51 +545,112 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -555,51 +545,112 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
555 }, nil 545 }, nil
556 } 546 }
557 547
558 -// 排行榜统计,排名(弃用)  
559 -func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time, offset int, limit int) (map[string]interface{}, error) {  
560 - var retWealth []struct {  
561 - Uid int  
562 - EmployeeName string  
563 - EmployeeSuMoney float64  
564 - Ranking int  
565 - }  
566 - var retContributions []struct { // 员工贡献值 548 +// 排行榜统计,排名
  549 +//func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time, offset int, limit int) (map[string]interface{}, error) {
  550 +// var retWealth []struct {
  551 +// Uid int
  552 +// EmployeeName string
  553 +// EmployeeSuMoney float64
  554 +// Ranking int
  555 +// }
  556 +// var retContributions []struct { // 员工贡献值
  557 +// Uid int
  558 +// EmployeeName string
  559 +// EmployeesContributions float64
  560 +// Ranking int
  561 +// }
  562 +// var retContributionDecrease []struct { // 员工减少的贡献值
  563 +// Uid int
  564 +// EmployeeName string
  565 +// EmployeesContributions float64
  566 +// Ranking int
  567 +// }
  568 +// tx := dao.transactionContext.PgTx
  569 +// suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
  570 +// if limit < -1 {
  571 +// limit = 20
  572 +// }
  573 +// if offset < -1 {
  574 +// offset = 0
  575 +// }
  576 +// // 员工财富值
  577 +// if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
  578 +// ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
  579 +// ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
  580 +// ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").
  581 +// Where(`e.company_id = ?`, companyId).
  582 +// Where(`e.status = ?`, 1).
  583 +// Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
  584 +// Where(`su_money_transaction_record.create_time > ?`, startTime).
  585 +// Where(`su_money_transaction_record.create_time < ?`, endTime).
  586 +// Group("su_money_transaction_record.employee").
  587 +// Order("employee_su_money DESC").
  588 +// Limit(limit).
  589 +// Offset(offset).
  590 +// Select(&retWealth); err != nil {
  591 +// return nil, err
  592 +// }
  593 +// // 增加的贡献值
  594 +// if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
  595 +// ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
  596 +// ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
  597 +// ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions").
  598 +// Where(`e.company_id = ?`, companyId).
  599 +// Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
  600 +// Where(`e.status = ?`, 1).
  601 +// Where(`su_money_transaction_record.create_time > ?`, startTime).
  602 +// Where(`su_money_transaction_record.create_time < ?`, endTime).
  603 +// Group("su_money_transaction_record.employee").
  604 +// Order("employees_contributions DESC").
  605 +// Limit(limit).
  606 +// Offset(offset).
  607 +// Select(&retContributions); err != nil {
  608 +// return nil, err
  609 +// }
  610 +// // 减少的贡献值
  611 +// if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
  612 +// ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
  613 +// ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
  614 +// ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions").
  615 +// Where(`e.company_id = ?`, companyId).
  616 +// Where(`su_money_transaction_record.record_type = ?`, 4).
  617 +// Where(`e.status = ?`, 1).
  618 +// Where(`su_money_transaction_record.create_time > ?`, startTime).
  619 +// Where(`su_money_transaction_record.create_time < ?`, endTime).
  620 +// Group("su_money_transaction_record.employee").
  621 +// Order("employees_contributions DESC").
  622 +// Limit(limit).
  623 +// Offset(offset).
  624 +// Select(&retContributionDecrease); err != nil {
  625 +// return nil, err
  626 +// }
  627 +// for i := 0; i < len(retContributions); i++ {
  628 +// for j := 0; j < len(retContributionDecrease); j++ {
  629 +// if retContributions[i].Uid == retContributionDecrease[j].Uid {
  630 +// retContributions[i].EmployeesContributions -= retContributionDecrease[j].EmployeesContributions
  631 +// }
  632 +// }
  633 +// }
  634 +// return map[string]interface{}{
  635 +// "employeesContributions": retContributions,
  636 +// "employeesWealth": retWealth,
  637 +// }, nil
  638 +//}
  639 +
  640 +// 公司员工贡献值分组统计
  641 +func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
  642 + var ret []struct { // 员工贡献值
567 Uid int 643 Uid int
568 EmployeeName string 644 EmployeeName string
569 EmployeesContributions float64 645 EmployeesContributions float64
570 - Ranking int  
571 } 646 }
572 - var retContributionDecrease []struct { // 员工减少的贡献值 647 + var retDecrease []struct { // 员工减少的贡献值
573 Uid int 648 Uid int
574 EmployeeName string 649 EmployeeName string
575 EmployeesContributions float64 650 EmployeesContributions float64
576 - Ranking int  
577 } 651 }
578 tx := dao.transactionContext.PgTx 652 tx := dao.transactionContext.PgTx
579 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 653 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
580 - if limit < -1 {  
581 - limit = 20  
582 - }  
583 - if offset < -1 {  
584 - offset = 0  
585 - }  
586 - // 员工财富值  
587 - if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").  
588 - ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").  
589 - ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").  
590 - ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").  
591 - Where(`e.company_id = ?`, companyId).  
592 - Where(`e.status = ?`, 1).  
593 - Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的  
594 - Where(`su_money_transaction_record.create_time > ?`, startTime).  
595 - Where(`su_money_transaction_record.create_time < ?`, endTime).  
596 - Group("su_money_transaction_record.employee").  
597 - Order("employee_su_money DESC").  
598 - Limit(limit).  
599 - Offset(offset).  
600 - Select(&retWealth); err != nil {  
601 - return nil, err  
602 - }  
603 // 增加的贡献值 654 // 增加的贡献值
604 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 655 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
605 ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid"). 656 ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
@@ -612,9 +663,7 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t @@ -612,9 +663,7 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t
612 Where(`su_money_transaction_record.create_time < ?`, endTime). 663 Where(`su_money_transaction_record.create_time < ?`, endTime).
613 Group("su_money_transaction_record.employee"). 664 Group("su_money_transaction_record.employee").
614 Order("employees_contributions DESC"). 665 Order("employees_contributions DESC").
615 - Limit(limit).  
616 - Offset(offset).  
617 - Select(&retContributions); err != nil { 666 + Select(&ret); err != nil {
618 return nil, err 667 return nil, err
619 } 668 }
620 // 减少的贡献值 669 // 减少的贡献值
@@ -629,77 +678,46 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t @@ -629,77 +678,46 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t
629 Where(`su_money_transaction_record.create_time < ?`, endTime). 678 Where(`su_money_transaction_record.create_time < ?`, endTime).
630 Group("su_money_transaction_record.employee"). 679 Group("su_money_transaction_record.employee").
631 Order("employees_contributions DESC"). 680 Order("employees_contributions DESC").
632 - Limit(limit).  
633 - Offset(offset).  
634 - Select(&retContributionDecrease); err != nil { 681 + Select(&retDecrease); err != nil {
635 return nil, err 682 return nil, err
636 } 683 }
637 - for i := 0; i < len(retContributions); i++ {  
638 - for j := 0; j < len(retContributionDecrease); j++ {  
639 - if retContributions[i].Uid == retContributionDecrease[j].Uid {  
640 - retContributions[i].EmployeesContributions -= retContributionDecrease[j].EmployeesContributions 684 + for i := 0; i < len(ret); i++ {
  685 + for j := 0; j < len(retDecrease); j++ {
  686 + if ret[i].Uid == retDecrease[j].Uid {
  687 + ret[i].EmployeesContributions -= retDecrease[j].EmployeesContributions
641 } 688 }
642 } 689 }
643 } 690 }
644 return map[string]interface{}{ 691 return map[string]interface{}{
645 - "employeesContributions": retContributions,  
646 - "employeesWealth": retWealth, 692 + "employeesContributions": ret,
647 }, nil 693 }, nil
648 } 694 }
649 695
650 -// 员工贡献值统计  
651 -func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {  
652 - var ret []struct { // 员工贡献值  
653 - Uid int  
654 - EmployeeName string  
655 - EmployeesContributions float64  
656 - }  
657 - var retDecrease []struct { // 员工减少的贡献值 696 +// 公司员工财富值分组统计
  697 +func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
  698 + var ret []struct {
658 Uid int 699 Uid int
659 EmployeeName string 700 EmployeeName string
660 - EmployeesContributions float64 701 + EmployeeSuMoney float64
661 } 702 }
662 tx := dao.transactionContext.PgTx 703 tx := dao.transactionContext.PgTx
663 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 704 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
664 - // 增加的贡献值  
665 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 705 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
666 ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid"). 706 ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
667 ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name"). 707 ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
668 - ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions"). 708 + ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").
669 Where(`e.company_id = ?`, companyId). 709 Where(`e.company_id = ?`, companyId).
670 - Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).  
671 Where(`e.status = ?`, 1). 710 Where(`e.status = ?`, 1).
  711 + Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
672 Where(`su_money_transaction_record.create_time > ?`, startTime). 712 Where(`su_money_transaction_record.create_time > ?`, startTime).
673 Where(`su_money_transaction_record.create_time < ?`, endTime). 713 Where(`su_money_transaction_record.create_time < ?`, endTime).
674 Group("su_money_transaction_record.employee"). 714 Group("su_money_transaction_record.employee").
675 - Order("employees_contributions DESC"). 715 + Order("employee_su_money DESC").
676 Select(&ret); err != nil { 716 Select(&ret); err != nil {
677 return nil, err 717 return nil, err
678 } 718 }
679 - // 减少的贡献值  
680 - if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").  
681 - ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").  
682 - ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").  
683 - ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions").  
684 - Where(`e.company_id = ?`, companyId).  
685 - Where(`su_money_transaction_record.record_type = ?`, 4).  
686 - Where(`e.status = ?`, 1).  
687 - Where(`su_money_transaction_record.create_time > ?`, startTime).  
688 - Where(`su_money_transaction_record.create_time < ?`, endTime).  
689 - Group("su_money_transaction_record.employee").  
690 - Order("employees_contributions DESC").  
691 - Select(&retDecrease); err != nil {  
692 - return nil, err  
693 - }  
694 - for i := 0; i < len(ret); i++ {  
695 - for j := 0; j < len(retDecrease); j++ {  
696 - if ret[i].Uid == retDecrease[j].Uid {  
697 - ret[i].EmployeesContributions -= retDecrease[j].EmployeesContributions  
698 - }  
699 - }  
700 - }  
701 return map[string]interface{}{ 719 return map[string]interface{}{
702 - "employeesContributions": ret, 720 + "employeesSuMoney": ret,
703 }, nil 721 }, nil
704 } 722 }
705 723
@@ -15,6 +15,7 @@ type StatisticsController struct { @@ -15,6 +15,7 @@ type StatisticsController struct {
15 beego.Controller 15 beego.Controller
16 } 16 }
17 17
  18 +// 系统任务统计
18 func (controller *StatisticsController) SystemTaskStatistics() { 19 func (controller *StatisticsController) SystemTaskStatistics() {
19 statisticsService := service.NewStatisticsService(nil) 20 statisticsService := service.NewStatisticsService(nil)
20 systemTaskStatisticsCommand := &command.SystemTaskStatisticsCommand{} 21 systemTaskStatisticsCommand := &command.SystemTaskStatisticsCommand{}
@@ -30,6 +31,7 @@ func (controller *StatisticsController) SystemTaskStatistics() { @@ -30,6 +31,7 @@ func (controller *StatisticsController) SystemTaskStatistics() {
30 controller.ServeJSON() 31 controller.ServeJSON()
31 } 32 }
32 33
  34 +// 个人任务统计
33 func (controller *StatisticsController) PersonTaskStatistics() { 35 func (controller *StatisticsController) PersonTaskStatistics() {
34 statisticsService := service.NewStatisticsService(nil) 36 statisticsService := service.NewStatisticsService(nil)
35 personTaskStatisticsCommand := &command.PersonTaskStatisticsCommand{} 37 personTaskStatisticsCommand := &command.PersonTaskStatisticsCommand{}
@@ -45,6 +47,7 @@ func (controller *StatisticsController) PersonTaskStatistics() { @@ -45,6 +47,7 @@ func (controller *StatisticsController) PersonTaskStatistics() {
45 controller.ServeJSON() 47 controller.ServeJSON()
46 } 48 }
47 49
  50 +// 个人素币统计
48 func (controller *StatisticsController) PersonSuMoneyStatistics() { 51 func (controller *StatisticsController) PersonSuMoneyStatistics() {
49 statisticsService := service.NewStatisticsService(nil) 52 statisticsService := service.NewStatisticsService(nil)
50 personSuMoneyStatisticsCommand := &command.PersonSuMoneyStatisticsCommand{} 53 personSuMoneyStatisticsCommand := &command.PersonSuMoneyStatisticsCommand{}
@@ -60,6 +63,7 @@ func (controller *StatisticsController) PersonSuMoneyStatistics() { @@ -60,6 +63,7 @@ func (controller *StatisticsController) PersonSuMoneyStatistics() {
60 controller.ServeJSON() 63 controller.ServeJSON()
61 } 64 }
62 65
  66 +// 个人通知统计
63 func (controller *StatisticsController) PersonNotificationStatistics() { 67 func (controller *StatisticsController) PersonNotificationStatistics() {
64 statisticsService := service.NewStatisticsService(nil) 68 statisticsService := service.NewStatisticsService(nil)
65 personNotificationStatisticsCommand := &command.PersonNotificationStatisticsCommand{} 69 personNotificationStatisticsCommand := &command.PersonNotificationStatisticsCommand{}
@@ -75,6 +79,7 @@ func (controller *StatisticsController) PersonNotificationStatistics() { @@ -75,6 +79,7 @@ func (controller *StatisticsController) PersonNotificationStatistics() {
75 controller.ServeJSON() 79 controller.ServeJSON()
76 } 80 }
77 81
  82 +// 系统素币统计
78 func (controller *StatisticsController) SystemSuMoneyStatistics() { 83 func (controller *StatisticsController) SystemSuMoneyStatistics() {
79 statisticsService := service.NewStatisticsService(nil) 84 statisticsService := service.NewStatisticsService(nil)
80 systemSuMoneyStatisticsCommand := &command.SystemSuMoneyStatisticsCommand{} 85 systemSuMoneyStatisticsCommand := &command.SystemSuMoneyStatisticsCommand{}
@@ -90,6 +95,7 @@ func (controller *StatisticsController) SystemSuMoneyStatistics() { @@ -90,6 +95,7 @@ func (controller *StatisticsController) SystemSuMoneyStatistics() {
90 controller.ServeJSON() 95 controller.ServeJSON()
91 } 96 }
92 97
  98 +// 系统现金统计
93 func (controller *StatisticsController) SystemCashStatistics() { 99 func (controller *StatisticsController) SystemCashStatistics() {
94 statisticsService := service.NewStatisticsService(nil) 100 statisticsService := service.NewStatisticsService(nil)
95 systemCashStatisticsCommand := &command.SystemCashStatisticsCommand{} 101 systemCashStatisticsCommand := &command.SystemCashStatisticsCommand{}
@@ -105,7 +111,7 @@ func (controller *StatisticsController) SystemCashStatistics() { @@ -105,7 +111,7 @@ func (controller *StatisticsController) SystemCashStatistics() {
105 controller.ServeJSON() 111 controller.ServeJSON()
106 } 112 }
107 113
108 -// 获取员工财富值 114 +// 获取公司员工财富值
109 func (controller *StatisticsController) EmployeesSuMoneyStatistics() { 115 func (controller *StatisticsController) EmployeesSuMoneyStatistics() {
110 statisticsService := service.NewStatisticsService(nil) 116 statisticsService := service.NewStatisticsService(nil)
111 employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{} 117 employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{}
@@ -122,7 +128,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() { @@ -122,7 +128,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() {
122 controller.ServeJSON() 128 controller.ServeJSON()
123 } 129 }
124 130
125 -// 获取员工贡献值 131 +// 获取公司员工贡献值
126 func (controller *StatisticsController) EmployeesContributionsStatistics() { 132 func (controller *StatisticsController) EmployeesContributionsStatistics() {
127 statisticsService := service.NewStatisticsService(nil) 133 statisticsService := service.NewStatisticsService(nil)
128 employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{} 134 employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{}
@@ -138,7 +144,7 @@ func (controller *StatisticsController) EmployeesContributionsStatistics() { @@ -138,7 +144,7 @@ func (controller *StatisticsController) EmployeesContributionsStatistics() {
138 controller.ServeJSON() 144 controller.ServeJSON()
139 } 145 }
140 146
141 -// 员工财富值、贡献值排行榜 147 +// 公司员工财富值、贡献值排行榜
142 func (controller *StatisticsController) RankingListStatistics() { 148 func (controller *StatisticsController) RankingListStatistics() {
143 statisticsService := service.NewStatisticsService(nil) 149 statisticsService := service.NewStatisticsService(nil)
144 contributionsWealthRankingQuery := &query.ContributionsWealthRankingQuery{} 150 contributionsWealthRankingQuery := &query.ContributionsWealthRankingQuery{}
@@ -85,6 +85,7 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() { @@ -85,6 +85,7 @@ func (controller *SuMoneyController) SearchSuMoneyTransactionRecord() {
85 controller.ServeJSON() 85 controller.ServeJSON()
86 } 86 }
87 87
  88 +// 素币事务统计(个人素币收支)
88 func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() { 89 func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() {
89 suMoneyService := service.NewSuMoneyService(nil) 90 suMoneyService := service.NewSuMoneyService(nil)
90 suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{} 91 suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{}
@@ -100,6 +101,22 @@ func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() { @@ -100,6 +101,22 @@ func (controller *SuMoneyController) SuMoneyTransactionRecordStatistics() {
100 controller.ServeJSON() 101 controller.ServeJSON()
101 } 102 }
102 103
  104 +// 贡献值事务统计(个人贡献值收支)
  105 +func (controller *SuMoneyController) ContributionsTransactionRecordStatistics() {
  106 + suMoneyService := service.NewSuMoneyService(nil)
  107 + contributionsTransactionRecordStatisticsCommand := &command.ContributionsTransactionRecordStatisticsCommand{}
  108 + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), contributionsTransactionRecordStatisticsCommand)
  109 + data, err := suMoneyService.ContributionsTransactionRecordStatistics(contributionsTransactionRecordStatisticsCommand)
  110 + var response utils.JsonResponse
  111 + if err != nil {
  112 + response = utils.ResponseError(controller.Ctx, err)
  113 + } else {
  114 + response = utils.ResponseData(controller.Ctx, data)
  115 + }
  116 + controller.Data["json"] = response
  117 + controller.ServeJSON()
  118 +}
  119 +
103 // 投入现金池 120 // 投入现金池
104 func (controller *SuMoneyController) CashInput() { 121 func (controller *SuMoneyController) CashInput() {
105 cashPoolService := service.NewCashPoolService(nil) 122 cashPoolService := service.NewCashPoolService(nil)
@@ -6,10 +6,10 @@ import ( @@ -6,10 +6,10 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
9 - beego.Router("/statistics/system-task", &controllers.StatisticsController{}, "Post:SystemTaskStatistics")  
10 - beego.Router("/statistics/person-task", &controllers.StatisticsController{}, "Post:PersonTaskStatistics")  
11 - beego.Router("/statistics/person-su-money", &controllers.StatisticsController{}, "Post:PersonSuMoneyStatistics")  
12 - beego.Router("/statistics/person-notification", &controllers.StatisticsController{}, "Post:PersonNotificationStatistics") 9 + beego.Router("/statistics/system-task", &controllers.StatisticsController{}, "Post:SystemTaskStatistics") // 系统任务统计
  10 + beego.Router("/statistics/person-task", &controllers.StatisticsController{}, "Post:PersonTaskStatistics") // 个人任务统计
  11 + beego.Router("/statistics/person-su-money", &controllers.StatisticsController{}, "Post:PersonSuMoneyStatistics") // 个人素币统计
  12 + beego.Router("/statistics/person-notification", &controllers.StatisticsController{}, "Post:PersonNotificationStatistics") // 个人通知统计
13 beego.Router("/statistics/system-su-money", &controllers.StatisticsController{}, "Post:SystemSuMoneyStatistics") // 系统素币统计 13 beego.Router("/statistics/system-su-money", &controllers.StatisticsController{}, "Post:SystemSuMoneyStatistics") // 系统素币统计
14 beego.Router("/statistics/system-cash", &controllers.StatisticsController{}, "Post:SystemCashStatistics") // 系统现金统计 14 beego.Router("/statistics/system-cash", &controllers.StatisticsController{}, "Post:SystemCashStatistics") // 系统现金统计
15 beego.Router("/statistics/employees-su-money", &controllers.StatisticsController{}, "Post:EmployeesSuMoneyStatistics") // 员工财富值统计 15 beego.Router("/statistics/employees-su-money", &controllers.StatisticsController{}, "Post:EmployeesSuMoneyStatistics") // 员工财富值统计
@@ -11,7 +11,8 @@ func init() { @@ -11,7 +11,8 @@ func init() {
11 beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") // 返回素币事务记录 11 beego.Router("/su-money/su-money-transaction-records/:suMoneyTransactionRecordId", &controllers.SuMoneyController{}, "Get:GetSuMoneyTransactionRecord") // 返回素币事务记录
12 beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") // 兑换素币 12 beego.Router("/su-money/exchange", &controllers.SuMoneyController{}, "Post:ExchangeSuMoney") // 兑换素币
13 beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") // 搜索素币事务记录 13 beego.Router("/su-money/search-su-money-transaction-record", &controllers.SuMoneyController{}, "Post:SearchSuMoneyTransactionRecord") // 搜索素币事务记录
14 - beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") // 返回素币事务记录统计 14 + beego.Router("/su-money/su-money-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:SuMoneyTransactionRecordStatistics") // 返回素币事务记录统计(个人素币收支)
  15 + beego.Router("/su-money/contributions-transaction-record-statistics", &controllers.SuMoneyController{}, "Post:ContributionsTransactionRecordStatistics") // 返回贡献值事务记录统计(个人贡献值收支)
15 beego.Router("/su-money/su-money-transaction-records/export-records", &controllers.SuMoneyController{}, "Post:ExportSuMoneyTransactionRecord") // 导出素币事务记录(流水) 16 beego.Router("/su-money/su-money-transaction-records/export-records", &controllers.SuMoneyController{}, "Post:ExportSuMoneyTransactionRecord") // 导出素币事务记录(流水)
16 beego.Router("/su-money/su-money-transaction-records/export-su-money", &controllers.SuMoneyController{}, "Post:ExportSuMoney") // 导出员工素币 17 beego.Router("/su-money/su-money-transaction-records/export-su-money", &controllers.SuMoneyController{}, "Post:ExportSuMoney") // 导出员工素币
17 18