作者 陈志颖

fix:兑换素币清单榜单总榜活动榜判断

@@ -2925,6 +2925,16 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ @@ -2925,6 +2925,16 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ
2925 employeeRepository = value 2925 employeeRepository = value
2926 } 2926 }
2927 2927
  2928 + // 兑换现金活动仓储初始化
  2929 + var exchangeCashActivityRepository domain.ExchangeActivityRepository
  2930 + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
  2931 + "transactionContext": transactionContext,
  2932 + }); err != nil {
  2933 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  2934 + } else {
  2935 + exchangeCashActivityRepository = value
  2936 + }
  2937 +
2928 // 现金池DAO初始化 2938 // 现金池DAO初始化
2929 var cashPoolDao *dao.CashPoolDao 2939 var cashPoolDao *dao.CashPoolDao
2930 if value, err := factory.CreateCashPoolDao(map[string]interface{}{ 2940 if value, err := factory.CreateCashPoolDao(map[string]interface{}{
@@ -2940,13 +2950,36 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ @@ -2940,13 +2950,36 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ
2940 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2950 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
2941 } else { 2951 } else {
2942 uidName := map[int64]interface{}{} 2952 uidName := map[int64]interface{}{}
2943 - if _, employees, err := employeeRepository.FindAll(map[string]interface{}{  
2944 - "companyId": exchangeListRankingQuery.CompanyId,  
2945 - }); err != nil {  
2946 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
2947 - } else {  
2948 - for _, employee := range employees {  
2949 - uidName[employee.EmployeeInfo.Uid] = employee.EmployeeInfo.EmployeeName 2953 + if exchangeListRankingQuery.CompanyId != 0 {
  2954 + // 根据company_id获取员工uid、姓名键值对
  2955 + if _, employees, err := employeeRepository.FindAll(map[string]interface{}{
  2956 + "companyId": exchangeListRankingQuery.CompanyId,
  2957 + }); err != nil {
  2958 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  2959 + } else {
  2960 + for _, employee := range employees {
  2961 + uidName[employee.EmployeeInfo.Uid] = employee.EmployeeInfo.EmployeeName
  2962 + }
  2963 + }
  2964 + } else if exchangeListRankingQuery.ActivityId != 0 {
  2965 + // 获取当前活动的company_id
  2966 + activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": exchangeListRankingQuery.ActivityId})
  2967 + if err != nil {
  2968 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  2969 + }
  2970 + if activityFound == nil {
  2971 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(exchangeListRankingQuery.ActivityId)))
  2972 + }
  2973 +
  2974 + // 根据company_id获取员工uid、姓名键值对
  2975 + if _, employees, err := employeeRepository.FindAll(map[string]interface{}{
  2976 + "companyId": activityFound.CompanyId,
  2977 + }); err != nil {
  2978 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  2979 + } else {
  2980 + for _, employee := range employees {
  2981 + uidName[employee.EmployeeInfo.Uid] = employee.EmployeeInfo.EmployeeName
  2982 + }
2950 } 2983 }
2951 } 2984 }
2952 2985