eta_business.go 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. package eta_business
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/controllers"
  7. "hongze/hz_crm_api/models"
  8. "hongze/hz_crm_api/models/eta_business"
  9. "hongze/hz_crm_api/models/help_doc"
  10. etaBusinessService "hongze/hz_crm_api/services/eta_business"
  11. "hongze/hz_crm_api/utils"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // EtaBusinessController ETA商家
  17. type EtaBusinessController struct {
  18. controllers.BaseAuthController
  19. }
  20. // PageList
  21. // @Title 商家列表-分页
  22. // @Description 商家列表-分页
  23. // @Param Keyword query string false "关键词: 商家名称/社会信用码/商家编码"
  24. // @Param SellerIds query string false "销售IDs"
  25. // @Param SigningStatus query string false "签约状态: 1-首次签约; 2-续约中; 3-已终止"
  26. // @Param Province query string false "省份筛选"
  27. // @Param City query string false "城市筛选"
  28. // @Param IndustryId query int false "行业ID"
  29. // @Param SortParam query int false "排序字段: 1-签约时间; 2-到期时间; 3-创建时间; 4-用户上限"
  30. // @Param SortType query int false "排序类型: 1-正序; 2-倒序"
  31. // @Success 200 Ret=200 获取成功
  32. // @router /page_list [get]
  33. func (this *EtaBusinessController) PageList() {
  34. br := new(models.BaseResponse).Init()
  35. defer func() {
  36. if br.ErrMsg == "" {
  37. br.IsSendEmail = false
  38. }
  39. this.Data["json"] = br
  40. this.ServeJSON()
  41. }()
  42. sysUser := this.SysUser
  43. if sysUser == nil {
  44. br.Msg = "请登录"
  45. br.ErrMsg = "请登录,SysUser Is Empty"
  46. br.Ret = 408
  47. return
  48. }
  49. // 分页
  50. pageSize, _ := this.GetInt("PageSize")
  51. currentIndex, _ := this.GetInt("CurrentIndex")
  52. var startSize int
  53. if pageSize <= 0 {
  54. pageSize = utils.PageSize20
  55. }
  56. if currentIndex <= 0 {
  57. currentIndex = 1
  58. }
  59. startSize = utils.StartIndex(currentIndex, pageSize)
  60. // 权限校验
  61. resp := new(eta_business.EtaBusinessListResp)
  62. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  63. if e != nil {
  64. br.Msg = "操作失败"
  65. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  66. return
  67. }
  68. if !ok {
  69. resp.Paging = paging.GetPaging(currentIndex, pageSize, 0)
  70. br.Data = resp
  71. br.Ret = 200
  72. br.Success = true
  73. br.Msg = "获取成功"
  74. return
  75. }
  76. cond := ``
  77. pars := make([]interface{}, 0)
  78. // 筛选项
  79. {
  80. // 关键词
  81. keyword := this.GetString("Keyword", "")
  82. keyword = strings.TrimSpace(keyword)
  83. if keyword != "" {
  84. kw := fmt.Sprint("%", keyword, "%")
  85. cond += fmt.Sprintf(` AND (%s LIKE ? OR %s LIKE ? OR %s LIKE ?)`, eta_business.EtaBusinessColumns.BusinessName, eta_business.EtaBusinessColumns.BusinessCode, eta_business.EtaBusinessColumns.CreditCode)
  86. pars = append(pars, kw, kw, kw)
  87. }
  88. // 销售
  89. sellerIds := this.GetString("SellerIds", "")
  90. if sellerIds != "" {
  91. arr := strings.Split(sellerIds, ",")
  92. ids := make([]int, 0)
  93. for _, s := range arr {
  94. v, e := strconv.Atoi(s)
  95. if e != nil {
  96. br.Msg = "销售ID有误"
  97. return
  98. }
  99. ids = append(ids, v)
  100. }
  101. if len(ids) == 0 {
  102. resp.Paging = paging.GetPaging(currentIndex, pageSize, 0)
  103. br.Data = resp
  104. br.Ret = 200
  105. br.Success = true
  106. br.Msg = "获取成功"
  107. return
  108. }
  109. cond += fmt.Sprintf(` AND %s IN (%s)`, eta_business.EtaBusinessColumns.SellerId, utils.GetOrmInReplace(len(ids)))
  110. pars = append(pars, ids)
  111. }
  112. // 签约状态
  113. signingStatus, _ := this.GetInt("SigningStatus", 0)
  114. if signingStatus > 0 {
  115. cond += fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessColumns.SigningStatus)
  116. pars = append(pars, signingStatus)
  117. }
  118. // 商家地址
  119. province := this.GetString("Province", "")
  120. province = strings.TrimSpace(province)
  121. if province != "" {
  122. provinceArr := strings.Split(province, ",")
  123. if len(provinceArr) == 0 {
  124. resp.Paging = paging.GetPaging(currentIndex, pageSize, 0)
  125. br.Data = resp
  126. br.Ret = 200
  127. br.Success = true
  128. br.Msg = "获取成功"
  129. return
  130. }
  131. cond += fmt.Sprintf(` AND %s IN (%s)`, eta_business.EtaBusinessColumns.Province, utils.GetOrmInReplace(len(provinceArr)))
  132. pars = append(pars, provinceArr)
  133. }
  134. city := this.GetString("City", "")
  135. city = strings.TrimSpace(city)
  136. if city != "" {
  137. cityArr := strings.Split(city, ",")
  138. if len(cityArr) == 0 {
  139. resp.Paging = paging.GetPaging(currentIndex, pageSize, 0)
  140. br.Data = resp
  141. br.Ret = 200
  142. br.Success = true
  143. br.Msg = "获取成功"
  144. return
  145. }
  146. cond += fmt.Sprintf(` AND %s IN (%s)`, eta_business.EtaBusinessColumns.City, utils.GetOrmInReplace(len(cityArr)))
  147. pars = append(pars, cityArr)
  148. }
  149. // 行业
  150. industryId, _ := this.GetInt("IndustryId", 0)
  151. if industryId > 0 {
  152. cond += fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessColumns.IndustryId)
  153. pars = append(pars, industryId)
  154. }
  155. // 国家
  156. nation := this.GetString("Nation", "")
  157. nation = strings.TrimSpace(nation)
  158. if nation != "" {
  159. cond += ` AND nation = ? `
  160. pars = append(pars, nation)
  161. }
  162. }
  163. order := ``
  164. // 排序
  165. {
  166. fieldArr := []int{1, 2, 3, 4}
  167. typeArr := []int{1, 2}
  168. fieldMap := map[int]string{
  169. 1: "signing_time",
  170. 2: "expired_time",
  171. 3: "create_time",
  172. 4: "user_max",
  173. }
  174. typeMap := map[int]string{
  175. 1: "ASC",
  176. 2: "DESC",
  177. }
  178. sortParam, _ := this.GetInt("SortParam", 0)
  179. sortType, _ := this.GetInt("SortType", 0)
  180. if utils.InArrayByInt(fieldArr, sortParam) && utils.InArrayByInt(typeArr, sortType) {
  181. order = fmt.Sprintf("%s %s", fieldMap[sortParam], typeMap[sortType])
  182. }
  183. fmt.Println("order: ", order)
  184. }
  185. // 获取列表
  186. businessOb := new(eta_business.EtaBusiness)
  187. total, e := businessOb.GetCountByCondition(cond, pars)
  188. if e != nil {
  189. br.Msg = "获取失败"
  190. br.ErrMsg = "获取商家总数失败, Err: " + e.Error()
  191. return
  192. }
  193. list, e := businessOb.GetPageItemsByCondition(cond, pars, []string{}, order, startSize, pageSize)
  194. if e != nil {
  195. br.Msg = "获取失败"
  196. br.ErrMsg = "获取商家列表失败, Err: " + e.Error()
  197. return
  198. }
  199. items := make([]*eta_business.EtaBusinessItem, 0)
  200. for _, v := range list {
  201. b := new(eta_business.EtaBusinessItem)
  202. b.EtaBusinessId = v.EtaBusinessId
  203. b.BusinessName = v.BusinessName
  204. b.BusinessCode = v.BusinessCode
  205. b.CreditCode = v.CreditCode
  206. b.RegionType = v.RegionType
  207. b.Province = v.Province
  208. b.City = v.City
  209. b.Address = v.Address
  210. b.SellerId = v.SellerId
  211. b.SellerName = v.SellerName
  212. b.Leader = v.Leader
  213. b.IndustryId = v.IndustryId
  214. b.IndustryName = v.IndustryName
  215. b.CapitalScale = v.CapitalScale
  216. b.ResearchTeamSize = v.ResearchTeamSize
  217. b.UserMax = v.UserMax
  218. b.SigningStatus = v.SigningStatus
  219. b.Enable = v.Enable
  220. b.ContractId = v.ContractId
  221. b.SigningTime = utils.TimeTransferString(utils.FormatDate, v.SigningTime)
  222. b.ExpiredTime = utils.TimeTransferString(utils.FormatDate, v.ExpiredTime)
  223. b.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  224. b.ModifyTime = v.ModifyTime.Format(utils.FormatDateTime)
  225. b.Nation = v.Nation
  226. items = append(items, b)
  227. }
  228. resp.List = items
  229. resp.Paging = paging.GetPaging(currentIndex, pageSize, total)
  230. br.Data = resp
  231. br.Ret = 200
  232. br.Success = true
  233. br.Msg = "获取成功"
  234. }
  235. // Add
  236. // @Title 新增商家
  237. // @Description 新增商家
  238. // @Param request body eta_business.EtaBusinessAddReq true "type json string"
  239. // @Success 200 Ret=200 操作成功
  240. // @router /add [post]
  241. func (this *EtaBusinessController) Add() {
  242. br := new(models.BaseResponse).Init()
  243. defer func() {
  244. if br.ErrMsg == "" {
  245. br.IsSendEmail = false
  246. }
  247. this.Data["json"] = br
  248. this.ServeJSON()
  249. }()
  250. sysUser := this.SysUser
  251. if sysUser == nil {
  252. br.Msg = "请登录"
  253. br.ErrMsg = "请登录,SysUser Is Empty"
  254. br.Ret = 408
  255. return
  256. }
  257. // 操作权限校验
  258. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  259. if e != nil {
  260. br.Msg = "操作失败"
  261. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  262. return
  263. }
  264. if !ok {
  265. br.Msg = "无权操作"
  266. return
  267. }
  268. // 参数校验
  269. var req eta_business.EtaBusinessAddReq
  270. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  271. br.Msg = "参数解析异常!"
  272. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  273. return
  274. }
  275. req.BusinessName = strings.TrimSpace(req.BusinessName)
  276. if req.BusinessName == "" {
  277. br.Msg = "商家名称不可为空"
  278. return
  279. }
  280. if req.CreditCode == "" {
  281. br.Msg = "社会统一信用码不可为空"
  282. return
  283. }
  284. req.Province = strings.TrimSpace(req.Province)
  285. if req.Nation == "" {
  286. if req.Province == "" {
  287. br.Msg = "省份不可为空"
  288. return
  289. }
  290. req.City = strings.TrimSpace(req.City)
  291. if req.City == "" {
  292. br.Msg = "城市不可为空"
  293. return
  294. }
  295. }
  296. req.Leader = strings.TrimSpace(req.Leader)
  297. if req.Leader == "" {
  298. br.Msg = "决策人不可为空"
  299. return
  300. }
  301. if req.IndustryId <= 0 || req.IndustryName == "" {
  302. br.Msg = "所属行业不可为空"
  303. return
  304. }
  305. if req.ResearchTeamSize == "" {
  306. br.Msg = "研究团队规模不可为空"
  307. return
  308. }
  309. if req.UserMax <= 0 {
  310. br.Msg = "用户上限不可小于0"
  311. return
  312. }
  313. req.CapitalScale = strings.TrimSpace(req.CapitalScale)
  314. // 如果仅校验不新增, 那么不做第二页签约时间的校验(已废弃, 20230919签约时间非必填)
  315. var signTime, expiredTime time.Time
  316. if !req.IsCheck {
  317. if req.SigningTime != "" && req.ExpiredTime != "" {
  318. signTime, e = time.ParseInLocation(utils.FormatDate, req.SigningTime, time.Local)
  319. if e != nil {
  320. br.Msg = "签约时间格式有误"
  321. br.ErrMsg = "签约时间格式有误, Err: " + e.Error()
  322. return
  323. }
  324. expiredTime, e = time.ParseInLocation(utils.FormatDate, req.ExpiredTime, time.Local)
  325. if e != nil {
  326. br.Msg = "到期时间格式有误"
  327. br.ErrMsg = "到期时间格式有误, Err: " + e.Error()
  328. return
  329. }
  330. if !expiredTime.After(signTime) {
  331. br.Msg = "到期时间不得早于签约时间"
  332. return
  333. }
  334. }
  335. }
  336. // 重名校验
  337. {
  338. item := new(eta_business.EtaBusiness)
  339. cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessColumns.BusinessName)
  340. pars := make([]interface{}, 0)
  341. pars = append(pars, req.BusinessName)
  342. exist, e := item.GetItemByCondition(cond, pars)
  343. if e != nil && e.Error() != utils.ErrNoRow() {
  344. br.Msg = "操作失败"
  345. br.ErrMsg = "获取重名商家失败, Err: " + e.Error()
  346. return
  347. }
  348. if exist != nil {
  349. br.Msg = "商家名称已存在"
  350. return
  351. }
  352. }
  353. // 社会信用码重复校验
  354. {
  355. item := new(eta_business.EtaBusiness)
  356. cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessColumns.CreditCode)
  357. pars := make([]interface{}, 0)
  358. pars = append(pars, req.CreditCode)
  359. exist, e := item.GetItemByCondition(cond, pars)
  360. if e != nil && e.Error() != utils.ErrNoRow() {
  361. br.Msg = "操作失败"
  362. br.ErrMsg = "获取重复信用码商家失败, Err: " + e.Error()
  363. return
  364. }
  365. if exist != nil {
  366. br.Msg = "商家社会信用码已存在"
  367. return
  368. }
  369. }
  370. // 如果只做校验不新增, 此处校验通过后直接返回true
  371. if req.IsCheck {
  372. br.Data = true
  373. br.Ret = 200
  374. br.Success = true
  375. br.Msg = "校验通过"
  376. return
  377. }
  378. // 商家编码
  379. businessCode, e := eta_business.CreateEtaBusinessCode()
  380. if e != nil {
  381. br.Msg = "操作失败"
  382. br.ErrMsg = "生成商家编码失败, Err: " + e.Error()
  383. return
  384. }
  385. codeEncrypt := utils.MD5(fmt.Sprintf("%s%s", businessCode, utils.BusinessCodeSalt))
  386. now := time.Now().Local()
  387. status := eta_business.EtaBusinessSigningStatusWait // 默认待签约
  388. // 若当前时间不在首次签约时间内, 也算作已终止, 进入合约期时会由定时任务改为首次签约
  389. if !signTime.IsZero() && !expiredTime.IsZero() {
  390. if !now.Before(signTime) && !now.After(expiredTime) {
  391. status = eta_business.EtaBusinessSigningStatusFirst // 首次签约
  392. } else {
  393. status = eta_business.EtaBusinessSigningStatusTerminate // 已终止
  394. }
  395. }
  396. // 新增商家和签约
  397. businessItem := new(eta_business.EtaBusiness)
  398. businessItem.BusinessName = req.BusinessName
  399. businessItem.BusinessCode = businessCode
  400. businessItem.CodeEncrypt = codeEncrypt
  401. businessItem.CreditCode = req.CreditCode
  402. businessItem.RegionType = req.RegionType
  403. businessItem.Province = req.Province
  404. businessItem.City = req.City
  405. businessItem.Address = req.Province + req.City
  406. businessItem.SellerId = req.SellerId
  407. businessItem.SellerName = req.SellerName
  408. businessItem.Leader = req.Leader
  409. businessItem.IndustryId = req.IndustryId
  410. businessItem.IndustryName = req.IndustryName
  411. businessItem.CapitalScale = req.CapitalScale
  412. businessItem.ResearchTeamSize = req.ResearchTeamSize
  413. businessItem.UserMax = req.UserMax
  414. businessItem.Enable = 1
  415. businessItem.SigningStatus = status
  416. businessItem.SigningTime = signTime
  417. businessItem.ExpiredTime = expiredTime
  418. businessItem.CreateTime = now
  419. businessItem.ModifyTime = now
  420. businessItem.Nation = req.Nation
  421. contractItem := new(eta_business.EtaBusinessContract)
  422. if !signTime.IsZero() && !expiredTime.IsZero() {
  423. contractItem.SigningTime = signTime
  424. contractItem.ExpiredTime = expiredTime
  425. contractItem.IsFirst = 1
  426. contractItem.CreateTime = now
  427. contractItem.ModifyTime = now
  428. } else {
  429. contractItem = nil
  430. }
  431. if e = eta_business.CreateEtaBusinessAndContract(businessItem, contractItem); e != nil {
  432. br.Msg = "操作失败"
  433. br.ErrMsg = "新增商家和签约失败, Err: " + e.Error()
  434. return
  435. }
  436. // 给商家帮助文档所有分类的权限
  437. if e = help_doc.AddAllHelpDocClassifyVisible(businessItem.EtaBusinessId); e != nil {
  438. br.Msg = "操作失败"
  439. br.ErrMsg = "新增商家分类文档权限失败, Err: " + e.Error()
  440. return
  441. }
  442. // 操作日志
  443. go func() {
  444. recordOb := new(eta_business.EtaBusinessOperationRecord)
  445. recordOb.EtaBusinessId = businessItem.EtaBusinessId
  446. recordOb.SellerId = businessItem.SellerId
  447. recordOb.SysUserId = sysUser.AdminId
  448. recordOb.SysRealName = sysUser.RealName
  449. recordOb.OperationType = eta_business.EtaBusinessOperationTypeAdd
  450. recordOb.OperationRemark = fmt.Sprintf("%s新增商户", sysUser.RealName)
  451. recordOb.CreateTime = time.Now().Local()
  452. _ = recordOb.Create()
  453. }()
  454. br.Ret = 200
  455. br.Success = true
  456. br.Msg = "操作成功"
  457. }
  458. // Edit
  459. // @Title 编辑商家
  460. // @Description 编辑商家
  461. // @Param request body eta_business.EtaBusinessEditReq true "type json string"
  462. // @Success 200 Ret=200 操作成功
  463. // @router /edit [post]
  464. func (this *EtaBusinessController) Edit() {
  465. br := new(models.BaseResponse).Init()
  466. defer func() {
  467. if br.ErrMsg == "" {
  468. br.IsSendEmail = false
  469. }
  470. this.Data["json"] = br
  471. this.ServeJSON()
  472. }()
  473. sysUser := this.SysUser
  474. if sysUser == nil {
  475. br.Msg = "请登录"
  476. br.ErrMsg = "请登录,SysUser Is Empty"
  477. br.Ret = 408
  478. return
  479. }
  480. var req eta_business.EtaBusinessEditReq
  481. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  482. br.Msg = "参数解析异常!"
  483. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  484. return
  485. }
  486. if req.EtaBusinessId <= 0 {
  487. br.Msg = "参数有误"
  488. br.ErrMsg = "参数有误, 商家ID为空"
  489. return
  490. }
  491. if req.Nation == "" {
  492. req.Province = strings.TrimSpace(req.Province)
  493. if req.Province == "" {
  494. br.Msg = "省份不可为空"
  495. return
  496. }
  497. req.City = strings.TrimSpace(req.City)
  498. if req.City == "" {
  499. br.Msg = "城市不可为空"
  500. return
  501. }
  502. }
  503. req.Leader = strings.TrimSpace(req.Leader)
  504. if req.Leader == "" {
  505. br.Msg = "决策人不可为空"
  506. return
  507. }
  508. if req.IndustryId <= 0 || req.IndustryName == "" {
  509. br.Msg = "所属行业不可为空"
  510. return
  511. }
  512. if req.ResearchTeamSize == "" {
  513. br.Msg = "研究团队规模不可为空"
  514. return
  515. }
  516. if req.UserMax <= 0 {
  517. br.Msg = "用户上限不可小于0"
  518. return
  519. }
  520. req.CapitalScale = strings.TrimSpace(req.CapitalScale)
  521. // 权限校验
  522. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  523. if e != nil {
  524. br.Msg = "操作失败"
  525. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  526. return
  527. }
  528. if !ok {
  529. br.Msg = "无权操作"
  530. return
  531. }
  532. ob := new(eta_business.EtaBusiness)
  533. item, e := ob.GetItemById(req.EtaBusinessId)
  534. if e != nil {
  535. if e.Error() == utils.ErrNoRow() {
  536. br.Msg = "商家不存在, 请刷新页面"
  537. return
  538. }
  539. br.Msg = "操作失败"
  540. br.ErrMsg = "获取商家信息失败, Err: " + e.Error()
  541. return
  542. }
  543. item.Province = req.Province
  544. item.City = req.City
  545. item.Address = req.Province + req.City
  546. item.Leader = req.Leader
  547. item.IndustryId = req.IndustryId
  548. item.IndustryName = req.IndustryName
  549. item.CapitalScale = req.CapitalScale
  550. item.ResearchTeamSize = req.ResearchTeamSize
  551. item.UserMax = req.UserMax
  552. item.Nation = req.Nation
  553. item.ModifyTime = time.Now().Local()
  554. cols := []string{
  555. "Province", "City", "Address", "Leader", "IndustryId", "IndustryName", "CapitalScale", "ResearchTeamSize", "UserMax", "ModifyTime",
  556. }
  557. if e := item.Update(cols); e != nil {
  558. br.Msg = "操作失败"
  559. br.ErrMsg = "编辑商家失败, Err: " + e.Error()
  560. return
  561. }
  562. // 操作日志
  563. go func() {
  564. recordOb := new(eta_business.EtaBusinessOperationRecord)
  565. recordOb.EtaBusinessId = item.EtaBusinessId
  566. recordOb.SellerId = item.SellerId
  567. recordOb.SysUserId = sysUser.AdminId
  568. recordOb.SysRealName = sysUser.RealName
  569. recordOb.OperationType = eta_business.EtaBusinessOperationTypeEdit
  570. recordOb.OperationRemark = fmt.Sprintf("%s编辑商户", sysUser.RealName)
  571. recordOb.CreateTime = time.Now().Local()
  572. _ = recordOb.Create()
  573. }()
  574. br.Ret = 200
  575. br.Success = true
  576. br.Msg = "操作成功"
  577. }
  578. // Signing
  579. // @Title 签约续约
  580. // @Description 签约续约(业务上仅用于续约, 兼容首次签约)
  581. // @Param request body eta_business.EtaBusinessSigningReq true "type json string"
  582. // @Success 200 Ret=200 操作成功
  583. // @router /signing [post]
  584. func (this *EtaBusinessController) Signing() {
  585. br := new(models.BaseResponse).Init()
  586. defer func() {
  587. if br.ErrMsg == "" {
  588. br.IsSendEmail = false
  589. }
  590. this.Data["json"] = br
  591. this.ServeJSON()
  592. }()
  593. sysUser := this.SysUser
  594. if sysUser == nil {
  595. br.Msg = "请登录"
  596. br.ErrMsg = "请登录,SysUser Is Empty"
  597. br.Ret = 408
  598. return
  599. }
  600. var req eta_business.EtaBusinessSigningReq
  601. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  602. br.Msg = "参数解析异常!"
  603. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  604. return
  605. }
  606. if req.EtaBusinessId <= 0 {
  607. br.Msg = "参数有误"
  608. br.ErrMsg = "参数有误, 商家ID为空"
  609. return
  610. }
  611. if req.SigningTime == "" {
  612. br.Msg = "签约时间不可为空"
  613. return
  614. }
  615. if req.ExpiredTime == "" {
  616. br.Msg = "到期时间不可为空"
  617. return
  618. }
  619. signTime, e := time.ParseInLocation(utils.FormatDate, req.SigningTime, time.Local)
  620. if e != nil {
  621. br.Msg = "签约时间格式有误"
  622. br.ErrMsg = "签约时间格式有误, Err: " + e.Error()
  623. return
  624. }
  625. expiredTime, e := time.ParseInLocation(utils.FormatDate, req.ExpiredTime, time.Local)
  626. if e != nil {
  627. br.Msg = "到期时间格式有误"
  628. br.ErrMsg = "到期时间格式有误, Err: " + e.Error()
  629. return
  630. }
  631. if !expiredTime.After(signTime) {
  632. br.Msg = "到期时间不得早于签约时间"
  633. return
  634. }
  635. // 权限校验
  636. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  637. if e != nil {
  638. br.Msg = "操作失败"
  639. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  640. return
  641. }
  642. if !ok {
  643. br.Msg = "无权操作"
  644. return
  645. }
  646. // 获取商家信息
  647. businessOb := new(eta_business.EtaBusiness)
  648. business, e := businessOb.GetItemById(req.EtaBusinessId)
  649. if e != nil {
  650. if e.Error() == utils.ErrNoRow() {
  651. br.Msg = "商家不存在, 请刷新页面"
  652. return
  653. }
  654. br.Msg = "操作失败"
  655. br.ErrMsg = "获取商家信息失败, Err: " + e.Error()
  656. return
  657. }
  658. // 续约不可早于当前生效合约的到期时间
  659. if business.ContractId > 0 {
  660. {
  661. ob := new(eta_business.EtaBusinessContract)
  662. item, e := ob.GetItemById(business.ContractId)
  663. if e != nil {
  664. br.Msg = "操作失败"
  665. br.ErrMsg = "获取商家当前合同失败, Err: " + e.Error()
  666. return
  667. }
  668. if !signTime.After(item.ExpiredTime) {
  669. br.Msg = "签约时间不可早于当前合同的到期时间"
  670. return
  671. }
  672. }
  673. }
  674. // 获取历史签约, 签约日期不可交叠
  675. contract := new(eta_business.EtaBusinessContract)
  676. cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessContractColumns.EtaBusinessId)
  677. pars := make([]interface{}, 0)
  678. pars = append(pars, req.EtaBusinessId)
  679. contracts, e := contract.GetItemsByCondition(cond, pars, []string{}, "signing_time ASC")
  680. if e != nil {
  681. br.Msg = "操作失败"
  682. br.ErrMsg = "获取商家签约列表失败, Err: " + e.Error()
  683. return
  684. }
  685. // 校验签约时间是否重叠
  686. isFirst := true // 是否为首次签约
  687. changeFirst := false // 是否需要更新首次签约合同
  688. if len(contracts) > 0 {
  689. isFirst = false
  690. for k, c := range contracts {
  691. pass := false
  692. if expiredTime.Before(c.SigningTime) {
  693. pass = true
  694. }
  695. if signTime.After(c.ExpiredTime) {
  696. pass = true
  697. }
  698. if !pass {
  699. br.Msg = "签约时间在存续期内, 请检查"
  700. return
  701. }
  702. // 若该合同签约时间早于第一份合同(业务上未限制所以可能会出现这种情况, contracts已排序), 则更新为首次签约合同
  703. if k == 0 && signTime.Before(c.SigningTime) {
  704. changeFirst = true
  705. isFirst = true
  706. }
  707. }
  708. }
  709. // 新增签约
  710. contract.EtaBusinessId = req.EtaBusinessId
  711. contract.SigningTime = signTime
  712. contract.ExpiredTime = expiredTime
  713. contract.CreateTime = time.Now().Local()
  714. contract.ModifyTime = time.Now().Local()
  715. if isFirst {
  716. contract.IsFirst = 1
  717. }
  718. if e = contract.CreateMaybeUpdateFirst(contract, changeFirst); e != nil {
  719. br.Msg = "操作失败"
  720. br.ErrMsg = "新增签约失败, Err: " + e.Error()
  721. return
  722. }
  723. // 签约后续操作
  724. go func() {
  725. _ = etaBusinessService.UpdateEtaBusinessAfterSigning(business.EtaBusinessId)
  726. }()
  727. // 续约操作日志
  728. if !isFirst {
  729. go func() {
  730. recordOb := new(eta_business.EtaBusinessOperationRecord)
  731. recordOb.EtaBusinessId = business.EtaBusinessId
  732. recordOb.SellerId = business.SellerId
  733. recordOb.SysUserId = sysUser.AdminId
  734. recordOb.SysRealName = sysUser.RealName
  735. recordOb.OperationType = eta_business.EtaBusinessOperationTypeRenewalContract
  736. recordOb.OperationRemark = fmt.Sprintf("%s添加续约", sysUser.RealName)
  737. recordOb.CreateTime = time.Now().Local()
  738. _ = recordOb.Create()
  739. }()
  740. }
  741. br.Ret = 200
  742. br.Success = true
  743. br.Msg = "操作成功"
  744. }
  745. // Enable
  746. // @Title 禁用启用
  747. // @Description 禁用启用
  748. // @Param request body eta_business.EtaBusinessEnableReq true "type json string"
  749. // @Success 200 Ret=200 操作成功
  750. // @router /enable [post]
  751. func (this *EtaBusinessController) Enable() {
  752. br := new(models.BaseResponse).Init()
  753. defer func() {
  754. if br.ErrMsg == "" {
  755. br.IsSendEmail = false
  756. }
  757. this.Data["json"] = br
  758. this.ServeJSON()
  759. }()
  760. sysUser := this.SysUser
  761. if sysUser == nil {
  762. br.Msg = "请登录"
  763. br.ErrMsg = "请登录,SysUser Is Empty"
  764. br.Ret = 408
  765. return
  766. }
  767. var req eta_business.EtaBusinessEnableReq
  768. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  769. br.Msg = "参数解析异常!"
  770. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  771. return
  772. }
  773. if req.EtaBusinessId <= 0 {
  774. br.Msg = "参数有误"
  775. br.ErrMsg = "参数有误, 商家ID为空"
  776. return
  777. }
  778. // 权限校验
  779. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  780. if e != nil {
  781. br.Msg = "操作失败"
  782. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  783. return
  784. }
  785. if !ok {
  786. br.Msg = "无权操作"
  787. return
  788. }
  789. // 获取商家信息
  790. businessOb := new(eta_business.EtaBusiness)
  791. business, e := businessOb.GetItemById(req.EtaBusinessId)
  792. if e != nil {
  793. if e.Error() == utils.ErrNoRow() {
  794. br.Msg = "商家不存在, 请刷新页面"
  795. return
  796. }
  797. br.Msg = "操作失败"
  798. br.ErrMsg = "获取商家信息失败, Err: " + e.Error()
  799. return
  800. }
  801. // 禁启用
  802. typeMap := map[int]int{
  803. 0: eta_business.EtaBusinessOperationTypeEnable,
  804. 1: eta_business.EtaBusinessOperationTypeDisable,
  805. }
  806. typeRemarkMap := map[int]string{
  807. 0: "启用",
  808. 1: "禁用",
  809. }
  810. operateType := typeMap[business.Enable]
  811. operateRemark := typeRemarkMap[business.Enable]
  812. business.Enable = business.Enable ^ 1
  813. business.ModifyTime = time.Now().Local()
  814. cols := []string{"Enable", "ModifyTime"}
  815. if e = business.Update(cols); e != nil {
  816. br.Msg = "操作失败"
  817. br.ErrMsg = "更新商家状态失败, Err: " + e.Error()
  818. return
  819. }
  820. // 操作日志
  821. go func() {
  822. recordOb := new(eta_business.EtaBusinessOperationRecord)
  823. recordOb.EtaBusinessId = business.EtaBusinessId
  824. recordOb.SellerId = business.SellerId
  825. recordOb.SysUserId = sysUser.AdminId
  826. recordOb.SysRealName = sysUser.RealName
  827. recordOb.OperationType = operateType
  828. recordOb.OperationRemark = fmt.Sprintf("%s%s商户", sysUser.RealName, operateRemark)
  829. recordOb.CreateTime = time.Now().Local()
  830. _ = recordOb.Create()
  831. }()
  832. br.Ret = 200
  833. br.Success = true
  834. br.Msg = "操作成功"
  835. }
  836. // MoveSeller
  837. // @Title 移动销售
  838. // @Description 移动销售
  839. // @Param request body eta_business.EtaBusinessMoveSellerReq true "type json string"
  840. // @Success 200 Ret=200 操作成功
  841. // @router /move_seller [post]
  842. func (this *EtaBusinessController) MoveSeller() {
  843. br := new(models.BaseResponse).Init()
  844. defer func() {
  845. if br.ErrMsg == "" {
  846. br.IsSendEmail = false
  847. }
  848. this.Data["json"] = br
  849. this.ServeJSON()
  850. }()
  851. sysUser := this.SysUser
  852. if sysUser == nil {
  853. br.Msg = "请登录"
  854. br.ErrMsg = "请登录,SysUser Is Empty"
  855. br.Ret = 408
  856. return
  857. }
  858. var req eta_business.EtaBusinessMoveSellerReq
  859. if e := json.Unmarshal(this.Ctx.Input.RequestBody, &req); e != nil {
  860. br.Msg = "参数解析异常!"
  861. br.ErrMsg = "参数解析失败,Err:" + e.Error()
  862. return
  863. }
  864. if req.EtaBusinessId <= 0 {
  865. br.Msg = "参数有误"
  866. br.ErrMsg = "参数有误, 商家ID为空"
  867. return
  868. }
  869. if req.SellerId <= 0 || req.SellerName == "" {
  870. br.Msg = "销售不可为空"
  871. return
  872. }
  873. // 权限校验
  874. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  875. if e != nil {
  876. br.Msg = "操作失败"
  877. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  878. return
  879. }
  880. if !ok {
  881. br.Msg = "无权操作"
  882. return
  883. }
  884. // 获取商家信息
  885. businessOb := new(eta_business.EtaBusiness)
  886. business, e := businessOb.GetItemById(req.EtaBusinessId)
  887. if e != nil {
  888. if e.Error() == utils.ErrNoRow() {
  889. br.Msg = "商家不存在, 请刷新页面"
  890. return
  891. }
  892. br.Msg = "操作失败"
  893. br.ErrMsg = "获取商家信息失败, Err: " + e.Error()
  894. return
  895. }
  896. // 更新销售
  897. business.SellerId = req.SellerId
  898. business.SellerName = req.SellerName
  899. business.ModifyTime = time.Now().Local()
  900. cols := []string{"SellerId", "SellerName", "ModifyTime"}
  901. if e = business.Update(cols); e != nil {
  902. br.Msg = "操作失败"
  903. br.ErrMsg = "移动至销售失败, Err: " + e.Error()
  904. return
  905. }
  906. // 操作日志
  907. go func() {
  908. recordOb := new(eta_business.EtaBusinessOperationRecord)
  909. recordOb.EtaBusinessId = business.EtaBusinessId
  910. recordOb.SellerId = req.SellerId
  911. recordOb.SysUserId = sysUser.AdminId
  912. recordOb.SysRealName = sysUser.RealName
  913. recordOb.OperationType = eta_business.EtaBusinessOperationTypeMoveSeller
  914. recordOb.OperationRemark = fmt.Sprintf("%s移动到: %s", sysUser.RealName, req.SellerName)
  915. recordOb.CreateTime = time.Now().Local()
  916. _ = recordOb.Create()
  917. }()
  918. br.Ret = 200
  919. br.Success = true
  920. br.Msg = "操作成功"
  921. }
  922. // Detail
  923. // @Title 商家详情
  924. // @Description 商家详情
  925. // @Param EtaBusinessId query int true "商家ID"
  926. // @Success 200 Ret=200 获取成功
  927. // @router /detail [get]
  928. func (this *EtaBusinessController) Detail() {
  929. br := new(models.BaseResponse).Init()
  930. defer func() {
  931. if br.ErrMsg == "" {
  932. br.IsSendEmail = false
  933. }
  934. this.Data["json"] = br
  935. this.ServeJSON()
  936. }()
  937. sysUser := this.SysUser
  938. if sysUser == nil {
  939. br.Msg = "请登录"
  940. br.ErrMsg = "请登录,SysUser Is Empty"
  941. br.Ret = 408
  942. return
  943. }
  944. // 权限校验
  945. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  946. if e != nil {
  947. br.Msg = "获取失败"
  948. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  949. return
  950. }
  951. if !ok {
  952. br.Ret = 200
  953. br.Success = true
  954. br.Msg = "获取成功"
  955. return
  956. }
  957. businessId, _ := this.GetInt("EtaBusinessId", 0)
  958. if businessId <= 0 {
  959. br.Msg = "参数有误"
  960. br.ErrMsg = "参数有误, 商家ID"
  961. return
  962. }
  963. businessOb := new(eta_business.EtaBusiness)
  964. item, e := businessOb.GetItemById(businessId)
  965. if e != nil {
  966. if e.Error() == utils.ErrNoRow() {
  967. br.Msg = "商家不存在, 请刷新页面"
  968. return
  969. }
  970. br.Msg = "获取失败"
  971. br.ErrMsg = "获取商家信息失败, Err: " + e.Error()
  972. return
  973. }
  974. resp := new(eta_business.EtaBusinessItem)
  975. resp.EtaBusinessId = item.EtaBusinessId
  976. resp.BusinessName = item.BusinessName
  977. resp.BusinessCode = item.BusinessCode
  978. resp.CreditCode = item.CreditCode
  979. resp.RegionType = item.RegionType
  980. resp.Province = item.Province
  981. resp.City = item.City
  982. resp.Address = item.Address
  983. resp.SellerId = item.SellerId
  984. resp.SellerName = item.SellerName
  985. resp.Leader = item.Leader
  986. resp.IndustryId = item.IndustryId
  987. resp.IndustryName = item.IndustryName
  988. resp.CapitalScale = item.CapitalScale
  989. resp.ResearchTeamSize = item.ResearchTeamSize
  990. resp.UserMax = item.UserMax
  991. resp.SigningStatus = item.SigningStatus
  992. resp.Enable = item.Enable
  993. resp.ContractId = item.ContractId
  994. resp.SigningTime = utils.TimeTransferString(utils.FormatDate, item.SigningTime)
  995. resp.ExpiredTime = utils.TimeTransferString(utils.FormatDate, item.ExpiredTime)
  996. resp.CreateTime = item.CreateTime.Format(utils.FormatDateTime)
  997. resp.ModifyTime = item.ModifyTime.Format(utils.FormatDateTime)
  998. resp.Nation = item.Nation
  999. br.Data = resp
  1000. br.Ret = 200
  1001. br.Success = true
  1002. br.Msg = "获取成功"
  1003. }
  1004. // ContractList
  1005. // @Title 商家签约列表
  1006. // @Description 商家签约列表
  1007. // @Param EtaBusinessId query int true "商家ID"
  1008. // @Success 200 Ret=200 获取成功
  1009. // @router /contract_list [get]
  1010. func (this *EtaBusinessController) ContractList() {
  1011. br := new(models.BaseResponse).Init()
  1012. defer func() {
  1013. if br.ErrMsg == "" {
  1014. br.IsSendEmail = false
  1015. }
  1016. this.Data["json"] = br
  1017. this.ServeJSON()
  1018. }()
  1019. sysUser := this.SysUser
  1020. if sysUser == nil {
  1021. br.Msg = "请登录"
  1022. br.ErrMsg = "请登录,SysUser Is Empty"
  1023. br.Ret = 408
  1024. return
  1025. }
  1026. // 权限校验
  1027. resp := make([]*eta_business.EtaBusinessContractItem, 0)
  1028. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  1029. if e != nil {
  1030. br.Msg = "操作失败"
  1031. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  1032. return
  1033. }
  1034. if !ok {
  1035. br.Data = resp
  1036. br.Ret = 200
  1037. br.Success = true
  1038. br.Msg = "获取成功"
  1039. return
  1040. }
  1041. businessId, _ := this.GetInt("EtaBusinessId", 0)
  1042. if businessId <= 0 {
  1043. br.Msg = "参数有误"
  1044. br.ErrMsg = "参数有误, 商家ID"
  1045. return
  1046. }
  1047. cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessContractColumns.EtaBusinessId)
  1048. pars := make([]interface{}, 0)
  1049. pars = append(pars, businessId)
  1050. order := `signing_time ASC`
  1051. contractOb := new(eta_business.EtaBusinessContract)
  1052. list, e := contractOb.GetItemsByCondition(cond, pars, []string{}, order)
  1053. if e != nil {
  1054. br.Msg = "获取失败"
  1055. br.ErrMsg = "获取商家签约列表失败, Err: " + e.Error()
  1056. return
  1057. }
  1058. now := time.Now().Local()
  1059. for _, v := range list {
  1060. b := new(eta_business.EtaBusinessContractItem)
  1061. b.EtaBusinessContractId = v.EtaBusinessContractId
  1062. b.EtaBusinessId = v.EtaBusinessId
  1063. b.SigningTime = utils.TimeTransferString(utils.FormatDate, v.SigningTime)
  1064. b.ExpiredTime = utils.TimeTransferString(utils.FormatDate, v.ExpiredTime)
  1065. // 到期天数, 终止日按当天的23:59:59算
  1066. strEnd := v.ExpiredTime.Format(utils.FormatDate)
  1067. strEnd = strEnd + " 23:59:59"
  1068. endTime, e := time.ParseInLocation(utils.FormatDateTime, strEnd, time.Local)
  1069. if e != nil {
  1070. br.Msg = "获取失败"
  1071. br.ErrMsg = "签约日期有误, Err: " + e.Error()
  1072. return
  1073. }
  1074. b.ExpireDay = "-"
  1075. if now.After(v.SigningTime) && now.Before(endTime) {
  1076. diff := utils.GetDiffDays(v.ExpiredTime, now)
  1077. b.ExpireDay = strconv.Itoa(diff)
  1078. b.Using = true
  1079. }
  1080. resp = append(resp, b)
  1081. }
  1082. br.Data = resp
  1083. br.Ret = 200
  1084. br.Success = true
  1085. br.Msg = "获取成功"
  1086. }
  1087. // OperateRecordList
  1088. // @Title 操作日志列表
  1089. // @Description 操作日志列表
  1090. // @Param EtaBusinessId query int true "商家ID"
  1091. // @Success 200 Ret=200 获取成功
  1092. // @router /operate_record_list [get]
  1093. func (this *EtaBusinessController) OperateRecordList() {
  1094. br := new(models.BaseResponse).Init()
  1095. defer func() {
  1096. if br.ErrMsg == "" {
  1097. br.IsSendEmail = false
  1098. }
  1099. this.Data["json"] = br
  1100. this.ServeJSON()
  1101. }()
  1102. sysUser := this.SysUser
  1103. if sysUser == nil {
  1104. br.Msg = "请登录"
  1105. br.ErrMsg = "请登录,SysUser Is Empty"
  1106. br.Ret = 408
  1107. return
  1108. }
  1109. // 权限校验
  1110. resp := make([]*eta_business.EtaBusinessOperationRecordItem, 0)
  1111. ok, e := etaBusinessService.CheckEtaBusinessOperateAuth(sysUser.RoleTypeCode)
  1112. if e != nil {
  1113. br.Msg = "操作失败"
  1114. br.ErrMsg = "操作权限校验失败, ErrMsg: " + e.Error()
  1115. return
  1116. }
  1117. if !ok {
  1118. br.Data = resp
  1119. br.Ret = 200
  1120. br.Success = true
  1121. br.Msg = "获取成功"
  1122. return
  1123. }
  1124. businessId, _ := this.GetInt("EtaBusinessId", 0)
  1125. if businessId <= 0 {
  1126. br.Msg = "参数有误"
  1127. br.ErrMsg = "参数有误, 商家ID"
  1128. return
  1129. }
  1130. cond := fmt.Sprintf(` AND %s = ?`, eta_business.EtaBusinessOperationRecordColumns.EtaBusinessId)
  1131. pars := make([]interface{}, 0)
  1132. pars = append(pars, businessId)
  1133. recordOb := new(eta_business.EtaBusinessOperationRecord)
  1134. list, e := recordOb.GetItemsByCondition(cond, pars, []string{}, "")
  1135. if e != nil {
  1136. br.Msg = "获取失败"
  1137. br.ErrMsg = "获取商家操作日志列表失败, Err: " + e.Error()
  1138. return
  1139. }
  1140. for _, v := range list {
  1141. r := new(eta_business.EtaBusinessOperationRecordItem)
  1142. r.EtaBusinessId = v.EtaBusinessId
  1143. r.SysUserId = v.SysUserId
  1144. r.SysRealName = v.SysRealName
  1145. r.OperationType = v.OperationType
  1146. r.OperationRemark = v.OperationRemark
  1147. r.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  1148. resp = append(resp, r)
  1149. }
  1150. br.Data = resp
  1151. br.Ret = 200
  1152. br.Success = true
  1153. br.Msg = "获取成功"
  1154. }