作者 陈志颖

feat:完善修改手机号回调

@@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
62 62
63 // 现金池仓储初始化 63 // 现金池仓储初始化
64 var cashPoolRepository domain.CashPoolRepository 64 var cashPoolRepository domain.CashPoolRepository
65 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 65 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
66 "transactionContext": transactionContext, 66 "transactionContext": transactionContext,
67 }); err != nil { 67 }); err != nil {
68 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 68 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
97 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 97 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
98 } 98 }
99 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币 99 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币
100 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币 100 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币
101 101
102 // 获取当前公司现金池 102 // 获取当前公司现金池
103 count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand)) 103 count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
104 if err != nil { 104 if err != nil {
105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
106 } 106 }
107 - if len(cashPools) > 0 { // 更新现金池 107 + if len(cashPools) > 0 { // 更新现金池
108 cashPoolExchangeCash := cashPools[0].ExchangedCash 108 cashPoolExchangeCash := cashPools[0].ExchangedCash
109 cashPoolUnExchangeCash := cashPools[0].UnExchangeCash 109 cashPoolUnExchangeCash := cashPools[0].UnExchangeCash
110 cashPoolCash := cashPools[0].Cash 110 cashPoolCash := cashPools[0].Cash
111 111
112 - if createCashPoolCommand.Cash < cashPoolExchangeCash { 112 + if createCashPoolCommand.Cash < cashPoolExchangeCash {
113 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值") 113 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值")
114 } 114 }
115 115
@@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
125 var lastActivityRate float64 125 var lastActivityRate float64
126 listExchangeCashActivityQuery := map[string]interface{}{ 126 listExchangeCashActivityQuery := map[string]interface{}{
127 "companyId": createCashPoolCommand.CompanyId, 127 "companyId": createCashPoolCommand.CompanyId,
128 - "order": "deadline DESC",  
129 - "nearest": true,  
130 - "limit": 1, 128 + "order": "deadline DESC",
  129 + "nearest": true,
  130 + "limit": 1,
131 } 131 }
132 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 132 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
133 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 133 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
134 } else { 134 } else {
135 if len(activities) > 0 { 135 if len(activities) > 0 {
136 lastActivityRate = activities[0].Rate 136 lastActivityRate = activities[0].Rate
137 - } else { // 未查询到相关兑换活动 137 + } else { // 未查询到相关兑换活动
138 lastActivityRate = 0 138 lastActivityRate = 0
139 } 139 }
140 } 140 }
@@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
143 143
144 // 更新现金池命令 144 // 更新现金池命令
145 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 145 updateCashPoolCommand := &command.UpdateCashPoolCommand{
146 - CashPoolId: cashPools[0].CashPoolId,  
147 - Cash: createCashPoolCommand.Cash, 146 + CashPoolId: cashPools[0].CashPoolId,
  147 + Cash: createCashPoolCommand.Cash,
148 ExchangedCash: cashPoolExchangeCash, 148 ExchangedCash: cashPoolExchangeCash,
149 //UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash), 149 //UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
150 - UnExchangeCash: unExchangeCash,  
151 - ExchangedSuMoney: systemExchangedSuMoney, 150 + UnExchangeCash: unExchangeCash,
  151 + ExchangedSuMoney: systemExchangedSuMoney,
152 UnExchangeSuMoney: systemUnExchangeSuMoney, 152 UnExchangeSuMoney: systemUnExchangeSuMoney,
153 - Rate: newRate,  
154 - LastRate: lastActivityRate, 153 + Rate: newRate,
  154 + LastRate: lastActivityRate,
155 } 155 }
156 156
157 // 更新现金池 157 // 更新现金池
@@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
180 cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64() 180 cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64()
181 return cashPool, nil 181 return cashPool, nil
182 } 182 }
183 - } else { // 新增现金池 183 + } else { // 新增现金池
184 // 获取上次兑换活动兑换汇率查询 184 // 获取上次兑换活动兑换汇率查询
185 var lastActivityRate float64 185 var lastActivityRate float64
186 listExchangeCashActivityQuery := map[string]interface{}{ 186 listExchangeCashActivityQuery := map[string]interface{}{
187 "companyId": createCashPoolCommand.CompanyId, 187 "companyId": createCashPoolCommand.CompanyId,
188 - "order": "deadline DESC",  
189 - "nearest": true,  
190 - "limit": 1, 188 + "order": "deadline DESC",
  189 + "nearest": true,
  190 + "limit": 1,
191 } 191 }
192 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 192 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
193 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 193 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
194 } else { 194 } else {
195 if len(activities) > 0 { 195 if len(activities) > 0 {
196 lastActivityRate = activities[0].Rate 196 lastActivityRate = activities[0].Rate
197 - } else { // 未查询到相关兑换活动 197 + } else { // 未查询到相关兑换活动
198 lastActivityRate = 0 198 lastActivityRate = 0
199 } 199 }
200 } 200 }
201 201
202 // 更新现金池 202 // 更新现金池
203 newCashPool := &domain.CashPool{ 203 newCashPool := &domain.CashPool{
204 - CompanyId: createCashPoolCommand.CompanyId,  
205 - Cash: createCashPoolCommand.Cash,  
206 - ExchangedCash: 0,  
207 - UnExchangeCash: createCashPoolCommand.Cash,  
208 - ExchangedSuMoney: systemExchangedSuMoney, 204 + CompanyId: createCashPoolCommand.CompanyId,
  205 + Cash: createCashPoolCommand.Cash,
  206 + ExchangedCash: 0,
  207 + UnExchangeCash: createCashPoolCommand.Cash,
  208 + ExchangedSuMoney: systemExchangedSuMoney,
209 UnExchangeSuMoney: systemUnExchangeSuMoney, 209 UnExchangeSuMoney: systemUnExchangeSuMoney,
210 - LastRate: lastActivityRate,  
211 - Rate: 0,  
212 - CreateTime: time.Now().Local(), 210 + LastRate: lastActivityRate,
  211 + Rate: 0,
  212 + CreateTime: time.Now().Local(),
213 } 213 }
214 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil { 214 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
215 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 215 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
271 271
272 // 现金池仓储初始化 272 // 现金池仓储初始化
273 var cashPoolRepository domain.CashPoolRepository 273 var cashPoolRepository domain.CashPoolRepository
274 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 274 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
275 "transactionContext": transactionContext, 275 "transactionContext": transactionContext,
276 }); err != nil { 276 }); err != nil {
277 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 277 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
304 var lastActivityRate float64 304 var lastActivityRate float64
305 listExchangeCashActivityQuery := map[string]interface{}{ 305 listExchangeCashActivityQuery := map[string]interface{}{
306 "companyId": getCashPoolQuery.CompanyId, 306 "companyId": getCashPoolQuery.CompanyId,
307 - "order": "deadline DESC",  
308 - "nearest": true,  
309 - "limit": 1, 307 + "order": "deadline DESC",
  308 + "nearest": true,
  309 + "limit": 1,
310 } 310 }
311 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 311 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
312 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 312 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
313 } else { 313 } else {
314 if len(activities) > 0 { 314 if len(activities) > 0 {
315 lastActivityRate = activities[0].Rate 315 lastActivityRate = activities[0].Rate
316 - } else { // 未查询到相关兑换活动 316 + } else { // 未查询到相关兑换活动
317 lastActivityRate = 0 317 lastActivityRate = 0
318 } 318 }
319 } 319 }
@@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
327 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 327 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
328 } 328 }
329 //systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币 329 //systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
330 - systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币 330 + systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币
331 331
332 // 查找当前公司现金池 332 // 查找当前公司现金池
333 if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil { 333 if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
@@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
338 } 338 }
339 // 现金池为空时处理 339 // 现金池为空时处理
340 if count == 0 { 340 if count == 0 {
341 - return map[string] interface{} {  
342 - "cashPoolId": 0,  
343 - "cash": 0,  
344 - "companyId": getCashPoolQuery.CompanyId,  
345 - "exchangedCash": 0,  
346 - "unExchangeCash": 0,  
347 - "exchangedSuMoney": 0, 341 + return map[string]interface{}{
  342 + "cashPoolId": 0,
  343 + "cash": 0,
  344 + "companyId": getCashPoolQuery.CompanyId,
  345 + "exchangedCash": 0,
  346 + "unExchangeCash": 0,
  347 + "exchangedSuMoney": 0,
348 "unExchangeSuMoney": systemUnExchangeSuMoney, 348 "unExchangeSuMoney": systemUnExchangeSuMoney,
349 - "rate": 0, // 平均兑换汇率  
350 - "lastRate": 0, // 上期活动兑换汇率  
351 - "createTime": time.Now().Local(), 349 + "rate": 0, // 平均兑换汇率
  350 + "lastRate": 0, // 上期活动兑换汇率
  351 + "createTime": time.Now().Local(),
352 }, nil 352 }, nil
353 } else { 353 } else {
354 //cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64) 354 //cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
@@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
426 // 创建兑换活动命令 426 // 创建兑换活动命令
427 newActivity := &domain.ExchangeCashActivity{ 427 newActivity := &domain.ExchangeCashActivity{
428 ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, 428 ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
429 - CompanyId: createExchangeCashActivityCommand.CompanyId,  
430 - ExchangedCash: 0,  
431 - ExchangedSuMoney: 0,  
432 - Deadline: t2,  
433 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时  
434 - Rate: createExchangeCashActivityCommand.ExchangeRate,  
435 - CreateTime: time.Now().Local(), 429 + CompanyId: createExchangeCashActivityCommand.CompanyId,
  430 + ExchangedCash: 0,
  431 + ExchangedSuMoney: 0,
  432 + Deadline: t2,
  433 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
  434 + Rate: createExchangeCashActivityCommand.ExchangeRate,
  435 + CreateTime: time.Now().Local(),
436 } 436 }
437 437
438 // 倒计时结束判断 438 // 倒计时结束判断
@@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
543 var t2 = activity.Deadline 543 var t2 = activity.Deadline
544 544
545 // 获取兑换活动前先更新兑换活动倒计时命令 545 // 获取兑换活动前先更新兑换活动倒计时命令
546 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 546 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
547 ExchangeCashActivityId: activity.ActivityId, 547 ExchangeCashActivityId: activity.ActivityId,
548 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时  
549 - Deadline: activity.Deadline,  
550 - ExchangedSuMoney: activity.ExchangedSuMoney,  
551 - ExchangedCash: activity.ExchangedCash,  
552 - ExchangeRate: activity.Rate, 548 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
  549 + Deadline: activity.Deadline,
  550 + ExchangedSuMoney: activity.ExchangedSuMoney,
  551 + ExchangedCash: activity.ExchangedCash,
  552 + ExchangeRate: activity.Rate,
553 } 553 }
554 554
555 // 倒计时结束处理 555 // 倒计时结束处理
@@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
579 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64) 579 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
580 cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64() 580 cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
581 suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64() 581 suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
582 - activityFormat := map[string]interface{} {  
583 - "activityId": activity.ActivityId, 582 + activityFormat := map[string]interface{}{
  583 + "activityId": activity.ActivityId,
584 "exchangeActivityName": activity.ExchangeActivityName, 584 "exchangeActivityName": activity.ExchangeActivityName,
585 - "companyId": activity.CompanyId,  
586 - "exchangedCash": cash,  
587 - "exchangedSuMoney": suMoney,  
588 - "deadline": activity.Deadline.Local(),  
589 - "countDown": activity.CountDown,  
590 - "rate": activity.Rate,  
591 - "createTime": activity.CreateTime.Local(), 585 + "companyId": activity.CompanyId,
  586 + "exchangedCash": cash,
  587 + "exchangedSuMoney": suMoney,
  588 + "deadline": activity.Deadline.Local(),
  589 + "countDown": activity.CountDown,
  590 + "rate": activity.Rate,
  591 + "createTime": activity.CreateTime.Local(),
592 } 592 }
593 activitiesFormat = append(activitiesFormat, activityFormat) 593 activitiesFormat = append(activitiesFormat, activityFormat)
594 } 594 }
@@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
598 } 598 }
599 599
600 return map[string]interface{}{ 600 return map[string]interface{}{
601 - "count": count, 601 + "count": count,
602 "activities": activitiesFormat, 602 "activities": activitiesFormat,
603 }, nil 603 }, nil
604 } 604 }
@@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
633 633
634 // 查找兑换现金活动 634 // 查找兑换现金活动
635 if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{ 635 if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{
636 - "companyId": listExchangeCashActivityQuery.CompanyId, 636 + "companyId": listExchangeCashActivityQuery.CompanyId,
637 "activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch, 637 "activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
638 - "offset": listExchangeCashActivityQuery.Offset,  
639 - "limit": listExchangeCashActivityQuery.Limit,  
640 - "countdown": 0,  
641 - "isEnd": listExchangeCashActivityQuery.IsEnd, 638 + "offset": listExchangeCashActivityQuery.Offset,
  639 + "limit": listExchangeCashActivityQuery.Limit,
  640 + "countdown": 0,
  641 + "isEnd": listExchangeCashActivityQuery.IsEnd,
642 }); err != nil { 642 }); err != nil {
643 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 643 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
644 } else { 644 } else {
@@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
647 var t2 = activityFound.Deadline.Local() 647 var t2 = activityFound.Deadline.Local()
648 648
649 // 更新兑换现金活动倒计时命令 649 // 更新兑换现金活动倒计时命令
650 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 650 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
651 ExchangeCashActivityId: activityFound.ActivityId, 651 ExchangeCashActivityId: activityFound.ActivityId,
652 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),  
653 - Deadline: activityFound.Deadline.Local(),  
654 - ExchangedSuMoney: activityFound.ExchangedSuMoney,  
655 - ExchangedCash: activityFound.ExchangedCash,  
656 - ExchangeRate: activityFound.Rate, 652 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
  653 + Deadline: activityFound.Deadline.Local(),
  654 + ExchangedSuMoney: activityFound.ExchangedSuMoney,
  655 + ExchangedCash: activityFound.ExchangedCash,
  656 + ExchangeRate: activityFound.Rate,
