eta_trial.go 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. package eta_forum
  2. import (
  3. "encoding/json"
  4. "eta/eta_api/models"
  5. "eta/eta_api/models/eta_trial"
  6. "eta/eta_api/services/alarm_msg"
  7. "fmt"
  8. )
  9. // EtaTrialUserReq 更新试用客户最后登录时间和次数请求体
  10. type EtaTrialUserReq struct {
  11. Mobile string `description:"手机号"`
  12. }
  13. // UpdateEtaTrialUserLogin eta_forum_hub服务-更新试用客户最后登录时间和次数
  14. func UpdateEtaTrialUserLogin(pars EtaTrialUserReq) (res bool, err error) {
  15. defer func() {
  16. if err != nil {
  17. alarm_msg.SendAlarmMsg(fmt.Sprintf("GetEtaTrialMobileCount, 新增试用客户手工录入权限失败, ErrMsg: %s", err.Error()), 3)
  18. }
  19. }()
  20. reqJson, e := json.Marshal(pars)
  21. if e != nil {
  22. err = fmt.Errorf("data json marshal err: %s", e.Error())
  23. return
  24. }
  25. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/update_login")
  26. resp := new(models.BaseResponse)
  27. err = json.Unmarshal(resultByte, &resp)
  28. if err != nil {
  29. return
  30. }
  31. if resp.Ret != 200 {
  32. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  33. return
  34. }
  35. res = true
  36. return
  37. }
  38. // GetEtaTrialUserReq 获取试用客户请求体
  39. type GetEtaTrialUserReq struct {
  40. Mobile string `description:"手机号"`
  41. }
  42. type EtaTrialUserResp struct {
  43. Ret int
  44. Msg string
  45. ErrMsg string
  46. ErrCode string
  47. Data eta_trial.EtaTrialUserItem
  48. Success bool `description:"true 执行成功,false 执行失败"`
  49. }
  50. // GetEtaTrialUser eta_forum_hub服务-获取试用客户信息
  51. func GetEtaTrialUser(pars GetEtaTrialUserReq) (res eta_trial.EtaTrialUserItem, err error) {
  52. defer func() {
  53. if err != nil {
  54. alarm_msg.SendAlarmMsg(fmt.Sprintf("GetEtaTrialUser, 获取试用客户信息, ErrMsg: %s", err.Error()), 3)
  55. }
  56. }()
  57. reqJson, e := json.Marshal(pars)
  58. if e != nil {
  59. err = fmt.Errorf("data json marshal err: %s", e.Error())
  60. return
  61. }
  62. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/mobile_fetch")
  63. resp := new(EtaTrialUserResp)
  64. err = json.Unmarshal(resultByte, &resp)
  65. if err != nil {
  66. return
  67. }
  68. if resp.Ret != 200 {
  69. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  70. return
  71. }
  72. res = resp.Data
  73. return
  74. }
  75. // DisableEtaTrialUser eta_forum_hub服务-禁用试用客户
  76. func DisableEtaTrialUser(pars EtaTrialUserReq) (res bool, err error) {
  77. defer func() {
  78. if err != nil {
  79. alarm_msg.SendAlarmMsg(fmt.Sprintf("DisableEtaTrialUser eta_forum_hub服务-禁用试用客户, ErrMsg: %s", err.Error()), 3)
  80. }
  81. }()
  82. reqJson, e := json.Marshal(pars)
  83. if e != nil {
  84. err = fmt.Errorf("data json marshal err: %s", e.Error())
  85. return
  86. }
  87. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/disable")
  88. resp := new(models.BaseResponse)
  89. err = json.Unmarshal(resultByte, &resp)
  90. if err != nil {
  91. return
  92. }
  93. if resp.Ret != 200 {
  94. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  95. return
  96. }
  97. res = true
  98. return
  99. }
  100. // RemoveEtaTrialUser eta_forum_hub服务-删除试用客户
  101. func RemoveEtaTrialUser(pars EtaTrialUserReq) (res bool, err error) {
  102. defer func() {
  103. if err != nil {
  104. alarm_msg.SendAlarmMsg(fmt.Sprintf("RemoveEtaTrialUser eta_forum_hub服务-删除试用客户失败, ErrMsg: %s", err.Error()), 3)
  105. }
  106. }()
  107. reqJson, e := json.Marshal(pars)
  108. if e != nil {
  109. err = fmt.Errorf("data json marshal err: %s", e.Error())
  110. return
  111. }
  112. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/remove")
  113. resp := new(models.BaseResponse)
  114. err = json.Unmarshal(resultByte, &resp)
  115. if err != nil {
  116. return
  117. }
  118. if resp.Ret != 200 {
  119. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  120. return
  121. }
  122. res = true
  123. return
  124. }
  125. // EtaTrialUserEditReq 更新用户信息请求体
  126. type EtaTrialUserEditReq struct {
  127. RealName string `description:"姓名"`
  128. Position string `description:"职务"`
  129. Mobile string `description:"手机号"`
  130. Enabled int `description:"禁启用"`
  131. }
  132. // EditEtaTrialUser eta_forum_hub服务-编辑试用客户
  133. func EditEtaTrialUser(pars EtaTrialUserEditReq) (res bool, err error) {
  134. defer func() {
  135. if err != nil {
  136. alarm_msg.SendAlarmMsg(fmt.Sprintf("EditEtaTrialUser eta_forum_hub服务-编辑试用客户失败, ErrMsg: %s", err.Error()), 3)
  137. }
  138. }()
  139. reqJson, e := json.Marshal(pars)
  140. if e != nil {
  141. err = fmt.Errorf("data json marshal err: %s", e.Error())
  142. return
  143. }
  144. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/edit")
  145. resp := new(models.BaseResponse)
  146. err = json.Unmarshal(resultByte, &resp)
  147. if err != nil {
  148. return
  149. }
  150. if resp.Ret != 200 {
  151. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  152. return
  153. }
  154. res = true
  155. return
  156. }
  157. // UpdateUserIndexNum eta_forum_hub服务-更新用户累计新增指标数
  158. func UpdateUserIndexNum(pars EtaTrialUserReq) (res bool, err error) {
  159. defer func() {
  160. if err != nil {
  161. alarm_msg.SendAlarmMsg(fmt.Sprintf(" UpdateUserIndexNum eta_forum_hub服务-更新用户累计新增指标数失败, ErrMsg: %s", err.Error()), 3)
  162. }
  163. }()
  164. reqJson, e := json.Marshal(pars)
  165. if e != nil {
  166. err = fmt.Errorf("data json marshal err: %s", e.Error())
  167. return
  168. }
  169. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/update_index_num")
  170. resp := new(models.BaseResponse)
  171. err = json.Unmarshal(resultByte, &resp)
  172. if err != nil {
  173. return
  174. }
  175. if resp.Ret != 200 {
  176. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  177. return
  178. }
  179. res = true
  180. return
  181. }
  182. // UpdateUserChartNum eta_forum_hub服务-更新用户累计新增图表数
  183. func UpdateUserChartNum(pars EtaTrialUserReq) (res bool, err error) {
  184. defer func() {
  185. if err != nil {
  186. alarm_msg.SendAlarmMsg(fmt.Sprintf("UpdateUserChartNum eta_forum_hub服务-更新用户累计新增图表数失败, ErrMsg: %s", err.Error()), 3)
  187. }
  188. }()
  189. reqJson, e := json.Marshal(pars)
  190. if e != nil {
  191. err = fmt.Errorf("data json marshal err: %s", e.Error())
  192. return
  193. }
  194. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/update_chart_num")
  195. resp := new(models.BaseResponse)
  196. err = json.Unmarshal(resultByte, &resp)
  197. if err != nil {
  198. return
  199. }
  200. if resp.Ret != 200 {
  201. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  202. return
  203. }
  204. res = true
  205. return
  206. }
  207. // UpdateEtaTrialUserActiveTimeReq 更新试用客户活跃时长请求体
  208. type UpdateEtaTrialUserActiveTimeReq struct {
  209. Mobile string `description:"手机号"`
  210. UserName string `description:"用户姓名"`
  211. ActiveTime int `description:"活跃时长, 单位秒"`
  212. Part string `description:"活跃板块"`
  213. }
  214. // UpdateEtaTrialUserActiveTime eta_forum_hub服务-更新试用客户活跃时长
  215. func UpdateEtaTrialUserActiveTime(pars UpdateEtaTrialUserActiveTimeReq) (res bool, err error) {
  216. defer func() {
  217. if err != nil {
  218. alarm_msg.SendAlarmMsg(fmt.Sprintf("UpdateEtaTrialUserActiveTime eta_forum_hub服务-更新试用客户活跃时长失败, ErrMsg: %s", err.Error()), 3)
  219. }
  220. }()
  221. reqJson, e := json.Marshal(pars)
  222. if e != nil {
  223. err = fmt.Errorf("data json marshal err: %s", e.Error())
  224. return
  225. }
  226. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/update_active_time")
  227. resp := new(models.BaseResponse)
  228. err = json.Unmarshal(resultByte, &resp)
  229. if err != nil {
  230. return
  231. }
  232. if resp.Ret != 200 {
  233. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  234. return
  235. }
  236. res = true
  237. return
  238. }
  239. // UpdateEtaTrialUserLoginDurationReq 更新试用客户登录时长请求体
  240. type UpdateEtaTrialUserLoginDurationReq struct {
  241. Mobile string `description:"手机号"`
  242. UserName string `description:"用户姓名"`
  243. ActiveTime int `description:"活跃时长, 单位秒"`
  244. }
  245. // UpdateEtaTrialUserLoginDuration eta_forum_hub服务-更新试用客户登录时长
  246. func UpdateEtaTrialUserLoginDuration(pars UpdateEtaTrialUserLoginDurationReq) (res bool, err error) {
  247. defer func() {
  248. if err != nil {
  249. alarm_msg.SendAlarmMsg(fmt.Sprintf("UpdateEtaTrialUserLoginDuration eta_forum_hub服务-更新试用客户登录时长失败, ErrMsg: %s", err.Error()), 3)
  250. }
  251. }()
  252. reqJson, e := json.Marshal(pars)
  253. if e != nil {
  254. err = fmt.Errorf("data json marshal err: %s", e.Error())
  255. return
  256. }
  257. _, resultByte, err := post(string(reqJson), "/v1/eta_trial/user/update_login_duration")
  258. resp := new(models.BaseResponse)
  259. err = json.Unmarshal(resultByte, &resp)
  260. if err != nil {
  261. return
  262. }
  263. if resp.Ret != 200 {
  264. err = fmt.Errorf("result: %s, errmsg: %s", resp.Msg, resp.ErrMsg)
  265. return
  266. }
  267. res = true
  268. return
  269. }