contract_approval.go 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  1. package contract
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "github.com/shopspring/decimal"
  7. "github.com/tealeg/xlsx"
  8. "hongze/hz_crm_api/controllers"
  9. "hongze/hz_crm_api/models"
  10. "hongze/hz_crm_api/models/company"
  11. "hongze/hz_crm_api/models/contract"
  12. "hongze/hz_crm_api/models/contract/request"
  13. "hongze/hz_crm_api/models/contract/response"
  14. "hongze/hz_crm_api/services"
  15. contractService "hongze/hz_crm_api/services/contract"
  16. "hongze/hz_crm_api/utils"
  17. "os"
  18. "path/filepath"
  19. "strconv"
  20. "strings"
  21. "time"
  22. )
  23. // 审批流管理
  24. type ContractApprovalController struct {
  25. controllers.BaseAuthController
  26. }
  27. // @Title 提交申请
  28. // @Description 提交申请接口
  29. // @Param ContractId query int true "合同id编号"
  30. // @Success Ret=200 申请成功
  31. // @router /approval/apply [get]
  32. func (this *ContractApprovalController) Apply() {
  33. br := new(models.BaseResponse).Init()
  34. defer func() {
  35. this.Data["json"] = br
  36. this.ServeJSON()
  37. }()
  38. sysUser := this.SysUser
  39. if sysUser == nil {
  40. br.Msg = "请登录"
  41. br.ErrMsg = "请登录,SysUser Is Empty"
  42. br.Ret = 408
  43. return
  44. }
  45. //合同id编号
  46. contractId, err := this.GetInt("ContractId")
  47. if err != nil {
  48. br.Msg = "获取合同编号失败"
  49. br.ErrMsg = "获取合同编号失败,err:" + err.Error()
  50. return
  51. }
  52. if contractId <= 0 {
  53. br.Msg = "请传入合同编号"
  54. br.ErrMsg = "请传入合同编号"
  55. return
  56. }
  57. err, errMsg := contractService.Apply(contractId)
  58. if err != nil {
  59. br.Msg = "发起审批失败!"
  60. if errMsg != "" {
  61. br.Msg = errMsg
  62. }
  63. br.ErrMsg = "发起审批失败,Err:" + err.Error()
  64. return
  65. }
  66. br.Ret = 200
  67. br.Success = true
  68. br.Msg = "申请成功"
  69. }
  70. // List
  71. // @Title 审批单列表
  72. // @Description 审批单列表接口
  73. // @Param ContractBusinessType query string false "合同业务类型,枚举值:'业务合同','代付合同',不传默认是全部"
  74. // @Param ContractType query string false "合同类型,枚举值:'新签合同','续约合同','补充协议'"
  75. // @Param Status query string false "合同状态,枚举值:'待审批','已审批','已驳回','已撤回'"
  76. // @Param ProductId query int false "客户类型:传0或者不传为当前账号权限,1 代表是:ficc;2 代表是:权益"
  77. // @Param SellerId query string false "选择的销售id"
  78. // @Param Keyword query string false "搜索关键字"
  79. // @Param ModifyStartTime query string false "服务更新时间的选择开始时间,格式:2021-05-23 00:00:00"
  80. // @Param ModifyEndTime query string false "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
  81. // @Param IsExport query bool false "是否导出excel,默认是false"
  82. // @Success 200 {object} response.ContractApprovalListResp
  83. // @router /approval/list [get]
  84. func (this *ContractApprovalController) List() {
  85. br := new(models.BaseResponse).Init()
  86. defer func() {
  87. this.Data["json"] = br
  88. this.ServeJSON()
  89. }()
  90. sysUser := this.SysUser
  91. if sysUser == nil {
  92. br.Msg = "请登录"
  93. br.ErrMsg = "请登录,SysUser Is Empty"
  94. br.Ret = 408
  95. return
  96. }
  97. //合同类型、产品类型、合同状态、更新时间、所选销售
  98. //关键字:合同编号、客户名称,社会信用码
  99. contractBusinessType := this.GetString("ContractBusinessType") //合同业务类型
  100. contractType := this.GetString("ContractType")
  101. status := this.GetString("Status")
  102. productId, _ := this.GetInt("ProductId")
  103. sellerIds := this.GetString("SellerId")
  104. keyword := this.GetString("Keyword")
  105. modifyStartTime := this.GetString("ModifyStartTime")
  106. modifyEndTime := this.GetString("ModifyEndTime")
  107. childCondition := ""
  108. condition := ""
  109. childPars := make([]interface{}, 0)
  110. pars := make([]interface{}, 0)
  111. productSlice := make([]int, 0) //需要下载的 产品 切片
  112. //如果不是超管或者合规,那么只能查看自己的合同
  113. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN { //权益管理员
  114. condition += ` AND c.product_id = ? `
  115. pars = append(pars, 2)
  116. } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN { //ficc管理员
  117. condition += ` AND c.product_id = ? `
  118. pars = append(pars, 1)
  119. } else {
  120. if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
  121. condition += ` AND c.seller_id = ? `
  122. pars = append(pars, sysUser.AdminId)
  123. }
  124. }
  125. //合同类型、、更新时间、所选销售
  126. //关键字:合同编号、客户名称,社会信用码
  127. if contractType != "" {
  128. condition += ` AND c.contract_type = ? `
  129. pars = append(pars, contractType)
  130. }
  131. //合同业务类型
  132. if contractBusinessType != "" {
  133. condition += ` AND c.contract_business_type = ? `
  134. pars = append(pars, contractBusinessType)
  135. }
  136. //审批状态
  137. if status != "" {
  138. //childCondition += ` AND status = ? `
  139. //childPars = append(childPars, status)
  140. if status == "已审批" {
  141. condition += ` AND c.status in ("已审批","已驳回") `
  142. } else {
  143. condition += ` AND c.status = ? `
  144. pars = append(pars, status)
  145. }
  146. } else {
  147. //childCondition += ` AND status != "已撤回" `
  148. condition += ` AND c.status not in ("已撤回","待提交") `
  149. }
  150. //产品类型
  151. if productId > 0 {
  152. condition += ` AND c.product_id = ? `
  153. pars = append(pars, productId)
  154. productSlice = append(productSlice, productId)
  155. } else {
  156. nowProductId := services.GetProductId(sysUser.RoleTypeCode)
  157. if nowProductId > 0 {
  158. productSlice = append(productSlice, nowProductId)
  159. } else {
  160. productSlice = append(productSlice, 1)
  161. productSlice = append(productSlice, 2)
  162. }
  163. }
  164. //所选销售
  165. if sellerIds != "" {
  166. condition += ` AND c.seller_id IN (` + sellerIds + `) `
  167. }
  168. //更新开始时间
  169. //更新开始时间
  170. if modifyStartTime != "" {
  171. condition += ` AND a.modify_time >= ? `
  172. pars = append(pars, modifyStartTime)
  173. }
  174. //更新结束时间
  175. if modifyEndTime != "" {
  176. condition += ` AND a.modify_time <= ? `
  177. pars = append(pars, modifyEndTime)
  178. }
  179. //关键字
  180. if keyword != "" {
  181. condition += ` AND (c.contract_code LIKE '%` + keyword + `%' OR c.company_name LIKE '%` + keyword + `%' OR c.credit_code LIKE '%` + keyword + `%' ) `
  182. }
  183. pageSize, _ := this.GetInt("PageSize")
  184. currentIndex, _ := this.GetInt("CurrentIndex")
  185. var startSize int
  186. if pageSize <= 0 {
  187. pageSize = utils.PageSize20
  188. }
  189. if currentIndex <= 0 {
  190. currentIndex = 1
  191. }
  192. startSize = paging.StartIndex(currentIndex, pageSize)
  193. //是否导出报表
  194. isExport, _ := this.GetBool("IsExport")
  195. if isExport {
  196. pageSize = 10000
  197. currentIndex = 1
  198. }
  199. total, err := contract.GetContractApprovalListCount(condition, pars)
  200. if err != nil {
  201. br.Msg = "获取失败"
  202. br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
  203. return
  204. }
  205. list, err := contract.GetContractApprovalList(childCondition, condition, childPars, pars, startSize, pageSize)
  206. if err != nil {
  207. br.Msg = "获取审批列表失败!"
  208. br.ErrMsg = "获取审批列表失败,Err:" + err.Error()
  209. return
  210. }
  211. if len(list) > 0 {
  212. contractApprovalIdSlice := make([]string, 0)
  213. for i := 0; i < len(list); i++ {
  214. contractApprovalIdSlice = append(contractApprovalIdSlice, strconv.Itoa(list[i].ContractApprovalId))
  215. }
  216. contractApprovalIdStr := strings.Join(contractApprovalIdSlice, ",")
  217. //获取审批流列表数据
  218. contractApprovalRecordList, err := contract.GetContractApprovalRecordList(contractApprovalIdStr, sysUser.AdminId)
  219. if err != nil {
  220. br.Msg = "获取审批流列表失败!"
  221. br.ErrMsg = "获取审批流列表失败,Err:" + err.Error()
  222. return
  223. }
  224. contractApprovalRecordMap := make(map[int]*contract.ContractApprovalRecord)
  225. for i := 0; i < len(contractApprovalRecordList); i++ {
  226. contractApprovalRecordMap[contractApprovalRecordList[i].ContractApprovalId] = contractApprovalRecordList[i]
  227. }
  228. for i := 0; i < len(list); i++ {
  229. item := list[i]
  230. list[i].StartDateStr = item.StartDate.Format(utils.FormatDate)
  231. list[i].EndDateStr = item.EndDate.Format(utils.FormatDate)
  232. list[i].CreateTimeStr = item.CreateTime.Format(utils.FormatDateTime)
  233. list[i].ModifyTimeStr = item.ModifyTime.Format(utils.FormatDateTime)
  234. list[i].ApproveTimeStr = item.ApproveTime.Format(utils.FormatDateTime)
  235. list[i].CheckBackFileTimeStr = item.CheckBackFileTime.Format(utils.FormatDateTime)
  236. list[i].InvalidTimeStr = item.InvalidTime.Format(utils.FormatDateTime)
  237. list[i].RescindTimeStr = item.RescindTime.Format(utils.FormatDateTime)
  238. //合同操作权限
  239. var opButton contract.ContractButton
  240. var contractDetail contract.ContractDetail
  241. jsonErr := json.Unmarshal([]byte(list[i].ContractDetail), &contractDetail)
  242. if jsonErr != nil {
  243. br.Msg = "审批合同数据转换失败!"
  244. br.ErrMsg = "审批合同数据转换失败,Err:" + jsonErr.Error()
  245. return
  246. }
  247. list[i].ContractInfo = contractDetail
  248. //校验最新审批流数据
  249. if contractApprovalRecord, has := contractApprovalRecordMap[item.ContractApprovalId]; has {
  250. //审批流id
  251. list[i].ContractApprovalRecordId = contractApprovalRecord.ContractApprovalRecordId
  252. //审批时间
  253. list[i].ApproveTime = contractApprovalRecord.ApproveTime
  254. list[i].ApproveTimeStr = contractApprovalRecord.ApproveTime.Format(utils.FormatDateTime)
  255. //判断是否有操作权限
  256. list[i].Status = contractApprovalRecord.Status
  257. //判断是否处于待审批状态
  258. if contractApprovalRecord.Status == "待审批" {
  259. //如果不是审批者,那么不能审批操作
  260. if contractApprovalRecord.NodeType != "check" {
  261. continue
  262. }
  263. //如果没有指定审批人的话
  264. if contractApprovalRecord.ApproveUserId <= 0 {
  265. //判断是否与审批角色一致,如果一致,那么允许操作审批
  266. if contractApprovalRecord.ApproveRoleTypeCode == sysUser.RoleTypeCode {
  267. opButton.Approval = true
  268. }
  269. } else if contractApprovalRecord.ApproveUserId == sysUser.AdminId {
  270. //如果指定审批人就是自己的话,那么操作审批
  271. opButton.Approval = true
  272. }
  273. }
  274. }
  275. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_COMPLIANCE {
  276. if item.ContractStatus == "已审批" {
  277. opButton.CheckBackFile = true
  278. }
  279. if item.ContractStatus == "已签回" {
  280. opButton.RescindFile = true
  281. opButton.CheckBackFile = true
  282. }
  283. }
  284. //合同状态(突然说要改成展示合同状态,那就根据业务需求,改成返回:合同状态咯)
  285. list[i].Status = item.ContractStatus
  286. //合同操作权限
  287. list[i].OpButton = opButton
  288. }
  289. }
  290. page := paging.GetPaging(currentIndex, pageSize, total)
  291. //导出excel
  292. if isExport {
  293. contractApprovalListExport(this, list, productSlice, br)
  294. return
  295. }
  296. br.Ret = 200
  297. br.Success = true
  298. br.Msg = "获取成功"
  299. br.Data = response.ContractApprovalListResp{
  300. List: list,
  301. Paging: page,
  302. }
  303. }
  304. // ContractApprovalListExport 导出审批列表
  305. func contractApprovalListExport(this *ContractApprovalController, list []*contract.ContractApprovalList, productSlice []int, br *models.BaseResponse) {
  306. sysUser := this.SysUser
  307. if sysUser == nil {
  308. br.Msg = "请登录"
  309. br.ErrMsg = "请登录,SysUser Is Empty"
  310. br.Ret = 408
  311. return
  312. }
  313. fmt.Println("list len:", len(list))
  314. //获取合同套餐服务列表
  315. serviceTemplateList, err := contract.GetAllContractServiceTemplateList()
  316. if err != nil {
  317. br.Msg = "获取合同套餐服务列表失败!"
  318. br.ErrMsg = "获取合同套餐服务列表失败,Err:" + err.Error()
  319. return
  320. }
  321. templateTitleMap := make(map[int]string)
  322. for _, serviceTemplate := range serviceTemplateList {
  323. templateTitleMap[serviceTemplate.ServiceTemplateId] = serviceTemplate.Title
  324. }
  325. //业务合同的关联合同id集合
  326. businessContractIdList := make([]string, 0)
  327. //代付合同的关联合同id集合
  328. paymentOnBehalfContractIdList := make([]string, 0)
  329. //所有合同id集合(用于查询服务内容)
  330. allServiceContractIdList := make([]string, 0)
  331. //基础合同的关联合同数据
  332. contractRelationMap := make(map[int][]*contract.RelationContractList)
  333. for _, v := range list {
  334. allServiceContractIdList = append(allServiceContractIdList, fmt.Sprint(v.ContractId))
  335. switch v.ContractBusinessType {
  336. case "业务合同":
  337. businessContractIdList = append(businessContractIdList, fmt.Sprint(v.ContractId))
  338. case "代付合同":
  339. paymentOnBehalfContractIdList = append(paymentOnBehalfContractIdList, fmt.Sprint(v.ContractId))
  340. }
  341. }
  342. //业务合同的关联合同
  343. if len(businessContractIdList) > 0 {
  344. contractIdStr := strings.Join(businessContractIdList, ",")
  345. businessContractList, err := contract.GetContractRelationListByRelationContractIds(contractIdStr)
  346. if err != nil {
  347. br.Msg = "获取失败"
  348. br.ErrMsg = "获取业务关联合同失败,Err:" + err.Error()
  349. return
  350. }
  351. for _, v := range businessContractList {
  352. //代付合同id
  353. allServiceContractIdList = append(allServiceContractIdList, fmt.Sprint(v.PaymentOnBehalfContractId))
  354. if _, ok := contractRelationMap[v.ContractId]; ok {
  355. contractRelationMap[v.ContractId] = append(contractRelationMap[v.ContractId], v)
  356. } else {
  357. tmpList := make([]*contract.RelationContractList, 0)
  358. contractRelationMap[v.ContractId] = append(tmpList, v)
  359. }
  360. }
  361. }
  362. //代付合同的关联合同
  363. if len(paymentOnBehalfContractIdList) > 0 {
  364. paymentOnBehalfContractIdStr := strings.Join(paymentOnBehalfContractIdList, ",")
  365. paymentOnBehalfContractList, err := contract.GetContractRelationListByPaymentOnBehalfContractIds(paymentOnBehalfContractIdStr)
  366. if err != nil {
  367. br.Msg = "获取失败"
  368. br.ErrMsg = "获取代付关联合同失败,Err:" + err.Error()
  369. return
  370. }
  371. for _, v := range paymentOnBehalfContractList {
  372. //业务合同id
  373. allServiceContractIdList = append(allServiceContractIdList, fmt.Sprint(v.ContractId))
  374. if _, ok := contractRelationMap[v.PaymentOnBehalfContractId]; ok {
  375. contractRelationMap[v.PaymentOnBehalfContractId] = append(contractRelationMap[v.PaymentOnBehalfContractId], v)
  376. } else {
  377. tmpList := make([]*contract.RelationContractList, 0)
  378. contractRelationMap[v.PaymentOnBehalfContractId] = append(tmpList, v)
  379. }
  380. }
  381. }
  382. //获取合同详情
  383. serviceListMap := make(map[int][]*contract.ContractServiceAndDetail, 0)
  384. if len(allServiceContractIdList) > 0 {
  385. allRelationIdStr := strings.Join(allServiceContractIdList, ",")
  386. tmpServiceList, err := contract.GetContractServiceAndDetailListByIds(allRelationIdStr)
  387. if err != nil {
  388. br.Msg = "获取失败"
  389. br.ErrMsg = "获取关联合同服务详情失败,Err:" + err.Error()
  390. return
  391. }
  392. allContractServiceIdList := make([]string, 0)
  393. serviceDetailListMap := make(map[int][]*contract.ContractServiceDetail, 0)
  394. for _, service := range tmpServiceList {
  395. if service.HasDetail == "是" {
  396. allContractServiceIdList = append(allContractServiceIdList, strconv.Itoa(service.ContractServiceId))
  397. }
  398. }
  399. if len(allContractServiceIdList) > 0 {
  400. allContractServiceIdStr := strings.Join(allContractServiceIdList, ",")
  401. list, detailErr := contract.GetContractServiceDetailListByServiceIds(allContractServiceIdStr)
  402. if detailErr != nil {
  403. br.Msg = "获取失败"
  404. br.ErrMsg = "查找合同服务详情异常,Err:" + err.Error()
  405. return
  406. }
  407. for _, v := range list {
  408. if _, ok := serviceDetailListMap[v.ContractServiceId]; ok {
  409. serviceDetailListMap[v.ContractServiceId] = append(serviceDetailListMap[v.ContractServiceId], v)
  410. } else {
  411. tmpList := make([]*contract.ContractServiceDetail, 0)
  412. serviceDetailListMap[v.ContractServiceId] = append(tmpList, v)
  413. }
  414. }
  415. }
  416. for _, service := range tmpServiceList {
  417. if service.HasDetail == "是" {
  418. if serviceDetailList, ok := serviceDetailListMap[service.ContractServiceId]; ok {
  419. service.DetailList = serviceDetailList
  420. }
  421. //套餐名称
  422. if title, ok := templateTitleMap[service.ServiceTemplateId]; ok {
  423. service.Title = title
  424. }
  425. }
  426. //服务列表
  427. if _, ok := serviceListMap[service.ContractId]; ok {
  428. serviceListMap[service.ContractId] = append(serviceListMap[service.ContractId], service)
  429. } else {
  430. tmpList := make([]*contract.ContractServiceAndDetail, 0)
  431. serviceListMap[service.ContractId] = append(tmpList, service)
  432. }
  433. }
  434. }
  435. //生成excel文件
  436. dir, err := os.Executable()
  437. exPath := filepath.Dir(dir)
  438. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  439. xlsxFile := xlsx.NewFile()
  440. if err != nil {
  441. br.Msg = "生成文件失败"
  442. br.ErrMsg = "生成文件失败"
  443. return
  444. }
  445. //设置默认字体和文字大小
  446. xlsx.SetDefaultFont(12, "宋体")
  447. //定义边框样式
  448. border := xlsx.NewBorder("thin", "thin", "thin", "thin")
  449. //定义文字排版样式
  450. alignment := xlsx.Alignment{
  451. Horizontal: "center",
  452. Vertical: "center",
  453. WrapText: true,
  454. }
  455. //普通样式
  456. style := xlsx.NewStyle()
  457. style.Alignment = alignment
  458. style.ApplyAlignment = true
  459. style.Border = *border
  460. //标红文字,便于查看哪些产品被勾选
  461. redStyle := xlsx.NewStyle()
  462. redStyle.Alignment = alignment
  463. redStyle.ApplyAlignment = true
  464. redStyle.Font.Color = "ff0000"
  465. //定义底色需要标黄的 单元格颜色
  466. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  467. redStyle.Fill = redFill
  468. redStyle.Border = *border
  469. //标题样式
  470. titleStyle := xlsx.NewStyle()
  471. titleFont := xlsx.NewFont(14, "宋体")
  472. titleFont.Bold = true
  473. titleStyle.Font = *titleFont
  474. titleStyle.Alignment = alignment
  475. titleStyle.Border = *border
  476. //titleStyle.ApplyAlignment = true
  477. //表头
  478. headerStyle := xlsx.NewStyle()
  479. headerFont := xlsx.NewFont(12, "宋体")
  480. headerFont.Bold = true
  481. headerStyle.Font = *headerFont
  482. headerStyle.Alignment = alignment
  483. headerStyle.ApplyAlignment = true
  484. headerStyle.Border = *border
  485. defer func() {
  486. os.Remove(downLoadnFilePath)
  487. }()
  488. //遍历所拥有的的产品权限,然后插入到对应的sheet表单中
  489. for pidIndex := 0; pidIndex < len(productSlice); pidIndex++ {
  490. productId := productSlice[pidIndex]
  491. //表单名称
  492. sheetName := "合同数据"
  493. switch productId {
  494. case 1:
  495. sheetName = "ficc合同信息"
  496. case 2:
  497. sheetName = "权益合同信息"
  498. }
  499. //新增一个sheet表单
  500. sheel, err := xlsxFile.AddSheet(sheetName)
  501. if err != nil {
  502. br.Msg = "新增Sheet失败"
  503. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  504. return
  505. }
  506. //设置列宽
  507. sheel.SetColWidth(0, 0, 28)
  508. sheel.SetColWidth(1, 1, 30)
  509. sheel.SetColWidth(2, 2, 18)
  510. sheel.SetColWidth(3, 3, 18)
  511. sheel.SetColWidth(4, 4, 35)
  512. sheel.SetColWidth(5, 6, 20)
  513. sheel.SetColWidth(7, 7, 40)
  514. //合同信息列
  515. endContractInfoColIndex := 9
  516. sheel.SetColWidth(8, 8, 40)
  517. sheel.SetColWidth(9, 9, 40)
  518. //权限列
  519. sheel.SetColWidth(endContractInfoColIndex, endContractInfoColIndex+18, 30)
  520. //标题行
  521. titleRow := sheel.AddRow()
  522. titleRow.SetHeight(30)
  523. //合同信息列
  524. titleCell := titleRow.AddCell()
  525. titleCell.HMerge = 7 //向右合并列数,不包括自身列
  526. //遍历去添加需要合并的列
  527. for i := 0; i < 7; i++ {
  528. titleRow.AddCell()
  529. }
  530. //报表标题名称
  531. titleCell.SetValue("合同信息")
  532. titleCell.SetStyle(titleStyle)
  533. startI := 8
  534. customStartCellI := 8
  535. serviceSlice := make([]string, 0)
  536. serviceCellMap := make(map[string]int)
  537. //获取所有套餐列表
  538. {
  539. serviceList, err := getServiceTemplateList(productId)
  540. if err != nil {
  541. br.Msg = "查询套餐类型失败"
  542. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  543. return
  544. }
  545. for i := 0; i < len(serviceList); i++ {
  546. //需要向右合并添加的列数
  547. addCellNum := 0
  548. item := serviceList[i]
  549. //套餐服务列
  550. servicesCell := titleRow.AddCell()
  551. //套餐名称
  552. servicesCell.SetValue(item.Title)
  553. servicesCell.SetStyle(titleStyle)
  554. //ficc小套餐
  555. if item.ServiceTemplateId == 2 {
  556. productPermission := make(map[int]string)
  557. productPermission[1] = "每日宏观商品复盘"
  558. productPermission[2] = "能化专栏《化里化外》"
  559. productPermission[3] = "股债日评"
  560. productPermission[4] = "黑色专栏《知白守黑》"
  561. productPermission[5] = "有色专栏《有声有色》"
  562. for id, name := range productPermission {
  563. key := fmt.Sprint(item.ServiceTemplateId, "_product_permission_", id)
  564. serviceCellMap[key] = startI
  565. serviceSlice = append(serviceSlice, name)
  566. startI++
  567. addCellNum++
  568. }
  569. permissionList := make([]*company.PermissionSetItem, 0)
  570. for _, v := range utils.PermissionFiccClassifyArr {
  571. items, err := company.GetPermissionSetItems(1, v)
  572. if err != nil {
  573. br.Msg = "获取失败"
  574. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  575. return
  576. }
  577. permissionList = append(permissionList, items...)
  578. }
  579. //权限列表
  580. for j := 0; j < len(permissionList); j++ {
  581. key := fmt.Sprint(item.ServiceTemplateId, "_permission_", permissionList[j].ChartPermissionId)
  582. serviceCellMap[key] = startI
  583. serviceSlice = append(serviceSlice, permissionList[j].PermissionName)
  584. startI++
  585. addCellNum++
  586. }
  587. //因为自己本身有一列了,所以在最后增加列的时候,需要减去自身列
  588. addCellNum = addCellNum - 1
  589. if addCellNum > 0 {
  590. for tmpAddCellNum := 0; tmpAddCellNum < addCellNum; tmpAddCellNum++ {
  591. titleRow.AddCell()
  592. }
  593. servicesCell.HMerge = addCellNum //向右合并列数,不包括自身列
  594. }
  595. continue
  596. } else {
  597. if item.Children != nil && len(item.Children) > 0 {
  598. for j := 0; j < len(item.Children); j++ {
  599. key := fmt.Sprint("service_template_", item.Children[j].ServiceTemplateId)
  600. serviceCellMap[key] = startI
  601. serviceSlice = append(serviceSlice, item.Children[j].Title)
  602. startI++
  603. addCellNum++
  604. }
  605. //因为自己本身有一列了,所以在最后增加列的时候,需要减去自身列
  606. addCellNum = addCellNum - 1
  607. if addCellNum > 0 {
  608. for tmpAddCellNum := 0; tmpAddCellNum < addCellNum; tmpAddCellNum++ {
  609. titleRow.AddCell()
  610. }
  611. servicesCell.HMerge = addCellNum //向右合并列数,不包括自身列
  612. }
  613. } else {
  614. key := fmt.Sprint("service_template_", item.ServiceTemplateId)
  615. serviceCellMap[key] = startI
  616. serviceSlice = append(serviceSlice, item.Title)
  617. startI++
  618. }
  619. }
  620. }
  621. }
  622. //表头
  623. headerRow := sheel.AddRow()
  624. headerRow.SetHeight(24)
  625. //合同基础信息
  626. {
  627. codeHeaderCell := headerRow.AddCell()
  628. codeHeaderCell.SetValue("合同编号")
  629. codeHeaderCell.SetStyle(headerStyle)
  630. companyHeaderCell := headerRow.AddCell()
  631. companyHeaderCell.SetValue("客户名称")
  632. companyHeaderCell.SetStyle(headerStyle)
  633. typeHeaderCell := headerRow.AddCell()
  634. typeHeaderCell.SetValue("合同类型")
  635. typeHeaderCell.SetStyle(headerStyle)
  636. priceHeaderCell := headerRow.AddCell()
  637. priceHeaderCell.SetValue("合同金额")
  638. priceHeaderCell.SetStyle(headerStyle)
  639. dateHeaderCell := headerRow.AddCell()
  640. dateHeaderCell.SetValue("合同有效期")
  641. dateHeaderCell.SetStyle(headerStyle)
  642. sellerHeaderCell := headerRow.AddCell()
  643. sellerHeaderCell.SetValue("销售")
  644. sellerHeaderCell.SetStyle(headerStyle)
  645. payHeaderCell := headerRow.AddCell()
  646. payHeaderCell.SetValue("付款方")
  647. payHeaderCell.SetStyle(headerStyle)
  648. useHeaderCell := headerRow.AddCell()
  649. useHeaderCell.SetValue("实际使用方")
  650. useHeaderCell.SetStyle(headerStyle)
  651. statusHeaderCell := headerRow.AddCell()
  652. statusHeaderCell.SetValue("合同状态")
  653. statusHeaderCell.SetStyle(headerStyle)
  654. remarkHeaderCell := headerRow.AddCell()
  655. remarkHeaderCell.SetValue("备注")
  656. remarkHeaderCell.SetStyle(headerStyle)
  657. }
  658. //添加服务套餐名称
  659. for _, service := range serviceSlice {
  660. cell := headerRow.AddCell()
  661. cell.SetValue(service)
  662. cell.SetStyle(headerStyle)
  663. }
  664. for _, v := range list {
  665. //如果当前合同不是该产品
  666. if v.ProductId != productId {
  667. continue
  668. }
  669. dataRow := sheel.AddRow()
  670. dataRow.SetHeight(24)
  671. //合同基础信息
  672. {
  673. codeCell := dataRow.AddCell()
  674. codeCell.SetValue(v.ContractCode)
  675. codeCell.SetStyle(style)
  676. companyCell := dataRow.AddCell()
  677. companyCell.SetValue(v.CompanyName)
  678. companyCell.SetStyle(style)
  679. typeCell := dataRow.AddCell()
  680. typeCell.SetValue(v.ContractType)
  681. typeCell.SetStyle(style)
  682. priceCell := dataRow.AddCell()
  683. priceCell.SetValue(v.Price)
  684. priceCell.SetStyle(style)
  685. dateCell := dataRow.AddCell()
  686. dateCell.SetValue(fmt.Sprint(v.StartDate.Format(utils.FormatDate), " 至 ", v.EndDate.Format(utils.FormatDate)))
  687. dateCell.SetStyle(style)
  688. sellerCell := dataRow.AddCell()
  689. sellerCell.SetValue(v.SellerName)
  690. sellerCell.SetStyle(style)
  691. //付款方
  692. payStr := v.PayChannel
  693. payCell := dataRow.AddCell()
  694. if v.ContractBusinessType == "业务合同" {
  695. if relationContractList, ok := contractRelationMap[v.ContractId]; ok {
  696. payCompanyNameList := make([]string, 0)
  697. for _, relationContract := range relationContractList {
  698. payCompanyNameList = append(payCompanyNameList, relationContract.CompanyName)
  699. }
  700. payStr = strings.Join(payCompanyNameList, ",")
  701. }
  702. } else {
  703. payStr = v.CompanyName
  704. }
  705. payCell.SetValue(payStr)
  706. payCell.SetStyle(style)
  707. //使用方
  708. useStr := ``
  709. useCell := dataRow.AddCell()
  710. if v.ContractBusinessType == "代付合同" {
  711. if relationContractList, ok := contractRelationMap[v.ContractId]; ok {
  712. payCompanyNameList := make([]string, 0)
  713. for _, relationContract := range relationContractList {
  714. payCompanyNameList = append(payCompanyNameList, relationContract.CompanyName)
  715. }
  716. useStr = strings.Join(payCompanyNameList, ",")
  717. }
  718. } else {
  719. useStr = v.CompanyName
  720. }
  721. useCell.SetValue(useStr)
  722. useCell.SetStyle(style)
  723. statusCell := dataRow.AddCell()
  724. statusCell.SetValue(v.Status)
  725. statusCell.SetStyle(style)
  726. //备注:该字段由三部分拼接:服务内容中的补充内容+赠送时间+优惠金额
  727. //补充内容直接取该字段内容;
  728. //赠送时间以年为单位,超过整年的月份作为赠送月份,如14个月即为赠送2个月;
  729. //优惠金额等于原价-优惠后价格=优惠价格
  730. //补充内容
  731. var remark string
  732. if v.Remark != "" {
  733. remark += "补充内容:" + v.Remark
  734. }
  735. //赠送时间
  736. //合同结束日期与合同开始日期的时间差(小时差)
  737. newDecimal := decimal.NewFromFloat(v.EndDate.Sub(v.StartDate).Hours())
  738. //分母为365天 * 24 小时
  739. newDecimal2 := decimal.NewFromInt(24 * 365)
  740. //计算出来相差多少年,保留一位小数(四舍五入)
  741. numYearDecimal := newDecimal.Div(newDecimal2).Round(1).Mul(decimal.NewFromInt(10))
  742. //如果大于1年,那么才去判断是否赠送
  743. numYear, _ := numYearDecimal.Float64()
  744. if numYear > 10 {
  745. //获取多出来的整数年数据
  746. numYearDecimal = numYearDecimal.Mod(decimal.NewFromInt(10)).Div(decimal.NewFromInt(10))
  747. //计算赠送出来的月份
  748. numMonthDecimal := numYearDecimal.Mul(decimal.NewFromInt(12)).Round(0)
  749. numMonth, _ := numMonthDecimal.Float64()
  750. if numMonth > 0 {
  751. if remark != "" {
  752. remark += ";"
  753. }
  754. remark += "赠送时间为:" + numMonthDecimal.String() + "个月"
  755. }
  756. }
  757. //优惠金额
  758. if v.OriginalPrice > v.Price {
  759. differencePrice := v.OriginalPrice - v.Price
  760. differencePriceDecimal := decimal.NewFromFloat(differencePrice)
  761. if remark != "" {
  762. remark += ";"
  763. }
  764. remark += "优惠金额:" + differencePriceDecimal.String() + "元。"
  765. }
  766. remarkCell := dataRow.AddCell()
  767. remarkCell.SetValue(remark)
  768. remarkCell.SetStyle(style)
  769. }
  770. //服务套餐
  771. {
  772. cellServiceMap := make(map[int]string)
  773. for _, cellI := range serviceCellMap {
  774. cellServiceMap[cellI] = "否"
  775. }
  776. //如果没有服务那么就进入下一个循环
  777. tmpService, ok := serviceListMap[v.ContractId]
  778. if !ok {
  779. continue
  780. }
  781. if tmpService != nil && len(tmpService) > 0 {
  782. permissionValues := []string{
  783. "FICC周报", "商品双周报+线上电话会讨论会<br/>(由弘则的研究员主持线上讨论)", "数据点评", "深度月报:包括宏观经济月报和下游草根调研月报+电话会讨论会<br/>(由弘则的研究员主持线上讨论)",
  784. }
  785. for _, item := range tmpService {
  786. //ficc小套餐
  787. if item.ServiceTemplateId == 2 {
  788. for _, detail := range item.DetailList {
  789. var tableCel request.AddContractServiceDetailReq
  790. tmpErr := json.Unmarshal([]byte(detail.Col1), &tableCel)
  791. if tmpErr != nil {
  792. err = tmpErr
  793. return
  794. }
  795. if tableCel.Value == "商品复盘" {
  796. var tableCel2 request.AddContractServiceDetailReq
  797. //获取品种列数据
  798. tmpErr := contractService.GetProductCelData(*detail, &tableCel2)
  799. if tmpErr != nil {
  800. err = tmpErr
  801. return
  802. }
  803. //tableCel2.Tag
  804. for _, serviceId := range tableCel2.ValueId {
  805. key := fmt.Sprint(item.ServiceTemplateId, "_product_permission_", serviceId)
  806. if cellI, ok := serviceCellMap[key]; ok {
  807. cellServiceMap[cellI] = "是"
  808. }
  809. }
  810. } else if strings.Contains(strings.Join(permissionValues, ","), tableCel.Value) {
  811. //获取品种列数据
  812. var tableCel2 request.AddContractServiceDetailReq
  813. tmpErr := contractService.GetProductCelData(*detail, &tableCel2)
  814. if tmpErr != nil {
  815. err = tmpErr
  816. return
  817. }
  818. for _, serviceId := range tableCel2.ValueId {
  819. key := fmt.Sprint(item.ServiceTemplateId, "_permission_", serviceId)
  820. if cellI, ok := serviceCellMap[key]; ok {
  821. cellServiceMap[cellI] = "是"
  822. }
  823. }
  824. }
  825. }
  826. } else {
  827. key := fmt.Sprint("service_template_", item.ServiceTemplateId)
  828. if cellI, ok := serviceCellMap[key]; ok {
  829. cellServiceMap[cellI] = "是"
  830. }
  831. }
  832. }
  833. }
  834. //遍历所有套餐
  835. for tmpStartCellI := customStartCellI; tmpStartCellI < startI; tmpStartCellI++ {
  836. servicesCell := dataRow.AddCell()
  837. cellValue, ok := cellServiceMap[tmpStartCellI]
  838. if ok == false {
  839. cellValue = "否"
  840. }
  841. servicesCell.SetValue(cellValue)
  842. if cellValue == "是" { //勾选了话,标红处理
  843. servicesCell.SetStyle(redStyle)
  844. } else {
  845. servicesCell.SetStyle(style)
  846. }
  847. }
  848. }
  849. }
  850. }
  851. err = xlsxFile.Save(downLoadnFilePath)
  852. if err != nil {
  853. br.Msg = "保存文件失败"
  854. br.ErrMsg = "保存文件失败"
  855. return
  856. }
  857. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  858. downloadFileName := "合同列表" + randStr + ".xlsx"
  859. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  860. br.Ret = 200
  861. br.Success = true
  862. br.Msg = "导出成功"
  863. }
  864. // @Title 合同列表数据导出
  865. // @Description 合同列表数据导出接口
  866. // @Description 合同列表接口
  867. // @Param ContractType query string false "合同类型,枚举值:'新签合同','续约合同','补充协议'"
  868. // @Param ContractStatus query string false "合同状态,枚举值:'待提交','待审批','已撤回','已审批','已驳回','已作废'"
  869. // @Param ProductId query int false "客户类型:传0或者不传为当前账号权限,1 代表是:ficc;2 代表是:权益"
  870. // @Param ModifyStartTime query string false "服务更新时间的选择开始时间,格式:2021-05-23 00:00:00"
  871. // @Param ModifyEndTime query string false "服务更新时间的选择结束时间,格式:2021-05-26 23:59:59"
  872. // @Param SellerId query string false "选择的销售id"
  873. // @Param Keyword query string false "搜索关键字"
  874. // @Success 200 {object} response.ContractListResp
  875. // @router /approval/export [get]
  876. func (this *ContractApprovalController) Export() {
  877. br := new(models.BaseResponse).Init()
  878. defer func() {
  879. this.Data["json"] = br
  880. this.ServeJSON()
  881. }()
  882. sysUser := this.SysUser
  883. if sysUser == nil {
  884. br.Msg = "请登录"
  885. br.ErrMsg = "请登录,SysUser Is Empty"
  886. br.Ret = 408
  887. return
  888. }
  889. contractType := this.GetString("ContractType")
  890. contractStatus := this.GetString("ContractStatus")
  891. productId, _ := this.GetInt("ProductId")
  892. modifyStartTime := this.GetString("ModifyStartTime")
  893. modifyEndTime := this.GetString("ModifyEndTime")
  894. sellerIds := this.GetString("SellerId")
  895. keyword := this.GetString("Keyword")
  896. condition := ""
  897. pars := make([]interface{}, 0)
  898. //如果不是超管或者合规,那么只能查看自己的合同
  899. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  900. condition += ` AND product_id = 1 AND status not in ("待提交","已撤回") `
  901. } else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  902. condition += ` AND product_id = 2 AND status not in ("待提交","已撤回") `
  903. } else {
  904. if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_COMPLIANCE && sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
  905. condition += ` AND seller_id = ? `
  906. pars = append(pars, sysUser.AdminId)
  907. }
  908. }
  909. //需要下载的 产品 切片
  910. productSlice := make([]int, 0)
  911. //合同类型、、更新时间、所选销售
  912. //关键字:合同编号、客户名称,社会信用码
  913. if contractType != "" {
  914. condition += ` AND contract_type = ? `
  915. pars = append(pars, contractType)
  916. }
  917. //合同状态
  918. if contractStatus != "" {
  919. if contractStatus == "已审批" {
  920. condition += ` AND status in ("已审批","已驳回") `
  921. } else {
  922. condition += ` AND status = ? `
  923. pars = append(pars, contractStatus)
  924. }
  925. } else {
  926. //condition += ` AND status != "已撤回" `
  927. condition += ` AND status not in ("已撤回","待提交") `
  928. }
  929. //产品类型
  930. if productId > 0 {
  931. condition += ` AND product_id = ? `
  932. pars = append(pars, productId)
  933. productSlice = append(productSlice, productId)
  934. } else {
  935. nowProductId := services.GetProductId(sysUser.RoleTypeCode)
  936. if nowProductId > 0 {
  937. productSlice = append(productSlice, nowProductId)
  938. } else {
  939. productSlice = append(productSlice, 1)
  940. productSlice = append(productSlice, 2)
  941. }
  942. }
  943. //所选销售
  944. if sellerIds != "" {
  945. condition += ` AND seller_id IN (` + sellerIds + `) `
  946. }
  947. //更新开始时间
  948. if modifyStartTime != "" {
  949. condition += ` AND modify_time >= ? `
  950. pars = append(pars, modifyStartTime)
  951. }
  952. //更新结束时间
  953. if modifyEndTime != "" {
  954. condition += ` AND modify_time <= ? `
  955. pars = append(pars, modifyEndTime)
  956. }
  957. //关键字
  958. if keyword != "" {
  959. condition += ` AND (contract_code LIKE '%` + keyword + `%' OR company_name LIKE '%` + keyword + `%' OR credit_code LIKE '%` + keyword + `%' ) `
  960. }
  961. //取 一万 条合同数据
  962. list, err := contract.GetContractList(condition, "", pars, 0, 10000)
  963. if err != nil {
  964. br.Msg = "获取合同列表失败!"
  965. br.ErrMsg = "获取合同列表失败,Err:" + err.Error()
  966. return
  967. }
  968. //获取合同套餐服务列表
  969. serviceTemplateList, err := contract.GetAllContractServiceTemplateList()
  970. if err != nil {
  971. br.Msg = "获取合同套餐服务列表失败!"
  972. br.ErrMsg = "获取合同套餐服务列表失败,Err:" + err.Error()
  973. return
  974. }
  975. templateTitleMap := make(map[int]string)
  976. for _, serviceTemplate := range serviceTemplateList {
  977. templateTitleMap[serviceTemplate.ServiceTemplateId] = serviceTemplate.Title
  978. }
  979. for i := 0; i < len(list); i++ {
  980. item := list[i]
  981. list[i].StartDateStr = item.StartDate.Format(utils.FormatDate)
  982. list[i].EndDateStr = item.EndDate.Format(utils.FormatDate)
  983. list[i].CreateTimeStr = item.CreateTime.Format(utils.FormatDateTime)
  984. list[i].ModifyTimeStr = item.ModifyTime.Format(utils.FormatDateTime)
  985. //服务列表
  986. serviceList, err := contract.GetContractServiceAndDetailList(item.ContractId)
  987. if err != nil {
  988. br.Msg = "获取失败"
  989. br.ErrMsg = "查找合同服务异常,Err:" + err.Error()
  990. return
  991. }
  992. for i := 0; len(serviceList) > i; i++ {
  993. if serviceList[i].HasDetail == "是" {
  994. list, detailErr := contract.GetContractServiceDetailListByServiceId(serviceList[i].ContractServiceId)
  995. if detailErr != nil {
  996. br.Msg = "获取失败"
  997. br.ErrMsg = "查找合同服务详情异常,Err:" + err.Error()
  998. return
  999. }
  1000. //套餐名称
  1001. serviceList[i].DetailList = list
  1002. if title, ok := templateTitleMap[serviceList[i].ServiceTemplateId]; ok {
  1003. serviceList[i].Title = title
  1004. }
  1005. }
  1006. }
  1007. list[i].Service = serviceList
  1008. }
  1009. //生成excel文件
  1010. dir, err := os.Executable()
  1011. exPath := filepath.Dir(dir)
  1012. downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
  1013. xlsxFile := xlsx.NewFile()
  1014. if err != nil {
  1015. br.Msg = "生成文件失败"
  1016. br.ErrMsg = "生成文件失败"
  1017. return
  1018. }
  1019. //设置默认字体和文字大小
  1020. xlsx.SetDefaultFont(12, "宋体")
  1021. //定义边框样式
  1022. border := xlsx.NewBorder("thin", "thin", "thin", "thin")
  1023. //定义文字排版样式
  1024. alignment := xlsx.Alignment{
  1025. Horizontal: "center",
  1026. Vertical: "center",
  1027. WrapText: true,
  1028. }
  1029. //普通样式
  1030. style := xlsx.NewStyle()
  1031. style.Alignment = alignment
  1032. style.ApplyAlignment = true
  1033. style.Border = *border
  1034. //标红文字,便于查看哪些产品被勾选
  1035. redStyle := xlsx.NewStyle()
  1036. redStyle.Alignment = alignment
  1037. redStyle.ApplyAlignment = true
  1038. redStyle.Font.Color = "ff0000"
  1039. //定义底色需要标黄的 单元格颜色
  1040. redFill := xlsx.Fill{"solid", "ffff00", "ffff00"}
  1041. redStyle.Fill = redFill
  1042. redStyle.Border = *border
  1043. //标题样式
  1044. titleStyle := xlsx.NewStyle()
  1045. titleFont := xlsx.NewFont(14, "宋体")
  1046. titleFont.Bold = true
  1047. titleStyle.Font = *titleFont
  1048. titleStyle.Alignment = alignment
  1049. titleStyle.Border = *border
  1050. //titleStyle.ApplyAlignment = true
  1051. //表头
  1052. headerStyle := xlsx.NewStyle()
  1053. headerFont := xlsx.NewFont(12, "宋体")
  1054. headerFont.Bold = true
  1055. headerStyle.Font = *headerFont
  1056. headerStyle.Alignment = alignment
  1057. headerStyle.ApplyAlignment = true
  1058. headerStyle.Border = *border
  1059. defer func() {
  1060. os.Remove(downLoadnFilePath)
  1061. }()
  1062. //遍历所拥有的的产品权限,然后插入到对应的sheet表单中
  1063. for pidIndex := 0; pidIndex < len(productSlice); pidIndex++ {
  1064. productId = productSlice[pidIndex]
  1065. //表单名称
  1066. sheetName := "合同数据"
  1067. switch productId {
  1068. case 1:
  1069. sheetName = "ficc合同信息"
  1070. case 2:
  1071. sheetName = "权益合同信息"
  1072. }
  1073. //新增一个sheet表单
  1074. sheel, err := xlsxFile.AddSheet(sheetName)
  1075. if err != nil {
  1076. br.Msg = "新增Sheet失败"
  1077. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1078. return
  1079. }
  1080. //设置列宽
  1081. sheel.SetColWidth(0, 0, 28)
  1082. sheel.SetColWidth(1, 1, 30)
  1083. sheel.SetColWidth(2, 2, 18)
  1084. sheel.SetColWidth(3, 3, 18)
  1085. sheel.SetColWidth(4, 4, 35)
  1086. sheel.SetColWidth(5, 6, 20)
  1087. sheel.SetColWidth(7, 7, 40)
  1088. sheel.SetColWidth(7, 35, 30)
  1089. //标题行
  1090. titleRow := sheel.AddRow()
  1091. titleRow.SetHeight(30)
  1092. //合同信息列
  1093. titleCell := titleRow.AddCell()
  1094. titleCell.HMerge = 7 //向右合并列数,不包括自身列
  1095. //遍历去添加需要合并的列
  1096. for i := 0; i < 7; i++ {
  1097. titleRow.AddCell()
  1098. }
  1099. //报表标题名称
  1100. titleCell.SetValue("合同信息")
  1101. titleCell.SetStyle(titleStyle)
  1102. startI := 8
  1103. customStartCellI := 8
  1104. serviceSlice := make([]string, 0)
  1105. serviceCellMap := make(map[string]int)
  1106. //获取所有套餐列表
  1107. {
  1108. serviceList, err := getServiceTemplateList(productId)
  1109. if err != nil {
  1110. br.Msg = "查询套餐类型失败"
  1111. br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
  1112. return
  1113. }
  1114. for i := 0; i < len(serviceList); i++ {
  1115. //需要向右合并添加的列数
  1116. addCellNum := 0
  1117. item := serviceList[i]
  1118. //套餐服务列
  1119. servicesCell := titleRow.AddCell()
  1120. //套餐名称
  1121. servicesCell.SetValue(item.Title)
  1122. servicesCell.SetStyle(titleStyle)
  1123. //ficc小套餐
  1124. if item.ServiceTemplateId == 2 {
  1125. productPermission := make(map[int]string)
  1126. productPermission[1] = "每日宏观商品复盘"
  1127. productPermission[2] = "能化专栏《化里化外》"
  1128. productPermission[3] = "股债日评"
  1129. productPermission[4] = "黑色专栏《知白守黑》"
  1130. productPermission[5] = "有色专栏《有声有色》"
  1131. for id, name := range productPermission {
  1132. key := fmt.Sprint(item.ServiceTemplateId, "_product_permission_", id)
  1133. serviceCellMap[key] = startI
  1134. serviceSlice = append(serviceSlice, name)
  1135. startI++
  1136. addCellNum++
  1137. }
  1138. permissionList := make([]*company.PermissionSetItem, 0)
  1139. for _, v := range utils.PermissionFiccClassifyArr {
  1140. items, err := company.GetPermissionSetItems(1, v)
  1141. if err != nil {
  1142. br.Msg = "获取失败"
  1143. br.ErrMsg = "获取权限信息失败,Err:" + err.Error()
  1144. return
  1145. }
  1146. permissionList = append(permissionList, items...)
  1147. }
  1148. //权限列表
  1149. for j := 0; j < len(permissionList); j++ {
  1150. key := fmt.Sprint(item.ServiceTemplateId, "_permission_", permissionList[j].ChartPermissionId)
  1151. serviceCellMap[key] = startI
  1152. serviceSlice = append(serviceSlice, permissionList[j].PermissionName)
  1153. startI++
  1154. addCellNum++
  1155. }
  1156. //因为自己本身有一列了,所以在最后增加列的时候,需要减去自身列
  1157. addCellNum = addCellNum - 1
  1158. if addCellNum > 0 {
  1159. for tmpAddCellNum := 0; tmpAddCellNum < addCellNum; tmpAddCellNum++ {
  1160. titleRow.AddCell()
  1161. }
  1162. servicesCell.HMerge = addCellNum //向右合并列数,不包括自身列
  1163. }
  1164. continue
  1165. } else {
  1166. if item.Children != nil && len(item.Children) > 0 {
  1167. for j := 0; j < len(item.Children); j++ {
  1168. key := fmt.Sprint("service_template_", item.Children[j].ServiceTemplateId)
  1169. serviceCellMap[key] = startI
  1170. serviceSlice = append(serviceSlice, item.Children[j].Title)
  1171. startI++
  1172. addCellNum++
  1173. }
  1174. //因为自己本身有一列了,所以在最后增加列的时候,需要减去自身列
  1175. addCellNum = addCellNum - 1
  1176. if addCellNum > 0 {
  1177. for tmpAddCellNum := 0; tmpAddCellNum < addCellNum; tmpAddCellNum++ {
  1178. titleRow.AddCell()
  1179. }
  1180. servicesCell.HMerge = addCellNum //向右合并列数,不包括自身列
  1181. }
  1182. } else {
  1183. key := fmt.Sprint("service_template_", item.ServiceTemplateId)
  1184. serviceCellMap[key] = startI
  1185. serviceSlice = append(serviceSlice, item.Title)
  1186. startI++
  1187. }
  1188. }
  1189. }
  1190. }
  1191. //表头
  1192. headerRow := sheel.AddRow()
  1193. headerRow.SetHeight(24)
  1194. //合同基础信息
  1195. {
  1196. codeHeaderCell := headerRow.AddCell()
  1197. codeHeaderCell.SetValue("合同编号")
  1198. codeHeaderCell.SetStyle(headerStyle)
  1199. companyHeaderCell := headerRow.AddCell()
  1200. companyHeaderCell.SetValue("客户名称")
  1201. companyHeaderCell.SetStyle(headerStyle)
  1202. typeHeaderCell := headerRow.AddCell()
  1203. typeHeaderCell.SetValue("合同类型")
  1204. typeHeaderCell.SetStyle(headerStyle)
  1205. priceHeaderCell := headerRow.AddCell()
  1206. priceHeaderCell.SetValue("合同金额")
  1207. priceHeaderCell.SetStyle(headerStyle)
  1208. dateHeaderCell := headerRow.AddCell()
  1209. dateHeaderCell.SetValue("合同有效期")
  1210. dateHeaderCell.SetStyle(headerStyle)
  1211. sellerHeaderCell := headerRow.AddCell()
  1212. sellerHeaderCell.SetValue("销售")
  1213. sellerHeaderCell.SetStyle(headerStyle)
  1214. statusHeaderCell := headerRow.AddCell()
  1215. statusHeaderCell.SetValue("合同状态")
  1216. statusHeaderCell.SetStyle(headerStyle)
  1217. remarkHeaderCell := headerRow.AddCell()
  1218. remarkHeaderCell.SetValue("备注")
  1219. remarkHeaderCell.SetStyle(headerStyle)
  1220. }
  1221. //添加服务套餐名称
  1222. for _, service := range serviceSlice {
  1223. cell := headerRow.AddCell()
  1224. cell.SetValue(service)
  1225. cell.SetStyle(headerStyle)
  1226. }
  1227. for _, v := range list {
  1228. //如果当前合同不是该产品
  1229. if v.ProductId != productId {
  1230. continue
  1231. }
  1232. dataRow := sheel.AddRow()
  1233. dataRow.SetHeight(24)
  1234. //合同基础信息
  1235. {
  1236. codeCell := dataRow.AddCell()
  1237. codeCell.SetValue(v.ContractCode)
  1238. codeCell.SetStyle(style)
  1239. companyCell := dataRow.AddCell()
  1240. companyCell.SetValue(v.CompanyName)
  1241. companyCell.SetStyle(style)
  1242. typeCell := dataRow.AddCell()
  1243. typeCell.SetValue(v.ContractType)
  1244. typeCell.SetStyle(style)
  1245. priceCell := dataRow.AddCell()
  1246. priceCell.SetValue(v.Price)
  1247. priceCell.SetStyle(style)
  1248. dateCell := dataRow.AddCell()
  1249. dateCell.SetValue(fmt.Sprint(v.StartDate.Format(utils.FormatDate), " 至 ", v.EndDate.Format(utils.FormatDate)))
  1250. dateCell.SetStyle(style)
  1251. sellerCell := dataRow.AddCell()
  1252. sellerCell.SetValue(v.SellerName)
  1253. sellerCell.SetStyle(style)
  1254. statusCell := dataRow.AddCell()
  1255. statusCell.SetValue(v.Status)
  1256. statusCell.SetStyle(style)
  1257. //备注:该字段由三部分拼接:服务内容中的补充内容+赠送时间+优惠金额
  1258. //补充内容直接取该字段内容;
  1259. //赠送时间以年为单位,超过整年的月份作为赠送月份,如14个月即为赠送2个月;
  1260. //优惠金额等于原价-优惠后价格=优惠价格
  1261. //补充内容
  1262. var remark string
  1263. if v.Remark != "" {
  1264. remark += "补充内容:" + v.Remark
  1265. }
  1266. //赠送时间
  1267. //合同结束日期与合同开始日期的时间差(小时差)
  1268. newDecimal := decimal.NewFromFloat(v.EndDate.Sub(v.StartDate).Hours())
  1269. //分母为365天 * 24 小时
  1270. newDecimal2 := decimal.NewFromInt(24 * 365)
  1271. //计算出来相差多少年,保留一位小数(四舍五入)
  1272. numYearDecimal := newDecimal.Div(newDecimal2).Round(1).Mul(decimal.NewFromInt(10))
  1273. //如果大于1年,那么才去判断是否赠送
  1274. numYear, _ := numYearDecimal.Float64()
  1275. if numYear > 10 {
  1276. //获取多出来的整数年数据
  1277. numYearDecimal = numYearDecimal.Mod(decimal.NewFromInt(10)).Div(decimal.NewFromInt(10))
  1278. //计算赠送出来的月份
  1279. numMonthDecimal := numYearDecimal.Mul(decimal.NewFromInt(12)).Round(0)
  1280. numMonth, _ := numMonthDecimal.Float64()
  1281. if numMonth > 0 {
  1282. if remark != "" {
  1283. remark += ";"
  1284. }
  1285. remark += "赠送时间为:" + numMonthDecimal.String() + "个月"
  1286. }
  1287. }
  1288. //优惠金额
  1289. if v.OriginalPrice > v.Price {
  1290. differencePrice := v.OriginalPrice - v.Price
  1291. differencePriceDecimal := decimal.NewFromFloat(differencePrice)
  1292. if remark != "" {
  1293. remark += ";"
  1294. }
  1295. remark += "优惠金额:" + differencePriceDecimal.String() + "元。"
  1296. }
  1297. remarkCell := dataRow.AddCell()
  1298. remarkCell.SetValue(remark)
  1299. remarkCell.SetStyle(style)
  1300. }
  1301. //服务套餐
  1302. {
  1303. cellServiceMap := make(map[int]string)
  1304. for _, cellI := range serviceCellMap {
  1305. cellServiceMap[cellI] = "否"
  1306. }
  1307. if v.Service != nil && len(v.Service) > 0 {
  1308. permissionValues := []string{
  1309. "FICC周报", "商品双周报+线上电话会讨论会<br/>(由弘则的研究员主持线上讨论)", "数据点评", "深度月报:包括宏观经济月报和下游草根调研月报+电话会讨论会<br/>(由弘则的研究员主持线上讨论)",
  1310. }
  1311. for _, item := range v.Service {
  1312. //ficc小套餐
  1313. if item.ServiceTemplateId == 2 {
  1314. for _, detail := range item.DetailList {
  1315. var tableCel request.AddContractServiceDetailReq
  1316. tmpErr := json.Unmarshal([]byte(detail.Col1), &tableCel)
  1317. if tmpErr != nil {
  1318. err = tmpErr
  1319. return
  1320. }
  1321. if tableCel.Value == "商品复盘" {
  1322. var tableCel2 request.AddContractServiceDetailReq
  1323. //获取品种列数据
  1324. tmpErr := contractService.GetProductCelData(*detail, &tableCel2)
  1325. if tmpErr != nil {
  1326. err = tmpErr
  1327. return
  1328. }
  1329. //tableCel2.Tag
  1330. for _, serviceId := range tableCel2.ValueId {
  1331. key := fmt.Sprint(item.ServiceTemplateId, "_product_permission_", serviceId)
  1332. if cellI, ok := serviceCellMap[key]; ok {
  1333. cellServiceMap[cellI] = "是"
  1334. }
  1335. }
  1336. } else if strings.Contains(strings.Join(permissionValues, ","), tableCel.Value) {
  1337. //获取品种列数据
  1338. var tableCel2 request.AddContractServiceDetailReq
  1339. tmpErr := contractService.GetProductCelData(*detail, &tableCel2)
  1340. if tmpErr != nil {
  1341. err = tmpErr
  1342. return
  1343. }
  1344. for _, serviceId := range tableCel2.ValueId {
  1345. key := fmt.Sprint(item.ServiceTemplateId, "_permission_", serviceId)
  1346. if cellI, ok := serviceCellMap[key]; ok {
  1347. cellServiceMap[cellI] = "是"
  1348. }
  1349. }
  1350. }
  1351. }
  1352. } else {
  1353. key := fmt.Sprint("service_template_", item.ServiceTemplateId)
  1354. if cellI, ok := serviceCellMap[key]; ok {
  1355. cellServiceMap[cellI] = "是"
  1356. }
  1357. }
  1358. }
  1359. }
  1360. //遍历所有套餐
  1361. for tmpStartCellI := customStartCellI; tmpStartCellI < startI; tmpStartCellI++ {
  1362. servicesCell := dataRow.AddCell()
  1363. cellValue, ok := cellServiceMap[tmpStartCellI]
  1364. if ok == false {
  1365. cellValue = "否"
  1366. }
  1367. servicesCell.SetValue(cellValue)
  1368. if cellValue == "是" { //勾选了话,标红处理
  1369. servicesCell.SetStyle(redStyle)
  1370. } else {
  1371. servicesCell.SetStyle(style)
  1372. }
  1373. }
  1374. }
  1375. }
  1376. }
  1377. err = xlsxFile.Save(downLoadnFilePath)
  1378. if err != nil {
  1379. br.Msg = "保存文件失败"
  1380. br.ErrMsg = "保存文件失败"
  1381. return
  1382. }
  1383. randStr := time.Now().Format(utils.FormatDateTimeUnSpace)
  1384. downloadFileName := "合同列表" + randStr + ".xlsx"
  1385. this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
  1386. br.Ret = 200
  1387. br.Success = true
  1388. br.Msg = "导出成功"
  1389. }
  1390. // CancelApply
  1391. // @Title 撤回审批申请
  1392. // @Description 撤回审批申请接口
  1393. // @Param ContractApprovalRecordId query int true "审批流id编号"
  1394. // @Param ContractId query int true "合同id编号"
  1395. // @Success Ret=200 撤回申请成功
  1396. // @router /approval/cancelApply [get]
  1397. func (this *ContractApprovalController) CancelApply() {
  1398. br := new(models.BaseResponse).Init()
  1399. defer func() {
  1400. this.Data["json"] = br
  1401. this.ServeJSON()
  1402. }()
  1403. sysUser := this.SysUser
  1404. if sysUser == nil {
  1405. br.Msg = "请登录"
  1406. br.ErrMsg = "请登录,SysUser Is Empty"
  1407. br.Ret = 408
  1408. return
  1409. }
  1410. //合同id编号
  1411. contractId, err := this.GetInt("ContractId")
  1412. if err != nil {
  1413. br.Msg = "获取审批流编号失败"
  1414. br.ErrMsg = "获取审批流编号失败,err:" + err.Error()
  1415. return
  1416. }
  1417. //审批流id编号
  1418. contractApprovalRecordId, err := this.GetInt("ContractApprovalRecordId", 0)
  1419. if err != nil {
  1420. br.Msg = "获取审批流编号失败"
  1421. br.ErrMsg = "获取审批流编号失败,err:" + err.Error()
  1422. return
  1423. }
  1424. if contractApprovalRecordId <= 0 && contractId <= 0 {
  1425. br.Msg = "请传入审批流编号获取合同编号"
  1426. br.ErrMsg = "请传入审批流编号获取合同编号"
  1427. return
  1428. }
  1429. if contractApprovalRecordId > 0 {
  1430. //获取审批流信息
  1431. contractApprovalRecord, err := contract.GetContractApprovalRecordById(contractApprovalRecordId)
  1432. if err != nil {
  1433. br.Msg = "获取审批流信息失败!"
  1434. br.ErrMsg = "获取审批流信息失败,Err:" + err.Error()
  1435. return
  1436. }
  1437. err = contractService.CancelApply(contractApprovalRecord, sysUser.AdminId)
  1438. if err != nil {
  1439. br.Msg = "撤回申请失败!"
  1440. br.ErrMsg = "撤回申请失败,Err:" + err.Error()
  1441. return
  1442. }
  1443. } else if contractId > 0 {
  1444. //获取审批流信息
  1445. contractInfo, err := contract.GetContractById(contractId)
  1446. if err != nil {
  1447. br.Msg = "获取审批流信息失败!"
  1448. br.ErrMsg = "获取审批流信息失败,Err:" + err.Error()
  1449. return
  1450. }
  1451. err = contractService.CancelApplyByContract(contractInfo, sysUser.AdminId)
  1452. if err != nil {
  1453. br.Msg = "撤回申请失败!"
  1454. br.ErrMsg = "撤回申请失败,Err:" + err.Error()
  1455. return
  1456. }
  1457. } else {
  1458. br.Msg = "请传入审批流编号获取合同编号"
  1459. br.ErrMsg = "请传入审批流编号获取合同编号"
  1460. return
  1461. }
  1462. br.Ret = 200
  1463. br.Success = true
  1464. br.Msg = "撤回申请成功"
  1465. }
  1466. // @Title 驳回审批
  1467. // @Description 驳回审批接口
  1468. // @Param request body request.RejectReq true "type json string"
  1469. // @Success Ret=200 驳回成功
  1470. // @router /approval/reject [post]
  1471. func (this *ContractApprovalController) Reject() {
  1472. br := new(models.BaseResponse).Init()
  1473. defer func() {
  1474. this.Data["json"] = br
  1475. this.ServeJSON()
  1476. }()
  1477. sysUser := this.SysUser
  1478. if sysUser == nil {
  1479. br.Msg = "请登录"
  1480. br.ErrMsg = "请登录,SysUser Is Empty"
  1481. br.Ret = 408
  1482. return
  1483. }
  1484. var req request.RejectReq
  1485. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1486. if err != nil {
  1487. br.Msg = "参数解析异常!"
  1488. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1489. return
  1490. }
  1491. //审批流id编号
  1492. contractApprovalRecordId := req.ContractApprovalRecordId
  1493. if contractApprovalRecordId <= 0 {
  1494. br.Msg = "请传入审批流编号"
  1495. br.ErrMsg = "请传入审批流编号"
  1496. return
  1497. }
  1498. //获取审批流信息
  1499. contractApprovalRecord, err := contract.GetContractApprovalRecordById(contractApprovalRecordId)
  1500. if err != nil {
  1501. br.Msg = "获取审批流信息失败!"
  1502. br.ErrMsg = "获取审批流信息失败,Err:" + err.Error()
  1503. return
  1504. }
  1505. err = contractService.Reject(contractApprovalRecord, sysUser, req.Remark)
  1506. if err != nil {
  1507. br.Msg = "驳回审批失败!"
  1508. br.ErrMsg = "驳回审批失败,Err:" + err.Error()
  1509. return
  1510. }
  1511. br.Ret = 200
  1512. br.Success = true
  1513. br.Msg = "驳回成功"
  1514. }
  1515. // @Title 处理审批单
  1516. // @Description 处理审批单
  1517. // @Param request body request.ApprovedReq true "type json string"
  1518. // @Success Ret=200 申请成功
  1519. // @router /approval/approved [post]
  1520. func (this *ContractApprovalController) Approved() {
  1521. br := new(models.BaseResponse).Init()
  1522. defer func() {
  1523. this.Data["json"] = br
  1524. this.ServeJSON()
  1525. }()
  1526. sysUser := this.SysUser
  1527. if sysUser == nil {
  1528. br.Msg = "请登录"
  1529. br.ErrMsg = "请登录,SysUser Is Empty"
  1530. br.Ret = 408
  1531. return
  1532. }
  1533. var req request.ApprovedReq
  1534. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1535. if err != nil {
  1536. br.Msg = "参数解析异常!"
  1537. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1538. return
  1539. }
  1540. //审批流id编号
  1541. contractApprovalRecordId := req.ContractApprovalRecordId
  1542. if contractApprovalRecordId <= 0 {
  1543. br.Msg = "请传入审批流编号"
  1544. br.ErrMsg = "请传入审批流编号"
  1545. return
  1546. }
  1547. //获取审批流信息
  1548. contractApprovalRecord, err := contract.GetContractApprovalRecordById(contractApprovalRecordId)
  1549. if err != nil {
  1550. br.Msg = "获取审批流信息失败!"
  1551. br.ErrMsg = "获取审批流信息失败,Err:" + err.Error()
  1552. return
  1553. }
  1554. err = contractService.Approved(contractApprovalRecord, sysUser, req.Remark)
  1555. if err != nil {
  1556. br.Msg = "审核失败!"
  1557. br.ErrMsg = "审核失败,Err:" + err.Error()
  1558. return
  1559. }
  1560. br.Ret = 200
  1561. br.Success = true
  1562. br.Msg = "审核通过"
  1563. }