657 } 657 }
658 658
659 // 倒计时结束处理 659 // 倒计时结束处理
@@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
684 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64) 684 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
685 cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64() 685 cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
686 suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64() 686 suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
687 - activityWithTs := map[string]interface{} {  
688 - "activityId": activityFound.ActivityId, 687 + activityWithTs := map[string]interface{}{
  688 + "activityId": activityFound.ActivityId,
689 "exchangeActivityName": activityFound.ExchangeActivityName, 689 "exchangeActivityName": activityFound.ExchangeActivityName,
690 - "companyId": activityFound.CompanyId,  
691 - "exchangedCash": cash,  
692 - "exchangedSuMoney": suMoney,  
693 - "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换  
694 - "countDown": activityFound.CountDown,  
695 - "rate": activityFound.Rate,  
696 - "createTime": activityFound.CreateTime.Local(), 690 + "companyId": activityFound.CompanyId,
  691 + "exchangedCash": cash,
  692 + "exchangedSuMoney": suMoney,
  693 + "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
  694 + "countDown": activityFound.CountDown,
  695 + "rate": activityFound.Rate,
  696 + "createTime": activityFound.CreateTime.Local(),
697 } 697 }
698 activitiesWithTs = append(activitiesWithTs, activityWithTs) 698 activitiesWithTs = append(activitiesWithTs, activityWithTs)
699 } 699 }
@@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
703 } 703 }
704 704
705 return map[string]interface{}{ 705 return map[string]interface{}{
706 - "count": count, 706 + "count": count,
707 "activities": activitiesWithTs, 707 "activities": activitiesWithTs,
708 }, nil 708 }, nil
709 } 709 }
@@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
798 var t2 = activityFound.Deadline 798 var t2 = activityFound.Deadline
799 799
800 // 更新兑换现金活动倒计时命令 800 // 更新兑换现金活动倒计时命令
801 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 801 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
802 ExchangeCashActivityId: activityFound.ActivityId, 802 ExchangeCashActivityId: activityFound.ActivityId,
803 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),  
804 - Deadline: activityFound.Deadline,  
805 - ExchangedSuMoney: activityFound.ExchangedSuMoney,  
806 - ExchangedCash: activityFound.ExchangedCash,  
807 - ExchangeRate: activityFound.Rate, 803 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
  804 + Deadline: activityFound.Deadline,
  805 + ExchangedSuMoney: activityFound.ExchangedSuMoney,
  806 + ExchangedCash: activityFound.ExchangedCash,
  807 + ExchangeRate: activityFound.Rate,
