config.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. package utils
  2. import (
  3. "fmt"
  4. beeLogger "github.com/beego/bee/v2/logger"
  5. "github.com/beego/beego/v2/server/web"
  6. "github.com/rdlucklib/rdluck_tools/cache"
  7. )
  8. var (
  9. RunMode string //运行模式
  10. MYSQL_URL string //数据库连接
  11. MYSQL_URL_RDDP string //数据库连接
  12. MYSQL_URL_EDB string
  13. MYSQL_URL_DATA string
  14. MYSQL_URL_GL string
  15. MYSQL_LOG_URL string
  16. MYSQL_URL_COMEIN_DATA string // 路演记录数据库
  17. REDIS_CACHE string //缓存地址
  18. Rc *cache.Cache //redis缓存
  19. Re error //redis错误
  20. )
  21. var (
  22. STATIC_DIR string
  23. )
  24. // 微信配置信息
  25. var (
  26. WxId string //微信原始ID
  27. WxAppId string
  28. WxAppSecret string
  29. TemplateIdByProduct string //产品运行报告通知-模板ID
  30. TemplateRedirectUrl string //模板消息跳转地址
  31. DayReportTemplateRedirectUrl string //模板消息跳转地址(晨报、周报)
  32. TemplateIdByCompanyApply string //客户申请单审批通知-模板ID
  33. TemplateCompanyApplyRedirectUrl string //审批单模板消息跳转地址
  34. TemplateIdByCompanyReceive string //销售跨部门领取客户通知-模板ID
  35. TemplateIdByCompanyReceivePermission string //销售"添加客户/领取客户"权限变更通知
  36. WxMsgTemplateIdActivityChangeApply string //查研观向活动变更通知-模板ID
  37. WxMsgTemplateIdActivityChangeApplyXzs string //查研观向活动变更通知-模板ID(小助手)
  38. TemplateIdByProductXzs string //产品运行报告通知-模板ID(小助手)
  39. WxCygxAppId string //查研观向小程序APPID
  40. WxMsgTemplateIdAskByUser string //查研观向用户提问新消息推送ID
  41. WxCrmAppId string //随手办公小程序APPID
  42. WxPublicIdXzs string //查研观向小助手公众号
  43. WxPublicSecretXzs string //查研观向小助手公众号
  44. WxYbAppId string //弘则研报小程序APPID
  45. YiDongHuaWeiYunUrl string //易董 华为云请求域名
  46. WxMsgTemplateIdWithRoadshowPending string //路演->研究员收到待处理的申请
  47. WxMsgTemplateIdWithRoadshowDetailResult string //路演->销售收到处理结果
  48. WxMsgTemplateIdWithRoadshowDeleteNotice string //路演->研究员收到活动删除通知
  49. WxMsgTemplateIdWithYbCommunityQuestion string // 研报小程序->问答社区回复通知
  50. WxMsgTemplateIdWithSealApplyFinished string // 用印申请-已签回通知
  51. //内部员工公众号(弘则部门)
  52. AdminWxAppId string
  53. AdminWxAppSecret string
  54. UserTemplateIdByProduct string //客户产品运行报告通知-模板ID
  55. )
  56. var (
  57. THS_SendUrl string //同花顺地址url
  58. THS_PubKey string //同花顺公钥
  59. )
  60. var (
  61. IndexName string //Es索引
  62. IndexNameArticleHistory string //文章阅读记录Es索引
  63. SummaryArticleId int //手动添加的纪要库开始ID
  64. YanxSummaryPermissionId int //研选纪要分类ID
  65. YanxViewpointPermissionId int //研选观点分类ID
  66. DATA_INDEX_NAME string //数据指标库索引
  67. CHART_INDEX_NAME string //研究图库索引
  68. EsReportIndexName string //研报ES索引
  69. EsEnglishReportIndexName string //英文研报ES索引
  70. Hz_CeLue_Article_Url string //策略平台报告地址
  71. MY_CHART_INDEX_NAME string //研究图库(MY ETA)索引
  72. EsSemanticAnalysisDocIndexName string //ES语义分析文档索引名
  73. )
  74. var (
  75. Bucketname string = "hongze"
  76. Endpoint string
  77. Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
  78. Upload_dir string = "static/images/"
  79. Upload_Audio_Dir string = "static/audio/"
  80. AccessKeyId string = "LTAIFMZYQhS2BTvW"
  81. AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
  82. )
  83. // LibreOfficePath LibreOfficePath的地址
  84. var LibreOfficePath string
  85. // 经济数据库
  86. var (
  87. EDB_LIB_URL string
  88. )
  89. // 上海crm开放api配置
  90. var (
  91. CRM_OPEN_API_URL string
  92. CRM_OPEN_API_APP_KEY string
  93. CRM_OPEN_API_APP_SECRET string
  94. )
  95. // 全时会议账号信息
  96. var (
  97. QsAppID string
  98. QsSecretKey string
  99. QsUserId int64
  100. QsUserName string
  101. )
  102. // 进门财经账号信息
  103. var (
  104. COMEIN_URL string
  105. COMEIN_APPID string
  106. COMEIN_SECREKEY string
  107. )
  108. // 模板消息推送
  109. var (
  110. SendWxTemplateMsgUrl string
  111. )
  112. // ppt转图片服务的地址
  113. var Ppt2ImageUrl string
  114. // 开放openapi的地址
  115. var HongzeOpenApiHost string
  116. var EnglishShareUrl string //英文研报群发邮件分享地址
  117. var EnPolicyReportUrl string
  118. func init() {
  119. tmpRunMode, err := web.AppConfig.String("run_mode")
  120. if err != nil {
  121. panic("配置文件读取run_mode错误 " + err.Error())
  122. }
  123. RunMode = tmpRunMode
  124. fmt.Println("RunMode:", RunMode)
  125. if RunMode == "" {
  126. localIp, err := GetLocalIP()
  127. fmt.Println("localIp:", localIp)
  128. if localIp == "10.0.0.123" {
  129. RunMode = "debug"
  130. } else {
  131. RunMode = "release"
  132. }
  133. fmt.Println("RunMode:", RunMode)
  134. configPath := `/home/code/config/hongze_ETA_mobile_api/conf/app.conf`
  135. fmt.Println("configPath:", configPath)
  136. err = web.LoadAppConfig("ini", configPath)
  137. if err != nil {
  138. fmt.Println("web.LoadAppConfig Err:" + err.Error())
  139. }
  140. }
  141. config, err := web.AppConfig.GetSection(RunMode)
  142. if err != nil {
  143. panic("配置文件读取错误 " + err.Error())
  144. }
  145. beeLogger.Log.Info(RunMode + " 模式")
  146. MYSQL_URL = config["mysql_url"]
  147. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  148. MYSQL_URL_EDB = config["mysql_url_edb"]
  149. MYSQL_URL_DATA = config["mysql_url_data"]
  150. MYSQL_URL_GL = config["mysql_url_gl"]
  151. MYSQL_LOG_URL = config["mysql_url_log"]
  152. MYSQL_URL_COMEIN_DATA = config["mysql_url_comein_data"]
  153. REDIS_CACHE = config["beego_cache"]
  154. if len(REDIS_CACHE) <= 0 {
  155. panic("redis链接参数没有配置")
  156. }
  157. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  158. if Re != nil {
  159. fmt.Println(Re)
  160. panic(Re)
  161. }
  162. WxCygxAppId = "wxcc32b61f96720d2f"
  163. SummaryArticleId = 1000000 //手动添加的纪要库开始ID
  164. YanxSummaryPermissionId = 1001 //研选纪要分类ID
  165. YanxViewpointPermissionId = 1002 //研选观点分类ID
  166. Hz_CeLue_Article_Url = "https://vmp.hzinsights.com/v2/articles/" //策略平台项目报告地址
  167. //随手办公 微信小程序appid
  168. WxCrmAppId = `wx67b68e39913e511e`
  169. WxYbAppId = `wxb059c872d79b9967` //弘则研报小程序
  170. //内部员工公众号(弘则部门)
  171. AdminWxAppId = "wx1392111da5426e9e"
  172. AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
  173. THS_PubKey = `-----BEGIN PUBLIC KEY-----
  174. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqugglfCboOEfWtHlGBOW
  175. 40a4Y3xOs0MPBwjTOzHgcaWzx5XCc20VftGVXkWlpjs8u4dza/Bp1SV7SJ5Y7U95
  176. jgUOP8Js9Qgp6UVqBJDJf3i1KpjHzlk3ma8zxAYUAdieEUE+SKSxSY+BD9A6lpf5
  177. n+igXLmzR5GeVGFeLzoMhB1+pXgGhW30ao9wPwuRF7DBl+FKa/ACi7iXLiwXVgqT
  178. FFi29TKeerEENu3EpMXvPml7tNUiVmVW6d83hlascfbAlkShwuHLSGpLqK7brtg6
  179. jRS9hreKFKb0BUQ4TB26e7IDCstbMRvUp4+OGezexzic5NYPQ8uLo5OTaS7f7PrW
  180. ZwIDAQAB
  181. -----END PUBLIC KEY-----`
  182. if RunMode == "release" {
  183. TemplateRedirectUrl = "https://ficc.hzinsights.com/reportdtl?id="
  184. DayReportTemplateRedirectUrl = "https://report.hzinsights.com/#/allindex/" //晨报模板跳转url
  185. TemplateCompanyApplyRedirectUrl = "https://ficc.hzinsights.com/approval/approval/list"
  186. STATIC_DIR = "/home/static/imgs/"
  187. Endpoint = "oss-cn-shanghai-internal.aliyuncs.com"
  188. //Endpoint = "oss-cn-shanghai.aliyuncs.com"
  189. IndexName = "cygx_article_v03_23"
  190. IndexNameArticleHistory = "cygx_article_history_v07_08"
  191. TemplateCompanyApplyRedirectUrl = "https://ficc.hzinsights.com/approval/approval/list"
  192. //同花顺正式地址
  193. THS_SendUrl = `https://board.10jqka.com.cn/gateway/ps/syncNews`
  194. DATA_INDEX_NAME = "hz_data_lib_v20220214"
  195. CHART_INDEX_NAME = "hz_chart_lib_v2"
  196. MY_CHART_INDEX_NAME = "hz_my_chart_v1"
  197. //同花顺,万得接口服务地址(阿里云windows服务器地址;内网地址)
  198. Hz_Server_Data_Url = "http://172.19.173.231:7000/"
  199. EDB_LIB_URL = "http://172.19.173.232:8300/edbapi/"
  200. EsReportIndexName = "research_report_v1"
  201. EsEnglishReportIndexName = "english_report_v1"
  202. EsSemanticAnalysisDocIndexName = "semantic_analysis_v1"
  203. WxRelease()
  204. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  205. HongzeOpenApiHost = "http://127.0.0.1:8609"
  206. EnglishShareUrl = "https://ybpcen.hzinsights.com"
  207. EnPolicyReportUrl = "https://en.hzinsights.com/v2api/"
  208. } else {
  209. TemplateRedirectUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id="
  210. DayReportTemplateRedirectUrl = "http://report.brilliantstart.cn/#/allindex/" //晨报模板跳转url
  211. TemplateCompanyApplyRedirectUrl = "http://advisoryadmin.brilliantstart.cn/approval/approval/list"
  212. STATIC_DIR = "static/imgs/"
  213. Endpoint = "oss-cn-shanghai.aliyuncs.com"
  214. IndexName = "cygx_article_v1"
  215. IndexNameArticleHistory = "cygx_article_history_v1"
  216. //同花顺测试地址
  217. THS_SendUrl = `https://mtest.10jqka.com.cn/gateway/ps/syncNews`
  218. DATA_INDEX_NAME = "test_hz_data_lib_v20220120"
  219. CHART_INDEX_NAME = "test_hz_chart_lib_v2"
  220. MY_CHART_INDEX_NAME = "test_hz_my_chart_v1"
  221. //同花顺,万得接口服务地址(阿里云windows服务器地址;外网地址)
  222. Hz_Server_Data_Url = "http://139.196.136.213:7000/"
  223. EDB_LIB_URL = "http://8.136.199.33:8300/edbapi/"
  224. //EDB_LIB_URL = "http://127.0.0.1:8900/edbapi/"
  225. EsReportIndexName = "test_research_report_v1"
  226. EsEnglishReportIndexName = "test_english_report_v1"
  227. EsSemanticAnalysisDocIndexName = "test_semantic_analysis_v1"
  228. WxDebug()
  229. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  230. HongzeOpenApiHost = "http://127.0.0.1:8608"
  231. EnglishShareUrl = "http://8.136.199.33:8301"
  232. //EnPolicyReportUrl = "https://beta.internal.hzinsights.com/v2api/"
  233. EnPolicyReportUrl = "https://en.hzinsights.com/v2api/"
  234. }
  235. tmpLibreOfficePath, err := web.AppConfig.String("libreOfficePath")
  236. if err != nil {
  237. panic("配置文件读取libreOfficePath错误 " + err.Error())
  238. }
  239. LibreOfficePath = tmpLibreOfficePath
  240. //上海crm开放api配置
  241. CrmOpenApiConfig()
  242. //初始化全时开放api配置
  243. initQsOpenApiConfig()
  244. //进门财经开放api配置
  245. ComeinOpenApiConfig()
  246. //易董开放api配置
  247. YiDongApiConfig()
  248. // 初始化内部服务配置
  249. initSystemServer()
  250. }
  251. // 测试环境模板消息
  252. func WxDebug() {
  253. WxAppId = "wx9b5d7291e581233a"
  254. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  255. WxId = "gh_5dc508325c6f"
  256. //模板消息
  257. {
  258. TemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
  259. WxMsgTemplateIdAskByUser = `qfNuops-sKrfIkbA7U97A7gSrX03mUpoEpJksRUdloo`
  260. TemplateIdByCompanyApply = "yqaDUavXAKBpsPqTr0zYXAGIQYeCijZtWwFsT07wTbE"
  261. //销售跨部门领取客户通知
  262. TemplateIdByCompanyReceive = "-ccp916f5rjMhwj8CtOAW_d_Os6ran8q5okVCENg924"
  263. //销售"添加客户/领取客户"权限变更通知
  264. TemplateIdByCompanyReceivePermission = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450"
  265. WxMsgTemplateIdActivityChangeApply = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
  266. //路演
  267. WxMsgTemplateIdWithRoadshowPending = "1JG9fvKx9o9B-wkZe_gBFQQzMBnp07-hvpZI9QiFcKQ" //路演->研究员收到待处理的申请
  268. WxMsgTemplateIdWithRoadshowDetailResult = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->销售收到处理结果
  269. WxMsgTemplateIdWithRoadshowDeleteNotice = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->研究员收到活动删除通知
  270. // 研报小程序
  271. WxMsgTemplateIdWithYbCommunityQuestion = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 研报小程序->问答社区回复通知
  272. WxMsgTemplateIdWithSealApplyFinished = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 用印申请-已签回通知
  273. UserTemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
  274. }
  275. //查研观向小助手
  276. {
  277. //原有的模板ID
  278. WxPublicIdXzs = "wx9b5d7291e581233a" //查研观向小助手
  279. WxPublicSecretXzs = "f4d52e34021eee262dce9682b31f8861" //查研观向小助手
  280. WxMsgTemplateIdActivityChangeApplyXzs = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM" //查研观向活动变更通知-模板ID(小助手)
  281. TemplateIdByProductXzs = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY" //产品运行报告通知-模板ID(小助手)
  282. }
  283. }
  284. // 生产环境模板消息
  285. func WxRelease() {
  286. WxAppId = "wx4a844c734d8c8e56"
  287. WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  288. WxId = "gh_b67e0049fb8c"
  289. //模板消息
  290. {
  291. TemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84"
  292. TemplateIdByCompanyApply = "yqaDUavXAKBpsPqTr0zYXAGIQYeCijZtWwFsT07wTbE"
  293. WxMsgTemplateIdActivityChangeApply = "dYg6iHooRq74PyCXmw_Ns7qdJZmbtLoKS2p2FKeaXl0"
  294. //销售跨部门领取客户通知
  295. TemplateIdByCompanyReceive = "-ccp916f5rjMhwj8CtOAW_d_Os6ran8q5okVCENg924"
  296. //销售"添加客户/领取客户"权限变更通知
  297. TemplateIdByCompanyReceivePermission = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450"
  298. //路演
  299. WxMsgTemplateIdWithRoadshowPending = "1JG9fvKx9o9B-wkZe_gBFQQzMBnp07-hvpZI9QiFcKQ" //路演->研究员收到待处理的申请
  300. WxMsgTemplateIdWithRoadshowDetailResult = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->销售收到处理结果
  301. WxMsgTemplateIdWithRoadshowDeleteNotice = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->研究员收到活动删除通知
  302. // 研报小程序
  303. WxMsgTemplateIdWithYbCommunityQuestion = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 研报小程序->问答社区回复通知
  304. WxMsgTemplateIdWithSealApplyFinished = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 用印申请-已签回通知
  305. UserTemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84" //用户产品允许通知模版
  306. }
  307. //查研观向小助手
  308. {
  309. //新的模板ID
  310. WxPublicIdXzs = "wxb7cb8a15abad5b8e" //查研观向小助手
  311. WxPublicSecretXzs = "f425ba2863084249722af1e2a5cfffd3" //查研观向小助手
  312. WxMsgTemplateIdActivityChangeApplyXzs = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s" //查研观向活动变更通知-模板ID(小助手)
  313. TemplateIdByProductXzs = "tNcCUiK_uUkuxaFF7M9NP2RwLkw8uHFjG-TDIxGUKxo" //产品运行报告通知-模板ID(小助手)
  314. }
  315. }
  316. // CrmOpenApiConfig 上海crm开放api配置
  317. func CrmOpenApiConfig() {
  318. if RunMode == "release" {
  319. CRM_OPEN_API_URL = "http://crm.hzinsights.com/openapi"
  320. CRM_OPEN_API_APP_KEY = "26945134"
  321. CRM_OPEN_API_APP_SECRET = "b99cb2bdec70d20156000f664ec5ac30"
  322. } else {
  323. CRM_OPEN_API_URL = "http://106.15.192.100:8100/openapi"
  324. CRM_OPEN_API_APP_KEY = "26945134"
  325. CRM_OPEN_API_APP_SECRET = "b99cb2bdec70d20156000f664ec5ac30"
  326. }
  327. }
  328. // initQsOpenApiConfig 全时开放api配置
  329. func initQsOpenApiConfig() {
  330. QsAppID = "ed1cc7c87c97089263fc899fbab193b0"
  331. QsSecretKey = "d92b91265dbbc5e3af44edfb82503635"
  332. if RunMode == "release" {
  333. QsUserId = 22330940
  334. QsUserName = "1406228535@qq.com"
  335. } else {
  336. QsUserId = 19896481
  337. QsUserName = "pyan@hzinsights.com"
  338. }
  339. }
  340. // ComeinOpenApiConfig 进门开放api配置
  341. func ComeinOpenApiConfig() {
  342. if RunMode == "release" {
  343. COMEIN_URL = "https://server.comein.cn/comein/index.php"
  344. COMEIN_APPID = "39b48779-debd-446a-a303-900322d8e356"
  345. COMEIN_SECREKEY = "9102a767f20f11ecb5d6b8599f142ed4"
  346. } else {
  347. COMEIN_URL = "https://testserver.comein.cn/comein/index.php"
  348. COMEIN_APPID = "7b966708-4a8b-4d24-9066-fe29920e7eee"
  349. COMEIN_SECREKEY = "76e004876fae4b3c8721a3f4c2d115da"
  350. }
  351. }
  352. // YiDongApiConfig 易董开放api配置
  353. func YiDongApiConfig() {
  354. if RunMode == "release" {
  355. YiDongHuaWeiYunUrl = "https://achievement.valueonline.cn/"
  356. } else {
  357. YiDongHuaWeiYunUrl = "https://achievement-test.valueonline.cn/"
  358. }
  359. }
  360. // initSystemServer 内部服务配置
  361. func initSystemServer() {
  362. if RunMode == "release" {
  363. // ppt 转图片服务地址
  364. Ppt2ImageUrl = "http://172.19.173.232:8086/v1/image/ppt2img"
  365. } else {
  366. // ppt 转图片服务地址
  367. Ppt2ImageUrl = "http://127.0.0.1:8086/v1/image/ppt2img"
  368. }
  369. }
  370. //http://adminapi.brilliantstart.cn/admin/
  371. //http://adminapi.brilliantstart.cn/swagger/
  372. //http://8.136.199.33:8602/swagger/