作者 陈志颖

fix:修复删除兑换清单

@@ -102,24 +102,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -102,24 +102,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
102 } 102 }
103 } 103 }
104 104
105 -// 更新现金池  
106 -func (cashPoolService *CashPoolService) UpdateCashPool(updateCashPoolCommand *command.UpdateCashPoolCommand) (interface{}, error) {  
107 - if err := updateCashPoolCommand.ValidateCommand(); err != nil {  
108 - return nil, application.ThrowError(application.ARG_ERROR, err.Error())  
109 - }  
110 - transactionContext, err := factory.CreateTransactionContext(nil)  
111 - if err != nil {  
112 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
113 - }  
114 - if err := transactionContext.StartTransaction(); err != nil {  
115 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
116 - }  
117 - defer func() {  
118 - transactionContext.RollbackTransaction()  
119 - }()  
120 - return nil , nil  
121 -}  
122 -  
123 // 返回现金池 105 // 返回现金池
124 func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) { 106 func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) {
125 if err := getCashPoolQuery.ValidateQuery(); err != nil { 107 if err := getCashPoolQuery.ValidateQuery(); err != nil {
@@ -425,7 +407,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -425,7 +407,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
425 } 407 }
426 } 408 }
427 409
428 -// TODO 更新兑换现金活动 410 +// 更新兑换现金活动
429 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) { 411 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
430 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil { 412 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
431 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 413 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -613,7 +595,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -613,7 +595,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
613 } else { 595 } else {
614 exchangeCashActivityRepository = value 596 exchangeCashActivityRepository = value
615 } 597 }
616 - activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": createExchangeCashPersonCommand.ExchangeCashActivityId}) 598 + activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
617 if err != nil { 599 if err != nil {
618 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 600 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
619 } 601 }
@@ -628,7 +610,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -628,7 +610,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
628 employeeRepository = value 610 employeeRepository = value
629 } 611 }
630 getEmployee := map[string]interface{}{} 612 getEmployee := map[string]interface{}{}
631 - if createExchangeCashPersonCommand.PersonName == "" { 613 + if createExchangeCashPersonCommand.PersonAccount == "" {
632 getEmployee = map[string]interface{}{ 614 getEmployee = map[string]interface{}{
633 "uid": createExchangeCashPersonCommand.Uid, 615 "uid": createExchangeCashPersonCommand.Uid,
634 } 616 }
@@ -637,6 +619,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -637,6 +619,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
637 "account": createExchangeCashPersonCommand.PersonAccount, 619 "account": createExchangeCashPersonCommand.PersonAccount,
638 } 620 }
639 } 621 }
  622 + fmt.Print(getEmployee, "\n")
640 employee, err := employeeRepository.FindOne(getEmployee) 623 employee, err := employeeRepository.FindOne(getEmployee)
641 if err != nil { 624 if err != nil {
642 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 625 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -686,6 +669,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -686,6 +669,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
686 OperationType: 3, 669 OperationType: 3,
687 OperationDescription: "素币兑换现金", 670 OperationDescription: "素币兑换现金",
688 } 671 }
  672 + fmt.Print(operationSuMoneyCommand, "\n")
689 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 673 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
690 if err != nil { 674 if err != nil {
691 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 675 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -693,6 +677,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -693,6 +677,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
693 if task == nil { 677 if task == nil {
694 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid))) 678 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
695 } 679 }
  680 + fmt.Print(task, "\n")
696 // 更新兑换活动 681 // 更新兑换活动
697 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{ 682 if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
698 "transactionContext": transactionContext, 683 "transactionContext": transactionContext,
@@ -946,6 +931,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -946,6 +931,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
946 OperationType: 1, 931 OperationType: 1,
947 OperationDescription: "素币兑换现金调整", 932 OperationDescription: "素币兑换现金调整",
948 } 933 }
  934 + fmt.Print(removeExchangeCashPersonCommand.Operator, "\n")
949 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 935 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
950 if err != nil { 936 if err != nil {
951 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 937 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1160,6 +1146,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1160,6 +1146,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1160 employeeDao = value 1146 employeeDao = value
1161 } 1147 }
1162 systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId) 1148 systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
  1149 + fmt.Print(activitySuMoney , "\n")
  1150 + fmt.Print(updateExchangeCashActivityCommand.ExchangeRate, "\n")
  1151 + fmt.Print(systemCashStatistics["systemUnExchangeCash"].(float64), "\n")
1163 if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > systemCashStatistics["systemUnExchangeCash"].(float64) { 1152 if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > systemCashStatistics["systemUnExchangeCash"].(float64) {
1164 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 1153 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
1165 } 1154 }
@@ -1171,6 +1160,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1171,6 +1160,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1171 OperationType: 0, 1160 OperationType: 0,
1172 OperationDescription: "参与兑换素币活动", 1161 OperationDescription: "参与兑换素币活动",
1173 } 1162 }
  1163 + //if (person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney) > 0 {
  1164 + // operationSuMoneyCommand.SuMoney = math.Abs(person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney)
  1165 + // operationSuMoneyCommand.OperationType = 1
  1166 + //} else {
  1167 + // operationSuMoneyCommand.SuMoney = math.Abs(person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney)
  1168 + // operationSuMoneyCommand.OperationType = 3
  1169 + //}