808 } 808 }
809 809
810 // 倒计时结束处理 810 // 倒计时结束处理
@@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
877 877
878 // 现金池仓储初始化 878 // 现金池仓储初始化
879 var cashPoolRepository domain.CashPoolRepository 879 var cashPoolRepository domain.CashPoolRepository
880 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 880 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
881 "transactionContext": transactionContext, 881 "transactionContext": transactionContext,
882 }); err != nil { 882 }); err != nil {
883 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 883 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
903 if activityFound == nil { 903 if activityFound == nil {
904 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) 904 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
905 } 905 }
906 - activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币  
907 - activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金 906 + activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币
  907 + activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金
908 908
909 // 获取当前公司现金池 909 // 获取当前公司现金池
910 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{ 910 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
@@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
968 // 获取当前兑换活动汇率 968 // 获取当前兑换活动汇率
969 activityFoundRate := activityFound.Rate 969 activityFoundRate := activityFound.Rate
970 970
971 - if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率 971 + if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
972 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值 972 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
973 - if activityFoundExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash { 973 + if activityFoundExchangedSuMoney*updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
974 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 974 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
975 } 975 }
976 976
@@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
988 988
989 // 更新兑换清单命令 989 // 更新兑换清单命令
990 exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 990 exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
991 - updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand { 991 + updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand{
992 //ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney, 992 //ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
993 - ExchangedCash: exchangeCash, 993 + ExchangedCash: exchangeCash,
994 ExchangedSuMoney: personFoundExchangedSuMoney, 994 ExchangedSuMoney: personFoundExchangedSuMoney,
995 } 995 }
996 996
@@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
1000 } 1000 }
1001 1001
1002 // 保存素币兑换清单更新 1002 // 保存素币兑换清单更新
1003 - if _, err := exchangeCashPersonListRepository.Save(personFound);err != nil { 1003 + if _, err := exchangeCashPersonListRepository.Save(personFound); err != nil {
1004 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1004 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1005 } 1005 }
1006 } 1006 }
@@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
1034 exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64() 1034 exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
1035 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64() 1035 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
1036 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1036 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1037 - CashPoolId: cashPoolFound.CashPoolId, 1037 + CashPoolId: cashPoolFound.CashPoolId,
1038 //ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash), 1038 //ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
1039 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash), 1039 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
1040 - ExchangedCash: exchangedCash,  
1041 - UnExchangeCash: unExchangeCash,  
1042 - ExchangedSuMoney: systemExchangedSuMoney,  
1043 - UnExchangeSuMoney: systemUnExchangeSuMoney,  
1044 - Rate: rate,  
1045 - LastRate: cashPoolFound.LastRate,  
1046 - Cash: cashPoolFound.Cash, 1040 + ExchangedCash: exchangedCash,
  1041 + UnExchangeCash: unExchangeCash,
  1042 + ExchangedSuMoney: systemExchangedSuMoney,
  1043 + UnExchangeSuMoney: systemUnExchangeSuMoney,
  1044 + Rate: rate,
  1045 + LastRate: cashPoolFound.LastRate,
  1046 + Cash: cashPoolFound.Cash,
