正在显示
5 个修改的文件
包含
80 行增加
和
72 行删除
@@ -1358,45 +1358,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -1358,45 +1358,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
1358 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值") | 1358 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值") |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | - //// 判断当前员工是否已经在素币兑换清单中,区分excel导入新增和页面添加新增 | ||
1362 | - //if !createFlag { // 页面新增 | ||
1363 | - // count, _, err := exchangeCashPersonListRepository.Find(map[string]interface{}{ | ||
1364 | - // "uid": employeeFound.EmployeeInfo.Uid, | ||
1365 | - // "exchangeCashActivityId": activityFound.ActivityId, | ||
1366 | - // }) | ||
1367 | - // if err != nil { | ||
1368 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1369 | - // } | ||
1370 | - // if count > 0 { // 已存在兑换素币清单 | ||
1371 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前员工已经在素币兑换清单中") | ||
1372 | - // } | ||
1373 | - // if count == 0 { // 未存在,新增兑换素币清单 | ||
1374 | - // | ||
1375 | - // } | ||
1376 | - //} else { // 导入新增 | ||
1377 | - // count, peopleFound, err := exchangeCashPersonListRepository.Find(map[string]interface{}{ | ||
1378 | - // "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount, | ||
1379 | - // "exchangeCashActivityId": activityFound.ActivityId, | ||
1380 | - // "offset": 0, | ||
1381 | - // "limit": 1, | ||
1382 | - // }) | ||
1383 | - // if err != nil { | ||
1384 | - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1385 | - // } | ||
1386 | - // if count > 0 { // 追加素币兑换或撤回素币兑换 | ||
1387 | - // if createExchangeCashPersonCommand.ExchangedSuMoney < peopleFound[0].ExchangedSuMoney { // 当前兑换的素币小于已兑换素币,撤回兑换素币 | ||
1388 | - // suMoneyDecrement := peopleFound[0].ExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney // 减量 | ||
1389 | - // | ||
1390 | - // } else if createExchangeCashPersonCommand.ExchangedSuMoney > peopleFound[0].ExchangedSuMoney { // 当前兑换素币大于已兑换素币,追加兑换素币 | ||
1391 | - // suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - peopleFound[0].ExchangedSuMoney // 增量 | ||
1392 | - // | ||
1393 | - // } | ||
1394 | - // } | ||
1395 | - // if count == 0 { // 新增 | ||
1396 | - // | ||
1397 | - // } | ||
1398 | - //} | ||
1399 | - | ||
1400 | // 新增兑换清单命令 | 1361 | // 新增兑换清单命令 |
1401 | newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64) | 1362 | newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64) |
1402 | 1363 |
@@ -153,39 +153,41 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | @@ -153,39 +153,41 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | ||
153 | if err := transactionContext.CommitTransaction(); err != nil { | 153 | if err := transactionContext.CommitTransaction(); err != nil { |
154 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 154 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
155 | } | 155 | } |
156 | - //for _, suMoneyTransactionRecord := range suMoneyTransactionRecords { | ||
157 | - // contributions := []int{2,3,4} | ||
158 | - // suMoney := []int{1,2,3,4,5} | ||
159 | - // // 查询贡献值时规范描述 | ||
160 | - // if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, contributions) { | ||
161 | - // switch suMoneyTransactionRecord.RecordType { | ||
162 | - // case 2: // 任务奖励 | ||
163 | - // suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励" | ||
164 | - // case 3: // 增加 | ||
165 | - // suMoneyTransactionRecord.RecordDescription = "增加贡献" | ||
166 | - // case 4: // 扣除 | ||
167 | - // suMoneyTransactionRecord.RecordDescription = "扣除贡献" | ||
168 | - // } | ||
169 | - // } | ||
170 | - // // 查询素币值时规范描述 | ||
171 | - // if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, suMoney) { | ||
172 | - // switch suMoneyTransactionRecord.RecordType { | ||
173 | - // case 1: // 兑换物资 | ||
174 | - // suMoneyTransactionRecord.RecordDescription = "兑换物资" | ||
175 | - // case 2: // 任务奖励 | ||
176 | - // suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励" | ||
177 | - // case 3: // 增加 | ||
178 | - // suMoneyTransactionRecord.RecordDescription = "增加素币" | ||
179 | - // case 4: // 扣除 | ||
180 | - // suMoneyTransactionRecord.RecordDescription = "扣除素币" | ||
181 | - // case 5: // 兑换现金 | ||
182 | - // suMoneyTransactionRecord.RecordDescription = "素币兑换现金" | ||
183 | - // } | ||
184 | - // } | ||
185 | - //} | 156 | + var suMoneyTransactionRecordsFormat []interface{} |
157 | + //loc, _ := time.LoadLocation("Local") | ||
158 | + for _, suMoneyTransactionRecord := range suMoneyTransactionRecords { | ||
159 | + //dt, _ := ("2006-01-02 15:04:05", suMoneyTransactionRecord.CreateTime, loc) | ||
160 | + suMoneyTransactionRecordFormat := map[string]interface{} { | ||
161 | + "suMoneyTransactionRecordId": suMoneyTransactionRecord.SuMoneyTransactionRecordId, | ||
162 | + "recordType": suMoneyTransactionRecord.RecordType, | ||
163 | + "employee": map[string]interface{} { | ||
164 | + "uid": suMoneyTransactionRecord.Employee.Uid, | ||
165 | + "employeeName": suMoneyTransactionRecord.Employee.EmployeeName, | ||
166 | + "employeeAccount": suMoneyTransactionRecord.Employee.EmployeeAccount, | ||
167 | + "employeeAvatarUrl": suMoneyTransactionRecord.Employee.EmployeeAvatarUrl, | ||
168 | + "isPrincipal": suMoneyTransactionRecord.Employee.IsPrincipal, | ||
169 | + }, | ||
170 | + "suMoneyBeforeTransaction": suMoneyTransactionRecord.SuMoneyBeforeTransaction, | ||
171 | + "currentSuMoney": suMoneyTransactionRecord.CurrentSuMoney, | ||
172 | + "suMoney": suMoneyTransactionRecord.SuMoney, | ||
173 | + "cashBeforeTransaction": suMoneyTransactionRecord.CashBeforeTransaction, | ||
174 | + "currentCash": suMoneyTransactionRecord.CurrentCash, | ||
175 | + "cash": suMoneyTransactionRecord.Cash, | ||
176 | + "operator": map[string]interface{} { | ||
177 | + "uid": suMoneyTransactionRecord.Operator.Uid, | ||
178 | + "employeeName": suMoneyTransactionRecord.Operator.EmployeeName, | ||
179 | + "employeeAccount": suMoneyTransactionRecord.Operator.EmployeeAccount, | ||
180 | + "employeeAvatarUrl": suMoneyTransactionRecord.Operator.EmployeeAvatarUrl, | ||
181 | + "isPrincipal": suMoneyTransactionRecord.Operator.IsPrincipal, | ||
182 | + }, | ||
183 | + "recordDescription": suMoneyTransactionRecord.RecordDescription, | ||
184 | + "createTime": suMoneyTransactionRecord.CreateTime.Location(), | ||
185 | + } | ||
186 | + suMoneyTransactionRecordsFormat = append(suMoneyTransactionRecordsFormat, suMoneyTransactionRecordFormat) | ||
187 | + } | ||
186 | return map[string]interface{}{ | 188 | return map[string]interface{}{ |
187 | "count": count, | 189 | "count": count, |
188 | - "suMoneyTransactionRecords": suMoneyTransactionRecords, | 190 | + "suMoneyTransactionRecords": suMoneyTransactionRecordsFormat, |
189 | }, nil | 191 | }, nil |
190 | } | 192 | } |
191 | } | 193 | } |
@@ -2,6 +2,7 @@ package domain_service | @@ -2,6 +2,7 @@ package domain_service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "github.com/linmadan/egglib-go/core/application" | ||
5 | coreDomain "github.com/linmadan/egglib-go/core/domain" | 6 | coreDomain "github.com/linmadan/egglib-go/core/domain" |
6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 7 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
@@ -20,6 +21,8 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | @@ -20,6 +21,8 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | ||
20 | var employeeRepository domain.EmployeeRepository | 21 | var employeeRepository domain.EmployeeRepository |
21 | var taskRepository domain.TaskRepository | 22 | var taskRepository domain.TaskRepository |
22 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository | 23 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository |
24 | + var cashPoolRepository domain.CashPoolRepository | ||
25 | + | ||
23 | var employeeDao *dao.EmployeeDao | 26 | var employeeDao *dao.EmployeeDao |
24 | if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { | 27 | if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { |
25 | return nil, err | 28 | return nil, err |
@@ -36,11 +39,17 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | @@ -36,11 +39,17 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | ||
36 | } else { | 39 | } else { |
37 | suMoneyTransactionRecordRepository = repository | 40 | suMoneyTransactionRecordRepository = repository |
38 | } | 41 | } |
42 | + if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil { | ||
43 | + return nil, err | ||
44 | + } else { | ||
45 | + cashPoolRepository = repository | ||
46 | + } | ||
39 | if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil { | 47 | if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil { |
40 | return nil, err | 48 | return nil, err |
41 | } else { | 49 | } else { |
42 | employeeDao = dao | 50 | employeeDao = dao |
43 | } | 51 | } |
52 | + | ||
44 | operator, err := employeeRepository.FindOne(map[string]interface{}{ | 53 | operator, err := employeeRepository.FindOne(map[string]interface{}{ |
45 | "uid": operatorUid, | 54 | "uid": operatorUid, |
46 | }) | 55 | }) |
@@ -53,6 +62,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | @@ -53,6 +62,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | ||
53 | task, err := taskRepository.FindOne(map[string]interface{}{ | 62 | task, err := taskRepository.FindOne(map[string]interface{}{ |
54 | "taskId": taskId, | 63 | "taskId": taskId, |
55 | }) | 64 | }) |
65 | + | ||
56 | if err != nil { | 66 | if err != nil { |
57 | return nil, err | 67 | return nil, err |
58 | } | 68 | } |
@@ -124,6 +134,41 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | @@ -124,6 +134,41 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 | ||
124 | if err := employeeDao.TransferSuMoney(taskPercentageItem.Contributor.Uid, taskPercentageItem.SuMoney); err != nil { | 134 | if err := employeeDao.TransferSuMoney(taskPercentageItem.Contributor.Uid, taskPercentageItem.SuMoney); err != nil { |
125 | return nil, err | 135 | return nil, err |
126 | } | 136 | } |
137 | + | ||
138 | + // 更新现金池未兑换素币 | ||
139 | + _, cashPoolFound, err := cashPoolRepository.Find(map[string]interface{}{ | ||
140 | + "companyId": task.CompanyId, | ||
141 | + }) | ||
142 | + if err != nil { | ||
143 | + return nil, err | ||
144 | + } | ||
145 | + if len(cashPoolFound) > 0 { | ||
146 | + // 获取平台素币兑换情况 | ||
147 | + systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId) | ||
148 | + if err != nil { | ||
149 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
150 | + } | ||
151 | + if systemSuMoneyStatistics == nil { | ||
152 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") | ||
153 | + } | ||
154 | + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) | ||
155 | + | ||
156 | + cashPool := &domain.CashPool{ | ||
157 | + CashPoolId: cashPoolFound[0].CashPoolId, | ||
158 | + Cash: cashPoolFound[0].Cash, | ||
159 | + CompanyId: cashPoolFound[0].CompanyId, | ||
160 | + ExchangedCash: cashPoolFound[0].ExchangedCash, | ||
161 | + UnExchangeCash: cashPoolFound[0].UnExchangeCash, | ||
162 | + ExchangedSuMoney: cashPoolFound[0].ExchangedSuMoney, | ||
163 | + UnExchangeSuMoney: systemUnExchangeSuMoney, | ||
164 | + Rate: cashPoolFound[0].Rate, | ||
165 | + LastRate: cashPoolFound[0].LastRate, | ||
166 | + CreateTime: time.Now(), | ||
167 | + } | ||
168 | + if _, err := cashPoolRepository.Save(cashPool); err != nil { | ||
169 | + return nil, err | ||
170 | + } | ||
171 | + } | ||
127 | } | 172 | } |
128 | if task, err := taskRepository.Save(task); err != nil { | 173 | if task, err := taskRepository.Save(task); err != nil { |
129 | return nil, err | 174 | return nil, err |
@@ -73,7 +73,7 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | @@ -73,7 +73,7 @@ func (repository *SuMoneyTransactionRecordRepository) FindById(queryOptions map[ | ||
73 | //if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 { | 73 | //if iDs, ok := queryOptions["iDs"]; ok && len(iDs.([]int)) != 0 { |
74 | // query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) | 74 | // query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) |
75 | //} | 75 | //} |
76 | - if iDs, ok := queryOptions["iDs"]; ok { | 76 | + if iDs, ok := queryOptions["ids"]; ok { |
77 | query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) | 77 | query = query.Where(`su_money_transaction_record.id IN (?)`, pg.In(iDs.([]int))) |
78 | } | 78 | } |
79 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { | 79 | if count, err := query.Order("id DESC").SelectAndCount(); err != nil { |
@@ -693,7 +693,7 @@ func (controller *SuMoneyController) ExportSuMoneyTransactionRecord() { | @@ -693,7 +693,7 @@ func (controller *SuMoneyController) ExportSuMoneyTransactionRecord() { | ||
693 | var data []map[string]interface{} | 693 | var data []map[string]interface{} |
694 | records, err := suMoneyService.ListSuMoneyTransactionRecordById(exportTransactionRecordCommand) | 694 | records, err := suMoneyService.ListSuMoneyTransactionRecordById(exportTransactionRecordCommand) |
695 | for _, record := range records { | 695 | for _, record := range records { |
696 | - timString := record.CreateTime.Format("2006/01/02 15:04:05") | 696 | + timString := record.CreateTime.UTC().Format("2006/01/02 15:04:05") |
697 | 697 | ||
698 | p := map[string]interface{} { | 698 | p := map[string]interface{} { |
699 | "name": record.Employee.EmployeeName, | 699 | "name": record.Employee.EmployeeName, |
-
请 注册 或 登录 后发表评论