generate.go 922 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. )
  14. // 定时生成账单
  15. func GenerateBill() {
  16. cache.RedisLock(common.TaskKey)
  17. defer cache.RedisUnlock(common.TaskKey)
  18. // 获取小区列表
  19. ids := common.GetGardenList()
  20. mreq := pb_v1.GenerateBillRequest{}
  21. fmt.Printf("开始生成账单\n")
  22. for _, v := range ids {
  23. fmt.Printf("xxxxxxxxxxxxxxxxxxxx:%v\n", v.GardenId)
  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. fmt.Printf("xxxxx:%v\n", err)
  32. }
  33. }