1047 } 1047 }
1048 1048
1049 // 更新现金池 1049 // 更新现金池
@@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1169 1169
1170 // 现金池仓储初始化 1170 // 现金池仓储初始化
1171 var cashPoolRepository domain.CashPoolRepository 1171 var cashPoolRepository domain.CashPoolRepository
1172 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1172 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
1173 "transactionContext": transactionContext, 1173 "transactionContext": transactionContext,
1174 }); err != nil { 1174 }); err != nil {
1175 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1175 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1258,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1258,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1258 // 更新素币兑换活动命令 1258 // 更新素币兑换活动命令
1259 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64() 1259 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64()
1260 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64() 1260 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
1261 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1261 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1262 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 1262 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
1263 //ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney), 1263 //ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
1264 //ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate, 1264 //ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
1265 - ExchangedSuMoney: exchangedSuMoney,  
1266 - ExchangedCash: exchangedCash,  
1267 - Deadline: activityFound.Deadline,  
1268 - CountDown: activityFound.CountDown,  
1269 - ExchangeRate: activityFound.Rate, 1265 + ExchangedSuMoney: exchangedSuMoney,
  1266 + ExchangedCash: exchangedCash,
  1267 + Deadline: activityFound.Deadline,
  1268 + CountDown: activityFound.CountDown,
  1269 + ExchangeRate: activityFound.Rate,
1270 } 1270 }
1271 1271
1272 // 操作素币服务以及生成素币兑换流水记录命令 1272 // 操作素币服务以及生成素币兑换流水记录命令
@@ -1279,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1279,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1279 } 1279 }
1280 1280
1281 // 判断操作素币类型 1281 // 判断操作素币类型
1282 - if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换 1282 + if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
1283 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) 1283 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
1284 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64() 1284 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
1285 operationSuMoneyCommand.OperationType = 4 1285 operationSuMoneyCommand.OperationType = 4
1286 - } else { // 撤回素币兑换 1286 + } else { // 撤回素币兑换
1287 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) 1287 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
1288 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64() 1288 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
1289 operationSuMoneyCommand.OperationType = 41 1289 operationSuMoneyCommand.OperationType = 41
@@ -1339,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1339,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1339 1339
1340 // 判断是否超过平台未兑换现金 1340 // 判断是否超过平台未兑换现金
1341 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney { 1341 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
1342 - if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash { 1342 + if (activityUpdated.ExchangedSuMoney-activityFoundExchangedSuMoney)*activityUpdated.Rate > cashPoolFoundUnExchangeCash {
1343 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 1343 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
1344 } 1344 }
1345 } 1345 }
@@ -1360,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1360,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1360 // 更新现金池命令 1360 // 更新现金池命令
1361 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64() 1361 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64()
1362 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1362 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1363 - CashPoolId: cashPoolFound.CashPoolId,  
1364 - Cash: cashPoolFound.Cash,  
1365 - ExchangedCash: systemExchangedCash, 1363 + CashPoolId: cashPoolFound.CashPoolId,
  1364 + Cash: cashPoolFound.Cash,
  1365 + ExchangedCash: systemExchangedCash,
1366 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate, 1366 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
1367 UnExchangeCash: unExchangeCash, 1367 UnExchangeCash: unExchangeCash,
1368 Rate: newRate, 1368 Rate: newRate,
1369 ExchangedSuMoney: systemExchangedSuMoney, 1369 ExchangedSuMoney: systemExchangedSuMoney,
1370 UnExchangeSuMoney: systemUnExchangeSuMoney, 1370 UnExchangeSuMoney: systemUnExchangeSuMoney,
1371 - LastRate: cashPoolFound.LastRate, 1371 + LastRate: cashPoolFound.LastRate,
1372 } 1372 }
1373 1373
1374 // 更新现金池 1374 // 更新现金池
@@ -1444,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1444,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1444 1444
1445 // 现金池仓储初始化 1445 // 现金池仓储初始化
1446 var cashPoolRepository domain.CashPoolRepository 1446 var cashPoolRepository domain.CashPoolRepository
1447 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1447 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
1448 "transactionContext": transactionContext, 1448 "transactionContext": transactionContext,
1449 }); err != nil { 1449 }); err != nil {
1450 return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1450 return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1506,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1506,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1506 failureDataList = append(failureDataList, row) 1506 failureDataList = append(failureDataList, row)
1507 continue 1507 continue
1508 } 1508 }
1509 - activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币  
1510 - activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币 1509 + activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币
  1510 + activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币
1511 1511
1512 // 获取当前公司现金池 1512 // 获取当前公司现金池
1513 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{ 1513 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
@@ -1533,13 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1533,13 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1533 failureDataList = append(failureDataList, row) 1533 failureDataList = append(failureDataList, row)
1534 continue 1534 continue
1535 } 1535 }
1536 - cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金  
1537 - cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金 1536 + cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
  1537 + cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
