config.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. package config
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. qrpc "app.yhyue.com/moapp/message/model"
  5. "github.com/gogf/gf/v2/frame/g"
  6. "github.com/gogf/gf/v2/os/gcfg"
  7. "github.com/gogf/gf/v2/os/gctx"
  8. )
  9. type config struct {
  10. Nsq struct {
  11. Address string
  12. }
  13. Redis struct {
  14. Address string
  15. }
  16. Mongodb struct {
  17. Address string
  18. Size int
  19. DbName string
  20. ReplSet string
  21. UserName string
  22. Password string
  23. }
  24. Etcd struct {
  25. Hosts []string
  26. Key string
  27. }
  28. DocPoints struct {
  29. AppId string
  30. Open struct {
  31. Max int64
  32. Jyweb_article_open int64
  33. Jydocs_doc_open int64
  34. }
  35. Jywx_subscribe_new int64
  36. Jywx_subscribe_invite int64
  37. Jywx_subscribe_invited int64
  38. }
  39. }
  40. type msgConf struct {
  41. Title string
  42. Content string
  43. MsgType int64
  44. Appid string
  45. PcUrl string
  46. MobileUrl string
  47. }
  48. var (
  49. PushConfig *pushConfig
  50. TaskConf *taskConf
  51. )
  52. type LotteryReceiveReq struct {
  53. UserName string `json:"userName"`
  54. UserId string `json:"userId"`
  55. LotteryIdArr string `json:"lotteryIdArr"`
  56. }
  57. type pushConfig struct {
  58. Webdomain string `json:"webdomain"`
  59. Weixinrpc string `json:"weixinrpc"`
  60. PushPoolSize int `json:"pushPoolSize"`
  61. WxMsg struct {
  62. Id string
  63. First *qrpc.TmplItem
  64. Keyword1 *qrpc.TmplItem
  65. Keyword2 *qrpc.TmplItem
  66. Keyword3 *qrpc.TmplItem
  67. Keyword4 *qrpc.TmplItem
  68. Remark *qrpc.TmplItem
  69. } `json:"wxTplMsg"`
  70. TestId string `json:"testId"`
  71. DelayedTime int `json:"delayedTime"`
  72. Subvip string `json:"subvip"`
  73. Points string `json:"points"`
  74. FullReduce string `json:"fullReduce"`
  75. Messages struct {
  76. NewUser *msgConf
  77. ConfirmChallenge *msgConf
  78. GetVip *msgConf
  79. }
  80. }
  81. type OrderMonitorConfig struct {
  82. DateSpecial string // 特别奖品活动日期
  83. OpenCron string // 每天开启订单查询的任务
  84. SelectCron string // 每5分钟查询一次
  85. WinNumberDaily int // 每天第xx个付款获得奖品
  86. WinNumbersSpecial int // 第xxx个付款获得特殊奖品
  87. Switch bool // 是否开启定时任务
  88. ActivityMode int // # 1. 每天第多少名 2. 活动期间内一共第多少名(双十二)
  89. Rules []struct { // 双十二活动规则
  90. WinNum []int // 获奖的下单顺序
  91. Mold int // 奖品 3 免单
  92. Products []string // # 参加活动的产品
  93. PriceLimit bool // 是否有实付金额限制
  94. PriceStart int // 实付金额最低 单位(分)
  95. PriceEnd int // 实付金额最高 单位(分)
  96. }
  97. }
  98. type taskConf struct {
  99. TaskStartTime int64 `json:"taskStartTime"` //限时活动开始时间
  100. NewTask []*TaskStruct `json:"newTask"` //新手任务
  101. OldTask []*TaskStruct `json:"oldTask"` //老用户限时任务
  102. TaskDayTime int64 `json:"taskDayTime"` //活动时间
  103. }
  104. type TaskStruct struct {
  105. Name string `json:"name"`
  106. Desc string `json:"desc"`
  107. PcHref string `json:"pcHref"`
  108. AppHref string `json:"appHref"`
  109. WxHref string `json:"wxHref"`
  110. Point int `json:"point"`
  111. Icon string `json:"icon"`
  112. Type string `json:"type"`
  113. Distinguish int `json:"distinguish"` // 0不用区分身份 1区分身份
  114. }
  115. type SaveLogConfig struct {
  116. Name string // 日志名称
  117. CollName string // 保存的coll
  118. MgoSaveCacheSize int // 缓存通道大小
  119. SPSize int // 数据库并发数据
  120. BulkSize int // 每批的数量
  121. TimeAfter int // 定时保存 毫秒
  122. Timeout int // 超时丢弃毫秒
  123. }
  124. //var Config *config
  125. var NsqLogConfig SaveLogConfig
  126. func init() {
  127. //推送配置文件
  128. common.ReadConfig("./etc/push.json", &PushConfig)
  129. //系统配置文件
  130. //common.ReadConfig(&Config)
  131. g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName("./etc/config.yaml")
  132. //任务配置文件
  133. common.ReadConfig("./etc/task.json", &TaskConf)
  134. NsqLogConfig = SaveLogConfig{
  135. Name: gcfg.Instance().MustGet(gctx.New(), "NsqLog.Name").String(),
  136. CollName: gcfg.Instance().MustGet(gctx.New(), "NsqLog.CollName").String(),
  137. MgoSaveCacheSize: gcfg.Instance().MustGet(gctx.New(), "NsqLog.MgoSaveCacheSize").Int(),
  138. SPSize: gcfg.Instance().MustGet(gctx.New(), "NsqLog.SPSize").Int(),
  139. BulkSize: gcfg.Instance().MustGet(gctx.New(), "NsqLog.BulkSize").Int(),
  140. TimeAfter: gcfg.Instance().MustGet(gctx.New(), "NsqLog.TimeAfter").Int(),
  141. Timeout: gcfg.Instance().MustGet(gctx.New(), "NsqLog.Timeout").Int(),
  142. }
  143. }