generate.go 889 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2021 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package bill
  4. import (
  5. "context"
  6. "fmt"
  7. "git.getensh.com/common/gopkgs/cache"
  8. "git.getensh.com/common/gopkgs/logger"
  9. "go.uber.org/zap"
  10. "property-task/impl/v1/common"
  11. "property-task/pb"
  12. pb_v1 "property-task/pb/v1"
  13. "time"
  14. )
  15. // 定时生成账单
  16. func GenerateBill() {
  17. cache.RedisLock(common.TaskKey)
  18. defer cache.RedisUnlock(common.TaskKey)
  19. // 获取小区列表
  20. ids := common.GetGardenList()
  21. mreq := pb_v1.GenerateBillRequest{}
  22. fmt.Printf("开始生成账单:%v\n", time.Now().Format("2006-01-02 15:04:05"))
  23. for _, v := range ids {
  24. mreq.GardenId = v.GardenId
  25. _, err := pb.Garden.GenerateBill(context.Background(), &mreq)
  26. if err != nil {
  27. logger.Error("func",
  28. zap.String("call", "pb.Garden.GenerateBill "),
  29. zap.String("error", err.Error()))
  30. }
  31. }
  32. }