rai_serve_bill.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type RaiServeTypeResp struct {
  8. ServeTypeId int `description:"服务类型id"`
  9. ServeTypeName string `description:"服务类型名称"`
  10. }
  11. type RaiServeTypeListResp struct {
  12. List []*RaiServeTypeResp
  13. }
  14. // 服务类型列表
  15. func GetRaiServeTypeRespList(condition string) (items []*RaiServeTypeResp, err error) {
  16. o := orm.NewOrmUsingDB("hz_cygx")
  17. sql := `SELECT * FROM cygx_rai_serve_type WHERE 1= 1 `
  18. if condition != "" {
  19. sql += condition
  20. }
  21. sql += ` ORDER BY sort DESC LIMIT 100 `
  22. _, err = o.Raw(sql).QueryRows(&items)
  23. return
  24. }
  25. type RaiServeTagResp struct {
  26. TagType int `description:"标签类型"`
  27. TagId int `description:"标签ID"`
  28. TagName string `description:"标签名称"`
  29. Md5Key string `description:"加密key,前端找参数当唯一索引值使用"`
  30. }
  31. type ChekChartPermissionNameResp struct {
  32. ChartPermissionName string `description:"权限名称"`
  33. Belong bool `description:"权限名称"`
  34. }
  35. type RaiServeTagListResp struct {
  36. List []*RaiServeTagResp
  37. }
  38. type RaiServeCoverageRateResp struct {
  39. //List []string
  40. ThisWeekAmount string `comment:"本周互动量"`
  41. LastWeekAmount string `comment:"上周互动量"`
  42. TwoWeekAmount string `comment:"上上周互动量"`
  43. ThreeWeekAmount string `comment:"上三周互动量"`
  44. }
  45. // 服务类型列表
  46. func GetRaiServeSearchTagRespList(keywords string) (items []*RaiServeTagResp, err error) {
  47. o := orm.NewOrmUsingDB("hz_cygx")
  48. sql := `SELECT
  49. 1 AS tag_type,
  50. i.industrial_management_id AS tag_id,
  51. i.industry_name AS tag_name,
  52. i.create_time
  53. FROM
  54. cygx_industrial_management AS i
  55. WHERE
  56. 1 = 1
  57. AND i.chart_permission_id IN ( 19, 20, 21, 22 )
  58. AND (i.industry_name LIKE '%` + keywords + `%' ) UNION ALL
  59. SELECT
  60. 2 AS tag_type,
  61. s.industrial_subject_id AS tag_id,
  62. s.subject_name AS tag_name,
  63. s.create_time
  64. FROM
  65. cygx_industrial_subject AS s
  66. INNER JOIN cygx_industrial_management AS i ON i.industrial_management_id = s.industrial_management_id
  67. WHERE
  68. 1 = 1
  69. AND i.chart_permission_id IN ( 19, 20, 21, 22 )
  70. AND ( s.subject_name LIKE '%` + keywords + `%')
  71. ORDER BY
  72. create_time ASC `
  73. _, err = o.Raw(sql).QueryRows(&items)
  74. return
  75. }
  76. func GetRaiServeSearchTagRespListBycharId(keywords, charIds, conditionindustrial, conditionsubject string) (items []*RaiServeTagResp, err error) {
  77. o := orm.NewOrmUsingDB("hz_cygx")
  78. sql := `SELECT
  79. 1 AS tag_type,
  80. i.industrial_management_id AS tag_id,
  81. i.industry_name AS tag_name,
  82. i.create_time
  83. FROM
  84. cygx_industrial_management AS i
  85. WHERE
  86. 1 = 1
  87. AND i.chart_permission_id IN (` + charIds + ` )
  88. AND (i.industry_name LIKE '%` + keywords + `%' ` + conditionindustrial + ` ) UNION ALL
  89. SELECT
  90. 2 AS tag_type,
  91. s.industrial_subject_id AS tag_id,
  92. s.subject_name AS tag_name,
  93. s.create_time
  94. FROM
  95. cygx_industrial_subject AS s
  96. INNER JOIN cygx_industrial_management AS i ON i.industrial_management_id = s.industrial_management_id
  97. WHERE
  98. 1 = 1
  99. AND i.chart_permission_id IN (` + charIds + ` )
  100. AND ( s.subject_name LIKE '%` + keywords + `%' ` + conditionsubject + ` )
  101. ORDER BY
  102. create_time ASC `
  103. _, err = o.Raw(sql).QueryRows(&items)
  104. return
  105. }
  106. // 权益服务明细表
  107. type CygxRaiServeBillResp struct {
  108. Content string `comment:"服务内容说明"`
  109. ServeTypeName string `comment:"服务类型"`
  110. Mobile string `comment:"手机号"`
  111. Email string `comment:"邮箱"`
  112. RealName string `comment:"用户实际名称"`
  113. ServeCount float64 `comment:"服务量小计"`
  114. Tag string `comment:"标签,多个用 , 隔开"`
  115. IsKp int `comment:"是否是KP,1:是、0:否"`
  116. SourceId int `comment:"来源ID"`
  117. Source string `comment:"来源 "`
  118. ViewTime string `comment:"浏览时间"`
  119. ChartPermissionId int `description:"行业id"`
  120. ChartPermissionName string `description:"行业名称"`
  121. }
  122. type CygxRaiServeBillListResp struct {
  123. Paging *paging.PagingItem `description:"分页数据"`
  124. List []*CygxRaiServeBillResp
  125. }
  126. func GetCygxRaiServeBillCount(condition string, pars []interface{}) (count int, err error) {
  127. o := orm.NewOrmUsingDB("hz_cygx")
  128. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_rai_serve_bill as art WHERE 1= 1 `
  129. if condition != "" {
  130. sqlCount += condition
  131. }
  132. err = o.Raw(sqlCount, pars).QueryRow(&count)
  133. return
  134. }
  135. // 列表
  136. func GetCygxRaiServeBillRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxRaiServeBillResp, err error) {
  137. o := orm.NewOrmUsingDB("hz_cygx")
  138. sql := `SELECT * FROM cygx_rai_serve_bill as art WHERE 1= 1 `
  139. if condition != "" {
  140. sql += condition
  141. }
  142. sql += ` ORDER BY bill_id DESC LIMIT ?,? `
  143. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  144. return
  145. }
  146. // 权益服务明细表
  147. type CygxRaiServeBill struct {
  148. BillId int `orm:"column(bill_id);pk" description:"服务明细主键ID"`
  149. Content string `comment:"服务内容说明"`
  150. ServeTypeId int `comment:"服务类型ID"`
  151. ServeTypeName string `comment:"服务类型"`
  152. UserId int `comment:"用户ID"`
  153. Mobile string `comment:"手机号"`
  154. Email string `comment:"邮箱"`
  155. CompanyId int `comment:"公司ID"`
  156. CompanyName string `comment:"公司名称"`
  157. RealName string `comment:"用户实际名称"`
  158. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  159. ServeCount float64 `comment:"服务量小计"`
  160. IsKp int `comment:"是否是KP,1:是、0:否"`
  161. SourceId int `comment:"来源ID"`
  162. Source string `comment:"来源 "`
  163. WeekStartDate string `comment:"周一开始日期"`
  164. WeekEndDate string `comment:"周日结束日期"`
  165. CreateTime time.Time `comment:"创建时间"`
  166. ViewTime string `comment:"浏览时间"`
  167. }
  168. // 列表
  169. func GetCygxRaiServeBillListAll(condition string, pars []interface{}) (items []*CygxRaiServeBill, err error) {
  170. if condition == "" {
  171. return
  172. }
  173. o := orm.NewOrmUsingDB("hz_cygx")
  174. sql := `SELECT * FROM cygx_rai_serve_bill WHERE 1= 1 `
  175. if condition != "" {
  176. sql += condition
  177. }
  178. _, err = o.Raw(sql, pars).QueryRows(&items)
  179. return
  180. }