1538 1538
1539 - // 更改:根据uid和companyId,判断当前员工是否有效 1539 + // 更改:根据uid、account和companyId,判断当前员工是否有效(身份有效、手机账号有效)
1540 getEmployee := map[string]interface{}{ 1540 getEmployee := map[string]interface{}{
1541 - "uid": createExchangeCashPersonCommand.Uid,  
1542 - //"account": createExchangeCashPersonCommand.PersonAccount, 1541 + "uid": createExchangeCashPersonCommand.Uid,
  1542 + "account": createExchangeCashPersonCommand.PersonAccount,
1543 "companyId": activityFound.CompanyId, 1543 "companyId": activityFound.CompanyId,
1544 } 1544 }
1545 employeeFound, err := employeeRepository.FindOne(getEmployee) 1545 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -1563,15 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1563,15 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1563 failureDataList = append(failureDataList, row) 1563 failureDataList = append(failureDataList, row)
1564 continue 1564 continue
1565 } 1565 }
1566 - employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值 1566 + employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
1567 1567
1568 - // 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中, 1568 + // 更改:根据uid、employeeAccount和activityId判断当前员工是否已经在素币兑换清单中,
1569 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{ 1569 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
1570 - "uid": employeeFound.EmployeeInfo.Uid,  
1571 - //"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,  
1572 - "activityId": activityFound.ActivityId, 1570 + "uid": employeeFound.EmployeeInfo.Uid,
  1571 + "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
  1572 + "activityId": activityFound.ActivityId,
1573 }) 1573 })
1574 - if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单 1574 + if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
1575 // 判断该员工兑换的素币是否超过本人持有的素币 1575 // 判断该员工兑换的素币是否超过本人持有的素币
1576 if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney { 1576 if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney {
1577 row := []interface{}{ 1577 row := []interface{}{
@@ -1594,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1594,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1594 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount, 1594 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
1595 }, 1595 },
1596 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, 1596 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
1597 - ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
1598 - ExchangedCash: newPersonExchangedCash, 1597 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  1598 + ExchangedCash: newPersonExchangedCash,
1599 } 1599 }
1600 personSaved, err := exchangeCashPersonListRepository.Save(newPerson) 1600 personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
1601 if err != nil { 1601 if err != nil {
@@ -1620,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1620,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1620 } 1620 }
1621 1621
1622 // 操作素币,生成素币流水 1622 // 操作素币,生成素币流水
1623 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 1623 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
1624 Uid: employeeFound.EmployeeInfo.Uid, 1624 Uid: employeeFound.EmployeeInfo.Uid,
1625 Operator: createExchangeCashPersonCommand.Operator, 1625 Operator: createExchangeCashPersonCommand.Operator,
1626 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, 1626 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
1627 - OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1627 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
1628 OperationDescription: "参与" + activityFound.ExchangeActivityName, 1628 OperationDescription: "参与" + activityFound.ExchangeActivityName,
1629 } 1629 }
1630 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1630 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -1652,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1652,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1652 // 更新兑换活动 1652 // 更新兑换活动
1653 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64() 1653 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
1654 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64() 1654 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
1655 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1655 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1656 ExchangeCashActivityId: personSaved.ExchangeCashActivityId, 1656 ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
1657 ExchangeActivityName: activityFound.ExchangeActivityName, 1657 ExchangeActivityName: activityFound.ExchangeActivityName,
1658 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney, 1658 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
1659 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate, 1659 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
1660 - ExchangedSuMoney: exchangedSuMoney,  
1661 - ExchangedCash: exchangedCash,  
1662 - Deadline: activityFound.Deadline,  
1663 - CountDown: activityFound.CountDown,  
1664 - ExchangeRate: activityFound.Rate, 1660 + ExchangedSuMoney: exchangedSuMoney,
  1661 + ExchangedCash: exchangedCash,
  1662 + Deadline: activityFound.Deadline,
  1663 + CountDown: activityFound.CountDown,
  1664 + ExchangeRate: activityFound.Rate,
1665 } 1665 }
1666 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1666 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1667 row := []interface{}{ 1667 row := []interface{}{
@@ -1696,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1696,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1696 } 1696 }
1697 1697
1698 // 判断是否超过平台未兑换现金 1698 // 判断是否超过平台未兑换现金
1699 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash { 1699 + if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
1700 row := []interface{}{ 1700 row := []interface{}{
1701 createExchangeCashPersonCommand.PersonName, 1701 createExchangeCashPersonCommand.PersonName,
1702 createExchangeCashPersonCommand.PersonAccount, 1702 createExchangeCashPersonCommand.PersonAccount,
@@ -1730,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1730,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1730 continue 1730 continue
1731 } 1731 }
1732 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币 1732 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
1733 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币 1733 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1734 1734
1735 // 更新现金池 1735 // 更新现金池
1736 var newRate float64 1736 var newRate float64
@@ -1740,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1740,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1740 //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney 1740 //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
1741 newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64() 1741 newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
1742 } 1742 }
1743 - newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()  
1744 - unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64() 1743 + newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
  1744 + unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
1745 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1745 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1746 - CashPoolId: cashPoolFound.CashPoolId,  
1747 - Cash: cashPoolFound.Cash, 1746 + CashPoolId: cashPoolFound.CashPoolId,
  1747 + Cash: cashPoolFound.Cash,
1748 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash, 1748 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
1749 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash, 1749 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
1750 - ExchangedCash: newExchangedCash, 1750 + ExchangedCash: newExchangedCash,
1751 UnExchangeCash: unExchangeCash, 1751 UnExchangeCash: unExchangeCash,
1752 ExchangedSuMoney: systemExchangedSuMoney, 1752 ExchangedSuMoney: systemExchangedSuMoney,
1753 UnExchangeSuMoney: systemUnExchangeSuMoney, 1753 UnExchangeSuMoney: systemUnExchangeSuMoney,
1754 Rate: newRate, 1754 Rate: newRate,
1755 - LastRate: cashPoolFound.LastRate, 1755 + LastRate: cashPoolFound.LastRate,
1756 } 1756 }
1757 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1757 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1758 row := []interface{}{ 1758 row := []interface{}{
@@ -1785,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1785,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1785 failureDataList = append(failureDataList, row) 1785 failureDataList = append(failureDataList, row)
1786 continue 1786 continue
1787 } 1787 }
1788 - } else { // 当前人员存在兑换素币清单中  
1789 - personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币  
1790 - personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金  
1791 - if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币 1788 + } else { // 当前人员存在兑换素币清单中
  1789 + personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币
  1790 + personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
  1791 + if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
1792 // 素币减量 1792 // 素币减量
1793 //suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney 1793 //suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
1794 suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64() 1794 suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
@@ -1799,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1799,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1799 1799
1800 // 更新兑换素币清单 1800 // 更新兑换素币清单
1801 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64() 1801 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
1802 - exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1802 + exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1803 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{ 1803 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
1804 - ListId: personFound.ListId, 1804 + ListId: personFound.ListId,
1805 //ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement, 1805 //ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
1806 //ExchangedCash: personFoundExchangedCash - cashDecrement, 1806 //ExchangedCash: personFoundExchangedCash - cashDecrement,
1807 ExchangedSuMoney: exchangedSuMoney, 1807 ExchangedSuMoney: exchangedSuMoney,
1808 - ExchangedCash: exchangedCash,  
1809 - Operator: createExchangeCashPersonCommand.Operator, 1808 + ExchangedCash: exchangedCash,
  1809 + Operator: createExchangeCashPersonCommand.Operator,
1810 } 1810 }
1811 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1811 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1812 row := []interface{}{ 1812 row := []interface{}{
@@ -1841,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1841,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1841 } 1841 }
1842 1842
1843 // 更新素币兑换活动 1843 // 更新素币兑换活动
1844 - newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64() 1844 + newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
1845 newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1845 newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1846 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1846 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1847 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 1847 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
1848 //ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement, 1848 //ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
1849 //ExchangedCash: activityFoundExchangedCash - cashDecrement, 1849 //ExchangedCash: activityFoundExchangedCash - cashDecrement,
1850 - ExchangedSuMoney: newExchangedSuMoney,  
1851 - ExchangedCash: newExchangedCash,  
1852 - Deadline: activityFound.Deadline,  
1853 - CountDown: activityFound.CountDown,  
1854 - ExchangeRate: activityFound.Rate, 1850 + ExchangedSuMoney: newExchangedSuMoney,
  1851 + ExchangedCash: newExchangedCash,
  1852 + Deadline: activityFound.Deadline,
  1853 + CountDown: activityFound.CountDown,
  1854 + ExchangeRate: activityFound.Rate,
