|
@@ -358,18 +358,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
|
@@ -358,18 +358,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivityDeadline(listExc |
358
|
for _, activity := range activities {
|
358
|
for _, activity := range activities {
|
359
|
deadlines = append(deadlines, activity.Deadline.Format("2006-01-02"))
|
359
|
deadlines = append(deadlines, activity.Deadline.Format("2006-01-02"))
|
360
|
}
|
360
|
}
|
361
|
-
|
|
|
362
|
if len(deadlines) == 0 {
|
361
|
if len(deadlines) == 0 {
|
363
|
deadlines = []interface{}{}
|
362
|
deadlines = []interface{}{}
|
364
|
}
|
363
|
}
|
365
|
-
|
|
|
366
|
return map[string]interface{}{
|
364
|
return map[string]interface{}{
|
367
|
"deadlines": deadlines,
|
365
|
"deadlines": deadlines,
|
368
|
}, nil
|
366
|
}, nil
|
369
|
}
|
367
|
}
|
370
|
}
|
368
|
}
|
371
|
|
369
|
|
372
|
-// 搜索兑换现金活动
|
370
|
+// 搜索兑换现金活动 for PC
|
373
|
func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityCommand *command.SearchExchangeCashActivityCommand) (interface{}, error) {
|
371
|
func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityCommand *command.SearchExchangeCashActivityCommand) (interface{}, error) {
|
374
|
if err := activityCommand.ValidateCommand(); err != nil {
|
372
|
if err := activityCommand.ValidateCommand(); err != nil {
|
375
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
373
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -434,7 +432,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -434,7 +432,6 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
434
|
if err := transactionContext.CommitTransaction(); err != nil {
|
432
|
if err := transactionContext.CommitTransaction(); err != nil {
|
435
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
433
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
436
|
}
|
434
|
}
|
437
|
-
|
|
|
438
|
return map[string]interface{}{
|
435
|
return map[string]interface{}{
|
439
|
"count": count,
|
436
|
"count": count,
|
440
|
"activities": activities,
|
437
|
"activities": activities,
|
|
@@ -442,7 +439,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -442,7 +439,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
442
|
}
|
439
|
}
|
443
|
}
|
440
|
}
|
444
|
|
441
|
|
445
|
-// 返回兑换现金活动列表
|
442
|
+// 返回兑换现金活动列表 for app
|
446
|
func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
|
443
|
func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
|
447
|
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
444
|
if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
|
448
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
445
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -476,7 +473,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -476,7 +473,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
476
|
var t1 = time.Now()
|
473
|
var t1 = time.Now()
|
477
|
var t2 = activity.Deadline
|
474
|
var t2 = activity.Deadline
|
478
|
|
475
|
|
479
|
- // 更新兑换现金活动命令
|
476
|
+ // 更新兑换现金活动倒计时命令
|
480
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
477
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
481
|
ExchangeCashActivityId: activity.ActivityId,
|
478
|
ExchangeCashActivityId: activity.ActivityId,
|
482
|
CountDown: int64(t2.Sub(t1).Hours() / 24), // 重新计算活动倒计时
|
479
|
CountDown: int64(t2.Sub(t1).Hours() / 24), // 重新计算活动倒计时
|
|
@@ -489,15 +486,14 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -489,15 +486,14 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
489
|
// 倒计时结束处理
|
486
|
// 倒计时结束处理
|
490
|
if t2.Before(t1) {
|
487
|
if t2.Before(t1) {
|
491
|
updateExchangeCashActivity.CountDown = 0
|
488
|
updateExchangeCashActivity.CountDown = 0
|
492
|
- updateExchangeCashActivity.Deadline = activity.Deadline
|
|
|
493
|
}
|
489
|
}
|
494
|
|
490
|
|
495
|
- // 更新兑换现金活动
|
491
|
+ // 更新兑换现金活动倒计时
|
496
|
if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
|
492
|
if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivity)); err != nil {
|
497
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
493
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
498
|
}
|
494
|
}
|
499
|
|
495
|
|
500
|
- // 保存兑换现金活动更新
|
496
|
+ // 保存兑换现金活动倒计时更新
|
501
|
_, err := exchangeActivityRepository.Save(activity)
|
497
|
_, err := exchangeActivityRepository.Save(activity)
|
502
|
if err != nil {
|
498
|
if err != nil {
|
503
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
499
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -524,7 +520,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
@@ -524,7 +520,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
524
|
}
|
520
|
}
|
525
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
521
|
activitiesWithTs = append(activitiesWithTs, activityWithTs)
|
526
|
}
|
522
|
}
|
527
|
-
|
|
|
528
|
return map[string]interface{}{
|
523
|
return map[string]interface{}{
|
529
|
"count": count,
|
524
|
"count": count,
|
530
|
"activities": activitiesWithTs,
|
525
|
"activities": activitiesWithTs,
|
|
@@ -699,14 +694,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -699,14 +694,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
699
|
}
|
694
|
}
|
700
|
|
695
|
|
701
|
// 现金池DAO初始化
|
696
|
// 现金池DAO初始化
|
702
|
- var cashPoolDao *dao.CashPoolDao
|
|
|
703
|
- if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
704
|
- "transactionContext": transactionContext,
|
|
|
705
|
- }); err != nil {
|
|
|
706
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
707
|
- } else {
|
|
|
708
|
- cashPoolDao = value
|
|
|
709
|
- }
|
697
|
+ //var cashPoolDao *dao.CashPoolDao
|
|
|
698
|
+ //if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
699
|
+ // "transactionContext": transactionContext,
|
|
|
700
|
+ //}); err != nil {
|
|
|
701
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
702
|
+ //} else {
|
|
|
703
|
+ // cashPoolDao = value
|
|
|
704
|
+ //}
|
710
|
|
705
|
|
711
|
// 员工DAO初始化
|
706
|
// 员工DAO初始化
|
712
|
var employeeDao *dao.EmployeeDao
|
707
|
var employeeDao *dao.EmployeeDao
|
|
@@ -728,15 +723,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -728,15 +723,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
728
|
}
|
723
|
}
|
729
|
|
724
|
|
730
|
if updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
|
725
|
if updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
|
731
|
- //// 增大汇率
|
|
|
732
|
- //if updateExchangeCashActivityCommand.ExchangeRate > activityFound.Rate {
|
|
|
733
|
- //
|
|
|
734
|
- //}
|
|
|
735
|
- //
|
|
|
736
|
- //// 减小汇率
|
|
|
737
|
- //if updateExchangeCashActivityCommand.ExchangeRate < activityFound.Rate {
|
|
|
738
|
- //
|
|
|
739
|
- //}
|
|
|
740
|
// 获取当前公司现金池
|
726
|
// 获取当前公司现金池
|
741
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
727
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
742
|
"companyId": activityFound.CompanyId,
|
728
|
"companyId": activityFound.CompanyId,
|
|
@@ -749,18 +735,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -749,18 +735,18 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
749
|
}
|
735
|
}
|
750
|
|
736
|
|
751
|
// 获取活动素币统计
|
737
|
// 获取活动素币统计
|
752
|
- activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.ActivityId)
|
|
|
753
|
- if err != nil {
|
|
|
754
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
755
|
- }
|
|
|
756
|
- if activitySuMoneyStatistics == nil {
|
|
|
757
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业")
|
|
|
758
|
- }
|
|
|
759
|
- activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
738
|
+ //activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.ActivityId)
|
|
|
739
|
+ //if err != nil {
|
|
|
740
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
741
|
+ //}
|
|
|
742
|
+ //if activitySuMoneyStatistics == nil {
|
|
|
743
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业")
|
|
|
744
|
+ //}
|
|
|
745
|
+ //activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
760
|
|
746
|
|
761
|
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
|
747
|
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
|
762
|
- if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
|
|
763
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
748
|
+ if activityFound.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
|
|
749
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
764
|
}
|
750
|
}
|
765
|
|
751
|
|
766
|
// 获取该活动所有兑换清单
|
752
|
// 获取该活动所有兑换清单
|
|
@@ -776,9 +762,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -776,9 +762,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
776
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
762
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
777
|
|
763
|
|
778
|
// 更新兑换清单命令
|
764
|
// 更新兑换清单命令
|
779
|
- updateExchangeCashActivityExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney), 64)
|
765
|
+ //updateExchangeCashActivityExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney), 64)
|
780
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
766
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
781
|
- ExchangedCash: updateExchangeCashActivityExchangedCash,
|
767
|
+ ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
782
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
768
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
783
|
}
|
769
|
}
|
784
|
|
770
|
|
|
@@ -805,32 +791,32 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -805,32 +791,32 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
805
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
791
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
806
|
|
792
|
|
807
|
// 获取平台现金状况
|
793
|
// 获取平台现金状况
|
808
|
- systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
|
|
809
|
- if err != nil {
|
|
|
810
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
811
|
- }
|
|
|
812
|
- if systemCashStatistics == nil {
|
|
|
813
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
814
|
- }
|
|
|
815
|
- systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
|
|
|
816
|
- systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
794
|
+ //systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
|
|
795
|
+ //if err != nil {
|
|
|
796
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
797
|
+ //}
|
|
|
798
|
+ //if systemCashStatistics == nil {
|
|
|
799
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
800
|
+ //}
|
|
|
801
|
+ //systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
|
|
|
802
|
+ //systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
817
|
|
803
|
|
818
|
// 更新兑换活动命令已兑换现金
|
804
|
// 更新兑换活动命令已兑换现金
|
819
|
- updateExchangeCashActivityCommand.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashActivityCommand.ExchangeRate * activityFound.ExchangedSuMoney), 64)
|
805
|
+ updateExchangeCashActivityCommand.ExchangedCash = updateExchangeCashActivityCommand.ExchangeRate * activityFound.ExchangedSuMoney
|
820
|
|
806
|
|
821
|
// 计算平均兑换汇率
|
807
|
// 计算平均兑换汇率
|
822
|
var rate float64
|
808
|
var rate float64
|
823
|
if systemExchangedSuMoney == 0 {
|
809
|
if systemExchangedSuMoney == 0 {
|
824
|
rate = 0
|
810
|
rate = 0
|
825
|
} else {
|
811
|
} else {
|
826
|
- rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (systemExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash)) / systemExchangedSuMoney), 64)
|
812
|
+ rate = (cashPoolsFound[0].ExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash)) / systemExchangedSuMoney
|
827
|
}
|
813
|
}
|
828
|
|
814
|
|
829
|
// 更新现金池命令
|
815
|
// 更新现金池命令
|
830
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
816
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
831
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
817
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
832
|
- ExchangedCash: systemExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash),
|
|
|
833
|
- UnExchangeCash: systemUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash) ,
|
818
|
+ ExchangedCash: cashPoolsFound[0].ExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash),
|
|
|
819
|
+ UnExchangeCash: cashPoolsFound[0].UnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFound.ExchangedCash) ,
|
834
|
ExchangedSuMoney: systemExchangedSuMoney,
|
820
|
ExchangedSuMoney: systemExchangedSuMoney,
|
835
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
821
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
836
|
Rate: rate,
|
822
|
Rate: rate,
|
|
@@ -865,7 +851,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -865,7 +851,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
865
|
}
|
851
|
}
|
866
|
|
852
|
|
867
|
// 更新兑换活动命令已兑换素币
|
853
|
// 更新兑换活动命令已兑换素币
|
868
|
- updateExchangeCashActivityCommand.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
854
|
+ updateExchangeCashActivityCommand.ExchangedSuMoney = activityFound.ExchangedSuMoney
|
869
|
|
855
|
|
870
|
// 更新兑换活动
|
856
|
// 更新兑换活动
|
871
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
857
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
|
@@ -939,15 +925,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -939,15 +925,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
939
|
employeeRepository = value
|
925
|
employeeRepository = value
|
940
|
}
|
926
|
}
|
941
|
|
927
|
|
942
|
- // 现金池DAO初始化
|
|
|
943
|
- var cashPoolDao *dao.CashPoolDao
|
|
|
944
|
- if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
945
|
- "transactionContext": transactionContext,
|
|
|
946
|
- }); err != nil {
|
|
|
947
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
948
|
- } else {
|
|
|
949
|
- cashPoolDao = value
|
|
|
950
|
- }
|
928
|
+ //// 现金池DAO初始化
|
|
|
929
|
+ //var cashPoolDao *dao.CashPoolDao
|
|
|
930
|
+ //if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
931
|
+ // "transactionContext": transactionContext,
|
|
|
932
|
+ //}); err != nil {
|
|
|
933
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
934
|
+ //} else {
|
|
|
935
|
+ // cashPoolDao = value
|
|
|
936
|
+ //}
|
951
|
|
937
|
|
952
|
// 员工DAO初始化
|
938
|
// 员工DAO初始化
|
953
|
var employeeDao *dao.EmployeeDao
|
939
|
var employeeDao *dao.EmployeeDao
|
|
@@ -1003,9 +989,19 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1003,9 +989,19 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1003
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
989
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
1004
|
}
|
990
|
}
|
1005
|
|
991
|
|
1006
|
- newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
992
|
+ // 判断当前员工是否已经在素币兑换清单中
|
|
|
993
|
+ employeeExist, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
|
|
|
994
|
+ "uid": employeeFound.EmployeeInfo.Uid,
|
|
|
995
|
+ })
|
|
|
996
|
+ if err != nil {
|
|
|
997
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
998
|
+ }
|
|
|
999
|
+ if employeeExist != nil {
|
|
|
1000
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前员工已经在素币兑换清单中")
|
|
|
1001
|
+ }
|
1007
|
|
1002
|
|
1008
|
// 新增兑换清单命令
|
1003
|
// 新增兑换清单命令
|
|
|
1004
|
+ newPersonExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
1009
|
newPerson := &domain.ExchangeCashPersonList{
|
1005
|
newPerson := &domain.ExchangeCashPersonList{
|
1010
|
EmployeeInfo: &domain.EmployeeInfo{
|
1006
|
EmployeeInfo: &domain.EmployeeInfo{
|
1011
|
Uid: employeeFound.EmployeeInfo.Uid,
|
1007
|
Uid: employeeFound.EmployeeInfo.Uid,
|
|
@@ -1041,14 +1037,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1041,14 +1037,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1041
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
1037
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
1042
|
}
|
1038
|
}
|
1043
|
|
1039
|
|
1044
|
- updateExchangeCashActivityExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
|
|
1045
|
-
|
|
|
1046
|
// 更新兑换活动命令
|
1040
|
// 更新兑换活动命令
|
1047
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1041
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1048
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1042
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
1049
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1043
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
1050
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1044
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
1051
|
- ExchangedCash: updateExchangeCashActivityExchangedCash,
|
1045
|
+ ExchangedCash: activityFound.ExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
1052
|
Deadline: activityFound.Deadline,
|
1046
|
Deadline: activityFound.Deadline,
|
1053
|
CountDown: activityFound.CountDown,
|
1047
|
CountDown: activityFound.CountDown,
|
1054
|
ExchangeRate: activityFound.Rate,
|
1048
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1069,14 +1063,14 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1069,14 +1063,14 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1069
|
}
|
1063
|
}
|
1070
|
|
1064
|
|
1071
|
// 获取兑换活动素币兑换情况
|
1065
|
// 获取兑换活动素币兑换情况
|
1072
|
- activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.ActivityId)
|
|
|
1073
|
- if err != nil {
|
|
|
1074
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1075
|
- }
|
|
|
1076
|
- if activitySuMoneyStatistics == nil {
|
|
|
1077
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业")
|
|
|
1078
|
- }
|
|
|
1079
|
- activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
1066
|
+ //activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.ActivityId)
|
|
|
1067
|
+ //if err != nil {
|
|
|
1068
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1069
|
+ //}
|
|
|
1070
|
+ //if activitySuMoneyStatistics == nil {
|
|
|
1071
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业")
|
|
|
1072
|
+ //}
|
|
|
1073
|
+ //activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
1080
|
|
1074
|
|
1081
|
// 获取当前现金池
|
1075
|
// 获取当前现金池
|
1082
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
1076
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
|
@@ -1090,7 +1084,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1090,7 +1084,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1090
|
}
|
1084
|
}
|
1091
|
|
1085
|
|
1092
|
// 判断兑换活动的现金是否超过现金池未兑换现金
|
1086
|
// 判断兑换活动的现金是否超过现金池未兑换现金
|
1093
|
- if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
1087
|
+ if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
1094
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
1088
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
1095
|
}
|
1089
|
}
|
1096
|
|
1090
|
|
|
@@ -1121,18 +1115,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1121,18 +1115,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1121
|
if systemExchangedSuMoney == 0 {
|
1115
|
if systemExchangedSuMoney == 0 {
|
1122
|
newRate = 0
|
1116
|
newRate = 0
|
1123
|
} else {
|
1117
|
} else {
|
1124
|
- newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney), 64)
|
1118
|
+ newRate = (cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
|
1125
|
}
|
1119
|
}
|
1126
|
|
1120
|
|
1127
|
- updateCashPoolExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash), 64)
|
|
|
1128
|
- updateCashPoolUnExchangeCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].UnExchangeCash - personSaved.ExchangedCash), 64)
|
|
|
1129
|
-
|
|
|
1130
|
// 更新现金池命令
|
1121
|
// 更新现金池命令
|
1131
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1122
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1132
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1123
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1133
|
Cash: cashPoolsFound[0].Cash,
|
1124
|
Cash: cashPoolsFound[0].Cash,
|
1134
|
- ExchangedCash: updateCashPoolExchangedCash,
|
|
|
1135
|
- UnExchangeCash: updateCashPoolUnExchangeCash,
|
1125
|
+ ExchangedCash: cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash,
|
|
|
1126
|
+ UnExchangeCash: cashPoolsFound[0].UnExchangeCash - personSaved.ExchangedCash,
|
1136
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1127
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1137
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1128
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1138
|
Rate: newRate,
|
1129
|
Rate: newRate,
|
|
@@ -1338,15 +1329,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1338,15 +1329,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1338
|
operationSuMoneyService = value
|
1329
|
operationSuMoneyService = value
|
1339
|
}
|
1330
|
}
|
1340
|
|
1331
|
|
1341
|
- // 现金池DAO初始化
|
|
|
1342
|
- var cashPoolDao *dao.CashPoolDao
|
|
|
1343
|
- if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
1344
|
- "transactionContext": transactionContext,
|
|
|
1345
|
- }); err != nil {
|
|
|
1346
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1347
|
- } else {
|
|
|
1348
|
- cashPoolDao = value
|
|
|
1349
|
- }
|
1332
|
+ //// 现金池DAO初始化
|
|
|
1333
|
+ //var cashPoolDao *dao.CashPoolDao
|
|
|
1334
|
+ //if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
1335
|
+ // "transactionContext": transactionContext,
|
|
|
1336
|
+ //}); err != nil {
|
|
|
1337
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1338
|
+ //} else {
|
|
|
1339
|
+ // cashPoolDao = value
|
|
|
1340
|
+ //}
|
1350
|
|
1341
|
|
1351
|
// 用户DAO初始化
|
1342
|
// 用户DAO初始化
|
1352
|
var employeeDao *dao.EmployeeDao
|
1343
|
var employeeDao *dao.EmployeeDao
|
|
@@ -1380,7 +1371,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1380,7 +1371,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1380
|
}
|
1371
|
}
|
1381
|
|
1372
|
|
1382
|
// 更新兑换清单,个人已兑换现金计算
|
1373
|
// 更新兑换清单,个人已兑换现金计算
|
1383
|
- updateExchangeCashPersonCommand.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate), 64)
|
1374
|
+ updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
1384
|
|
1375
|
|
1385
|
// 更新兑换素币清单
|
1376
|
// 更新兑换素币清单
|
1386
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
1377
|
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
|
|
@@ -1393,13 +1384,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1393,13 +1384,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1393
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1384
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1394
|
}
|
1385
|
}
|
1395
|
|
1386
|
|
1396
|
- updateActivityExchangeCash ,_ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
|
|
1397
|
-
|
|
|
1398
|
// 更新素币兑换活动命令
|
1387
|
// 更新素币兑换活动命令
|
1399
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1388
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
1400
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1389
|
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
|
1401
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1390
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
1402
|
- ExchangedCash: updateActivityExchangeCash,
|
1391
|
+ ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
|
1403
|
Deadline: activityFound.Deadline,
|
1392
|
Deadline: activityFound.Deadline,
|
1404
|
CountDown: activityFound.CountDown,
|
1393
|
CountDown: activityFound.CountDown,
|
1405
|
ExchangeRate: activityFound.Rate,
|
1394
|
ExchangeRate: activityFound.Rate,
|
|
@@ -1415,12 +1404,12 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1415,12 +1404,12 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1415
|
}
|
1404
|
}
|
1416
|
|
1405
|
|
1417
|
// 判断操作素币类型
|
1406
|
// 判断操作素币类型
|
1418
|
- if updateExchangeCashActivityCommand.ExchangedSuMoney - personUpdated.ExchangedSuMoney > 0 {
|
1407
|
+ if updateExchangeCashActivityCommand.ExchangedSuMoney - personFound.ExchangedSuMoney > 0 { // 追加素币兑换
|
1419
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1408
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1420
|
operationSuMoneyCommand.OperationType = 4
|
1409
|
operationSuMoneyCommand.OperationType = 4
|
1421
|
- } else {
|
1410
|
+ } else { // 撤回素币兑换
|
1422
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1411
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1423
|
- operationSuMoneyCommand.OperationType = 3
|
1412
|
+ operationSuMoneyCommand.OperationType = 41
|
1424
|
}
|
1413
|
}
|
1425
|
|
1414
|
|
1426
|
// 操作素币并生成素币流水
|
1415
|
// 操作素币并生成素币流水
|
|
@@ -1446,26 +1435,26 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1446,26 +1435,26 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1446
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
1435
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
|
1447
|
}
|
1436
|
}
|
1448
|
|
1437
|
|
1449
|
- // 统计活动已兑换素币
|
|
|
1450
|
- activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityUpdated.ActivityId)
|
|
|
1451
|
- if err != nil {
|
|
|
1452
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1453
|
- }
|
|
|
1454
|
- if activitySuMoneyStatistics == nil {
|
|
|
1455
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
1456
|
- }
|
|
|
1457
|
- activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
1438
|
+ //// 统计活动已兑换素币
|
|
|
1439
|
+ //activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityUpdated.ActivityId)
|
|
|
1440
|
+ //if err != nil {
|
|
|
1441
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1442
|
+ //}
|
|
|
1443
|
+ //if activitySuMoneyStatistics == nil {
|
|
|
1444
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
1445
|
+ //}
|
|
|
1446
|
+ //activitySuMoney := activitySuMoneyStatistics["activityExchangedSuMoney"].(float64)
|
1458
|
|
1447
|
|
1459
|
- // 统计平台现金兑换情况
|
|
|
1460
|
- systemCashStatistics, err := employeeDao.CalculateSystemCash(activityUpdated.CompanyId)
|
|
|
1461
|
- if err != nil {
|
|
|
1462
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1463
|
- }
|
|
|
1464
|
- if systemCashStatistics == nil {
|
|
|
1465
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
1466
|
- }
|
|
|
1467
|
- //systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
|
|
|
1468
|
- systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
1448
|
+ //// 统计平台现金兑换情况
|
|
|
1449
|
+ //systemCashStatistics, err := employeeDao.CalculateSystemCash(activityUpdated.CompanyId)
|
|
|
1450
|
+ //if err != nil {
|
|
|
1451
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1452
|
+ //}
|
|
|
1453
|
+ //if systemCashStatistics == nil {
|
|
|
1454
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
1455
|
+ //}
|
|
|
1456
|
+ ////systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
|
|
|
1457
|
+ //systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
|
1469
|
|
1458
|
|
1470
|
// 统计平台素币兑换状况
|
1459
|
// 统计平台素币兑换状况
|
1471
|
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityUpdated.CompanyId)
|
1460
|
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(activityUpdated.CompanyId)
|
|
@@ -1475,14 +1464,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1475,14 +1464,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1475
|
if systemSuMoneyStatistics == nil {
|
1464
|
if systemSuMoneyStatistics == nil {
|
1476
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
1465
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
1477
|
}
|
1466
|
}
|
1478
|
- //systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
|
1467
|
+ systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
|
1479
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
1468
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
1480
|
|
1469
|
|
1481
|
- // 判断是否超过平台未兑换现金
|
|
|
1482
|
- if activitySuMoney * activityUpdated.Rate > systemUnExchangeCash {
|
|
|
1483
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
|
|
1484
|
- }
|
|
|
1485
|
-
|
|
|
1486
|
// 获取当前现金池
|
1470
|
// 获取当前现金池
|
1487
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
1471
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
1488
|
"companyId": activityUpdated.CompanyId,
|
1472
|
"companyId": activityUpdated.CompanyId,
|
|
@@ -1494,25 +1478,28 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
@@ -1494,25 +1478,28 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
1494
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1478
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))
|
1495
|
}
|
1479
|
}
|
1496
|
|
1480
|
|
1497
|
- systemExchangedCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
|
|
1498
|
- systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1481
|
+ // 判断是否超过平台未兑换现金
|
|
|
1482
|
+ if activityUpdated.ExchangedSuMoney * activityUpdated.Rate > cashPoolsFound[0].UnExchangeCash {
|
|
|
1483
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
1484
|
+ }
|
|
|
1485
|
+
|
|
|
1486
|
+ systemExchangedCash := cashPoolsFound[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate
|
|
|
1487
|
+ //systemExchangedSuMoney := cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
|
1499
|
|
1488
|
|
1500
|
// 计算现金池平均兑换汇率
|
1489
|
// 计算现金池平均兑换汇率
|
1501
|
var newRate float64
|
1490
|
var newRate float64
|
1502
|
if systemExchangedSuMoney == 0 {
|
1491
|
if systemExchangedSuMoney == 0 {
|
1503
|
newRate = 0
|
1492
|
newRate = 0
|
1504
|
} else {
|
1493
|
} else {
|
1505
|
- newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemExchangedSuMoney), 64)
|
1494
|
+ newRate = systemExchangedCash / systemExchangedSuMoney
|
1506
|
}
|
1495
|
}
|
1507
|
|
1496
|
|
1508
|
- updateCashPoolUnExchangeCash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", cashPoolsFound[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate), 64)
|
|
|
1509
|
-
|
|
|
1510
|
// 更新现金池命令
|
1497
|
// 更新现金池命令
|
1511
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1498
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
1512
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1499
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
1513
|
Cash: cashPoolsFound[0].Cash,
|
1500
|
Cash: cashPoolsFound[0].Cash,
|
1514
|
ExchangedCash: systemExchangedCash,
|
1501
|
ExchangedCash: systemExchangedCash,
|
1515
|
- UnExchangeCash: updateCashPoolUnExchangeCash,
|
1502
|
+ UnExchangeCash: cashPoolsFound[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
|
1516
|
Rate: newRate,
|
1503
|
Rate: newRate,
|
1517
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1504
|
ExchangedSuMoney: systemExchangedSuMoney,
|
1518
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1505
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
@@ -1618,9 +1605,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -1618,9 +1605,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
1618
|
// 获取兑换清单员工已兑换素币
|
1605
|
// 获取兑换清单员工已兑换素币
|
1619
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
1606
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
1620
|
|
1607
|
|
1621
|
- // 删除兑换清单人员
|
|
|
1622
|
- personDeleted, err := exchangeCashPersonListRepository.Remove(personFound)
|
|
|
1623
|
-
|
|
|
1624
|
// 获取相关兑换活动
|
1608
|
// 获取相关兑换活动
|
1625
|
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
1609
|
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
1626
|
if err != nil {
|
1610
|
if err != nil {
|
|
@@ -1659,8 +1643,8 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -1659,8 +1643,8 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
1659
|
Uid: personFound.EmployeeInfo.Uid,
|
1643
|
Uid: personFound.EmployeeInfo.Uid,
|
1660
|
Operator: removeExchangeCashPersonCommand.Operator,
|
1644
|
Operator: removeExchangeCashPersonCommand.Operator,
|
1661
|
SuMoney: personFoundExchangedSuMoney,
|
1645
|
SuMoney: personFoundExchangedSuMoney,
|
1662
|
- OperationType: 1, // 增加素币
|
|
|
1663
|
- OperationDescription: activityFound.ExchangeActivityName + "素币调整",
|
1646
|
+ OperationType: 41, // 删除兑换素币清单,撤回已兑换素币
|
|
|
1647
|
+ OperationDescription: "删除兑换素币清单",
|
1664
|
}
|
1648
|
}
|
1665
|
|
1649
|
|
1666
|
// 操作素币,生成素币流水
|
1650
|
// 操作素币,生成素币流水
|
|
@@ -1710,7 +1694,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -1710,7 +1694,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
1710
|
if systemExchangedSuMoney == 0 {
|
1694
|
if systemExchangedSuMoney == 0 {
|
1711
|
newRate = 0
|
1695
|
newRate = 0
|
1712
|
} else {
|
1696
|
} else {
|
1713
|
- newRate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (cashPoolsFound[0].ExchangedCash - personFoundExchangedSuMoney) / systemExchangedSuMoney), 64)
|
1697
|
+ newRate = (cashPoolsFound[0].ExchangedCash - personFoundExchangedSuMoney) / systemExchangedSuMoney
|
1714
|
}
|
1698
|
}
|
1715
|
|
1699
|
|
1716
|
// 更新现金池命令
|
1700
|
// 更新现金池命令
|
|
@@ -1719,7 +1703,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -1719,7 +1703,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
1719
|
ExchangedCash: cashPoolsFound[0].ExchangedCash - personFoundExchangedSuMoney,
|
1703
|
ExchangedCash: cashPoolsFound[0].ExchangedCash - personFoundExchangedSuMoney,
|
1720
|
UnExchangeCash: cashPoolsFound[0].UnExchangeCash + personFoundExchangedSuMoney,
|
1704
|
UnExchangeCash: cashPoolsFound[0].UnExchangeCash + personFoundExchangedSuMoney,
|
1721
|
Rate: newRate,
|
1705
|
Rate: newRate,
|
1722
|
- ExchangedSuMoney: cashPoolsFound[0].ExchangedSuMoney - personFoundExchangedSuMoney,
|
1706
|
+ ExchangedSuMoney: systemExchangedSuMoney,
|
1723
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1707
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
1724
|
}
|
1708
|
}
|
1725
|
|
1709
|
|
|
@@ -1737,6 +1721,9 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
@@ -1737,6 +1721,9 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
1737
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1721
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1738
|
}
|
1722
|
}
|
1739
|
|
1723
|
|
|
|
1724
|
+ // 删除兑换清单人员
|
|
|
1725
|
+ personDeleted, err := exchangeCashPersonListRepository.Remove(personFound)
|
|
|
1726
|
+
|
1740
|
if err != nil {
|
1727
|
if err != nil {
|
1741
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1728
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1742
|
} else {
|
1729
|
} else {
|