1174 if updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney > 0 { 1170 if updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney > 0 {
1175 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney) 1171 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
1176 operationSuMoneyCommand.OperationType = 5 1172 operationSuMoneyCommand.OperationType = 5
@@ -1178,6 +1174,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1178,6 +1174,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1178 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney) 1174 operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
1179 operationSuMoneyCommand.OperationType = 3 1175 operationSuMoneyCommand.OperationType = 3
1180 } 1176 }
  1177 + fmt.Print(updateExchangeCashPersonCommand.Operator, "\n")
1181 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1178 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
1182 if err != nil { 1179 if err != nil {
1183 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1180 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1186,7 +1183,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1186,7 +1183,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1186 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid))) 1183 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
1187 } 1184 }
1188 // 更新现金池 1185 // 更新现金池
1189 - // 获取平台现金状况  
1190 newSystemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId) 1186 newSystemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
1191 if err != nil { 1187 if err != nil {
1192 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1188 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -15,7 +15,6 @@ type OperationSuMoneyService struct { @@ -15,7 +15,6 @@ type OperationSuMoneyService struct {
15 transactionContext *pgTransaction.TransactionContext 15 transactionContext *pgTransaction.TransactionContext
16 } 16 }
17 17
18 -// TODO 增加兑换现金事务记录  
19 func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64, suMoney float64, operationType int, recordDescription string) (*domain.SuMoneyTransactionRecord, error) { 18 func (service *OperationSuMoneyService) Operation(uid int64, operatorUid int64, suMoney float64, operationType int, recordDescription string) (*domain.SuMoneyTransactionRecord, error) {
20 var employeeRepository domain.EmployeeRepository 19 var employeeRepository domain.EmployeeRepository
21 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository 20 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
@@ -37,7 +37,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str @@ -37,7 +37,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str
37 tx := repository.transactionContext.PgTx 37 tx := repository.transactionContext.PgTx
38 exchangeCashListModel := new(models.ExchangeCashPersonList) 38 exchangeCashListModel := new(models.ExchangeCashPersonList)
39 query := tx.Model(exchangeCashListModel) 39 query := tx.Model(exchangeCashListModel)
40 - if exchangeCashListId, ok := queryOptions["listId"]; ok { 40 + if exchangeCashListId, ok := queryOptions["id"]; ok {
41 query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId) 41 query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId)
42 } 42 }
43 if err := query.First(); err != nil { 43 if err := query.First(); err != nil {
@@ -287,7 +287,9 @@ func (controller *SuMoneyController) RemoveExchangeCashPerson() { @@ -287,7 +287,9 @@ func (controller *SuMoneyController) RemoveExchangeCashPerson() {
287 cashPoolService := service.NewCashPoolService(nil) 287 cashPoolService := service.NewCashPoolService(nil)
288 removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{} 288 removeExchangeCashPersonCommand := &command.RemoveExchangeCashPersonCommand{}
289 personId, _ := controller.GetInt64(":listId") 289 personId, _ := controller.GetInt64(":listId")
  290 + operatorId, _ := controller.GetInt64("operator")
290 removeExchangeCashPersonCommand.ListId = personId 291 removeExchangeCashPersonCommand.ListId = personId
  292 + removeExchangeCashPersonCommand.Operator = operatorId
291 data, err := cashPoolService.RemoveExchangeCashPerson(removeExchangeCashPersonCommand) 293 data, err := cashPoolService.RemoveExchangeCashPerson(removeExchangeCashPersonCommand)
292 var response utils.JsonResponse 294 var response utils.JsonResponse
293 if err != nil { 295 if err != nil {
@@ -321,6 +323,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -321,6 +323,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
321 cashPoolService := service.NewCashPoolService(nil) 323 cashPoolService := service.NewCashPoolService(nil)
322 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} 324 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
323 activityId, _ := controller.GetInt64("activityId") 325 activityId, _ := controller.GetInt64("activityId")
  326 + operatorId, _ := controller.GetInt64("operatorId")
324 file, h, _ := controller.GetFile("file") //获取上传的文件 327 file, h, _ := controller.GetFile("file") //获取上传的文件
325 ext := path.Ext(h.Filename) 328 ext := path.Ext(h.Filename)
326 AllowExtMap := map[string]bool{ 329 AllowExtMap := map[string]bool{
@@ -339,9 +342,10 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -339,9 +342,10 @@ func (controller *SuMoneyController) ImportExchangeList () {
339 dataList := make([]interface{}, 0) 342 dataList := make([]interface{}, 0)
340 rows, _ := xlsx.GetRows("Sheet1") 343 rows, _ := xlsx.GetRows("Sheet1")
341 for i, row := range rows { 344 for i, row := range rows {
342 - if i > 3 { 345 + if i > 2 {
343 for _, _ = range row { 346 for _, _ = range row {
344 createExchangeCashPersonCommand.ExchangeCashActivityId = activityId 347 createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
  348 + createExchangeCashPersonCommand.Operator = operatorId
345 createExchangeCashPersonCommand.PersonName = row[0] 349 createExchangeCashPersonCommand.PersonName = row[0]
346 createExchangeCashPersonCommand.PersonAccount = row[1] 350 createExchangeCashPersonCommand.PersonAccount = row[1]
347 createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[2], 64) 351 createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[2], 64)