1855 } 1855 }
1856 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1856 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1857 row := []interface{}{ 1857 row := []interface{}{
@@ -1890,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1890,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1890 Uid: employeeFound.EmployeeInfo.Uid, 1890 Uid: employeeFound.EmployeeInfo.Uid,
1891 Operator: createExchangeCashPersonCommand.Operator, 1891 Operator: createExchangeCashPersonCommand.Operator,
1892 SuMoney: suMoneyDecrement, 1892 SuMoney: suMoneyDecrement,
1893 - OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1893 + OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
1894 OperationDescription: activityFound.ExchangeActivityName + "调整", 1894 OperationDescription: activityFound.ExchangeActivityName + "调整",
1895 } 1895 }
1896 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1896 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -1938,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1938,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1938 continue 1938 continue
1939 } 1939 }
1940 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币 1940 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
1941 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币 1941 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1942 1942
1943 // 更新现金池 1943 // 更新现金池
1944 var newRate float64 1944 var newRate float64
@@ -1951,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1951,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1951 cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1951 cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1952 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64() 1952 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64()
1953 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1953 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1954 - CashPoolId: cashPoolFound.CashPoolId,  
1955 - Cash: cashPoolFound.Cash, 1954 + CashPoolId: cashPoolFound.CashPoolId,
  1955 + Cash: cashPoolFound.Cash,
1956 //ExchangedCash: cashPoolFoundExchangedCash - cashDecrement, 1956 //ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
1957 //UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement, 1957 //UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
1958 ExchangedCash: cashPoolExchangedCash, 1958 ExchangedCash: cashPoolExchangedCash,
@@ -1960,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1960,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1960 ExchangedSuMoney: systemExchangedSuMoney, 1960 ExchangedSuMoney: systemExchangedSuMoney,
1961 UnExchangeSuMoney: systemUnExchangeSuMoney, 1961 UnExchangeSuMoney: systemUnExchangeSuMoney,
1962 Rate: newRate, 1962 Rate: newRate,
1963 - LastRate: cashPoolFound.LastRate, 1963 + LastRate: cashPoolFound.LastRate,
1964 } 1964 }
1965 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1965 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1966 row := []interface{}{ 1966 row := []interface{}{
@@ -1993,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1993,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1993 failureDataList = append(failureDataList, row) 1993 failureDataList = append(failureDataList, row)
1994 continue 1994 continue
1995 } 1995 }
1996 - } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币 1996 + } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
1997 // 素币增量 1997 // 素币增量
1998 //suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney 1998 //suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
1999 suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 1999 suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
@@ -2017,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2017,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2017 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64() 2017 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
2018 exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64() 2018 exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
2019 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{ 2019 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
2020 - ListId: personFound.ListId, 2020 + ListId: personFound.ListId,
2021 //ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement, 2021 //ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
2022 //ExchangedCash: personFoundExchangedCash + cashIncrement, 2022 //ExchangedCash: personFoundExchangedCash + cashIncrement,
2023 ExchangedSuMoney: exchangedSuMoney, 2023 ExchangedSuMoney: exchangedSuMoney,
2024 - ExchangedCash: exchangedCash,  
2025 - Operator: createExchangeCashPersonCommand.Operator, 2024 + ExchangedCash: exchangedCash,
  2025 + Operator: createExchangeCashPersonCommand.Operator,
2026 } 2026 }
2027 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 2027 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
2028 row := []interface{}{ 2028 row := []interface{}{
@@ -2063,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2063,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2063 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 2063 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
2064 //ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement, 2064 //ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
2065 //ExchangedCash: activityFoundExchangedCash + cashIncrement, 2065 //ExchangedCash: activityFoundExchangedCash + cashIncrement,
2066 - ExchangedSuMoney: newExchangedSuMoney,  
2067 - ExchangedCash: newExchangedCash,  
2068 - Deadline: activityFound.Deadline,  
2069 - CountDown: activityFound.CountDown,  
2070 - ExchangeRate: activityFound.Rate, 2066 + ExchangedSuMoney: newExchangedSuMoney,
  2067 + ExchangedCash: newExchangedCash,
  2068 + Deadline: activityFound.Deadline,
  2069 + CountDown: activityFound.CountDown,
  2070 + ExchangeRate: activityFound.Rate,
2071 } 2071 }
2072 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 2072 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
2073 row := []interface{}{ 2073 row := []interface{}{
@@ -2106,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2106,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2106 Uid: employeeFound.EmployeeInfo.Uid, 2106 Uid: employeeFound.EmployeeInfo.Uid,
2107 Operator: createExchangeCashPersonCommand.Operator, 2107 Operator: createExchangeCashPersonCommand.Operator,
2108 SuMoney: suMoneyIncrement, 2108 SuMoney: suMoneyIncrement,
2109 - OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 2109 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
2110 OperationDescription: activityFound.ExchangeActivityName + "调整", 2110 OperationDescription: activityFound.ExchangeActivityName + "调整",
2111 } 2111 }
2112 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 2112 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -2179,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2179,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2179 newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64() 2179 newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
2180 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64() 2180 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64()
2181 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2181 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2182 - CashPoolId: cashPoolFound.CashPoolId,  
2183 - Cash: cashPoolFound.Cash, 2182 + CashPoolId: cashPoolFound.CashPoolId,
  2183 + Cash: cashPoolFound.Cash,
