config.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. package utils
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/core/logs"
  5. "github.com/beego/beego/v2/server/web"
  6. "github.com/rdlucklib/rdluck_tools/cache"
  7. "github.com/rdlucklib/rdluck_tools/log"
  8. )
  9. var (
  10. RunMode string //运行模式
  11. MYSQL_URL string //数据库连接
  12. MYSQL_URL_RDDP string //数据库连接
  13. MYSQL_URL_CYGX 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. TemplateIdByProduct string //产品运行报告通知-模板ID
  24. TemplateRedirectUrl string //模板消息跳转地址
  25. WxPlatform int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:1
  26. TemplateIdByCompanyApply string //客户申请单审批通知-模板ID
  27. TemplateCompanyApplyRedirectUrl string //审批单模板消息跳转地址
  28. //内部员工公众号(弘则部门)
  29. AdminWxAppId string
  30. AdminWxAppSecret string
  31. //微信小程序appid
  32. WxId2 string //微信原始ID
  33. WxAppId2 string
  34. WxAppSecret2 string
  35. WxPlatform2 int //用户来源,需要入库,用来保存该用户来自哪个平台,默认是:1
  36. WxYbAppId string //弘则研报小程序APPID
  37. WxMsgTemplateIdWithRoadshowPending string //路演->研究员收到待处理的申请
  38. WxMsgTemplateIdWithRoadshowDetailResult string //路演->销售收到处理结果
  39. WxMsgTemplateIdWithRoadshowDeleteNotice string //路演->研究员收到活动删除通知
  40. WxMsgTemplateIdWithSealApplyFinished string // 用印申请-已签回通知
  41. WxMsgTemplateIdWithYbCommunityQuestion string // 研报小程序->问答社区回复通知
  42. SendWxTemplateMsgUrl string //模板消息推送
  43. SendWxCategoryTemplateMsgUrl string
  44. //查研观向
  45. WxMsgTemplateIdCompanyApprovalMessageRai string //权益销售签约成功通知查研观向小助手模版消息
  46. WxMsgTemplateIdActivityChangeApply string //查研观向活动变更通知-模板ID
  47. // 类目模板
  48. WxCategoryMsgTemplateIdApplyXzs string //申请待处理(买方研选)
  49. WxCategoryMsgTemplateIdActivitySign string //买方研选活动签到通知-类目模板ID(买方研选)
  50. WxMsgCategoryTemplateIdCompanyApprovalMessageRai string //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  51. WxMsgCategoryTemplateIdActivityPublishApply string //买方研选关注的产业下,单个活动/研选报告发布通知-类目模板ID
  52. )
  53. var (
  54. STATIC_DIR string
  55. )
  56. var ApiLog *log.Log
  57. // LibreOfficePath LibreOfficePath的地址
  58. var LibreOfficePath string
  59. // 上海crm开放api配置
  60. var (
  61. CRM_OPEN_API_URL string
  62. CRM_OPEN_API_APP_KEY string
  63. CRM_OPEN_API_APP_SECRET string
  64. )
  65. var (
  66. Bucketname string = "hongze"
  67. Endpoint string
  68. Imghost string = "https://hongze.oss-accelerate.aliyuncs.com/"
  69. Upload_dir string = "static/images/"
  70. Upload_Audio_Dir string = "static/audio/"
  71. AccessKeyId string = "LTAIFMZYQhS2BTvW"
  72. AccessKeySecret string = "12kk1ptCHoGWedhBnKRVW5hRJzq9Fq"
  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, tempErr := GetLocalIP()
  82. if tempErr != nil {
  83. fmt.Println("init GetLocalIP Err:" + tempErr.Error())
  84. }
  85. fmt.Println("localIp:", localIp)
  86. if localIp == "10.0.0.123" {
  87. RunMode = "debug"
  88. } else {
  89. RunMode = "release"
  90. }
  91. fmt.Println("RunMode:", RunMode)
  92. configPath := `/home/code/config/hongze_mobile_admin/conf/app.conf`
  93. tempErr = web.LoadAppConfig("ini", configPath)
  94. if tempErr != nil {
  95. fmt.Println("web.LoadAppConfig Err:" + tempErr.Error())
  96. }
  97. }
  98. fmt.Println(RunMode, "模式")
  99. config, err := web.AppConfig.GetSection(RunMode)
  100. if err != nil {
  101. panic("配置文件读取错误 " + err.Error())
  102. }
  103. logs.Info(RunMode + " 模式")
  104. MYSQL_URL = config["mysql_url"]
  105. MYSQL_URL_RDDP = config["mysql_url_rddp"]
  106. MYSQL_URL_CYGX = config["mysql_url_cygx"]
  107. REDIS_CACHE = config["beego_cache"]
  108. if len(REDIS_CACHE) <= 0 {
  109. panic("redis链接参数没有配置")
  110. }
  111. Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
  112. if Re != nil {
  113. fmt.Println(Re)
  114. panic(Re)
  115. }
  116. //小程序appid配置
  117. WxAppId2 = `wx67b68e39913e511e`
  118. WxId2 = `wx67b68e39913e511e`
  119. WxAppSecret2 = `660b0375f701a19220bb8a662b41c77c`
  120. WxPlatform2 = 5
  121. WxYbAppId = `wxb059c872d79b9967` //弘则研报小程序
  122. if RunMode == "release" {
  123. //oss
  124. STATIC_DIR = "/home/static/imgs/"
  125. Endpoint = "oss-cn-shanghai-internal.aliyuncs.com"
  126. } else {
  127. //oss配置
  128. STATIC_DIR = "static/imgs/"
  129. Endpoint = "oss-cn-shanghai.aliyuncs.com"
  130. }
  131. tmpLibreOfficePath, err := web.AppConfig.String("libreOfficePath")
  132. if err != nil {
  133. panic("配置文件读取libreOfficePath错误 " + err.Error())
  134. }
  135. LibreOfficePath = tmpLibreOfficePath
  136. //日志类
  137. if RunMode == "release" {
  138. logDir := `/data/rdlucklog/hongze_mobile_admin`
  139. ApiLog = log.Init("20060102.api", logDir)
  140. } else {
  141. ApiLog = log.Init("20060102.api")
  142. }
  143. //上海crm开放api配置
  144. CrmOpenApiConfig()
  145. //微信配置
  146. wxConfig()
  147. }
  148. // CrmOpenApiConfig 上海crm开放api配置
  149. func CrmOpenApiConfig() {
  150. if RunMode == "release" {
  151. CRM_OPEN_API_URL = "http://crm.hzinsights.com/openapi"
  152. CRM_OPEN_API_APP_KEY = "26945134"
  153. CRM_OPEN_API_APP_SECRET = "b99cb2bdec70d20156000f664ec5ac30"
  154. } else {
  155. CRM_OPEN_API_URL = "http://106.15.192.100:8100/openapi"
  156. CRM_OPEN_API_APP_KEY = "26945134"
  157. CRM_OPEN_API_APP_SECRET = "b99cb2bdec70d20156000f664ec5ac30"
  158. }
  159. }
  160. func wxConfig() {
  161. if RunMode == "release" {
  162. WxAppId = "wx4a844c734d8c8e56"
  163. WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
  164. WxId = "gh_b67e0049fb8c"
  165. TemplateIdByProduct = "Cp2wF8gvBtxyWV4DeYuI172oqwyYXVRSm3AyJO42d84"
  166. TemplateRedirectUrl = "https://ficc.hzinsights.com/reportdtl?id="
  167. WxPlatform = 1
  168. TemplateIdByCompanyApply = "yqaDUavXAKBpsPqTr0zYXAGIQYeCijZtWwFsT07wTbE"
  169. TemplateCompanyApplyRedirectUrl = "https://ficc.hzinsights.com/approval/approval/list"
  170. //路演
  171. WxMsgTemplateIdWithRoadshowPending = "1JG9fvKx9o9B-wkZe_gBFQQzMBnp07-hvpZI9QiFcKQ" //路演->研究员收到待处理的申请
  172. WxMsgTemplateIdWithRoadshowDetailResult = "D6AFTJ7CbDDFBYg1R-HRir5bBXkIqGrwUtb2bjN-Wr4" //路演->销售收到处理结果
  173. WxMsgTemplateIdWithRoadshowDeleteNotice = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->研究员收到活动删除通知
  174. WxMsgTemplateIdWithSealApplyFinished = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 用印申请-已签回通知
  175. // 研报小程序
  176. WxMsgTemplateIdWithYbCommunityQuestion = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 研报小程序->问答社区回复通知
  177. //查研观向小助手原有的模板ID
  178. {
  179. WxMsgTemplateIdCompanyApprovalMessageRai = "JlGx2rKZKIsolvkQ1ZbGSBDNzIIJAaF1bbwcdLuJwQ8" //权益销售签约成功通知查研观向小助手模版消息-模板ID
  180. WxMsgTemplateIdActivityChangeApply = "dYg6iHooRq74PyCXmw_Ns7qdJZmbtLoKS2p2FKeaXl0" //查研观向活动变更通知-模板ID
  181. }
  182. //内部员工公众号(弘则部门)
  183. AdminWxAppId = "wx1392111da5426e9e"
  184. AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
  185. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  186. SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
  187. // 类目模版
  188. WxCategoryMsgTemplateIdApplyXzs = "HKD03oZfSv8LJgeoHz0pynai3G2Ls4h8zZ6BfOpZmIA"
  189. WxCategoryMsgTemplateIdActivitySign = "11rITVC5Gl8qwetxl92NqY887Uk14kg3nPtEA_i_zLo"
  190. WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "t1CcxcOkoZkWZrDRs6zYUlceBGYMV3mhkBYUa8a6Mx0" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  191. WxMsgCategoryTemplateIdActivityPublishApply = "IBMqiE61lVgUfFM4rsH0XCH57R_G3PbWvRbnzg9JHPI"
  192. } else {
  193. WxAppId = "wx9b5d7291e581233a"
  194. WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
  195. WxId = "gh_5dc508325c6f"
  196. TemplateIdByProduct = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"
  197. TemplateRedirectUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id="
  198. WxPlatform = 1
  199. TemplateIdByCompanyApply = "yqaDUavXAKBpsPqTr0zYXAGIQYeCijZtWwFsT07wTbE"
  200. TemplateCompanyApplyRedirectUrl = "http://advisoryadmin.brilliantstart.cn/approval/approval/list"
  201. //路演
  202. WxMsgTemplateIdWithRoadshowPending = "1JG9fvKx9o9B-wkZe_gBFQQzMBnp07-hvpZI9QiFcKQ" //路演->研究员收到待处理的申请
  203. WxMsgTemplateIdWithRoadshowDetailResult = "D6AFTJ7CbDDFBYg1R-HRir5bBXkIqGrwUtb2bjN-Wr4" //路演->销售收到处理结果
  204. WxMsgTemplateIdWithRoadshowDeleteNotice = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" //路演->研究员收到活动删除通知
  205. WxMsgTemplateIdWithSealApplyFinished = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 用印申请-已签回通知
  206. // 研报小程序
  207. WxMsgTemplateIdWithYbCommunityQuestion = "rciDm9ThigRBGi1SZ4TFd74XA4aoAxSz_ugdv_tZ450" // 研报小程序->问答社区回复通知
  208. //查研观向小助手原有的模板ID
  209. {
  210. WxMsgTemplateIdCompanyApprovalMessageRai = "RcV2uM5nFSiUtOHsq4SdYz2Fhk-OVfg5rutWz2IsSJQ" //权益销售签约成功通知查研观向小助手模版消息-模板ID
  211. WxMsgTemplateIdActivityChangeApply = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM" //查研观向活动变更通知-模板ID
  212. }
  213. //内部员工公众号(弘则部门)
  214. AdminWxAppId = "wx1392111da5426e9e"
  215. AdminWxAppSecret = "30eceb7cf29bf2f046031155ab55d7b4"
  216. SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
  217. SendWxCategoryTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_category_template_msg"
  218. //SendWxCategoryTemplateMsgUrl = "http://8.136.199.33:8086/v1/wechat/send_category_template_msg"
  219. // 类目模版
  220. WxCategoryMsgTemplateIdApplyXzs = "IemWOTzbnLBqJ2ozSiFqm13WjaotoC3V4uXaxTij08I"
  221. WxCategoryMsgTemplateIdActivitySign = "aczgUYZASO97UJiCD_nDmD1eNWZAWudzw3JYcvjJ2x4"
  222. WxMsgCategoryTemplateIdCompanyApprovalMessageRai = "wU4x_c5XruwuA44VZelyklRNOfq4XrU9ILckTtDs6hg" //权益销售签约成功通知买方研选类目模版消息通知-类目模板ID
  223. WxMsgCategoryTemplateIdActivityPublishApply = "wLeV7tVK4ZJBoAvsmfXkHveVW8yefGAkwnVKQWRi8uQ"
  224. }
  225. }
  226. //http://webapi.brilliantstart.cn/api/
  227. //http://webapi.brilliantstart.cn/swagger/
  228. //http://8.136.199.33:8607/swagger/