company_user.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. package company
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/utils"
  7. "time"
  8. )
  9. // 新增客户请求参数
  10. type AddUserReq struct {
  11. RealName string `description:"姓名"`
  12. Sex int `description:"用户性别,1为男性,2为女性"`
  13. Source string `description:"来源,新增客户时添加:add_custom;领取客户时添加:pick_custom;普通领取联系人时添加:add_user"`
  14. RegionType string `description:"区域,枚举值:国内、海外"`
  15. CountryCode string `description:"区号,86、852、886等"`
  16. MobileOne string `description:"手机号1"`
  17. MobileTwo string `description:"手机号2"`
  18. Email string `description:"邮箱"`
  19. Position string `description:"职位"`
  20. IsMaker int `description:"是否决策人,1:是,0:否"`
  21. BusinessCardUrl string `description:"名片地址"`
  22. CompanyId int `description:"客户id"`
  23. DepartmentName string `description:"联系人部门"`
  24. CompanyName string `description:"客户名称(公司名称)"`
  25. }
  26. type CompanyUser struct {
  27. UserId int64 `orm:"column(user_id);pk"`
  28. CountryCode string `description:"区号,86、852、886等"`
  29. Mobile string `description:"手机号"`
  30. Email string `description:"邮箱"`
  31. CompanyId int `description:"公司id"`
  32. CompanyName string `description:"公司名称"`
  33. RealName string `description:"姓名"`
  34. CreatedTime string `description:"创建时间"`
  35. MobileTwo string `description:"备用手机号"`
  36. BusinessCardUrl string `description:"名片地址"`
  37. IsMaker int `description:"是否决策人,1:是,0:否"`
  38. Position string `description:"职位"`
  39. Sex int `description:"普通用户性别,1为男性,2为女性"`
  40. IsRegister bool `description:"是否注册,true:已注册,false:未注册"`
  41. OpenId string `json:"-"`
  42. DepartmentName string `description:"联系人部门"`
  43. SellerRealName string `description:"销售"`
  44. Status string `description:"客户状态"`
  45. HasMove bool `description:"true:可移动,false:显示知道了"`
  46. ViewTotal int `description:"累计阅读次数"`
  47. LastViewTime time.Time `json:"-" description:"最后一次阅读时间"`
  48. LastViewTimeStr string `description:"最后一次阅读时间"`
  49. ApplyMethod int `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
  50. RegisterTime string `description:"注册时间"`
  51. RegisterPlatform int `description:"注册平台,1:微信端,2:网页端"`
  52. SellerId int `description:"销售id"`
  53. SellerName string `description:"销售名称"`
  54. GroupId int `description:"所属销售分组id"`
  55. DepartmentId int `description:"所属销售分组id"`
  56. IsShared bool `description:"是否共享联系人"`
  57. ProductIds string `description:"商品权限集合,用英文,隔开"`
  58. IsChartPermissionSetting int `description:"是否设置过图表权限, 0-未设置,1-已设置,2-无需设置"`
  59. YbProductViewTotal int `description:"研报分产品阅读统计"`
  60. IsSubscribe int `description:"是否关注了微信公众号: 0-未关注; 1-已关注"`
  61. IsFollow int `description:"是否特别关注: 0-未关注; 1-已关注"`
  62. IsSubscribeHzyj int `description:"是否关注了弘则研究微信公众号: 0-未关注; 1-已关注"`
  63. IsSubscribeCygx int `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
  64. FiccViewTotal int `description:"ficc报告的阅读次数" json:"-"`
  65. FiccLastViewTime time.Time `description:"ficc报告最近一次阅读时间" json:"-"`
  66. RaiViewTotal int `description:"权益报告的阅读次数" json:"-"`
  67. RaiLastViewTime time.Time `description:"权益报告的最近一次阅读时间" json:"-"`
  68. NotRead bool `description:"是否七天内未阅读"`
  69. }
  70. type CompanyUserListResp struct {
  71. Paging *paging.PagingItem
  72. List []*CompanyUser
  73. }
  74. // 联系人数量总数返回数据结构体
  75. type CompanyUserTotal struct {
  76. Total int `description:"联系人总数"`
  77. }
  78. func GetCompanyUserListCount(condition string, pars []interface{}, companyId int) (count int, err error) {
  79. o := orm.NewOrm()
  80. sql := ` SELECT COUNT(1) AS count FROM wx_user AS a WHERE company_id=? `
  81. if condition != "" {
  82. sql += condition
  83. }
  84. err = o.Raw(sql, companyId, pars).QueryRow(&count)
  85. return
  86. }
  87. func GetCompanyUserList(condition string, pars []interface{}, companyId, startSize, pageSize int) (items []*CompanyUser, err error) {
  88. o := orm.NewOrm()
  89. sql := ` SELECT a.*,b.company_name,
  90. (SELECT count(1) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS view_total,
  91. (SELECT max(uvh.created_time) FROM user_view_history AS uvh WHERE uvh.user_id=a.user_id GROUP BY a.user_id) AS last_view_time
  92. FROM wx_user AS a
  93. INNER JOIN company AS b ON a.company_id=b.company_id
  94. WHERE a.company_id=? `
  95. if condition != "" {
  96. sql += condition
  97. }
  98. sql += `ORDER BY a.last_updated_time DESC LIMIT ?,? `
  99. _, err = o.Raw(sql, companyId, pars, startSize, pageSize).QueryRows(&items)
  100. return
  101. }
  102. // 获取该用户下联系人数量(跟销售绑定,2021年03月09日16:35:11)
  103. func GetCompanyUserListCountV2(condition string, pars []interface{}, companyId int) (count int, err error) {
  104. o := orm.NewOrm()
  105. tmpSql := `SELECT
  106. a.*, c.subscribe AS is_subscribe
  107. FROM
  108. wx_user AS a
  109. LEFT JOIN user_seller_relation AS b ON a.user_id = b.user_id
  110. LEFT JOIN (SELECT * FROM user_record WHERE create_platform = 1 GROUP BY user_id) AS c ON a.user_id = c.user_id
  111. WHERE
  112. a.company_id = ? `
  113. if condition != "" {
  114. tmpSql += condition
  115. }
  116. sql := `SELECT COUNT(1) AS count FROM (` + tmpSql + ` group by a.user_id) AS c `
  117. err = o.Raw(sql, companyId, pars).QueryRow(&count)
  118. return
  119. }
  120. // 获取该用户下联系人切片列表(跟销售绑定,2021年03月09日16:35:11)
  121. func GetCompanyUserListV2(condition string, pars []interface{}, companyId, startSize, pageSize int) (items []*CompanyUser, err error) {
  122. o := orm.NewOrm()
  123. sql := `SELECT
  124. a.*, a.cygx_subscribe as is_subscribe_cygx, c.subscribe AS is_subscribe_hzyj
  125. FROM
  126. wx_user AS a
  127. LEFT JOIN user_seller_relation AS b ON a.user_id = b.user_id
  128. LEFT JOIN (SELECT * FROM user_record WHERE create_platform = 1 GROUP BY user_id) AS c ON a.user_id = c.user_id
  129. WHERE
  130. a.company_id = ? `
  131. if condition != "" {
  132. sql += condition
  133. }
  134. sql += ` group by a.user_id ORDER BY CASE WHEN is_follow = 1 AND (report_last_view_time < NOW() - INTERVAL 7 DAY or report_last_view_time is NULL ) THEN 0 ELSE 1 END,a.is_register desc,a.report_last_view_time desc,a.last_updated_time DESC LIMIT ?,? `
  135. //sql += ` group by a.user_id ORDER BY CASE WHEN is_follow = 1 AND (report_last_view_time < NOW() - INTERVAL 7 DAY or report_last_view_time is NULL ) THEN 0 ELSE 1 END,a.is_register desc,a.report_last_view_time ASC,a.last_updated_time ASC LIMIT ?,? `
  136. _, err = o.Raw(sql, companyId, pars, startSize, pageSize).QueryRows(&items)
  137. return
  138. }
  139. // GetCompanyUserListById 获取该用户下联系人切片列表
  140. func GetCompanyUserListById(companyId int) (items []*CompanyUser, err error) {
  141. o := orm.NewOrm()
  142. sql := ` SELECT a.* FROM wx_user AS a WHERE a.company_id=? `
  143. _, err = o.Raw(sql, companyId).QueryRows(&items)
  144. return
  145. }
  146. // 删除客户请求参数
  147. type DeleteUserReq struct {
  148. UserId int `orm:"column(user_id);pk"`
  149. }
  150. func DeleteCompanyUser(userId int) (err error) {
  151. o := orm.NewOrm()
  152. sql := ` DELETE FROM wx_user WHERE user_id=? `
  153. _, err = o.Raw(sql, userId).Exec()
  154. return
  155. }
  156. // 新增客户请求参数
  157. type EditUserReq struct {
  158. UserId int `orm:"column(user_id);pk"`
  159. RealName string `description:"姓名"`
  160. Sex int `description:"用户性别,1为男性,2为女性"`
  161. CountryCode string `description:"区号,86、852、886等"`
  162. MobileOne string `description:"手机号1"`
  163. MobileTwo string `description:"手机号2"`
  164. Email string `description:"邮箱"`
  165. Position string `description:"职位"`
  166. IsMaker int `description:"是否决策人,1:是,0:否"`
  167. BusinessCardUrl string `description:"名片地址"`
  168. CompanyId int `description:"客户id"`
  169. DepartmentName string `description:"联系人部门"`
  170. }
  171. func EditCompanyUser(item *EditUserReq) (err error) {
  172. o := orm.NewOrm()
  173. sql := ` UPDATE wx_user
  174. SET
  175. real_name=?,
  176. mobile= ?,
  177. email = ?,
  178. sex = ?,
  179. last_updated_time = NOW(),
  180. position = ?,
  181. is_maker = ?,
  182. business_card_url = ?,
  183. mobile_two= ?,
  184. department_name=?,
  185. company_id=?,country_code=?
  186. WHERE user_id = ? `
  187. _, err = o.Raw(sql, item.RealName, item.MobileOne, item.Email, item.Sex, item.Position, item.IsMaker, item.BusinessCardUrl, item.MobileTwo, item.DepartmentName, item.CompanyId, item.CountryCode, item.UserId).Exec()
  188. return
  189. }
  190. // 修改联系人的联系方式
  191. func EditCompanyUserContact(userId int64, mobileOne, mobileTwo, email, businessCardUrl string) (err error) {
  192. o := orm.NewOrm()
  193. sql := ` UPDATE wx_user
  194. SET
  195. mobile= ?,
  196. mobile_two= ?,
  197. email = ?,
  198. business_card_url = ?,
  199. last_updated_time = NOW()
  200. WHERE user_id = ? `
  201. _, err = o.Raw(sql, mobileOne, mobileTwo, email, businessCardUrl, userId).Exec()
  202. return
  203. }
  204. func GetCompanyIdByKeyWord(keyWord string) (company_id string, err error) {
  205. o := orm.NewOrm()
  206. sql := ` SELECT GROUP_CONCAT(DISTINCT company_id) AS company_id FROM wx_user WHERE mobile LIKE '%` + keyWord + `%' OR email LIKE '%` + keyWord + `%'`
  207. err = o.Raw(sql).QueryRow(&company_id)
  208. return
  209. }
  210. func GetCompanyIdByKeyWordAll(keyWord string) (company_id string, err error) {
  211. o := orm.NewOrm()
  212. sql := ` SELECT GROUP_CONCAT(DISTINCT company_id) AS company_id FROM wx_user WHERE mobile LIKE '%` + keyWord + `%' OR email LIKE '%` + keyWord + `%' `
  213. err = o.Raw(sql).QueryRow(&company_id)
  214. return
  215. }
  216. func GetCompanyUserCount(companyId int) (count int, err error) {
  217. o := orm.NewOrm()
  218. sql := ` SELECT COUNT(1) AS count FROM wx_user WHERE company_id =? `
  219. err = o.Raw(sql, companyId).QueryRow(&count)
  220. return
  221. }
  222. func CheckCompanyUserCountByMobileTwo(mobileTwo string) (item *CompanyUser, err error) {
  223. o := orm.NewOrm()
  224. sql := ` SELECT a.*,b.company_name,GROUP_CONCAT(DISTINCT d.real_name SEPARATOR '/') AS seller_real_name,GROUP_CONCAT(DISTINCT c.status SEPARATOR '/') AS status
  225. FROM wx_user AS a
  226. LEFT JOIN company AS b ON a.company_id=b.company_id
  227. LEFT JOIN company_product AS c ON b.company_id=c.company_id
  228. LEFT JOIN admin AS d ON c.seller_id=d.admin_id
  229. WHERE a.mobile_two =? GROUP BY a.company_id `
  230. err = o.Raw(sql, mobileTwo).QueryRow(&item)
  231. return
  232. }
  233. func CheckCompanyUserCountByEmail(email string) (item *CompanyUser, err error) {
  234. o := orm.NewOrm()
  235. sql := ` SELECT a.*,b.company_name,GROUP_CONCAT(DISTINCT d.real_name SEPARATOR '/') AS seller_real_name,GROUP_CONCAT(DISTINCT c.status SEPARATOR '/') AS status
  236. FROM wx_user AS a
  237. LEFT JOIN company AS b ON a.company_id=b.company_id
  238. LEFT JOIN company_product AS c ON b.company_id=c.company_id
  239. LEFT JOIN admin AS d ON c.seller_id=d.admin_id
  240. WHERE a.email =? GROUP BY a.company_id `
  241. err = o.Raw(sql, email).QueryRow(&item)
  242. return
  243. }
  244. func GetUserCountByMobile(mobile string) (item *CompanyUser, err error) {
  245. o := orm.NewOrm()
  246. sql := ` SELECT a.*,b.company_name,GROUP_CONCAT(DISTINCT d.real_name SEPARATOR '/') AS seller_real_name,GROUP_CONCAT(DISTINCT c.status SEPARATOR '/') AS status
  247. FROM wx_user AS a
  248. LEFT JOIN company AS b ON a.company_id=b.company_id
  249. LEFT JOIN company_product AS c ON b.company_id=c.company_id
  250. LEFT JOIN admin AS d ON c.seller_id=d.admin_id
  251. WHERE a.mobile=? GROUP BY a.company_id `
  252. err = o.Raw(sql, mobile).QueryRow(&item)
  253. return
  254. }
  255. //<template slot-scope="scope">{{scope.row.ReportType=='day'?'晨报':scope.row.ReportType=='week'?'周报':scope.row.ReportType=='twoweek'?'双周报':scope.row.ReportType=='month'?'月报':scope.row.ReportType=='rddp'?'日度点评':scope.row.ReportType=='cygx'?'查研观向':scope.row.ReportType=='advisory'?'每日商品聚焦':''}}</template>
  256. type ViewReportList struct {
  257. ResearchReportName string `description:"报告标题"`
  258. ReportType string `description:"报告类型 'day 晨报'、'week 周报'、'twoweek 双周报'、'month 月报'、'rddp 日度点评'、'cygx 查研观向'、'advisory 每日商品聚焦'"`
  259. CreatedTime string `description:"创建时间"`
  260. TxtType string `description:"类型 ficc:ficc 、 rights:权益"`
  261. MatchTypeName string `description:"匹配类型"`
  262. StopTime string `description:"停留时间"`
  263. }
  264. type ViewReportListResp struct {
  265. Total int `description:"数量"`
  266. List []*ViewReportList
  267. }
  268. func ModifyCompanyUserCompanyId(userId, companyId int) (err error) {
  269. o := orm.NewOrm()
  270. sql := ` UPDATE wx_user SET company_id=? WHERE user_id=? `
  271. _, err = o.Raw(sql, companyId, userId).Exec()
  272. return
  273. }
  274. func GetCompanyUserBusinessCardCount(companyId int) (count int, err error) {
  275. o := orm.NewOrm()
  276. sql := ` SELECT COUNT(1) AS count FROM wx_user WHERE company_id =? AND business_card_url<>'' `
  277. err = o.Raw(sql, companyId).QueryRow(&count)
  278. return
  279. }
  280. // 标记用户
  281. func DealCompanyUser(userId int) (err error) {
  282. o := orm.NewOrm()
  283. sql := ` UPDATE wx_user SET is_deal=1 WHERE user_id=? `
  284. _, err = o.Raw(sql, userId).Exec()
  285. return
  286. }
  287. type CompanyActivityUser struct {
  288. UserId int64
  289. Mobile string `description:"手机号"`
  290. Email string `description:"邮箱"`
  291. CompanyId int `description:"公司id"`
  292. CompanyName string `description:"公司名称"`
  293. RealName string `description:"姓名"`
  294. }
  295. // GetNoPotentialCompanyUserList 获取不是潜在客户的联系人列表
  296. func GetNoPotentialCompanyUserList(condition string, pars []interface{}) (items []*CompanyActivityUser, err error) {
  297. o := orm.NewOrm()
  298. sql := ` SELECT a.user_id,a.mobile,a.email,a.company_id,a.real_name,b.company_name FROM wx_user AS a
  299. INNER JOIN company AS b ON a.company_id=b.company_id WHERE a.company_id>1 `
  300. if condition != "" {
  301. sql += condition
  302. }
  303. sql += `ORDER BY a.last_updated_time DESC `
  304. _, err = o.Raw(sql, pars).QueryRows(&items)
  305. return
  306. }
  307. // GetFiccCompanyUserByUserIds 批量查询用户的购买ficc的产品详情
  308. func GetFiccCompanyUserByUserIds(userIds string) (list []*CompanyUser, err error) {
  309. o := orm.NewOrm()
  310. sql := ` SELECT a.user_id, a.real_name, if(b.company_id=1,"",b.company_name) as company_name, c.status, b.company_id, c.seller_name
  311. FROM wx_user AS a
  312. LEFT JOIN company AS b ON a.company_id=b.company_id
  313. LEFT JOIN company_product AS c ON a.company_id=c.company_id and c.product_id=1
  314. WHERE a.user_id in (` + userIds + `)`
  315. _, err = o.Raw(sql).QueryRows(&list)
  316. return
  317. }
  318. // UserImportMatchResp 联系人名单导入匹配响应体
  319. type UserImportMatchResp struct {
  320. List []*UserImportMatch `description:"名单列表"`
  321. Code string `description:"下载名单的code"`
  322. }
  323. // UserImportMatch 联系人名单导入匹配
  324. type UserImportMatch struct {
  325. UserName string `description:"姓名"`
  326. CountryCode string `description:"国际(区号)"`
  327. Mobile string `description:"手机号"`
  328. CompanyName string `description:"导入的客户名称"`
  329. SysCompanyName string `description:"系统匹配的客户名称"`
  330. FiccStatus string `descripiton:"FICC状态"`
  331. FiccSeller string `description:"FICC销售"`
  332. RaiStatus string `description:"权益状态"`
  333. RaiSeller string `description:"权益销售"`
  334. }
  335. // GetCompanyUsersByCondition 获取联系人列表
  336. func GetCompanyUsersByCondition(condition string, pars []interface{}) (list []*CompanyUser, err error) {
  337. sql := `SELECT * FROM wx_user WHERE 1 = 1 `
  338. if condition != `` {
  339. sql += condition
  340. }
  341. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
  342. return
  343. }
  344. type ViewReportListV2 struct {
  345. Id int `description:"阅读记录id"`
  346. UserId int `description:"用户id"`
  347. Mobile string `description:"手机号"`
  348. Email string `description:"邮箱"`
  349. RealName string `description:"真实姓名"`
  350. CompanyName string `description:"客户名称"`
  351. ResearchReportName string `description:"报告标题"`
  352. ReportType int8 `description:"来源:1:rddp的报告;2:weekly_report的PHP报告;3:weekly_report商品的报告(应该是作废了);4:察研观向的报告""`
  353. CreatedTime string `description:"创建时间"`
  354. TxtType string `description:"类型 ficc:ficc 、 rights:权益"`
  355. MatchTypeName string `description:"匹配类型"`
  356. StopTime int `description:"停留时间"`
  357. ReportId int `description:"报告id"`
  358. ReportChapterId int `description:"报告章节id"`
  359. }
  360. func GetViewReportListByDate(startDate, endDate string) (items []*ViewReportListV2, err error) {
  361. dataName := ""
  362. sql := ``
  363. if utils.RunMode == "debug" {
  364. dataName = "test_v2_hongze_rddp"
  365. } else {
  366. dataName = "hongze_rddp"
  367. }
  368. ficcSql := `SELECT
  369. uvh.user_id,uvh.mobile,uvh.email,uvh.view_history_id AS id,uvh.real_name,uvh.company_name,
  370. uvh.research_report_id as report_id,
  371. uvh.research_report_type_id as report_chapter_id,
  372. rr.research_report_name,
  373. "2" AS report_type,
  374. 'ficc' AS txt_type,
  375. '--' AS match_type_name,
  376. '0' AS stop_time,
  377. uvh.created_time AS created_time
  378. FROM
  379. user_view_history uvh
  380. LEFT JOIN research_report rr ON rr.research_report_id = uvh.research_report_id
  381. WHERE
  382. uvh.created_time >= ? AND uvh.created_time< ?
  383. UNION ALL
  384. SELECT
  385. rvr.user_id,rvr.mobile,rvr.email,rvr.id,rvr.real_name,rvr.company_name,
  386. rvr.report_id,
  387. rvr.report_chapter_id,
  388. r.title AS research_report_name,
  389. '1' AS report_type,
  390. 'ficc' AS txt_type,
  391. r.classify_name_first AS match_type_name,
  392. '0' AS stop_time,
  393. rvr.create_time AS created_time
  394. FROM %s.report_view_record rvr
  395. LEFT JOIN %s.report r ON r.id = rvr.report_id
  396. WHERE
  397. rvr.create_time >= ? AND rvr.create_time< ?
  398. UNION ALL
  399. SELECT
  400. auc.user_id,auc.mobile,auc.email,auc.id,auc.real_name,auc.company_name,
  401. auc.chart_permission_id as report_id,
  402. '0' AS report_chapter_id,
  403. cha.permission_name AS research_report_name,
  404. '3' AS report_type,
  405. 'ficc' AS txt_type,
  406. cha.classify_name AS match_type_name,
  407. '0' AS stop_time,
  408. auc.create_time AS created_time
  409. FROM
  410. advisory_user_chart_article_record auc
  411. LEFT JOIN chart_permission cha ON cha.chart_permission_id = auc.chart_permission_id
  412. WHERE
  413. auc.create_time >= ? AND auc.create_time< ?`
  414. rightsSql := `SELECT
  415. h.user_id,h.mobile,h.email,h.id,h.company_name,'' AS real_name,
  416. h.article_id AS report_id,
  417. '0' AS report_chapter_id,
  418. art.title AS research_report_name,
  419. '4' AS report_type,
  420. 'rights' AS txt_type,
  421. art.match_type_name,
  422. h.stop_time,
  423. h.create_time AS created_time
  424. FROM
  425. cygx_article_history_record_newpv h
  426. INNER JOIN cygx_article art ON art.article_id = h.article_id
  427. WHERE
  428. h.create_time >= ? AND h.create_time< ? `
  429. sql = ` SELECT * FROM ( ` + ficcSql + " UNION ALL " + rightsSql + `
  430. )AS t ORDER BY t.created_time asc`
  431. o := orm.NewOrm()
  432. sql = fmt.Sprintf(sql, dataName, dataName)
  433. _, err = o.Raw(sql, startDate, endDate, startDate, endDate, startDate, endDate, startDate, endDate).QueryRows(&items)
  434. return
  435. }