2184 //ExchangedCash: cashPoolFoundExchangedCash + cashIncrement, 2184 //ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
2185 //UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement, 2185 //UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
2186 ExchangedCash: newCashPoolExchangedCash, 2186 ExchangedCash: newCashPoolExchangedCash,
@@ -2188,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2188,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2188 ExchangedSuMoney: systemExchangedSuMoney, 2188 ExchangedSuMoney: systemExchangedSuMoney,
2189 UnExchangeSuMoney: systemUnExchangeSuMoney, 2189 UnExchangeSuMoney: systemUnExchangeSuMoney,
2190 Rate: newRate, 2190 Rate: newRate,
2191 - LastRate: cashPoolFound.LastRate, 2191 + LastRate: cashPoolFound.LastRate,
2192 } 2192 }
2193 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 2193 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
2194 row := []interface{}{ 2194 row := []interface{}{
@@ -2274,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2274,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2274 2274
2275 // 现金池仓储初始化 2275 // 现金池仓储初始化
2276 var cashPoolRepository domain.CashPoolRepository 2276 var cashPoolRepository domain.CashPoolRepository
2277 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 2277 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
2278 "transactionContext": transactionContext, 2278 "transactionContext": transactionContext,
2279 }); err != nil { 2279 }); err != nil {
2280 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2280 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -2322,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2322,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2322 2322
2323 // 判断当前员工是否有效 2323 // 判断当前员工是否有效
2324 getEmployee := map[string]interface{}{ 2324 getEmployee := map[string]interface{}{
2325 - "uid": createExchangeCashPersonCommand.Uid, 2325 + "uid": createExchangeCashPersonCommand.Uid,
2326 "companyId": activityFound.CompanyId, 2326 "companyId": activityFound.CompanyId,
2327 } 2327 }
2328 employeeFound, err := employeeRepository.FindOne(getEmployee) 2328 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -2337,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2337,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2337 // 判断当前员工是否已经存在兑换素币清单中 2337 // 判断当前员工是否已经存在兑换素币清单中
2338 if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{ 2338 if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
2339 "exchangeCashActivityId": activityFound.ActivityId, 2339 "exchangeCashActivityId": activityFound.ActivityId,
2340 - "uid": employeeFound.EmployeeInfo.Uid, 2340 + "uid": employeeFound.EmployeeInfo.Uid,
2341 }); err != nil { 2341 }); err != nil {
2342 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2342 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
2343 } else { 2343 } else {
@@ -2361,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2361,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2361 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount, 2361 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
2362 }, 2362 },
2363 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, 2363 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
2364 - ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
2365 - ExchangedCash: newPersonExchangedCash, 2364 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  2365 + ExchangedCash: newPersonExchangedCash,
2366 } 2366 }
2367 2367
2368 // 保存兑换素币清单 2368 // 保存兑换素币清单
@@ -2372,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2372,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2372 } 2372 }
2373 2373
2374 // 操作素币命令 2374 // 操作素币命令
2375 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 2375 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
2376 Uid: employeeFound.EmployeeInfo.Uid, 2376 Uid: employeeFound.EmployeeInfo.Uid,
2377 Operator: createExchangeCashPersonCommand.Operator, 2377 Operator: createExchangeCashPersonCommand.Operator,
2378 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, 2378 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
@@ -2390,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2390,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2390 } 2390 }
2391 2391
2392 // 更新兑换活动命令 2392 // 更新兑换活动命令
2393 - exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()  
2394 - exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()  
2395 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 2393 + exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
  2394 + exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
  2395 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
2396 ExchangeCashActivityId: personSaved.ExchangeCashActivityId, 2396 ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
2397 ExchangeActivityName: activityFound.ExchangeActivityName, 2397 ExchangeActivityName: activityFound.ExchangeActivityName,
2398 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney, 2398 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
2399 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate, 2399 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
2400 - ExchangedSuMoney: exchangedSuMoney,  
2401 - ExchangedCash: exchangedCash,  
2402 - Deadline: activityFound.Deadline,  
2403 - CountDown: activityFound.CountDown,  
2404 - ExchangeRate: activityFound.Rate, 2400 + ExchangedSuMoney: exchangedSuMoney,
  2401 + ExchangedCash: exchangedCash,
  2402 + Deadline: activityFound.Deadline,
  2403 + CountDown: activityFound.CountDown,
  2404 + ExchangeRate: activityFound.Rate,
2405 } 2405 }
2406 2406
2407 // 更新兑换活动 2407 // 更新兑换活动
@@ -2432,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2432,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2432 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash 2432 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
2433 2433
2434 // 判断是否超过平台未兑换现金 2434 // 判断是否超过平台未兑换现金
2435 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash { 2435 + if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
2436 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 2436 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
2437 } 2437 }
2438 2438
@@ -2457,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2457,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2457 } 2457 }
2458 2458
2459 // 更新现金池命令 2459 // 更新现金池命令
2460 - newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()  
2461 - unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64() 2460 + newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
  2461 + unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
2462 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2462 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2463 - CashPoolId: cashPoolsFound[0].CashPoolId,  
2464 - Cash: cashPoolsFound[0].Cash, 2463 + CashPoolId: cashPoolsFound[0].CashPoolId,
  2464 + Cash: cashPoolsFound[0].Cash,
