config.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/server/web"
  5. "github.com/rdlucklib/rdluck_tools/cache"
  6. )
  7. var (
  8. RunMode string //运行模式
  9. MYSQL_URL string //数据库连接
  10. MYSQL_URL_RDDP string //数据库连接
  11. MYSQL_URL_TACTICS string
  12. MYSQL_URL_COMEIN_DATA string // 路演记录数据库
  13. REDIS_CACHE string //缓存地址
  14. Rc *cache.Cache //redis缓存
  15. Re error //redis错误
  16. )
  17. //微信配置信息
  18. var (
  19. WxId string //微信原始ID
  20. WxAppId string //查研观向小程序
  21. WxAppSecret string //查研观向小程序
  22. WxPublicIdXzs string //查研观向小助手公众号
  23. WxPublicSecretXzs string //查研观向小助手公众号
  24. WxMsgTemplateIdApply string //申请待处理
  25. WxMsgTemplateIdApplyXzs string //申请待处理(小助手)
  26. WxMsgTemplateIdApplyCancel string //预约取消提醒
  27. WxMsgTemplateIdApplyCancelXzs string //预约取消提醒(小助手)
  28. WxMsgTemplateIdPermissionApply string //预约取消提醒
  29. WxMsgTemplateIdActivityApply string //活动预约消息提醒
  30. WxMsgTemplateIdActivityApplyXzs string //活动预约消息提醒(小助手)
  31. WxMsgTemplateIdActivityChange string //活动预约变更提醒
  32. WxMsgTemplateIdAskMsg string //手机号用户【XXX】发送模板消息模板ID
  33. WxMsgTemplateIdAskMsgXzs string //手机号用户【XXX】发送模板消息模板ID(小助手)
  34. WxMsgTemplateIdAskMsgMobile string //手机号用户【XXX】发送模板消息
  35. WxMsgTemplateIdAskMsgMobileAll string //手机号用户【XXX】发送模板消rm -
  36. TemplateIdByProductXzs string //产品运行报告通知-模板ID(小助手)
  37. WxMsgTemplateIdArticleUserRemind string //用户阅读报告通知-模板ID
  38. WxMsgTemplateIdArticleUserRemindXzs string //用户阅读报告通知-模板ID(小助手)
  39. )
  40. //微信公众号配置信息
  41. var (
  42. WxPublicId string //微信原始ID
  43. WxPublicAppId string
  44. WxPublicAppSecret string
  45. WxPlatform = 4 //注册平台,1:日度点评公众号,2:管理后台,3:pc端网站,4:查研观向小程序
  46. )
  47. var (
  48. IndexName string
  49. IndexNameArticleHistory string //文章阅读记录Es索引
  50. OnlineTime string
  51. SummaryArticleId int
  52. YanxSummaryPermissionId int //研选纪要分类ID
  53. YanxViewpointPermissionId int //研选观点分类ID
  54. EmailTechnology string //科技行业专家邮箱
  55. EmailMedicine string //医药行业专家邮箱
  56. EmailConsumption string //消费行业专家邮箱
  57. EmailZhizao string //智造行业专家邮箱
  58. EmailStrategy string //策略行业专家邮箱
  59. EmailExpert string //研选行业专家邮箱
  60. EmaiWhiteUserList string //白名单邮箱
  61. IsTask bool //是否执行定时任务
  62. HtgjDefaultSaleName string //海通默认销售名称
  63. HtgjSalt string //海通加密使用的盐
  64. HtgjName string //海通国际名称
  65. HtgjPublicMobile string //海通国际公共请求的手机号
  66. ActSendMsgMobile string //活动带问发送模板消息接收者的手机号
  67. StrategyPlatform string //策略品台跳转链接地址
  68. ArticleTaskClassMobile string //策略平台报告自动归类消息通知对象
  69. YiDongZhengTongYunUrl string //易董 证通云请求域名
  70. YiDongZhengTongYunAppid string //易董 证通云请求appid
  71. YiDongZhengTongYunSecret string //易董 证通云请求secret
  72. YiDongHuaWeiYunUrl string //易董 华为云请求域名
  73. YiDonggetOriginalLink string //易董 短连接转为长链接
  74. ShangHaiCrmApiLink string //上海CRM用户同步api调用地址
  75. )
  76. func init() {
  77. tmpRunMode, err := web.AppConfig.String("run_mode")
  78. if err != nil {
  79. panic("配置文件读取run_mode错误 " + err.Error())
  80. }
  81. fmt.Println("line 80:", tmpRunMode, err)
  82. RunMode = tmpRunMode
  83. fmt.Println("RunMode:", RunMode)
  84. if RunMode == "" {
  85. localIp, err := GetLocalIP()
  86. fmt.Println("localIp:", localIp)
  87. if localIp == "10.0.0.123" {
  88. RunMode = "debug"
  89. } else {
  90. RunMode = "release"
  91. }
  92. fmt.Println("RunMode:", RunMode)
  93. configPath := `/home/code/config/hongze_cygx/conf/app.conf`
  94. fmt.Println("configPath:", configPath)
  95. err = web.LoadAppConfig("ini", configPath)
  96. if err != nil {
  97. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  98. }
  99. }
  100. config, err := web.AppConfig.GetSection(RunMode)
  101. if err != nil {
  102. panic("配置文件读取错误 " + err.Error())
  103. }
  104. //beego.Info(RunMode + " 模式")
  105. MYSQL_URL = config["mysql_url"]
  106. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  107. MYSQL_URL_TACTICS = config["mysql_url_tactics"]
  108. MYSQL_URL_COMEIN_DATA = config["mysql_url_comein_data"]
  109. REDIS_CACHE = config["beego_cache"]
  110. if len(REDIS_CACHE) <= 0 {
  111. panic("redis链接参数没有配置")
  112. }
  113. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  114. if Re != nil {
  115. fmt.Println(Re)
  116. panic(Re)
  117. }
  118. IsTask, err = web.AppConfig.Bool("IsTask")
  119. if err != nil {
  120. panic("定时任务配置文件读取错误 " + err.Error())
  121. }
  122. OnlineTime = "2021-06-01 00:00:01" //上线时间
  123. SummaryArticleId = 1000000 //手动添加的纪要库开始ID
  124. YanxSummaryPermissionId = 1001 //研选纪要分类ID
  125. YanxViewpointPermissionId = 1002 //研选观点分类ID
  126. WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,15618524605"
  127. HtgjDefaultSaleName = "王芳"
  128. HtgjSalt = "HTGJ&HZ"
  129. HtgjName = "海通国际"
  130. HtgjPublicMobile = "18767183955"
  131. StrategyPlatform = "https://vmp.hzinsights.com/v2/articles/"
  132. if RunMode == "release" {
  133. WxAppId = "wxcc32b61f96720d2f"
  134. WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
  135. WxId = "gh_a9d3744e1072"
  136. //模板消息ID
  137. WxMsgTemplateIdApply = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
  138. WxMsgTemplateIdApplyCancel = "iEi4YRHwcPbc2PSEF1pptc39H4NsAJPrUIPEk2ynwiA"
  139. WxMsgTemplateIdPermissionApply = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
  140. WxMsgTemplateIdActivityApply = "MwZ5wxfd0O1Yt0Pkf6OkfWP4USQzZbiEo5SkZ26735s"
  141. WxPublicAppId = "wx4a844c734d8c8e56"
  142. WxPublicAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  143. WxPublicId = "gh_b67e0049fb8c"
  144. IndexName = "cygx_article_v0718"
  145. IndexNameArticleHistory = "cygx_article_history_v07_08"
  146. //接收附件邮箱
  147. EmailTechnology = "mlluo@hzinsights.com;jxu@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com" //科技行业专家邮箱
  148. EmailMedicine = "xlzheng@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com" //医药行业专家邮箱
  149. EmailConsumption = "yrhuang@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com;jxu@hzinsights.com" //消费行业专家邮箱
  150. EmailZhizao = "xfma@hzinsights.com;agne@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com" //智造行业专家邮箱
  151. EmailStrategy = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com" //策略行业专家邮箱
  152. EmailExpert = "experts@hzinsights.com;tshen@hzinsights.com;cxzhang@hzinsights.com;jhwang@hzinsights.com" //研选行业专家邮箱
  153. EmaiWhiteUserList = "tshen@hzinsights.com;cxzhang@hzinsights.com;yyli@hzinsights.com" //白名单邮箱
  154. WxMsgTemplateIdAskMsg = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
  155. WxMsgTemplateIdArticleUserRemind = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s"
  156. WxMsgTemplateIdAskMsgMobile = ""
  157. ActSendMsgMobile = "15618524605"
  158. ArticleTaskClassMobile = "15557270714,18767183922,15216736473,15000123056,18701809782,17706316791,18652179672"
  159. ShangHaiCrmApiLink = "https://crm.hzinsights.com/"
  160. } else {
  161. WxAppId = "wxcc32b61f96720d2f"
  162. WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
  163. WxId = "gh_a9d3744e1072"
  164. //模板消息ID
  165. WxMsgTemplateIdApply = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo"
  166. WxMsgTemplateIdApplyCancel = "UU_d7ks0XZBnWg2xFzxL9Heilm4kisX39K7dr4SDdO8"
  167. WxMsgTemplateIdPermissionApply = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo"
  168. WxMsgTemplateIdActivityApply = "Y59n_AHg-RLCKaz293geW76KDHpGL1qOnE7eF_lxelY"
  169. WxMsgTemplateIdActivityChange = "qfNuops-CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
  170. WxMsgTemplateIdArticleUserRemind = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
  171. WxPublicAppId = "wx9b5d7291e581233a"
  172. WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861"
  173. WxPublicId = "gh_5dc508325c6f"
  174. IndexName = "cygx_article_v1"
  175. IndexNameArticleHistory = "cygx_article_history_v1"
  176. //接收附件邮箱
  177. EmailTechnology = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //科技行业专家邮箱
  178. EmailMedicine = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //医药行业专家邮箱
  179. EmailConsumption = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //消费行业专家邮箱
  180. EmailZhizao = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //智造行业专家邮箱
  181. EmailStrategy = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //策略行业专家邮箱
  182. EmailExpert = "jhwang@hzinsights.com;cxzhang@hzinsights.com" //研选行业专家邮箱
  183. EmaiWhiteUserList = "cxzhang@hzinsights.com"
  184. WxMsgTemplateIdAskMsg = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo"
  185. WxMsgTemplateIdAskMsgMobile = "15557270714,17634786714,18767183922,17516315016"
  186. ActSendMsgMobile = "17634786714"
  187. ArticleTaskClassMobile = "15557270714,18767183922,17706316791"
  188. ShangHaiCrmApiLink = "http://106.15.192.100:8100/"
  189. }
  190. //查研观向小助手
  191. if RunMode != "release" {
  192. //原有的模板ID
  193. WxPublicIdXzs = "wx9b5d7291e581233a" //查研观向小助手
  194. WxPublicSecretXzs = "f4d52e34021eee262dce9682b31f8861" //查研观向小助手
  195. WxMsgTemplateIdActivityApplyXzs = "Y59n_AHg-RLCKaz293geW76KDHpGL1qOnE7eF_lxelY" //活动预约消息提醒(小助手)
  196. WxMsgTemplateIdAskMsgXzs = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo" //手机号用户【XXX】发送模板消息模板ID(小助手)
  197. WxMsgTemplateIdApplyXzs = "qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo" //申请待处理(小助手)
  198. WxMsgTemplateIdApplyCancelXzs = "UU_d7ks0XZBnWg2xFzxL9Heilm4kisX39K7dr4SDdO8" ////预约取消提醒(小助手)
  199. TemplateIdByProductXzs = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY" //产品运行报告通知-模板ID(小助手)
  200. } else {
  201. //新的模板ID
  202. WxPublicIdXzs = "wxb7cb8a15abad5b8e" //查研观向小助手
  203. WxPublicSecretXzs = "f425ba2863084249722af1e2a5cfffd3" //查研观向小助手
  204. WxMsgTemplateIdActivityApplyXzs = "nsfOASdg2O5KNk8hnBvu8MFsoP9X0o8ED6yPLPvEkao" //活动预约消息提醒(小助手)
  205. WxMsgTemplateIdAskMsgXzs = "IpS-yuNNQc8osCoy20jPHNkvBUyKRL1NGn7c0G9xmQA" //手机号用户【XXX】发送模板消息模板ID(小助手)
  206. WxMsgTemplateIdApplyXzs = "IpS-yuNNQc8osCoy20jPHNkvBUyKRL1NGn7c0G9xmQA" //申请待处理(小助手)
  207. WxMsgTemplateIdApplyCancelXzs = "gCSCAWNNhjkzE2V1cjbIV_Ex68R_8LM_u25qDlSKWyM" ////预约取消提醒(小助手)
  208. TemplateIdByProductXzs = "tNcCUiK_uUkuxaFF7M9NP2RwLkw8uHFjG-TDIxGUKxo" //产品运行报告通知-模板ID(小助手)
  209. }
  210. //易董开放api配置
  211. YiDongApiConfig()
  212. }
  213. // YiDongApiConfig 易董开放api配置
  214. func YiDongApiConfig() {
  215. if RunMode == "release" {
  216. YiDongZhengTongYunUrl = "https://services.valueonline.cn/"
  217. YiDongZhengTongYunAppid = "ca86a257ebb46fce"
  218. YiDongZhengTongYunSecret = "338db2b2ca86a257ebb46fced9003f53"
  219. YiDongHuaWeiYunUrl = "https://achievement.valueonline.cn/"
  220. YiDonggetOriginalLink = "https://services.easy-board.com.cn/short-link/getOriginalLink?shortKey="
  221. } else {
  222. YiDongZhengTongYunUrl = "https://services-dev.valueonline.cn/"
  223. YiDongZhengTongYunAppid = "d9bfb79627ac30d0"
  224. YiDongZhengTongYunSecret = "96a61dd2d9bfb79627ac30d02188bbe2"
  225. YiDongHuaWeiYunUrl = "https://achievement-test.valueonline.cn/"
  226. YiDonggetOriginalLink = "https://services-dev.valueonline.cn/short-link/getOriginalLink?shortKey="
  227. }
  228. }
  229. //
  230. //YiDongZhengTongYunUrl string //易董 证通云请求域名
  231. //YiDongZhengTongYunAppid string //易董 证通云请求appid
  232. //YiDongZhengTongYunSecret string //易董 证通云请求secret
  233. //YiDongHuaWeiYunUrl string //易董 华为云请求域名
  234. //http://webapi.brilliantstart.cn/api/
  235. //http://webapi.brilliantstart.cn/swagger/
  236. //http://139.196.122.219:8603/swagger/