approval.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. package controllers
  2. import (
  3. "encoding/json"
  4. approval2 "hongze/hongze_mobile_admin/models/request/approval"
  5. "hongze/hongze_mobile_admin/models/response/approval"
  6. "hongze/hongze_mobile_admin/models/tables/admin"
  7. "hongze/hongze_mobile_admin/models/tables/company_approval"
  8. "hongze/hongze_mobile_admin/models/tables/company_contract"
  9. "hongze/hongze_mobile_admin/models/tables/company_delay_permission"
  10. "hongze/hongze_mobile_admin/models/tables/company_product"
  11. "hongze/hongze_mobile_admin/models/tables/company_product_log"
  12. "hongze/hongze_mobile_admin/models/tables/company_report_permission"
  13. "hongze/hongze_mobile_admin/services"
  14. "hongze/hongze_mobile_admin/utils"
  15. "rdluck_tools/paging"
  16. "strconv"
  17. "time"
  18. )
  19. type ApprovalCommon struct {
  20. BaseAuth
  21. }
  22. // @Title 获取审批列表接口
  23. // @Description 获取审批列表接口
  24. // @Param PageSize query int true "每页数据条数"
  25. // @Param CurrentIndex query int true "当前页页码,从1开始"
  26. // @Param Status query string true "状态:'全部','待审批','已审批','驳回','已撤回'"
  27. // @Param KeyWord query string true "搜索关键词"
  28. // @Success 200 {object} approval.CompanyApprovalListResp
  29. // @router /list [get]
  30. func (this *ApprovalCommon) List() {
  31. sysUser := this.AdminWx
  32. roleTypeCode := sysUser.RoleTypeCode
  33. pageSize, _ := this.GetInt("PageSize")
  34. currentIndex, _ := this.GetInt("CurrentIndex")
  35. status := this.GetString("Status")
  36. keyWord := this.GetString("KeyWord")
  37. var startSize int
  38. if pageSize <= 0 {
  39. pageSize = utils.PageSize20
  40. }
  41. if currentIndex <= 0 {
  42. currentIndex = 1
  43. }
  44. startSize = paging.StartIndex(currentIndex, pageSize)
  45. var condition string
  46. var pars []interface{}
  47. if status != "" {
  48. if status == "已审批" {
  49. condition += ` AND c.approve_status IN('已审批','驳回','已撤回') `
  50. } else {
  51. condition += ` AND c.approve_status=? `
  52. pars = append(pars, status)
  53. }
  54. }
  55. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN { //审批
  56. condition += ` AND c.approve_role_type_code=? `
  57. pars = append(pars, roleTypeCode)
  58. } else if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER { //销售
  59. condition += ` AND c.apply_user_id=? `
  60. pars = append(pars, sysUser.AdminId)
  61. }
  62. if keyWord != "" {
  63. condition += ` AND (a.company_name LIKE '%` + keyWord + `%' OR a.credit_code LIKE '%` + keyWord + `%') `
  64. }
  65. total, err := company_approval.GetApprovalCount(condition, pars)
  66. if err != nil {
  67. this.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
  68. return
  69. }
  70. list, err := company_approval.GetApprovalList(condition, pars, startSize, pageSize)
  71. if err != nil {
  72. this.FailWithMessage("获取失败", "获取数据失败,Err:"+err.Error())
  73. return
  74. }
  75. listLen := len(list)
  76. for i := 0; i < listLen; i++ {
  77. item := list[i]
  78. if item.FreezeStartDate != "" && item.FreezeEndDate != "" && item.Status == utils.COMPANY_STATUS_FREEZE {
  79. freezeEndDate, _ := time.Parse(utils.FormatDate, item.FreezeEndDate)
  80. if time.Now().Before(freezeEndDate) {
  81. expireDays := freezeEndDate.Sub(time.Now()).Hours() / 24
  82. list[i].FreezeExpireDays = int(expireDays)
  83. }
  84. }
  85. if item.StartDate != "" && item.EndDate != "" {
  86. endDate, _ := time.Parse(utils.FormatDate, item.EndDate)
  87. if time.Now().Before(endDate) {
  88. expireDays := endDate.Sub(time.Now()).Hours() / 24
  89. list[i].ExpireDay = int(expireDays)
  90. }
  91. }
  92. approvalCount, err := company_approval.GetCompanyApprovalCount(item.CompanyId, item.ProductId)
  93. if err != nil && err.Error() != utils.ErrNoRow() {
  94. this.FailWithMessage("获取失败", "获取延期审批次数失败,Err:"+err.Error())
  95. return
  96. }
  97. list[i].ApprovalCount = approvalCount
  98. if item.ApplyMethod == 3 {
  99. delayPermission, err := company_delay_permission.GetApplyDelayPermission(item.CompanyApprovalId)
  100. if err != nil && err.Error() != utils.ErrNoRow() {
  101. this.FailWithMessage("获取失败", "获取延期审批权限失败,Err:"+err.Error())
  102. return
  103. }
  104. list[i].DelayPermission = delayPermission
  105. }
  106. if item.ApproveRoleTypeCode == roleTypeCode {
  107. list[i].OpButton = true
  108. }
  109. }
  110. page := paging.GetPaging(currentIndex, pageSize, total)
  111. resp := approval.CompanyApprovalListResp{
  112. Paging: page,
  113. List: list,
  114. }
  115. this.OkDetailed(resp, "获取成功")
  116. }
  117. // @Title 获取审批单详情接口
  118. // @Description 获取审批单详情接口
  119. // @Param ApprovalId query int true "审批单id"
  120. // @Success 200 {object} approval.CompanyApprovalDetailResp
  121. // @router /detail [get]
  122. func (this *ApprovalCommon) Detail() {
  123. sysUser := this.AdminWx
  124. roleTypeCode := sysUser.RoleTypeCode
  125. companyApprovalId, _ := this.GetInt("ApprovalId")
  126. var condition string
  127. var pars []interface{}
  128. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN { //审批
  129. condition += ` AND c.approve_role_type_code=? `
  130. pars = append(pars, roleTypeCode)
  131. } else if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER { //销售
  132. condition += ` AND c.apply_user_id=? `
  133. pars = append(pars, sysUser.AdminId)
  134. }
  135. item, err := company_approval.GetApprovalListByApprovalId(condition, pars, companyApprovalId)
  136. if err != nil {
  137. this.FailWithMessage("获取失败", "获取数据失败,Err:"+err.Error())
  138. return
  139. }
  140. if item.FreezeStartDate != "" && item.FreezeEndDate != "" && item.Status == utils.COMPANY_STATUS_FREEZE {
  141. freezeEndDate, _ := time.Parse(utils.FormatDate, item.FreezeEndDate)
  142. if time.Now().Before(freezeEndDate) {
  143. expireDays := freezeEndDate.Sub(time.Now()).Hours() / 24
  144. item.FreezeExpireDays = int(expireDays)
  145. }
  146. }
  147. if item.StartDate != "" && item.EndDate != "" {
  148. endDate, _ := time.Parse(utils.FormatDate, item.EndDate)
  149. if time.Now().Before(endDate) {
  150. expireDays := endDate.Sub(time.Now()).Hours() / 24
  151. item.ExpireDay = int(expireDays)
  152. }
  153. }
  154. approvalCount, err := company_approval.GetCompanyApprovalCount(item.CompanyId, item.ProductId)
  155. if err != nil && err.Error() != utils.ErrNoRow() {
  156. this.FailWithMessage("获取失败", "获取延期审批次数失败,Err:"+err.Error())
  157. return
  158. }
  159. item.ApprovalCount = approvalCount
  160. //if item.ApplyMethod == 3 {
  161. // delayPermission, err := company_delay_permission.GetApplyDelayPermission(item.CompanyApprovalId)
  162. // if err != nil && err.Error() != utils.ErrNoRow() {
  163. // this.FailWithMessage("获取失败", "获取延期审批权限失败,Err:"+err.Error())
  164. // return
  165. // }
  166. // item.DelayPermission = delayPermission
  167. //}
  168. resp := approval.CompanyApprovalDetailResp{
  169. CompanyApprovalDetail: item,
  170. }
  171. //获取权限列表
  172. //子权限切片集合
  173. var permissionClassifyArr []string
  174. if item.ProductId == 1 {
  175. for _, v := range utils.PermissionFiccClassifyArr {
  176. permissionClassifyArr = append(permissionClassifyArr, v)
  177. }
  178. } else {
  179. permissionClassifyArr = append(permissionClassifyArr, "权益")
  180. }
  181. //获取需要审批的权限
  182. delayPermissionList, err := company_delay_permission.GetDelayPermissionItems(item.CompanyId, item.CompanyApprovalId)
  183. if err != nil && err.Error() != utils.ErrNoRow() {
  184. this.FailWithMessage("获取失败", "获取审批权限失败,Err:"+err.Error())
  185. return
  186. }
  187. delayPermissionIdMap := make(map[int]int)
  188. for _, delayPermission := range delayPermissionList {
  189. delayPermissionIdMap[delayPermission.ChartPermissionId] = 0
  190. }
  191. //遍历获取
  192. for _, v := range permissionClassifyArr {
  193. checkList := make([]int, 0)
  194. plist := new(company_report_permission.PermissionLookList)
  195. items, err := company_report_permission.GetPermissionLookItems(item.ProductId, v)
  196. if err != nil {
  197. this.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  198. return
  199. }
  200. for _, n := range items {
  201. if _, ok := delayPermissionIdMap[n.ChartPermissionId]; ok {
  202. checkList = append(checkList, n.ChartPermissionId)
  203. }
  204. }
  205. plist.Items = items
  206. plist.ClassifyName = v
  207. plist.CheckList = checkList
  208. if item.ProductId == 1 {
  209. resp.FiccPermissionList = append(resp.FiccPermissionList, plist)
  210. } else {
  211. resp.PermissionList = append(resp.PermissionList, plist)
  212. }
  213. }
  214. this.OkDetailed(resp, "获取成功")
  215. }
  216. // @Title 获取审批单中的权限列表
  217. // @Description 获取审批单中的权限列表接口
  218. // @Param ApprovalId query int true "审批单id"
  219. // @Success 200 {object} approval.CompanyPermissionResp
  220. // @router /getApprovalPermissionList [get]
  221. func (this *ApprovalCommon) GetApprovalPermissionList() {
  222. //this.FailWithMessage("获取失败", "获取数据总数失败,Err:"+err.Error())
  223. //返回基础参数
  224. resp := new(approval.CompanyPermissionResp)
  225. //获取审批单信息
  226. approvalId, _ := this.GetInt("ApprovalId")
  227. if approvalId <= 0 {
  228. this.FailWithMessage("审批单参数异常", "提交审批单参数异常")
  229. return
  230. }
  231. approvalInfo, err := company_approval.GetCompanyApprovalByApprovalId(approvalId)
  232. if err != nil {
  233. this.FailWithMessage("获取失败", "获取审批单数据失败,Err:"+err.Error())
  234. return
  235. }
  236. //子权限切片集合
  237. var permissionClassifyArr []string
  238. if approvalInfo.ProductId == 1 {
  239. for _, v := range utils.PermissionFiccClassifyArr {
  240. permissionClassifyArr = append(permissionClassifyArr, v)
  241. }
  242. } else {
  243. permissionClassifyArr = append(permissionClassifyArr, "权益")
  244. }
  245. //获取需要审批的权限
  246. delayPermissionList, err := company_delay_permission.GetDelayPermissionItems(approvalInfo.CompanyId, approvalInfo.CompanyApprovalId)
  247. if err != nil && err.Error() != utils.ErrNoRow() {
  248. this.FailWithMessage("获取失败", "获取审批权限失败,Err:"+err.Error())
  249. return
  250. }
  251. delayPermissionIdMap := make(map[int]int)
  252. for _, delayPermission := range delayPermissionList {
  253. delayPermissionIdMap[delayPermission.ChartPermissionId] = 0
  254. }
  255. //遍历获取
  256. for _, v := range permissionClassifyArr {
  257. checkList := make([]int, 0)
  258. plist := new(company_report_permission.PermissionLookList)
  259. items, err := company_report_permission.GetPermissionLookItems(approvalInfo.ProductId, v)
  260. if err != nil {
  261. this.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  262. return
  263. }
  264. for _, n := range items {
  265. if _, ok := delayPermissionIdMap[n.ChartPermissionId]; ok {
  266. checkList = append(checkList, n.ChartPermissionId)
  267. }
  268. }
  269. plist.Items = items
  270. plist.ClassifyName = v
  271. plist.CheckList = checkList
  272. if approvalInfo.ProductId == 1 {
  273. resp.FiccPermissionList = append(resp.FiccPermissionList, plist)
  274. } else {
  275. resp.PermissionList = append(resp.PermissionList, plist)
  276. }
  277. }
  278. this.OkDetailed(resp, "获取成功")
  279. }
  280. // @Title 审批
  281. // @Description 审批接口
  282. // @Param request body approval.CompanyApplyApproveReq true "type json string"
  283. // @Success Ret=200 审批成功
  284. // @router /approve [post]
  285. func (this *ApprovalCommon) ApplyApprove() {
  286. sysUser := this.AdminWx
  287. var req approval2.CompanyApplyApproveReq
  288. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  289. if err != nil {
  290. this.FailWithMessage("参数解析异常!", "参数解析失败,Err:"+err.Error())
  291. return
  292. }
  293. roleTypeCode := sysUser.RoleTypeCode
  294. productId := services.GetProductId(roleTypeCode)
  295. if productId == 0 {
  296. this.FailWithMessage("参数错误", "参数解析失败,Err:"+"客户类型为:"+roleTypeCode)
  297. return
  298. }
  299. if req.CompanyId <= 0 {
  300. this.FailWithMessage("参数错误", "客户Id小于等于0")
  301. return
  302. }
  303. if req.Status != 1 && req.Status != 2 {
  304. this.FailWithMessage("参数错误", "审批状态Id小于等于0")
  305. return
  306. }
  307. companyProduct, err := company_product.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
  308. if err != nil {
  309. this.FailWithMessage("获取信息失败", "获取信息失败,Err:"+err.Error())
  310. return
  311. }
  312. if companyProduct == nil {
  313. this.FailWithMessage("获取审批信息失败", "获取信息失败,Err:"+err.Error())
  314. return
  315. }
  316. approvalItem, err := company_approval.GetCompanyApprovalByCompanyId(req.CompanyId, productId)
  317. if err != nil {
  318. if err.Error() == utils.ErrNoRow() {
  319. this.FailWithMessage("订单已审批,请刷新页面查看最新状态", "待审批信息不存在,CompanyId:"+strconv.Itoa(req.CompanyId)+";productId:"+strconv.Itoa(productId))
  320. } else {
  321. this.FailWithMessage("获取信息失败", "获取信息失败,Err:"+err.Error())
  322. }
  323. return
  324. }
  325. if approvalItem == nil {
  326. this.FailWithMessage("订单已审批,请刷新页面查看最新状态", "待审批信息不存在,CompanyId:"+strconv.Itoa(req.CompanyId)+";productId:"+strconv.Itoa(productId))
  327. return
  328. }
  329. if approvalItem.ApproveRoleTypeCode != roleTypeCode {
  330. this.FailWithMessage("您无权审批", "ApproveRoleTypeCode:"+approvalItem.ApproveRoleTypeCode+";roleTypeCode:"+roleTypeCode)
  331. return
  332. }
  333. var approveStatus, approveContent string
  334. if req.Status == 1 { //通过
  335. //申请类型:1:试用->正式,2:冻结—>试用,3:试用延期,4:原销售申请领取流失客户,5:正式客户申请服务更新
  336. if approvalItem.ApplyMethod == 1 { //试用转正式
  337. //获取合同信息
  338. contract, err := company_contract.GetCompanyContractDetail(req.CompanyId, productId, req.CompanyContractId)
  339. if err != nil {
  340. this.FailWithMessage("待审批信息不存在", "待审批信息不存在,CompanyId:"+strconv.Itoa(req.CompanyId)+";productId:"+strconv.Itoa(productId)+";Err:"+err.Error())
  341. return
  342. }
  343. if contract == nil {
  344. this.FailWithMessage("待审批信息不存在", "待审批信息不存在,CompanyId:"+strconv.Itoa(req.CompanyId)+";productId:"+strconv.Itoa(productId))
  345. return
  346. }
  347. err = company_approval.TryOutToFormal(req.CompanyId, productId, sysUser.AdminId, approvalItem.CompanyApprovalId, contract.CompanyContractId, contract.StartDate, contract.EndDate, sysUser.RealName, companyProduct.ProductName)
  348. if err != nil {
  349. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  350. return
  351. }
  352. } else if approvalItem.ApplyMethod == 2 { //冻结->试用
  353. err = company_approval.FreezeToTryOut(req.CompanyId, productId, sysUser.AdminId, approvalItem.CompanyApprovalId, approvalItem.ApplyUserId, sysUser.RealName, companyProduct.ProductName)
  354. if err != nil {
  355. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  356. return
  357. }
  358. } else if approvalItem.ApplyMethod == 3 { //试用延期
  359. err = company_approval.TryOutDelay(req.CompanyId, productId, sysUser.AdminId, approvalItem.CompanyApprovalId, sysUser.RealName, companyProduct.EndDate, companyProduct.ProductName)
  360. if err != nil {
  361. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  362. return
  363. }
  364. } else if approvalItem.ApplyMethod == 4 { //原销售申请领取流失客户
  365. err = company_approval.ApplyReceive(req.CompanyId, productId, sysUser.AdminId, approvalItem.CompanyApprovalId, approvalItem.ApplyUserId, sysUser.RealName, companyProduct.ProductName)
  366. if err != nil {
  367. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  368. return
  369. }
  370. } else if approvalItem.ApplyMethod == 5 { //正式客户申请服务更新
  371. //获取合同信息
  372. contract, err := company_contract.GetCompanyContractDetail(req.CompanyId, productId, req.CompanyContractId)
  373. if err != nil {
  374. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  375. return
  376. }
  377. if contract == nil {
  378. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  379. return
  380. }
  381. err = company_approval.ApplyServiceUpdate(req.CompanyId, productId, sysUser.AdminId, approvalItem.CompanyApprovalId, contract.CompanyContractId, companyProduct.StartDate, contract.EndDate, sysUser.RealName, companyProduct.ProductName)
  382. if err != nil {
  383. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  384. return
  385. }
  386. } else {
  387. this.FailWithMessage("审批失败", "无效的审批状态,CompanyId:"+strconv.Itoa(req.CompanyId)+";productId:"+
  388. strconv.Itoa(productId)+";ApplyMethod:"+strconv.Itoa(approvalItem.ApplyMethod)+" ApproveStatus;"+approvalItem.ApproveStatus)
  389. return
  390. }
  391. approveContent = "审批通过"
  392. } else { //拒绝
  393. if req.Remark == "" {
  394. this.FailWithMessage("请填写驳回理由", "请填写驳回理由")
  395. return
  396. }
  397. approveStatus = "驳回"
  398. err = company_approval.ApproveRefuse(req.CompanyId, productId, approveStatus, req.Remark)
  399. approveContent = "审批驳回"
  400. if err != nil {
  401. this.FailWithMessage("审批失败", "审批失败,Err:"+err.Error())
  402. return
  403. }
  404. }
  405. //新增客户产品日志
  406. {
  407. productLog := new(company_product_log.CompanyProductLog)
  408. productLog.CompanyProductId = companyProduct.CompanyProductId
  409. productLog.CompanyId = companyProduct.CompanyId
  410. productLog.ProductId = companyProduct.ProductId
  411. productLog.ProductName = companyProduct.ProductName
  412. productLog.CompanyName = companyProduct.CompanyName
  413. productLog.CompanyName = companyProduct.CompanyName
  414. productLog.Source = companyProduct.Source
  415. productLog.Reasons = companyProduct.Reasons
  416. productLog.Status = companyProduct.Status
  417. productLog.IndustryId = companyProduct.IndustryId
  418. productLog.IndustryName = companyProduct.IndustryName
  419. productLog.SellerId = companyProduct.SellerId
  420. productLog.SellerName = companyProduct.SellerName
  421. productLog.GroupId = companyProduct.GroupId
  422. productLog.DepartmentId = companyProduct.DepartmentId
  423. productLog.IsSuspend = companyProduct.IsSuspend
  424. productLog.SuspendTime = companyProduct.SuspendTime
  425. productLog.ApproveStatus = companyProduct.ApproveStatus
  426. productLog.FreezeTime = companyProduct.FreezeTime
  427. productLog.Remark = companyProduct.Remark
  428. productLog.StartDate = companyProduct.StartDate
  429. productLog.EndDate = companyProduct.EndDate
  430. productLog.CreateTime = companyProduct.CreateTime
  431. productLog.ModifyTime = companyProduct.ModifyTime
  432. productLog.LoseReason = companyProduct.LoseReason
  433. productLog.LossTime = companyProduct.LossTime
  434. productLog.LogType = "modify"
  435. productLog.LogCreateTime = time.Now()
  436. productLog.AdminId = this.AdminWx.AdminId
  437. go company_product_log.AddCompanyProductLog(productLog)
  438. }
  439. //新增操作记录
  440. {
  441. remark := "审批"
  442. operation := "approve"
  443. services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, sysUser.AdminId, companyProduct.CompanyName,
  444. companyProduct.ProductName, sysUser.RealName, remark, operation, approveContent, sysUser.RealName, req.Remark, companyProduct.Status)
  445. }
  446. //待办通知
  447. {
  448. content := companyProduct.CompanyName + " " + approvalItem.ApproveContent + approveContent
  449. approvalSysUser, _ := admin.GetAdminById(approvalItem.ApplyUserId)
  450. if sysUser != nil {
  451. go services.AddCompanyApprovalMessage(sysUser.AdminId, approvalItem.ApplyUserId, req.CompanyId, approvalItem.CompanyApprovalId, 2, companyProduct.CompanyName, content, content, approvalSysUser.Mobile)
  452. }
  453. }
  454. this.OkWithMessage("审批操作成功")
  455. }
  456. //// @Title 审批列表删除
  457. //// @Description 审批列表删除接口
  458. //// @Param request body company.CompanyApplyDeleteReq true "type json string"
  459. //// @Success Ret=200 删除成功
  460. //// @router /approval/delete [post]
  461. //func (this *CompanyApprovalController) ApplyDelete() {
  462. // br := new(models.BaseResponse).Init()
  463. // defer func() {
  464. // this.Data["json"] = br
  465. // this.ServeJSON()
  466. // }()
  467. // sysUser := this.SysUser
  468. // if sysUser == nil {
  469. // br.Msg = "请登录"
  470. // br.ErrMsg = "请登录,SysUser Is Empty"
  471. // br.Ret = 408
  472. // return
  473. // }
  474. // var req company.CompanyApplyDeleteReq
  475. // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  476. // if err != nil {
  477. // br.Msg = "参数解析异常!"
  478. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  479. // return
  480. // }
  481. // roleTypeCode := sysUser.RoleTypeCode
  482. // productId := services.GetProductId(roleTypeCode)
  483. // if productId == 0 {
  484. // br.Msg = "参数错误"
  485. // br.ErrMsg = "客户类型为:" + roleTypeCode
  486. // return
  487. // }
  488. // if req.CompanyId <= 0 {
  489. // br.Msg = "参数错误"
  490. // br.ErrMsg = "客户Id小于等于0:"
  491. // return
  492. // }
  493. // companyProduct, err := company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, productId)
  494. // if err != nil {
  495. // br.Msg = "获取信息失败"
  496. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  497. // return
  498. // }
  499. // if companyProduct == nil {
  500. // br.Msg = "获取信息失败"
  501. // br.ErrMsg = "获取审批信息失败,Err:" + err.Error()
  502. // return
  503. // }
  504. // approvalItem, err := company.GetCompanyApprovalByApprovalId(req.CompanyApprovalId)
  505. // if err != nil {
  506. // if err.Error() == utils.ErrNoRow() {
  507. // br.Msg = "待审批信息不存在"
  508. // br.ErrMsg = "待审批信息不存在,CompanyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
  509. // return
  510. // }
  511. // br.Msg = "获取信息失败"
  512. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  513. // return
  514. // }
  515. // if approvalItem == nil {
  516. // br.Msg = "待审批信息不存在"
  517. // br.ErrMsg = "待审批信息不存在,CompanyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
  518. // return
  519. // }
  520. // if approvalItem.ApproveStatus != "待审批" && approvalItem.ApproveStatus != "已撤回" {
  521. // br.Msg = "审批状态为:" + approvalItem.ApproveStatus + ";不可删除"
  522. // br.ErrMsg = "审批状态为:" + approvalItem.ApproveStatus + ";不可删除" + ";CompanyId:" + strconv.Itoa(req.CompanyId) + ";productId:" + strconv.Itoa(productId)
  523. // return
  524. // }
  525. // //删除
  526. // err = company.ApplyDelete(req.CompanyId, req.CompanyApprovalId, approvalItem.ProductId)
  527. // if err != nil {
  528. // br.Msg = "删除失败"
  529. // br.ErrMsg = "删除失败,Err:" + err.Error()
  530. // return
  531. // }
  532. // //新增操作记录
  533. // {
  534. // remark := "删除审批申请"
  535. // operation := "approve_delete"
  536. // services.AddCompanyOperationRecord(req.CompanyId, companyProduct.SellerId, sysUser.AdminId, productId, sysUser.AdminId, companyProduct.CompanyName,
  537. // companyProduct.ProductName, sysUser.RealName, remark, operation, remark, sysUser.RealName, "", companyProduct.Status)
  538. // }
  539. // br.Ret = 200
  540. // br.Success = true
  541. // br.Msg = "删除成功"
  542. //}