正在显示
1 个修改的文件
包含
24 行增加
和
14 行删除
@@ -41,7 +41,10 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -41,7 +41,10 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
41 | } else { | 41 | } else { |
42 | cashPoolDao = value | 42 | cashPoolDao = value |
43 | } | 43 | } |
44 | - var systemExchangedCash float64 | 44 | + var ( |
45 | + systemExchangedCash float64 | ||
46 | + systemUnExchangeCash float64 | ||
47 | + ) | ||
45 | if value, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil { | 48 | if value, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil { |
46 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 49 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
47 | } else { | 50 | } else { |
@@ -67,19 +70,25 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -67,19 +70,25 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
67 | cashPoolRepository = value | 70 | cashPoolRepository = value |
68 | } | 71 | } |
69 | 72 | ||
70 | - _, cashPools, err := cashPoolRepository.Find(map[string]interface{}{ | ||
71 | - "companyId": createCashPoolCommand.CompanyId, | ||
72 | - }) | ||
73 | - if err != nil { | ||
74 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
75 | - } | 73 | + // TODO 获取系统未兑换现金 |
74 | + //count, cashPools, err := cashPoolRepository.Find(map[string]interface{}{ | ||
75 | + // "companyId": createCashPoolCommand.CompanyId, | ||
76 | + //}) | ||
77 | + //if err != nil { | ||
78 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
79 | + //} | ||
80 | + //if count == 0 { | ||
81 | + // systemUnExchangeCash = 0 | ||
82 | + //} else { | ||
83 | + // systemUnExchangeCash = cashPools[0].UnExchangeCash | ||
84 | + //} | ||
76 | 85 | ||
77 | rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 | 86 | rate, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemChangedSuMoney), 64) // 平均兑换汇率 |
78 | newCashPool := &domain.CashPool{ | 87 | newCashPool := &domain.CashPool{ |
79 | CompanyId: createCashPoolCommand.CompanyId, | 88 | CompanyId: createCashPoolCommand.CompanyId, |
80 | Cash: createCashPoolCommand.Cash, | 89 | Cash: createCashPoolCommand.Cash, |
81 | ExchangedCash: systemExchangedCash, | 90 | ExchangedCash: systemExchangedCash, |
82 | - UnExchangeCash: createCashPoolCommand.Cash + cashPools[0].UnExchangeCash, | 91 | + UnExchangeCash: createCashPoolCommand.Cash + systemUnExchangeCash, |
83 | ExchangedSuMoney: systemChangedSuMoney, | 92 | ExchangedSuMoney: systemChangedSuMoney, |
84 | UnExchangeSuMoney: systemUnChangeSuMoney, | 93 | UnExchangeSuMoney: systemUnChangeSuMoney, |
85 | Rate: rate, | 94 | Rate: rate, |
@@ -94,13 +103,13 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | @@ -94,13 +103,13 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co | ||
94 | cashPoolRepository = value | 103 | cashPoolRepository = value |
95 | } | 104 | } |
96 | 105 | ||
97 | - if activity, err := cashPoolRepository.Save(newCashPool); err != nil { | 106 | + if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil { |
98 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 107 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
99 | } else { | 108 | } else { |
100 | if err := transactionContext.CommitTransaction(); err != nil { | 109 | if err := transactionContext.CommitTransaction(); err != nil { |
101 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 110 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
102 | } | 111 | } |
103 | - return activity, nil | 112 | + return cashPool, nil |
104 | } | 113 | } |
105 | } | 114 | } |
106 | 115 | ||
@@ -387,16 +396,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -387,16 +396,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
387 | 396 | ||
388 | // TODO 获取兑换活动兑换汇率 | 397 | // TODO 获取兑换活动兑换汇率 |
389 | //var exchangeCashActivityRepository domain.ExchangeActivityRepository | 398 | //var exchangeCashActivityRepository domain.ExchangeActivityRepository |
390 | - //activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId}) | 399 | + //activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": createExchangeCashPersonCommand.ExchangeCashActivityId}) |
391 | //if err != nil { | 400 | //if err != nil { |
392 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 401 | // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
393 | //} | 402 | //} |
394 | - //if activity.Rate == 0 { | 403 | + //if activity == nil { |
395 | // return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string("请设置汇率"))) | 404 | // return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string("请设置汇率"))) |
405 | + //} else { | ||
406 | + // fmt.Print(activity.Rate) | ||
396 | //} | 407 | //} |
397 | 408 | ||
398 | - // TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金” | ||
399 | 409 | ||
410 | + // TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金” | ||
400 | 411 | ||
401 | 412 | ||
402 | // TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据 | 413 | // TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据 |
@@ -409,7 +420,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | @@ -409,7 +420,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC | ||
409 | }, | 420 | }, |
410 | ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, | 421 | ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, |
411 | ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, | 422 | ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, |
412 | - //ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney * activity.Rate, | ||
413 | ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney, | 423 | ExchangedCash: createExchangeCashPersonCommand.ExchangedSuMoney, |
414 | } | 424 | } |
415 | 425 |
-
请 注册 或 登录 后发表评论