|
@@ -302,12 +302,36 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -302,12 +302,36 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
302
|
exchangeCashActivityRepository = value
|
302
|
exchangeCashActivityRepository = value
|
303
|
}
|
303
|
}
|
304
|
|
304
|
|
|
|
305
|
+ // 兑换现金活动仓储初始化
|
|
|
306
|
+ var exchangeActivityRepository domain.ExchangeActivityRepository
|
|
|
307
|
+ if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
308
|
+ "transactionContext": transactionContext,
|
|
|
309
|
+ }); err != nil {
|
|
|
310
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
311
|
+ } else {
|
|
|
312
|
+ exchangeActivityRepository = value
|
|
|
313
|
+ }
|
|
|
314
|
+
|
305
|
// 时间格式化
|
315
|
// 时间格式化
|
306
|
- dd, _ := time.ParseDuration("24h")
|
|
|
307
|
- var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
|
316
|
+ //dd, _ := time.ParseDuration("24h")
|
|
|
317
|
+ //var deadline = createExchangeCashActivityCommand.Deadline.Add(dd)
|
|
|
318
|
+ var deadline = createExchangeCashActivityCommand.Deadline
|
308
|
var t1 = time.Now()
|
319
|
var t1 = time.Now()
|
309
|
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
320
|
var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
310
|
|
321
|
|
|
|
322
|
+ // 获取该公司所有兑换现金活动
|
|
|
323
|
+ if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
|
|
|
324
|
+ "companyId": createExchangeCashActivityCommand.CompanyId,
|
|
|
325
|
+ }); err != nil {
|
|
|
326
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
327
|
+ } else {
|
|
|
328
|
+ for _, activity := range activities {
|
|
|
329
|
+ if t2.Equal(activity.Deadline) {
|
|
|
330
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
|
|
|
331
|
+ }
|
|
|
332
|
+ }
|
|
|
333
|
+ }
|
|
|
334
|
+
|
311
|
// 创建兑换活动命令
|
335
|
// 创建兑换活动命令
|
312
|
newActivity := &domain.ExchangeCashActivity{
|
336
|
newActivity := &domain.ExchangeCashActivity{
|
313
|
ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
|
337
|
ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
|
|
@@ -332,6 +356,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
|
@@ -332,6 +356,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang |
332
|
if err := transactionContext.CommitTransaction(); err != nil {
|
356
|
if err := transactionContext.CommitTransaction(); err != nil {
|
333
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
357
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
334
|
}
|
358
|
}
|
|
|
359
|
+ activity.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
360
|
+ activity.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
335
|
return activity, nil
|
361
|
return activity, nil
|
336
|
}
|
362
|
}
|
337
|
}
|
363
|
}
|
|
@@ -454,12 +480,14 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
@@ -454,12 +480,14 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
454
|
|
480
|
|
455
|
var activitiesFormat []interface{}
|
481
|
var activitiesFormat []interface{}
|
456
|
for _, activity := range activities {
|
482
|
for _, activity := range activities {
|
|
|
483
|
+ cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
|
|
|
484
|
+ suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
457
|
activityFormat := map[string]interface{} {
|
485
|
activityFormat := map[string]interface{} {
|
458
|
"activityId": activity.ActivityId,
|
486
|
"activityId": activity.ActivityId,
|
459
|
"exchangeActivityName": activity.ExchangeActivityName,
|
487
|
"exchangeActivityName": activity.ExchangeActivityName,
|
460
|
"companyId": activity.CompanyId,
|
488
|
"companyId": activity.CompanyId,
|
461
|
- "exchangedCash": activity.ExchangedCash,
|
|
|
462
|
- "exchangedSuMoney": activity.ExchangedSuMoney,
|
489
|
+ "exchangedCash": cash,
|
|
|
490
|
+ "exchangedSuMoney": suMoney,
|
463
|
"deadline": activity.Deadline.UTC().Format("2006-01-02"),
|
491
|
"deadline": activity.Deadline.UTC().Format("2006-01-02"),
|
464
|
"countDown": activity.CountDown,
|
492
|
"countDown": activity.CountDown,
|
465
|
"rate": activity.Rate,
|
493
|
"rate": activity.Rate,
|
|
@@ -682,6 +710,8 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
@@ -682,6 +710,8 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
682
|
if err := transactionContext.CommitTransaction(); err != nil {
|
710
|
if err := transactionContext.CommitTransaction(); err != nil {
|
683
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
711
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
684
|
}
|
712
|
}
|
|
|
713
|
+ activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
714
|
+ activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
685
|
return activityUpdated, nil
|
715
|
return activityUpdated, nil
|
686
|
}
|
716
|
}
|
687
|
}
|
717
|
}
|
|
@@ -872,6 +902,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
@@ -872,6 +902,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
872
|
if err := transactionContext.CommitTransaction(); err != nil {
|
902
|
if err := transactionContext.CommitTransaction(); err != nil {
|
873
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
903
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
874
|
}
|
904
|
}
|
|
|
905
|
+ activityUpdated.ExchangedSuMoney, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedSuMoney), 64)
|
|
|
906
|
+ activityUpdated.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", activityUpdated.ExchangedCash), 64)
|
875
|
return activityUpdated, nil
|
907
|
return activityUpdated, nil
|
876
|
}
|
908
|
}
|
877
|
}
|
909
|
}
|
|
@@ -1831,7 +1863,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
@@ -1831,7 +1863,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
1831
|
|
1863
|
|
1832
|
// 判断兑换活动的现金是否超过现金池未兑换现金
|
1864
|
// 判断兑换活动的现金是否超过现金池未兑换现金
|
1833
|
if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
1865
|
if activityUpdated.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
|
1834
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
1866
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池未兑换现金")
|
1835
|
}
|
1867
|
}
|
1836
|
|
1868
|
|
1837
|
// 获取平台素币兑换情况
|
1869
|
// 获取平台素币兑换情况
|