|
@@ -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())
|