作者 陈志颖

fix:更新兑换活动增加重复时间判断

@@ -326,7 +326,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -326,7 +326,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
326 var t1 = time.Now().Local() 326 var t1 = time.Now().Local()
327 var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local) 327 var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
328 328
329 - fmt.Print(t2, "\n")  
330 329
331 // 获取该公司所有兑换现金活动 330 // 获取该公司所有兑换现金活动
332 if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{ 331 if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
@@ -930,6 +929,19 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -930,6 +929,19 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
930 if activityUpdated, err := exchangeCashActivityRepository.Save(activityFound); err != nil { 929 if activityUpdated, err := exchangeCashActivityRepository.Save(activityFound); err != nil {
931 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 930 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
932 } else { 931 } else {
  932 + // 获取该公司所有兑换现金活动
  933 + if _, activities, err := exchangeCashActivityRepository.FindAll(map[string]interface{}{
  934 + "companyId": activityFound.CompanyId,
  935 + }); err != nil {
  936 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  937 + } else {
  938 + for _, activity := range activities {
  939 + if t2.Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
  940 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
  941 + }
  942 + }
  943 + }
  944 +
933 if err := transactionContext.CommitTransaction(); err != nil { 945 if err := transactionContext.CommitTransaction(); err != nil {
934 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 946 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
935 } 947 }
@@ -399,13 +399,22 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -399,13 +399,22 @@ func (controller *SuMoneyController) ImportExchangeList () {
399 //fmt.Printf("命令:%+v\n", importExchangeCashListCommand.Where) 399 //fmt.Printf("命令:%+v\n", importExchangeCashListCommand.Where)
400 //fmt.Print(controller.GetString("where"), "\n") 400 //fmt.Print(controller.GetString("where"), "\n")
401 where := controller.GetString("where") 401 where := controller.GetString("where")
402 - //fmt.Print(reflect.TypeOf(importExchangeCashListCommand.Where), "\n") 402 + //typeOf := reflect.TypeOf(where)
  403 + //if reflect.TypeOf(where) == Type.String() {
  404 + // jsonMap := make(map[string]interface{})
  405 + // _ := json.Unmarshal([]byte(where), &jsonMap)
  406 + // fmt.Printf("%+v\n", jsonMap)
  407 + //}
  408 + //fmt.Print(reflect.TypeOf(where), "\n")
403 file, h, _ := controller.GetFile("file") 409 file, h, _ := controller.GetFile("file")
404 410
405 jsonMap := make(map[string]interface{}) 411 jsonMap := make(map[string]interface{})
406 err := json.Unmarshal([]byte(where), &jsonMap) 412 err := json.Unmarshal([]byte(where), &jsonMap)
  413 + fmt.Printf("%+v\n", jsonMap)
407 414
408 - fmt.Print(jsonMap["activityId"]) 415 + tmp, _ := strconv.ParseInt(jsonMap["activityId"].(string), 10, 64 )
  416 +
  417 + fmt.Print(tmp, "\n")
409 418
410 // 错误信息返回 419 // 错误信息返回
411 var response utils.JsonResponse 420 var response utils.JsonResponse