2465 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash, 2465 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
2466 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash, 2466 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
2467 ExchangedCash: newCashPoolExchangedCash, 2467 ExchangedCash: newCashPoolExchangedCash,
@@ -2469,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2469,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2469 ExchangedSuMoney: systemExchangedSuMoney, 2469 ExchangedSuMoney: systemExchangedSuMoney,
2470 UnExchangeSuMoney: systemUnExchangeSuMoney, 2470 UnExchangeSuMoney: systemUnExchangeSuMoney,
2471 Rate: newRate, 2471 Rate: newRate,
2472 - LastRate: cashPoolsFound[0].LastRate, 2472 + LastRate: cashPoolsFound[0].LastRate,
2473 } 2473 }
2474 2474
2475 // 更新现金池 2475 // 更新现金池
@@ -2592,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2592,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2592 // 获取该公司活动下所有兑换员工 2592 // 获取该公司活动下所有兑换员工
2593 if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{ 2593 if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{
2594 "exchangeCashActivityIds": activityIds, 2594 "exchangeCashActivityIds": activityIds,
2595 - "offset": listExchangeCashPersonQuery.Offset,  
2596 - "limit": listExchangeCashPersonQuery.Limit, 2595 + "offset": listExchangeCashPersonQuery.Offset,
  2596 + "limit": listExchangeCashPersonQuery.Limit,
2597 }); err != nil { 2597 }); err != nil {
2598 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2598 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
2599 } else { 2599 } else {
@@ -2605,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2605,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2605 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64() 2605 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
2606 } 2606 }
2607 return map[string]interface{}{ 2607 return map[string]interface{}{
2608 - "count": count,  
2609 - "people": people, 2608 + "count": count,
  2609 + "people": people,
2610 }, nil 2610 }, nil
2611 } 2611 }
2612 } 2612 }
@@ -2623,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2623,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2623 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64() 2623 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
2624 } 2624 }
2625 return map[string]interface{}{ 2625 return map[string]interface{}{
2626 - "count": count,  
2627 - "people": people, 2626 + "count": count,
  2627 + "people": people,
2628 }, nil 2628 }, nil
2629 } 2629 }
2630 } 2630 }
@@ -2668,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2668,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2668 2668
2669 // 现金池仓储初始化 2669 // 现金池仓储初始化
2670 var cashPoolRepository domain.CashPoolRepository 2670 var cashPoolRepository domain.CashPoolRepository
2671 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 2671 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
2672 "transactionContext": transactionContext, 2672 "transactionContext": transactionContext,
2673 }); err != nil { 2673 }); err != nil {
2674 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2674 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -2735,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2735,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2735 2735
2736 // 判断当前员工是否有效 2736 // 判断当前员工是否有效
2737 getEmployee := map[string]interface{}{ 2737 getEmployee := map[string]interface{}{
2738 - "uid": personFound.EmployeeInfo.Uid, 2738 + "uid": personFound.EmployeeInfo.Uid,
2739 "companyId": activityFound.CompanyId, 2739 "companyId": activityFound.CompanyId,
2740 } 2740 }
2741 employeeFound, err := employeeRepository.FindOne(getEmployee) 2741 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -2748,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2748,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2748 2748
2749 // 更新兑换素币活动命令 2749 // 更新兑换素币活动命令
2750 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 2750 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
2751 - exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()  
2752 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 2751 + exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
  2752 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
2753 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 2753 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
2754 //ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney, 2754 //ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
2755 //ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash, 2755 //ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
2756 - ExchangedSuMoney: exchangedSuMoney,  
2757 - ExchangedCash: exchangedCash,  
2758 - Deadline: activityFound.Deadline,  
2759 - CountDown: activityFound.CountDown,  
2760 - ExchangeRate: activityFound.Rate, 2756 + ExchangedSuMoney: exchangedSuMoney,
  2757 + ExchangedCash: exchangedCash,
  2758 + Deadline: activityFound.Deadline,
  2759 + CountDown: activityFound.CountDown,
  2760 + ExchangeRate: activityFound.Rate,
2761 } 2761 }
2762 2762
2763 // 更新兑换活动 2763 // 更新兑换活动
@@ -2775,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2775,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2775 } 2775 }
2776 2776
2777 // 操作素币命令 2777 // 操作素币命令
2778 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 2778 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
2779 Uid: personFound.EmployeeInfo.Uid, 2779 Uid: personFound.EmployeeInfo.Uid,
2780 Operator: removeExchangeCashPersonCommand.Operator, 2780 Operator: removeExchangeCashPersonCommand.Operator,
2781 SuMoney: personFoundExchangedSuMoney, 2781 SuMoney: personFoundExchangedSuMoney,
2782 - OperationType: 41, // 删除兑换素币清单,撤回已兑换素币 2782 + OperationType: 41, // 删除兑换素币清单,撤回已兑换素币
2783 OperationDescription: activityFound.ExchangeActivityName + "调整", 2783 OperationDescription: activityFound.ExchangeActivityName + "调整",
2784 } 2784 }
2785 2785
@@ -2827,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2827,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2827 } 2827 }
2828 2828
2829 // 更新现金池命令 2829 // 更新现金池命令
2830 - newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()  
2831 - UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64() 2830 + newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
  2831 + UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
2832 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2832 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2833 - CashPoolId: cashPoolsFound[0].CashPoolId,  
2834 - Cash: cashPoolsFound[0].Cash,  
2835 - LastRate: cashPoolsFound[0].LastRate, 2833 + CashPoolId: cashPoolsFound[0].CashPoolId,
  2834 + Cash: cashPoolsFound[0].Cash,
  2835 + LastRate: cashPoolsFound[0].LastRate,
2836 //ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash, 2836 //ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
2837 //UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash, 2837 //UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
2838 ExchangedCash: newExchangedCash, 2838 ExchangedCash: newExchangedCash,
@@ -3002,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ @@ -3002,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ
3002 } 3002 }
3003 3003
3004 // 兑换素币清单排行榜 3004 // 兑换素币清单排行榜
3005 - for i, _ := range exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int}) {  
3006 - uid := exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].Uid 3005 + for i, _ := range exchangeCashListRankingStatistics["people"].([]struct {
  3006 + Uid int64
  3007 + EmployeeName string
  3008 + SuMoney float64
  3009 + Cash float64
  3010 + Ranking int
  3011 + }) {
  3012 + uid := exchangeCashListRankingStatistics["people"].([]struct {
  3013 + Uid int64
  3014 + EmployeeName string
  3015 + SuMoney float64
  3016 + Cash float64
  3017 + Ranking int
  3018 + })[i].Uid
3007 if uidName[uid] != nil { 3019 if uidName[uid] != nil {
3008 - exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].EmployeeName = uidName[uid].(string) 3020 + exchangeCashListRankingStatistics["people"].([]struct {
  3021 + Uid int64
  3022 + EmployeeName string
  3023 + SuMoney float64
  3024 + Cash float64
  3025 + Ranking int
  3026 + })[i].EmployeeName = uidName[uid].(string)
3009 } 3027 }
3010 } 3028 }
3011 3029
3012 // 个人素币兑换清单 3030 // 个人素币兑换清单
3013 if exchangeCashListRankingStatistics["currentEmployee"] != nil { 3031 if exchangeCashListRankingStatistics["currentEmployee"] != nil {
3014 - currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int})  
3015 - uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int}).Uid 3032 + currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
  3033 + Uid int64
  3034 + EmployeeName string
  3035 + SuMoney float64
  3036 + Cash float64
  3037 + Ranking int
  3038 + })
  3039 + uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
  3040 + Uid int64
  3041 + EmployeeName string
  3042 + SuMoney float64
  3043 + Cash float64
  3044 + Ranking int
  3045 + }).Uid
3016 if uidName[uidExchangeCashList] != nil { 3046 if uidName[uidExchangeCashList] != nil {
3017 currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string) 3047 currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
3018 } 3048 }