config.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/server/web"
  5. "github.com/rdlucklib/rdluck_tools/cache"
  6. "strconv"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_CYGX string //查研观向数据库连接
  12. MYSQL_URL_RDDP string //数据库连接
  13. MYSQL_URL_TACTICS string
  14. REDIS_CACHE string //缓存地址
  15. Rc *cache.Cache //redis缓存
  16. Re error //redis错误
  17. )
  18. // 微信配置信息
  19. var (
  20. WxId string //微信原始ID
  21. WxAppId string //查研观向小程序
  22. WxAppSecret string //查研观向小程序
  23. WxPublicAppId string //查研观向小助手公众号
  24. WxPublicAppSecret string //查研观向小助手公众号
  25. WxOpenAppId string //公众平台AppId
  26. WxOpenAppSecret string //公众平台AppSecret
  27. HeadimgurlDefault string //默认头像
  28. WxMsgTemplateIdApplyXzs string //申请待处理(小助手)
  29. WxMsgTemplateIdApplyCancelXzs string //预约取消提醒(小助手)
  30. WxMsgTemplateIdApply string //申请待处理
  31. WxMsgTemplateIdAskMsgMobile string //手机号用户【XXX】发送模板消息
  32. WxMsgTemplateIdAskMsgMobileAll string //手机号用户【XXX】发送模板消rm --
  33. WxMsgTemplateIdAskMsgXzs string //手机号用户【XXX】发送模板消息模板ID(小助手)
  34. IndexName string
  35. IndexNameComprehensive string //综合搜索Es索引
  36. WxMsgTemplateIdAskMsgMobilePublic string //手机号用户【XXX】发送模板消rm --
  37. WxMsgTemplateIdArticleUserRemind string //用户阅读报告通知-模板ID
  38. WxMsgTemplateIdYXSpecialReview string //王芳、葛琳和沈涛--
  39. ActSendMsgMobile string //活动带问发送模板消息接收者的手机号
  40. YiDongZhengTongYunUrl string //易董 证通云请求域名
  41. YiDongZhengTongYunAppid string //易董 证通云请求appid
  42. YiDongZhengTongYunSecret string //易董 证通云请求secret
  43. YiDongHuaWeiYunUrl string //易董 华为云请求域名
  44. YiDonggetOriginalLink string //易董 短连接转为长链接
  45. //权益内容组手机号
  46. RAI_MOBILE_GAO_YI_WEN string // 权益高亦文手机号
  47. RAI_MOBILE_DONG_HENG string // 权益董衡手机号
  48. RAI_MOBILE_WU_ANG_DI string // 权益吴昂迪手机号
  49. RAI_MOBILE_GE_LIN string // 权益葛琳手机号
  50. ZHOU_QI_ID int // 行业周期的ID
  51. )
  52. // 模板消息推送
  53. var (
  54. SendWxTemplateMsgUrl string
  55. SendWxCategoryTemplateMsgUrl string
  56. // 类目模板
  57. WxCategoryMsgTemplateIdApplyXzs string //申请待处理(买方研选)
  58. WxCategoryMsgTemplateIdActivitySign string //买方研选活动签到通知-类目模板ID(买方研选)
  59. WxMsgCategoryTemplateIdCompanyApprovalMessageRai string //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  60. WxMsgCategoryTemplateIdActivityPublishApply string //买方研选关注的产业下,单个活动/研选报告发布通知-类目模板ID
  61. )
  62. // 日志配置
  63. var (
  64. LogPath string //调用过程中的日志存放地址
  65. LogFile string
  66. LogDataPath string //调用过程中图表相关的日志存放地址
  67. LogDataFile string
  68. BinLogPath string //数据库相关的日志存放地址
  69. BinLogFile string
  70. ApiLogPath string //接口请求地址和接口返回值日志存放地址
  71. ApiLogFile string
  72. LogMaxDays int //日志最大保留天数
  73. )
  74. func init() {
  75. tmpRunMode, err := web.AppConfig.String("run_mode")
  76. if err != nil {
  77. panic("配置文件读取run_mode错误 " + err.Error())
  78. }
  79. RunMode = tmpRunMode
  80. if RunMode == "" {
  81. localIp, err := GetLocalIP()
  82. fmt.Println("localIp:", localIp)
  83. if localIp == "10.0.0.123" {
  84. RunMode = "debug"
  85. } else {
  86. RunMode = "release"
  87. }
  88. configPath := `/home/code/config/hongze_clpt/conf/app.conf`
  89. err = web.LoadAppConfig("ini", configPath)
  90. if err != nil {
  91. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  92. }
  93. }
  94. config, err := web.AppConfig.GetSection(RunMode)
  95. if err != nil {
  96. panic("配置文件读取错误 " + err.Error())
  97. }
  98. fmt.Println(RunMode + " 模式")
  99. MYSQL_URL = config["mysql_url"]
  100. MYSQL_URL_CYGX = config["mysql_url_cygx"]
  101. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  102. REDIS_CACHE = config["beego_cache"]
  103. if len(REDIS_CACHE) <= 0 {
  104. panic("redis链接参数没有配置")
  105. }
  106. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  107. if Re != nil {
  108. fmt.Println(Re)
  109. panic(Re)
  110. }
  111. WxAppId = "wxcc32b61f96720d2f"
  112. WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
  113. WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829"
  114. WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829" // 王芳沈涛张传星(类目模板消息都接收的人)
  115. WxMsgTemplateIdYXSpecialReview = "18621268829,18258485832,18767183922" // 王芳、葛琳和沈涛
  116. if RunMode == "release" {
  117. WxPublicAppId = "wxb7cb8a15abad5b8e" //查研观向小助手
  118. WxPublicAppSecret = "f425ba2863084249722af1e2a5cfffd3" //查研观向小助手
  119. WxMsgTemplateIdApplyXzs = "IpS-yuNNQc8osCoy20jPHNkvBUyKRL1NGn7c0G9xmQA" //申请待处理(小助手)
  120. WxMsgTemplateIdApplyCancelXzs = "gCSCAWNNhjkzE2V1cjbIV_Ex68R_8LM_u25qDlSKWyM" ////预约取消提醒(小助手)
  121. WxMsgTemplateIdApply = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
  122. WxMsgTemplateIdAskMsgMobile = "15557270714,17634786714,18767183922,17516315016"
  123. WxMsgTemplateIdAskMsgXzs = "IpS-yuNNQc8osCoy20jPHNkvBUyKRL1NGn7c0G9xmQA" //手机号用户【XXX】发送模板消息模板ID(小助手)
  124. WxMsgTemplateIdArticleUserRemind = "fxnlsjx-gm3dAZVJf6f3w27wA7anETl42kexXLP8FDs"
  125. WxOpenAppId = "wx26ccbe242908ed73" //公众平台AppId
  126. WxOpenAppSecret = "0851cc85027c6eb74a400016648ecda8" //公众平台AppSecret
  127. IndexName = "cygx_article_v03_23"
  128. IndexNameComprehensive = "cygx_comprehensive"
  129. ActSendMsgMobile = "15557270714"
  130. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  131. SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
  132. // 类目模版
  133. WxCategoryMsgTemplateIdApplyXzs = "HKD03oZfSv8LJgeoHz0pynai3G2Ls4h8zZ6BfOpZmIA"
  134. WxCategoryMsgTemplateIdActivitySign = "11rITVC5Gl8qwetxl92NqY887Uk14kg3nPtEA_i_zLo"
  135. WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "t1CcxcOkoZkWZrDRs6zYUlceBGYMV3mhkBYUa8a6Mx0" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  136. WxMsgCategoryTemplateIdActivityPublishApply = "IBMqiE61lVgUfFM4rsH0XCH57R_G3PbWvRbnzg9JHPI"
  137. //权益内容组手机号
  138. RAI_MOBILE_GAO_YI_WEN = "15000123056" //权益高亦文手机号
  139. RAI_MOBILE_DONG_HENG = "15216736473" // 权益董衡手机号
  140. RAI_MOBILE_WU_ANG_DI = "18701809782" // 权益吴昂迪手机号
  141. RAI_MOBILE_GE_LIN = "18258485832" // 权益葛琳手机号
  142. } else {
  143. WxPublicAppId = "wx9b5d7291e581233a" //弘则投研公众号 开发者ID(AppID)
  144. WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861" //弘则投研公众号秘钥
  145. WxMsgTemplateIdApplyXzs = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo" //申请待处理(小助手)
  146. WxMsgTemplateIdApplyCancelXzs = "UU_d7ks0XZBnWg2xFzxL9Heilm4kisX39K7dr4SDdO8" ////预约取消提醒(小助手)
  147. WxMsgTemplateIdApply = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo"
  148. WxMsgTemplateIdAskMsgMobile = "15557270714,17634786714,18767183922,17516315016"
  149. WxMsgTemplateIdAskMsgXzs = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo" //手机号用户【XXX】发送模板消息模板ID(小助手)
  150. WxMsgTemplateIdArticleUserRemind = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
  151. WxOpenAppId = "wx294d2825f451f851" //公众平台AppId
  152. WxOpenAppSecret = "7bf62d2d037280f8b635c6eca2f31db9" //公众平台AppSecret
  153. IndexName = "cygx_article_v1"
  154. IndexNameComprehensive = "cygx_comprehensive_test"
  155. ActSendMsgMobile = "17634786714"
  156. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  157. SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
  158. //SendWxCategoryTemplateMsgUrl = "http://8.136.199.33:8086/v1/wechat/send_category_template_msg"
  159. // 类目模版
  160. WxCategoryMsgTemplateIdApplyXzs = "IemWOTzbnLBqJ2ozSiFqm13WjaotoC3V4uXaxTij08I"
  161. WxCategoryMsgTemplateIdActivitySign = "aczgUYZASO97UJiCD_nDmD1eNWZAWudzw3JYcvjJ2x4"
  162. WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "wU4x_c5XruwuA44VZelyklRNOfq4XrU9ILckTtDs6hg" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  163. WxMsgCategoryTemplateIdActivityPublishApply = "wLeV7tVK4ZJBoAvsmfXkHveVW8yefGAkwnVKQWRi8uQ"
  164. //权益内容组手机号测试环境没什么用,配合测试切换他们的手机号
  165. RAI_MOBILE_GAO_YI_WEN = "17706316791" //权益高亦文手机号
  166. RAI_MOBILE_DONG_HENG = "15557270714" // 权益董衡手机号
  167. RAI_MOBILE_WU_ANG_DI = "15557270714" // 权益吴昂迪手机号
  168. RAI_MOBILE_GE_LIN = "15557270714" // 权益葛琳手机号
  169. }
  170. HeadimgurlDefault = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202202/20220225/XFBBOUmDC5AXkfxnHiuqKpPtoofH.png"
  171. //日志配置
  172. {
  173. LogPath = config["log_path"]
  174. LogFile = config["log_file"]
  175. LogDataPath = config["log_data_path"]
  176. LogDataFile = config["log_data_file"]
  177. BinLogPath = config["binlog_path"]
  178. BinLogFile = config["binlog_file"]
  179. ApiLogPath = config["apilog_path"]
  180. ApiLogFile = config["apilog_file"]
  181. logMaxDaysStr := config["log_max_day"]
  182. LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
  183. }
  184. //易董开放api配置
  185. YiDongApiConfig()
  186. }
  187. // YiDongApiConfig 易董开放api配置
  188. func YiDongApiConfig() {
  189. if RunMode == "release" {
  190. YiDongZhengTongYunUrl = "https://services.valueonline.cn/"
  191. YiDongZhengTongYunAppid = "ca86a257ebb46fce"
  192. YiDongZhengTongYunSecret = "338db2b2ca86a257ebb46fced9003f53"
  193. YiDongHuaWeiYunUrl = "https://achievement.valueonline.cn/"
  194. YiDonggetOriginalLink = "https://services.easy-board.com.cn/short-link/getOriginalLink?shortKey="
  195. } else {
  196. YiDongZhengTongYunUrl = "https://services-dev.valueonline.cn/"
  197. YiDongZhengTongYunAppid = "d9bfb79627ac30d0"
  198. YiDongZhengTongYunSecret = "96a61dd2d9bfb79627ac30d02188bbe2"
  199. YiDongHuaWeiYunUrl = "https://achievement-test.valueonline.cn/"
  200. YiDonggetOriginalLink = "https://services-dev.valueonline.cn/short-link/getOriginalLink?shortKey="
  201. }
  202. }
  203. // 行业ID信息
  204. func ChartPermissionId() {
  205. if RunMode == "release" {
  206. ZHOU_QI_ID = 62
  207. } else {
  208. ZHOU_QI_ID = 148
  209. }
  210. }
  211. //http://webapi.brilliantstart.cn/api/
  212. //http://webapi.brilliantstart.cn/swagger/
  213. //http://139.196.122.219:8603/swagger/