|
@@ -902,6 +902,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -902,6 +902,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
902
|
exchangeCashPersonListRepository = value
|
902
|
exchangeCashPersonListRepository = value
|
903
|
}
|
903
|
}
|
904
|
|
904
|
|
|
|
905
|
+ // 员工仓储初始化
|
|
|
906
|
+ var employeeRepository domain.EmployeeRepository
|
|
|
907
|
+ if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
908
|
+ "transactionContext": transactionContext,
|
|
|
909
|
+ }); err != nil {
|
|
|
910
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
911
|
+ } else {
|
|
|
912
|
+ employeeRepository = value
|
|
|
913
|
+ }
|
|
|
914
|
+
|
905
|
// 兑换现金活动仓储初始化
|
915
|
// 兑换现金活动仓储初始化
|
906
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
916
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
907
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
917
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
@@ -951,9 +961,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -951,9 +961,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
951
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
|
961
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
|
952
|
}
|
962
|
}
|
953
|
|
963
|
|
954
|
- // 获取兑换清单员工已兑换素币
|
|
|
955
|
- personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
|
|
956
|
-
|
|
|
957
|
// 获取相关兑换活动
|
964
|
// 获取相关兑换活动
|
958
|
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
965
|
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
959
|
if err != nil {
|
966
|
if err != nil {
|
|
@@ -963,6 +970,29 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -963,6 +970,29 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
963
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(personFound.ExchangeCashActivityId)))
|
970
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(personFound.ExchangeCashActivityId)))
|
964
|
}
|
971
|
}
|
965
|
|
972
|
|
|
|
973
|
+ // 获取员工查询条件
|
|
|
974
|
+ getEmployee := map[string]interface{}{
|
|
|
975
|
+ "account": personFound.EmployeeInfo.EmployeeAccount,
|
|
|
976
|
+ "companyId": activityFound.CompanyId,
|
|
|
977
|
+ }
|
|
|
978
|
+
|
|
|
979
|
+ // 判断当前员工是否有效
|
|
|
980
|
+ employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
|
981
|
+ if err != nil {
|
|
|
982
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
983
|
+ }
|
|
|
984
|
+ if employeeFound == nil {
|
|
|
985
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
|
|
|
986
|
+ }
|
|
|
987
|
+
|
|
|
988
|
+ // 判断该员工兑换的素币是否超过本人持有的素币
|
|
|
989
|
+ if employeeFound.SuMoney < updateExchangeCashPersonCommand.ExchangedSuMoney {
|
|
|
990
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
|
|
991
|
+ }
|
|
|
992
|
+
|
|
|
993
|
+ // 获取兑换清单员工已兑换素币
|
|
|
994
|
+ personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
|
|
995
|
+
|
966
|
// 更新兑换清单,个人已兑换现金计算
|
996
|
// 更新兑换清单,个人已兑换现金计算
|
967
|
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
997
|
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
968
|
|
998
|
|