rai_serve_bill.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. }
  120. type CygxRaiServeBillListResp struct {
  121. Paging *paging.PagingItem `description:"分页数据"`
  122. List []*CygxRaiServeBillResp
  123. }
  124. func GetCygxRaiServeBillCount(condition string, pars []interface{}) (count int, err error) {
  125. o := orm.NewOrmUsingDB("hz_cygx")
  126. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_rai_serve_bill as art WHERE 1= 1 `
  127. if condition != "" {
  128. sqlCount += condition
  129. }
  130. err = o.Raw(sqlCount, pars).QueryRow(&count)
  131. return
  132. }
  133. // 列表
  134. func GetCygxRaiServeBillRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxRaiServeBillResp, err error) {
  135. o := orm.NewOrmUsingDB("hz_cygx")
  136. sql := `SELECT * FROM cygx_rai_serve_bill as art WHERE 1= 1 `
  137. if condition != "" {
  138. sql += condition
  139. }
  140. sql += ` ORDER BY bill_id DESC LIMIT ?,? `
  141. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  142. return
  143. }
  144. // 权益服务明细表
  145. type CygxRaiServeBill struct {
  146. BillId int `orm:"column(bill_id);pk" description:"服务明细主键ID"`
  147. Content string `comment:"服务内容说明"`
  148. ServeTypeId int `comment:"服务类型ID"`
  149. ServeTypeName string `comment:"服务类型"`
  150. UserId int `comment:"用户ID"`
  151. Mobile string `comment:"手机号"`
  152. Email string `comment:"邮箱"`
  153. CompanyId int `comment:"公司ID"`
  154. CompanyName string `comment:"公司名称"`
  155. RealName string `comment:"用户实际名称"`
  156. RegisterPlatform int `comment:"来源 1小程序,2:网页"`
  157. ServeCount float64 `comment:"服务量小计"`
  158. IsKp int `comment:"是否是KP,1:是、0:否"`
  159. SourceId int `comment:"来源ID"`
  160. Source string `comment:"来源 "`
  161. WeekStartDate string `comment:"周一开始日期"`
  162. WeekEndDate string `comment:"周日结束日期"`
  163. CreateTime time.Time `comment:"创建时间"`
  164. ViewTime string `comment:"浏览时间"`
  165. }
  166. // 列表
  167. func GetCygxRaiServeBillListAll(condition string, pars []interface{}) (items []*CygxRaiServeBill, err error) {
  168. if condition == "" {
  169. return
  170. }
  171. o := orm.NewOrmUsingDB("hz_cygx")
  172. sql := `SELECT * FROM cygx_rai_serve_bill WHERE 1= 1 `
  173. if condition != "" {
  174. sql += condition
  175. }
  176. _, err = o.Raw(sql, pars).QueryRows(&items)
  177. return
  178. }