english_company_todo.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. package english_report
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "eta/eta_api/controllers"
  6. "eta/eta_api/models"
  7. "eta/eta_api/models/system"
  8. "eta/eta_api/services"
  9. "eta/eta_api/utils"
  10. "html"
  11. "time"
  12. )
  13. // EnglishCompanyTodoController 英文客户-TODO任务
  14. type EnglishCompanyTodoController struct {
  15. controllers.BaseAuthController
  16. }
  17. // List
  18. // @Title 任务列表
  19. // @Description 任务列表
  20. // @Param CompanyId query int true "客户ID"
  21. // @Param SortType query int false "创建时间排序:1-降序; 2-升序"
  22. // @Success 200 {object} []models.EnglishCompanyTodoListItem
  23. // @router /company_todo/list [get]
  24. func (this *EnglishCompanyTodoController) List() {
  25. br := new(models.BaseResponse).Init()
  26. defer func() {
  27. this.Data["json"] = br
  28. this.ServeJSON()
  29. }()
  30. sysUser := this.SysUser
  31. if sysUser == nil {
  32. br.Msg = "请登录"
  33. br.ErrMsg = "请登录,SysUser Is Empty"
  34. br.Ret = 408
  35. return
  36. }
  37. companyId, _ := this.GetInt("CompanyId")
  38. if companyId <= 0 {
  39. br.Msg = "请选择客户"
  40. return
  41. }
  42. authList := services.GetEnglishCompanyTodoAuthRole()
  43. if !utils.InArrayByStr(authList, sysUser.RoleTypeCode) {
  44. br.Msg = "账号角色异常,不允许查看任务"
  45. return
  46. }
  47. var startSize int
  48. pageSize, _ := this.GetInt("PageSize")
  49. currentIndex, _ := this.GetInt("CurrentIndex")
  50. if pageSize <= 0 {
  51. pageSize = utils.PageSize20
  52. }
  53. if currentIndex <= 0 {
  54. currentIndex = 1
  55. }
  56. startSize = paging.StartIndex(currentIndex, pageSize)
  57. var order string
  58. sortType, _ := this.GetInt("SortType", 0)
  59. if sortType == 2 {
  60. order = ` ORDER BY a.create_time ASC `
  61. }
  62. // 获取任务列表
  63. total, todoList, err := models.GetEnglishCompanyTodoList(companyId, startSize, pageSize, order)
  64. if err != nil {
  65. br.Msg = "获取任务列表失败"
  66. br.ErrMsg = "获取英文客户任务列表失败,err:" + err.Error()
  67. return
  68. }
  69. list := make([]*models.EnglishCompanyTodoResp, 0)
  70. for _, v := range todoList {
  71. td := &models.EnglishCompanyTodoResp{
  72. Id: v.Id,
  73. CompanyId: v.CompanyId,
  74. Content: v.Content,
  75. SellerId: v.SellerId,
  76. SellerName: v.SellerName,
  77. CreateUserId: v.CreateUserId,
  78. CreateUserName: v.CreateUserName,
  79. ApproveUserId: v.ApproveUserId,
  80. ApproveUserName: v.ApproveUserName,
  81. Status: v.Status,
  82. CreateTime: v.CreateTime.Format(utils.FormatDateTime),
  83. EndTime: v.EndTime.Format(utils.FormatDateTime),
  84. ApproveTime: v.ApproveTime.Format(utils.FormatDateTime),
  85. EndTimeStr: v.EndTime.Format(utils.FormatDate),
  86. Remark: v.Remark,
  87. }
  88. if td.EndTimeStr == "0001-01-01" {
  89. td.EndTimeStr = ""
  90. }
  91. if td.ApproveTime == "0001-01-01 00:00:00" {
  92. td.ApproveTime = ""
  93. }
  94. list = append(list, td)
  95. }
  96. page := paging.GetPaging(currentIndex, pageSize, total)
  97. resp := &models.GetEnglishCompanyTodoPageListResp{
  98. Paging: page,
  99. List: list,
  100. }
  101. br.Ret = 200
  102. br.Success = true
  103. br.Msg = "获取成功"
  104. br.Data = resp
  105. }
  106. // Add
  107. // @Title 新增任务
  108. // @Description 新增任务接口
  109. // @Param request body models.EnglishCompanyTodoAddReq true "type json string"
  110. // @Success 200 操作成功
  111. // @router /company_todo/add [post]
  112. func (this *EnglishCompanyTodoController) Add() {
  113. br := new(models.BaseResponse).Init()
  114. defer func() {
  115. this.Data["json"] = br
  116. this.ServeJSON()
  117. }()
  118. sysUser := this.SysUser
  119. if sysUser == nil {
  120. br.Msg = "请登录"
  121. br.ErrMsg = "请登录,SysUser Is Empty"
  122. br.Ret = 408
  123. return
  124. }
  125. var req models.EnglishCompanyTodoAddReq
  126. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  127. if err != nil {
  128. br.Msg = "参数解析异常!"
  129. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  130. return
  131. }
  132. if req.CompanyId <= 0 {
  133. br.Msg = "请选择客户"
  134. br.ErrMsg = "客户ID不能为空"
  135. return
  136. }
  137. if req.Description == "" {
  138. br.Msg = "任务描述不能为空"
  139. return
  140. }
  141. if req.EndTime == "" {
  142. br.Msg = "请选择截止日期"
  143. return
  144. }
  145. endTime, e := time.ParseInLocation(utils.FormatDate, req.EndTime, time.Local)
  146. if e != nil {
  147. br.Msg = "截止日期格式错误"
  148. return
  149. }
  150. description := utils.TrimStr(req.Description)
  151. // 客户、销售信息
  152. companyId := req.CompanyId
  153. companyInfo, e := models.GetEnglishCompanyById(companyId)
  154. if e != nil {
  155. br.Msg = "保存失败"
  156. br.ErrMsg = "获取英文客户失败, Err: " + e.Error()
  157. return
  158. }
  159. sellerInfo, e := system.GetSysUserById(companyInfo.SellerId)
  160. if e != nil {
  161. br.Msg = "保存失败"
  162. br.ErrMsg = "获取英文客户销售信息失败, Err: " + e.Error()
  163. return
  164. }
  165. // 校验操作权限
  166. ok, msg, e := services.CheckEnglishCompanyTodoAuth(sysUser, sellerInfo)
  167. if e != nil {
  168. br.Msg = "保存失败"
  169. br.ErrMsg = "校验英文客户TODO操作权限失败, Err: " + e.Error()
  170. return
  171. }
  172. if !ok {
  173. br.Msg = msg
  174. return
  175. }
  176. // 获取处理中的任务数
  177. ingCount, e := models.GetCountDoingEnglishCompanyTodo(companyId)
  178. if e != nil {
  179. br.Msg = "保存失败"
  180. br.ErrMsg = "获取处理中的任务数失败, Err: " + e.Error()
  181. return
  182. }
  183. if ingCount > 0 {
  184. br.Msg = "当前存在待处理的任务,不允许添加新的任务待办"
  185. return
  186. }
  187. // 新增任务
  188. nowTime := time.Now().Local()
  189. newTodo := &models.EnglishCompanyTodo{
  190. CompanyId: companyId,
  191. Content: description,
  192. SellerId: companyInfo.SellerId,
  193. SellerName: companyInfo.SellerName,
  194. CreateUserId: sysUser.AdminId,
  195. CreateUserName: sysUser.RealName,
  196. Status: models.EnglishCompanyTodoStatusDoing,
  197. CreateTime: nowTime,
  198. ModifyTime: nowTime,
  199. EndTime: endTime,
  200. }
  201. if e = newTodo.Create(); e != nil {
  202. br.Msg = "保存失败"
  203. br.ErrMsg = "新增英文客户TODO待办失败, Err: " + e.Error()
  204. return
  205. }
  206. br.Ret = 200
  207. br.Success = true
  208. br.Msg = "操作成功"
  209. }
  210. // Edit
  211. // @Title 编辑任务
  212. // @Description 编辑任务
  213. // @Param request body models.EnglishCompanyTodoEditReq true "type json string"
  214. // @Success 200 操作成功
  215. // @router /company_todo/edit [post]
  216. func (this *EnglishCompanyTodoController) Edit() {
  217. br := new(models.BaseResponse).Init()
  218. defer func() {
  219. this.Data["json"] = br
  220. this.ServeJSON()
  221. }()
  222. sysUser := this.SysUser
  223. if sysUser == nil {
  224. br.Msg = "请登录"
  225. br.ErrMsg = "请登录,SysUser Is Empty"
  226. br.Ret = 408
  227. return
  228. }
  229. var req models.EnglishCompanyTodoEditReq
  230. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  231. if err != nil {
  232. br.Msg = "参数解析异常!"
  233. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  234. return
  235. }
  236. if req.Id <= 0 {
  237. br.Msg = "请选择待办任务"
  238. br.ErrMsg = "待办任务ID不能为空"
  239. return
  240. }
  241. if req.Description == "" {
  242. br.Msg = "任务描述不能为空"
  243. return
  244. }
  245. if req.EndTime == "" {
  246. br.Msg = "请输入截止日期"
  247. return
  248. }
  249. endTime, err := time.ParseInLocation(utils.FormatDate, req.EndTime, time.Local)
  250. if err != nil {
  251. br.Msg = "截止日期格式错误"
  252. return
  253. }
  254. description := utils.TrimStr(req.Description)
  255. // 客户、销售信息
  256. companyId := req.CompanyId
  257. companyInfo, e := models.GetEnglishCompanyById(companyId)
  258. if e != nil {
  259. br.Msg = "保存失败"
  260. br.ErrMsg = "获取英文客户失败, Err: " + e.Error()
  261. return
  262. }
  263. sellerInfo, e := system.GetSysUserById(companyInfo.SellerId)
  264. if e != nil {
  265. br.Msg = "保存失败"
  266. br.ErrMsg = "获取英文客户销售信息失败, Err: " + e.Error()
  267. return
  268. }
  269. // 校验操作权限
  270. ok, msg, e := services.CheckEnglishCompanyTodoAuth(sysUser, sellerInfo)
  271. if e != nil {
  272. br.Msg = "保存失败"
  273. br.ErrMsg = "校验英文客户TODO操作权限失败, Err: " + e.Error()
  274. return
  275. }
  276. if !ok {
  277. br.Msg = msg
  278. return
  279. }
  280. // 校验任务状态
  281. todoInfo, e := models.GetEnglishCompanyTodoById(req.Id)
  282. if e != nil {
  283. br.Msg = "保存失败"
  284. br.ErrMsg = "获取英文客户TODO信息失败, Err: " + e.Error()
  285. return
  286. }
  287. if todoInfo.Status != models.EnglishCompanyTodoStatusDoing {
  288. br.Msg = `任务状态异常: ` + todoInfo.Status + `, 不允许编辑该任务待办`
  289. return
  290. }
  291. // 编辑任务
  292. todoInfo.Content = description
  293. todoInfo.SellerId = sellerInfo.AdminId
  294. todoInfo.SellerName = sellerInfo.RealName
  295. todoInfo.ModifyTime = time.Now()
  296. todoInfo.EndTime = endTime
  297. updateCols := []string{"Content", "SellerId", "SellerName", "ModifyTime", "EndTime"}
  298. if e = todoInfo.Update(updateCols); e != nil {
  299. br.Msg = "保存失败"
  300. br.ErrMsg = "编辑英文客户TODO待办失败, Err: " + e.Error()
  301. return
  302. }
  303. br.Ret = 200
  304. br.Success = true
  305. br.Msg = "操作成功"
  306. }
  307. // Approve
  308. // @Title 审批任务
  309. // @Description 审批任务接口
  310. // @Param request body models.EnglishCompanyTodoApproveReq true "type json string"
  311. // @Success 200 操作成功
  312. // @router /company_todo/approve [post]
  313. func (this *EnglishCompanyTodoController) Approve() {
  314. br := new(models.BaseResponse).Init()
  315. defer func() {
  316. this.Data["json"] = br
  317. this.ServeJSON()
  318. }()
  319. sysUser := this.SysUser
  320. if sysUser == nil {
  321. br.Msg = "请登录"
  322. br.ErrMsg = "请登录,SysUser Is Empty"
  323. br.Ret = 408
  324. return
  325. }
  326. var req models.EnglishCompanyTodoApproveReq
  327. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  328. if err != nil {
  329. br.Msg = "参数解析异常!"
  330. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  331. return
  332. }
  333. if req.Id <= 0 {
  334. br.Msg = "参数错误"
  335. br.ErrMsg = "参数错误,任务编号必传 "
  336. return
  337. }
  338. // 校验任务状态
  339. todoInfo, e := models.GetEnglishCompanyTodoById(req.Id)
  340. if e != nil {
  341. br.Msg = "审核失败"
  342. br.ErrMsg = "获取英文客户TODO信息失败, Err: " + e.Error()
  343. return
  344. }
  345. if todoInfo.Status != models.EnglishCompanyTodoStatusDoing {
  346. br.Msg = `任务状态异常: ` + todoInfo.Status + `, 不允许审核该任务待办`
  347. return
  348. }
  349. // 客户、销售信息
  350. companyInfo, e := models.GetEnglishCompanyById(todoInfo.CompanyId)
  351. if e != nil {
  352. br.Msg = "审核失败"
  353. br.ErrMsg = "获取英文客户失败, Err: " + e.Error()
  354. return
  355. }
  356. sellerInfo, e := system.GetSysUserById(companyInfo.SellerId)
  357. if e != nil {
  358. br.Msg = "审核失败"
  359. br.ErrMsg = "获取英文客户销售信息失败, Err: " + e.Error()
  360. return
  361. }
  362. switch sysUser.RoleTypeCode {
  363. case utils.ROLE_TYPE_CODE_ADMIN, utils.ROLE_TYPE_CODE_FICC_ADMIN, utils.ROLE_TYPE_CODE_FICC_DEPARTMENT, utils.ROLE_TYPE_CODE_FICC_RESEARCHR:
  364. break
  365. case utils.ROLE_TYPE_CODE_FICC_GROUP:
  366. same, e := services.CheckAdminIsSameBigGroup(sysUser, sellerInfo)
  367. if e != nil {
  368. br.Msg = "审核失败"
  369. br.ErrMsg = "判断主管与客户所属销售是否属于同一大组失败, Err: " + e.Error()
  370. return
  371. }
  372. if !same {
  373. br.Msg = "该客户销售不是当前账号所属组员,不允许审批任务"
  374. return
  375. }
  376. case utils.ROLE_TYPE_CODE_FICC_TEAM:
  377. if sellerInfo.GroupId != sysUser.GroupId {
  378. br.Msg = "该客户销售不是当前账号所属组员,不允许审批任务"
  379. return
  380. }
  381. default:
  382. br.Msg = `操作人角色异常, 不允许审批任务: ` + sysUser.RoleName
  383. return
  384. }
  385. todoInfo.Status = "已完成"
  386. todoInfo.ApproveUserId = sysUser.AdminId
  387. todoInfo.ApproveUserName = sysUser.RealName
  388. todoInfo.ModifyTime = time.Now()
  389. todoInfo.ApproveTime = time.Now()
  390. todoInfo.ApprovedSellerId = sellerInfo.AdminId
  391. todoInfo.ApprovedSellerName = sellerInfo.RealName
  392. todoInfo.Remark = req.Remark
  393. updateCols := []string{"Status", "ApproveUserId", "ApproveUserName", "ModifyTime", "ApproveTime", "ApprovedSellerId", "ApprovedSellerName", "Remark"}
  394. if e = todoInfo.Update(updateCols); e != nil {
  395. br.Msg = "审核失败"
  396. br.ErrMsg = "更新英文客户TODO任务审核信息失败, Err: " + e.Error()
  397. return
  398. }
  399. br.Ret = 200
  400. br.Success = true
  401. br.Msg = "操作成功"
  402. }
  403. // EditList
  404. // @Title 进行中任务列表
  405. // @Description 进行中任务列表
  406. // @Param CompanyId query int true "客户ID"
  407. // @Success 200 {object} []models.EnglishCompanyTodoListItem
  408. // @router /company_todo/edit_list [get]
  409. func (this *EnglishCompanyTodoController) EditList() {
  410. br := new(models.BaseResponse).Init()
  411. defer func() {
  412. this.Data["json"] = br
  413. this.ServeJSON()
  414. }()
  415. sysUser := this.SysUser
  416. if sysUser == nil {
  417. br.Msg = "请登录"
  418. br.ErrMsg = "请登录,SysUser Is Empty"
  419. br.Ret = 408
  420. return
  421. }
  422. companyId, _ := this.GetInt("CompanyId")
  423. if companyId <= 0 {
  424. br.Msg = "请选择客户"
  425. return
  426. }
  427. authList := services.GetEnglishCompanyTodoAuthRole()
  428. if !utils.InArrayByStr(authList, sysUser.RoleTypeCode) {
  429. br.Msg = "账号角色异常,不允许查看任务"
  430. return
  431. }
  432. // 获取进行中的任务信息
  433. todoList, e := models.GetDoingEnglishCompanyTodoList(companyId)
  434. if e != nil {
  435. br.Msg = "获取任务信息失败"
  436. br.ErrMsg = "获取任务信息失败,err:" + e.Error()
  437. return
  438. }
  439. list := make([]*models.EnglishCompanyTodoResp, 0)
  440. for _, v := range todoList {
  441. td := &models.EnglishCompanyTodoResp{
  442. Id: v.Id,
  443. CompanyId: v.CompanyId,
  444. Content: v.Content,
  445. SellerId: v.SellerId,
  446. SellerName: v.SellerName,
  447. CreateUserId: v.CreateUserId,
  448. CreateUserName: v.CreateUserName,
  449. ApproveUserId: v.ApproveUserId,
  450. ApproveUserName: v.ApproveUserName,
  451. Status: v.Status,
  452. CreateTime: v.CreateTime.Format(utils.FormatDateTime),
  453. EndTime: v.EndTime.Format(utils.FormatDateTime),
  454. ApproveTime: v.ApproveTime.Format(utils.FormatDateTime),
  455. EndTimeStr: v.EndTime.Format(utils.FormatDate),
  456. }
  457. if td.EndTimeStr == "0001-01-01" {
  458. td.EndTimeStr = ""
  459. }
  460. if td.ApproveTime == "0001-01-01 00:00:00" {
  461. td.ApproveTime = ""
  462. }
  463. list = append(list, td)
  464. }
  465. br.Ret = 200
  466. br.Success = true
  467. br.Msg = "获取成功"
  468. br.Data = list
  469. }
  470. // LastPublicTodo
  471. // @Title 获取最新的公共TODO
  472. // @Description 获取最新的公共TODO
  473. // @Success 200 {object} models.GetEnglishCompanyTodoDoingPageListResp
  474. // @router /company_todo/last_public_todo [get]
  475. func (this *EnglishCompanyTodoController) LastPublicTodo() {
  476. br := new(models.BaseResponse).Init()
  477. defer func() {
  478. this.Data["json"] = br
  479. this.ServeJSON()
  480. }()
  481. sysUser := this.SysUser
  482. if sysUser == nil {
  483. br.Msg = "请登录"
  484. br.ErrMsg = "请登录,SysUser Is Empty"
  485. br.Ret = 408
  486. return
  487. }
  488. item, e := models.GetLastEnglishCompanyTodoPublic()
  489. if e != nil && e.Error() != utils.ErrNoRow() {
  490. br.Msg = "获取失败"
  491. br.ErrMsg = "获取最新的公共TODO失败, Err: " + e.Error()
  492. return
  493. }
  494. if item != nil {
  495. resp := &models.EnglishCompanyTodoPublicResp{
  496. Content: html.UnescapeString(item.Content),
  497. CreateUserId: item.CreateUserId,
  498. CreateUserName: item.CreateUserName,
  499. ModifyTime: item.ModifyTime.Format(utils.FormatDateTime),
  500. CreateTime: item.CreateTime.Format(utils.FormatDateTime),
  501. }
  502. br.Data = resp
  503. }
  504. br.Ret = 200
  505. br.Success = true
  506. br.Msg = "获取成功"
  507. }
  508. // AddPublic
  509. // @Title 新增公共任务
  510. // @Description 新增公共任务接口
  511. // @Param request body models.EnglishCompanyTodoPublicAddReq true "type json string"
  512. // @Success 200 操作成功
  513. // @router /company_todo/add_public [post]
  514. func (this *EnglishCompanyTodoController) AddPublic() {
  515. br := new(models.BaseResponse).Init()
  516. defer func() {
  517. this.Data["json"] = br
  518. this.ServeJSON()
  519. }()
  520. sysUser := this.SysUser
  521. if sysUser == nil {
  522. br.Msg = "请登录"
  523. br.ErrMsg = "请登录,SysUser Is Empty"
  524. br.Ret = 408
  525. return
  526. }
  527. var req models.EnglishCompanyTodoPublicAddReq
  528. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  529. if err != nil {
  530. br.Msg = "参数解析异常!"
  531. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  532. return
  533. }
  534. // 新增公共任务
  535. nowTime := time.Now().Local()
  536. newTodo := &models.EnglishCompanyTodoPublic{
  537. Content: html.EscapeString(req.Description),
  538. CreateUserId: sysUser.AdminId,
  539. CreateUserName: sysUser.RealName,
  540. CreateTime: nowTime,
  541. ModifyTime: nowTime,
  542. }
  543. if e := newTodo.Create(); e != nil {
  544. br.Msg = "保存失败"
  545. br.ErrMsg = "新增英文客户公共TODO失败, Err: " + e.Error()
  546. return
  547. }
  548. br.Ret = 200
  549. br.Success = true
  550. br.Msg = "操作成功"
  551. }
  552. // DoingList
  553. // @Title 未完成的任务列表
  554. // @Description 未完成的任务列表
  555. // @Param PageSize query int true "每页数据量"
  556. // @Param CurrentIndex query int true "当前页码"
  557. // @Param SortType query int false "截止日期排序: 0-默认(截止日期正序); 1-正序; 2-倒序"
  558. // @Success 200 {object} models.GetEnglishCompanyTodoDoingPageListResp
  559. // @router /company_todo/doing_list [get]
  560. func (this *EnglishCompanyTodoController) DoingList() {
  561. br := new(models.BaseResponse).Init()
  562. defer func() {
  563. this.Data["json"] = br
  564. this.ServeJSON()
  565. }()
  566. sysUser := this.SysUser
  567. if sysUser == nil {
  568. br.Msg = "请登录"
  569. br.ErrMsg = "请登录,SysUser Is Empty"
  570. br.Ret = 408
  571. return
  572. }
  573. var startSize int
  574. pageSize, _ := this.GetInt("PageSize")
  575. currentIndex, _ := this.GetInt("CurrentIndex")
  576. if pageSize <= 0 {
  577. pageSize = utils.PageSize20
  578. }
  579. if currentIndex <= 0 {
  580. currentIndex = 1
  581. }
  582. startSize = paging.StartIndex(currentIndex, pageSize)
  583. var order string
  584. sortType, _ := this.GetInt("SortType", 0)
  585. if sortType == 2 {
  586. order = ` ORDER BY a.end_time DESC `
  587. }
  588. // 获取任务列表
  589. total, todoList, err := models.GetEnglishCompanyTodoDoingList(startSize, pageSize, order)
  590. if err != nil {
  591. br.Msg = "获取任务列表失败"
  592. br.ErrMsg = "获取英文客户任务列表失败,err:" + err.Error()
  593. return
  594. }
  595. list := make([]*models.EnglishCompanyTodoDoingResp, 0)
  596. for _, v := range todoList {
  597. td := &models.EnglishCompanyTodoDoingResp{
  598. Id: v.Id,
  599. CompanyId: v.CompanyId,
  600. CompanyName: v.CompanyName,
  601. Content: v.Content,
  602. SellerId: v.SellerId,
  603. SellerName: v.SellerName,
  604. CreateUserId: v.CreateUserId,
  605. CreateUserName: v.CreateUserName,
  606. ApproveUserId: v.ApproveUserId,
  607. ApproveUserName: v.ApproveUserName,
  608. Status: v.Status,
  609. CreateTime: v.CreateTime.Format(utils.FormatDateTime),
  610. EndTime: v.EndTime.Format(utils.FormatDate),
  611. ApproveTime: v.ApproveTime.Format(utils.FormatDateTime),
  612. Remark: v.Remark,
  613. }
  614. if td.EndTime == "0001-01-01" {
  615. td.EndTime = ""
  616. }
  617. if td.ApproveTime == "0001-01-01 00:00:00" {
  618. td.ApproveTime = ""
  619. }
  620. list = append(list, td)
  621. }
  622. page := paging.GetPaging(currentIndex, pageSize, total)
  623. resp := &models.GetEnglishCompanyTodoDoingPageListResp{
  624. Paging: page,
  625. List: list,
  626. }
  627. br.Ret = 200
  628. br.Success = true
  629. br.Msg = "获取成功"
  630. br.Data = resp
  631. }