rai_serve_bill.go 6.4 KB

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