order.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/controllers"
  6. "hongze/hz_crm_api/models"
  7. "hongze/hz_crm_api/models/cygx"
  8. cygxService "hongze/hz_crm_api/services/cygx"
  9. "hongze/hz_crm_api/utils"
  10. "strconv"
  11. "time"
  12. )
  13. // 产品内测
  14. type OrderController struct {
  15. controllers.BaseAuthController
  16. }
  17. // @Title 列表
  18. // @Description 列表接口
  19. // @Param PageSize query int true "每页数据条数"
  20. // @Param CurrentIndex query int true "当前页页码,从1开始"
  21. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  22. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  23. // @Param AdminId query string false "销售ID "
  24. // @Param ShareId query string false "推荐人ID "
  25. // @Param PaymentType query string false "支付渠道 取值范围:1微信小程序,2微信扫码支付,3微信H5支付。 "
  26. // @Param OrderType query int false "订单类型 1:畅读卡订单,2:单场付费订单"
  27. // @Param OrderStatus query int false "订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭"
  28. // @Param PaymentProject query string false "付款项目"
  29. // @Param UserCardType query string false "会员卡类型 ,日卡、月卡"
  30. // @Param OrderCode query string false "订单编号"
  31. // @Param KeyWord query string false "搜索关键词"
  32. // @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
  33. // @router /order/list [get]
  34. func (this *OrderController) OrderList() {
  35. br := new(models.BaseResponse).Init()
  36. defer func() {
  37. this.Data["json"] = br
  38. this.ServeJSON()
  39. }()
  40. sysUser := this.SysUser
  41. if sysUser == nil {
  42. br.Msg = "请登录"
  43. br.ErrMsg = "请登录,SysUser Is Empty"
  44. br.Ret = 408
  45. return
  46. }
  47. resp := new(cygx.UserOrderListResp)
  48. pageSize, _ := this.GetInt("PageSize")
  49. currentIndex, _ := this.GetInt("CurrentIndex")
  50. orderType, _ := this.GetInt("OrderType", 1)
  51. orderStatus, _ := this.GetInt("OrderStatus", -1)
  52. startDate := this.GetString("StartDate")
  53. endDate := this.GetString("EndDate")
  54. adminId := this.GetString("AdminId")
  55. shareId := this.GetString("ShareId")
  56. paymentType, _ := this.GetInt("PaymentType")
  57. orderCode := this.GetString("OrderCode")
  58. keyWord := this.GetString("KeyWord")
  59. paymentProject := this.GetString("PaymentProject")
  60. userCardType := this.GetString("UserCardType")
  61. var startSize int
  62. if pageSize <= 0 {
  63. pageSize = utils.PageSize20
  64. }
  65. if currentIndex <= 0 {
  66. currentIndex = 1
  67. }
  68. startSize = utils.StartIndex(currentIndex, pageSize)
  69. var condition string
  70. var pars []interface{}
  71. if orderType > 0 { //订单类型 1:畅读卡订单,2:单场付费订单
  72. condition += ` AND order_type = ? `
  73. pars = append(pars, orderType)
  74. }
  75. if startDate != "" && endDate != "" { //时间范围
  76. condition += ` AND create_time BETWEEN ? AND ? `
  77. pars = append(pars, startDate+" 00:00:01", endDate+" 23:59:59")
  78. }
  79. if adminId != "" { //所属销售筛选
  80. condition += ` AND seller_id IN (` + adminId + `) `
  81. }
  82. if shareId != "" { //推荐人ID
  83. condition += ` AND share_id IN (` + shareId + `) `
  84. }
  85. if paymentType > 0 { // 支付渠道
  86. var tradeType string
  87. switch paymentType {
  88. case 1:
  89. tradeType = "JSAPI"
  90. case 2:
  91. tradeType = "NATIVE"
  92. case 3:
  93. tradeType = "MWEB"
  94. }
  95. condition += ` AND trade_type = ? `
  96. pars = append(pars, tradeType)
  97. }
  98. if orderStatus > -1 { //订单状态
  99. condition += ` AND order_status = ? `
  100. pars = append(pars, orderStatus)
  101. }
  102. if orderCode != "" { //订单编号
  103. orderCode = "%" + orderCode + "%"
  104. condition += ` AND order_code LIKE ? `
  105. pars = append(pars, orderCode)
  106. }
  107. if paymentProject != "" { //付款项目
  108. condition += ` AND goods_name = ? `
  109. pars = append(pars, paymentProject)
  110. }
  111. if userCardType != "" { //日卡月卡, 前端不好区分这里用了两个字段
  112. condition += ` AND goods_name = ? `
  113. pars = append(pars, userCardType)
  114. }
  115. if keyWord != "" { //用户姓名,手机号
  116. keyWord = "%" + keyWord + "%"
  117. condition += ` AND (mobile LIKE ? OR real_name LIKE ? ) `
  118. pars = append(pars, keyWord, keyWord)
  119. }
  120. total, err := cygx.GetCygxOrderCount(condition, pars)
  121. if err != nil {
  122. br.Msg = "获取失败"
  123. br.ErrMsg = "获取失败,Err:" + err.Error()
  124. return
  125. }
  126. condition += " ORDER BY order_id DESC "
  127. list, err := cygx.GetCygxOrderList(condition, pars, startSize, pageSize)
  128. if err != nil {
  129. br.Msg = "获取失败"
  130. br.ErrMsg = "获取失败,Err:" + err.Error()
  131. return
  132. }
  133. var mobiles []string
  134. for _, v := range list {
  135. mobiles = append(mobiles, v.Mobile)
  136. }
  137. inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
  138. for _, v := range list {
  139. item := new(cygx.OrderListResp)
  140. item.OrderCode = v.OrderCode
  141. item.OrderMoney = v.OrderMoney
  142. item.SourceId = v.SourceId
  143. item.Source = v.Source
  144. item.SourceTitle = v.SourceTitle
  145. switch v.Source {
  146. case utils.CYGX_OBJ_ARTICLE: //文章详情
  147. item.HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.SourceId)
  148. case utils.CYGX_OBJ_ACTIVITY: //活动详情
  149. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  150. case utils.CYGX_OBJ_ACTIVITYVIDEO: //活动视频
  151. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  152. case utils.CYGX_OBJ_ACTIVITYVOICE: //活动音频
  153. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  154. case utils.CYGX_OBJ_YANXUANSPECIAL: //专栏详情
  155. item.HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.SourceId)
  156. }
  157. item.OrderStatus = v.OrderStatus
  158. switch item.OrderStatus {
  159. case 0:
  160. item.OrderStatusText = "已取消"
  161. case 1:
  162. item.OrderStatusText = "待支付"
  163. case 2:
  164. item.OrderStatusText = "已支付"
  165. case 3:
  166. item.OrderStatusText = "退款成功"
  167. case 4:
  168. item.OrderStatusText = "退款处理中"
  169. case 5:
  170. item.OrderStatusText = "退款异常"
  171. case 6:
  172. item.OrderStatusText = "退款关闭"
  173. }
  174. //TradeType string `comment:"交易类型,枚举值:JSAPI:公众号支付 、 NATIVE:扫码支付 、 App:App支付 、 MICROPAY:付款码支付 、 MWEB:H5支付 、 FACEPAY:刷脸支付"`
  175. switch v.TradeType {
  176. case "JSAPI":
  177. item.PaymentTypeText = "小程序"
  178. case "NATIVE":
  179. item.PaymentTypeText = "PC"
  180. case "MWEB":
  181. item.PaymentTypeText = "H5"
  182. }
  183. item.UserId = v.UserId
  184. item.RealName = v.RealName
  185. item.Mobile = v.Mobile
  186. item.Email = v.Email
  187. item.CompanyId = v.CompanyId
  188. item.CompanyName = v.CompanyName
  189. item.SellerName = v.SellerName
  190. if v.ShareName != "" {
  191. item.InviteName = v.ShareName
  192. } else {
  193. item.InviteName = inviteNameMap[v.Mobile]
  194. }
  195. item.PaymentProject = v.GoodsName
  196. if v.OrderStatus != 0 && v.OrderStatus != 1 {
  197. item.PayTime = v.PayTime.Format(utils.FormatDateTime)
  198. }
  199. if orderType == 1 && v.OrderStatus != 0 && v.OrderStatus != 1 {
  200. if v.GoodsId == 1 {
  201. item.StartDate = v.StartDate.Format(utils.FormatDateTime)
  202. item.EndDate = v.EndDate.Format(utils.FormatDateTime)
  203. } else {
  204. item.StartDate = v.StartDate.Format(utils.FormatDate)
  205. item.EndDate = v.EndDate.Format(utils.FormatDate)
  206. }
  207. }
  208. item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  209. resp.List = append(resp.List, item)
  210. }
  211. if len(resp.List) == 0 {
  212. resp.List = make([]*cygx.OrderListResp, 0)
  213. }
  214. page := paging.GetPaging(currentIndex, pageSize, total)
  215. resp.Paging = page
  216. br.Ret = 200
  217. br.Success = true
  218. br.Msg = "获取成功"
  219. br.Data = resp
  220. }
  221. // @Title 退款
  222. // @Description 退款接口
  223. // @Param request body cygx.UserRemarAddReq true "type json string"
  224. // @Success 200 操作成功
  225. // @router /order/refund [post]
  226. func (this *UserController) OrderRefund() {
  227. br := new(models.BaseResponse).Init()
  228. defer func() {
  229. this.Data["json"] = br
  230. this.ServeJSON()
  231. }()
  232. sysUser := this.SysUser
  233. if sysUser == nil {
  234. br.Msg = "请登录"
  235. br.ErrMsg = "请登录,SysUser Is Empty"
  236. br.Ret = 408
  237. return
  238. }
  239. var req cygx.CygxOrderRefundReq
  240. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  241. if err != nil {
  242. br.Msg = "参数解析异常!"
  243. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  244. return
  245. }
  246. orderCode := req.OrderCode
  247. remark := req.Remark
  248. if remark == "" {
  249. br.Msg = "请填写退款原因"
  250. return
  251. }
  252. orderDetail, err := cygx.GetCygxOrderDetailByOrderCode(orderCode)
  253. if err != nil {
  254. br.Msg = "获取失败"
  255. br.ErrMsg = "获取失败, Err:" + err.Error()
  256. return
  257. }
  258. if orderDetail.OrderStatus != 2 {
  259. br.Msg = "订单状态异常!"
  260. br.ErrMsg = "订单状态异常,orderCode:" + orderCode
  261. return
  262. }
  263. //订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭
  264. statusCode, err := cygxService.RefundsApiService(orderDetail)
  265. var orderStatus int
  266. if statusCode == 200 && err == nil {
  267. orderStatus = 4
  268. } else {
  269. orderStatus = 5
  270. }
  271. item := new(cygx.CygxOrderRefund)
  272. item.OrderCode = orderCode
  273. item.RefundMoney = orderDetail.OrderMoney
  274. item.RefundWay = 1
  275. item.Remark = remark
  276. item.CreateTime = time.Now()
  277. item.RefundTime = time.Now()
  278. item.AdminId = sysUser.AdminId
  279. item.AdminName = sysUser.RealName
  280. err = cygx.AddCygxOrderRefund(item, orderStatus)
  281. if err != nil {
  282. br.Msg = "新增失败."
  283. br.ErrMsg = "新增失败,Err:" + err.Error()
  284. return
  285. }
  286. br.Ret = 200
  287. br.Success = true
  288. br.Msg = "已提交退款,请到退款记录页面查看"
  289. }
  290. // @Title 退款记录列表
  291. // @Description 退款记录列表接口
  292. // @Param PageSize query int true "每页数据条数"
  293. // @Param CurrentIndex query int true "当前页页码,从1开始"
  294. // @Param StartDate query string false "开始时间 ,列如2021-03-06 "
  295. // @Param EndDate query string false "结束时间,列如2021-03-06 "
  296. // @Param AdminId query string false "销售ID "
  297. // @Param ShareId query string false "推荐人ID "
  298. // @Param PaymentType query string false "支付渠道 取值范围:1微信小程序,2微信扫码支付,3微信H5支付。 "
  299. // @Param OrderType query int false "订单类型 1:畅读卡订单,2:单场付费订单"
  300. // @Param OrderStatus query int false "订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭"
  301. // @Param PaymentProject query string false "付款项目"
  302. // @Param UserCardType query string false "会员卡类型 ,日卡、月卡"
  303. // @Param OrderCode query string false "订单编号"
  304. // @Param KeyWord query string false "搜索关键词"
  305. // @Success Ret=200 {object} cygx.GetCygxTacticsTimeLineResp
  306. // @router /order/refund/list [get]
  307. func (this *OrderController) OrderRefundList() {
  308. br := new(models.BaseResponse).Init()
  309. defer func() {
  310. this.Data["json"] = br
  311. this.ServeJSON()
  312. }()
  313. sysUser := this.SysUser
  314. if sysUser == nil {
  315. br.Msg = "请登录"
  316. br.ErrMsg = "请登录,SysUser Is Empty"
  317. br.Ret = 408
  318. return
  319. }
  320. resp := new(cygx.UserOrderListResp)
  321. pageSize, _ := this.GetInt("PageSize")
  322. currentIndex, _ := this.GetInt("CurrentIndex")
  323. orderType, _ := this.GetInt("OrderType", 1)
  324. orderStatus, _ := this.GetInt("OrderStatus", -1)
  325. startDate := this.GetString("StartDate")
  326. endDate := this.GetString("EndDate")
  327. adminId := this.GetString("AdminId")
  328. shareId := this.GetString("ShareId")
  329. paymentType, _ := this.GetInt("PaymentType")
  330. orderCode := this.GetString("OrderCode")
  331. keyWord := this.GetString("KeyWord")
  332. paymentProject := this.GetString("PaymentProject")
  333. userCardType := this.GetString("UserCardType")
  334. var startSize int
  335. if pageSize <= 0 {
  336. pageSize = utils.PageSize20
  337. }
  338. if currentIndex <= 0 {
  339. currentIndex = 1
  340. }
  341. startSize = utils.StartIndex(currentIndex, pageSize)
  342. var condition string
  343. var pars []interface{}
  344. condition += ` AND order_status IN (3,4,5,6) `
  345. if orderType > 0 { //订单类型 1:畅读卡订单,2:单场付费订单
  346. condition += ` AND order_type = ? `
  347. pars = append(pars, orderType)
  348. }
  349. if startDate != "" && endDate != "" { //时间范围
  350. condition += ` AND create_time BETWEEN ? AND ? `
  351. pars = append(pars, startDate+" 00:00:01", endDate+" 23:59:59")
  352. }
  353. if adminId != "" { //所属销售筛选
  354. condition += ` AND seller_id IN (` + adminId + `) `
  355. }
  356. if shareId != "" { //推荐人ID
  357. condition += ` AND share_id IN (` + shareId + `) `
  358. }
  359. if paymentType > 0 { // 支付渠道
  360. var tradeType string
  361. switch paymentType {
  362. case 1:
  363. tradeType = "JSAPI"
  364. case 2:
  365. tradeType = "NATIVE"
  366. case 3:
  367. tradeType = "MWEB"
  368. }
  369. condition += ` AND trade_type = ? `
  370. pars = append(pars, tradeType)
  371. }
  372. if orderStatus > -1 { //订单状态
  373. condition += ` AND order_status = ? `
  374. pars = append(pars, orderStatus)
  375. }
  376. if orderCode != "" { //订单编号
  377. orderCode = "%" + orderCode + "%"
  378. condition += ` AND order_code LIKE ? `
  379. pars = append(pars, orderCode)
  380. }
  381. if paymentProject != "" { //付款项目
  382. condition += ` AND goods_name = ? `
  383. pars = append(pars, paymentProject)
  384. }
  385. if userCardType != "" { //日卡月卡, 前端不好区分这里用了两个字段
  386. condition += ` AND goods_name = ? `
  387. pars = append(pars, userCardType)
  388. }
  389. if keyWord != "" { //用户姓名,手机号
  390. keyWord = "%" + keyWord + "%"
  391. condition += ` AND (mobile LIKE ? OR real_name LIKE ? ) `
  392. pars = append(pars, keyWord, keyWord)
  393. }
  394. total, err := cygx.GetCygxOrderCount(condition, pars)
  395. if err != nil {
  396. br.Msg = "获取失败"
  397. br.ErrMsg = "获取失败,Err:" + err.Error()
  398. return
  399. }
  400. condition += " ORDER BY order_id DESC "
  401. list, err := cygx.GetCygxOrderList(condition, pars, startSize, pageSize)
  402. if err != nil {
  403. br.Msg = "获取失败"
  404. br.ErrMsg = "获取失败,Err:" + err.Error()
  405. return
  406. }
  407. var mobiles []string
  408. for _, v := range list {
  409. mobiles = append(mobiles, v.Mobile)
  410. }
  411. inviteNameMap := cygxService.GetCygxUserBusinessCardMap(mobiles) // 根据手机号获取邀请人
  412. for _, v := range list {
  413. item := new(cygx.OrderListResp)
  414. item.OrderCode = v.OrderCode
  415. item.OrderMoney = v.OrderMoney
  416. item.SourceId = v.SourceId
  417. item.Source = v.Source
  418. item.SourceTitle = v.SourceTitle
  419. switch v.Source {
  420. case utils.CYGX_OBJ_ARTICLE: //文章详情
  421. item.HttpUrl = utils.CYGX_MFYX_URL + "/material/info/" + strconv.Itoa(v.SourceId)
  422. case utils.CYGX_OBJ_ACTIVITY: //活动详情
  423. case utils.CYGX_OBJ_ACTIVITYVIDEO: //活动视频
  424. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  425. case utils.CYGX_OBJ_ACTIVITYVOICE: //活动音频
  426. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  427. item.HttpUrl = utils.CYGX_MFYX_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  428. case utils.CYGX_OBJ_YANXUANSPECIAL: //专栏详情
  429. item.HttpUrl = utils.CYGX_MFYX_URL + "/column/detail/" + strconv.Itoa(v.SourceId)
  430. }
  431. //OrderStatus int `comment:"订单状态,0:已取消、1:待支付、2:已支付、3:退款成功、4:退款处理中、5:退款异常、6:退款关闭"`
  432. item.OrderStatus = v.OrderStatus
  433. switch item.OrderStatus {
  434. case 3:
  435. item.OrderStatusText = "退款成功"
  436. case 4:
  437. item.OrderStatusText = "退款处理中"
  438. case 5:
  439. item.OrderStatusText = "退款异常"
  440. case 6:
  441. item.OrderStatusText = "退款关闭"
  442. }
  443. //TradeType string `comment:"交易类型,枚举值:JSAPI:公众号支付 、 NATIVE:扫码支付 、 App:App支付 、 MICROPAY:付款码支付 、 MWEB:H5支付 、 FACEPAY:刷脸支付"`
  444. switch v.TradeType {
  445. case "JSAPI":
  446. item.PaymentTypeText = "小程序"
  447. case "NATIVE":
  448. item.PaymentTypeText = "PC"
  449. case "MWEB":
  450. item.PaymentTypeText = "H5"
  451. }
  452. item.UserId = v.UserId
  453. item.RealName = v.RealName
  454. item.Mobile = v.Mobile
  455. item.Email = v.Email
  456. item.CompanyId = v.CompanyId
  457. item.CompanyName = v.CompanyName
  458. item.SellerName = v.SellerName
  459. if v.ShareName != "" {
  460. item.InviteName = v.ShareName
  461. } else {
  462. item.InviteName = inviteNameMap[v.Mobile]
  463. }
  464. item.PaymentProject = v.GoodsName
  465. switch v.GoodsId {
  466. case 1:
  467. item.PaymentProject = "日卡"
  468. case 2:
  469. item.PaymentProject = "月卡"
  470. }
  471. item.RefundTime = v.RefundTime.Format(utils.FormatDateTime)
  472. item.RefundRemark = v.RefundRemark
  473. //if v.OrderStatus == 2 {
  474. item.PayTime = v.PayTime.Format(utils.FormatDateTime)
  475. //}
  476. if orderType == 1 {
  477. if v.GoodsId == 1 {
  478. item.StartDate = v.StartDate.Format(utils.FormatDateTime)
  479. item.EndDate = v.EndDate.Format(utils.FormatDateTime)
  480. } else {
  481. item.StartDate = v.StartDate.Format(utils.FormatDate)
  482. item.EndDate = v.EndDate.Format(utils.FormatDate)
  483. }
  484. }
  485. item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  486. resp.List = append(resp.List, item)
  487. }
  488. if len(resp.List) == 0 {
  489. resp.List = make([]*cygx.OrderListResp, 0)
  490. }
  491. page := paging.GetPaging(currentIndex, pageSize, total)
  492. resp.Paging = page
  493. br.Ret = 200
  494. br.Success = true
  495. br.Msg = "获取成功"
  496. br.Data = resp
  497. }
  498. // @Title 退款撤销
  499. // @Description 退款撤销接口
  500. // @Param request body cygx.UserRemarAddReq true "type json string"
  501. // @Success 200 操作成功
  502. // @router /order/refund_revoke [post]
  503. func (this *UserController) OrderRefundRevoke() {
  504. br := new(models.BaseResponse).Init()
  505. defer func() {
  506. this.Data["json"] = br
  507. this.ServeJSON()
  508. }()
  509. sysUser := this.SysUser
  510. if sysUser == nil {
  511. br.Msg = "请登录"
  512. br.ErrMsg = "请登录,SysUser Is Empty"
  513. br.Ret = 408
  514. return
  515. }
  516. var req cygx.CygxOrderRefundReq
  517. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  518. if err != nil {
  519. br.Msg = "参数解析异常!"
  520. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  521. return
  522. }
  523. orderCode := req.OrderCode
  524. orderDetail, err := cygx.GetCygxOrderDetailByOrderCode(orderCode)
  525. if err != nil {
  526. br.Msg = "获取失败"
  527. br.ErrMsg = "获取失败, Err:" + err.Error()
  528. return
  529. }
  530. if orderDetail.OrderStatus != 4 {
  531. br.Msg = "订单状态异常!"
  532. br.ErrMsg = "订单状态异常,orderCode:" + orderCode
  533. return
  534. }
  535. item := new(cygx.CygxOrderAction)
  536. item.Action = "关闭退款"
  537. item.OrderStatus = 6
  538. item.OrderStatusText = "关闭退款"
  539. item.OrderCode = orderDetail.OrderCode
  540. item.UserId = orderDetail.UserId
  541. item.RealName = orderDetail.RealName
  542. item.Mobile = orderDetail.Mobile
  543. item.Email = orderDetail.Email
  544. item.CompanyId = orderDetail.CompanyId
  545. item.CompanyName = orderDetail.CompanyName
  546. item.SellerName = orderDetail.SellerName
  547. item.CreateTime = time.Now()
  548. item.ModifyTime = time.Now()
  549. item.AdminId = sysUser.AdminId
  550. item.AdminName = sysUser.RealName
  551. err = cygx.AddCygxOrderRefundRevoke(item)
  552. if err != nil {
  553. br.Msg = "新增失败."
  554. br.ErrMsg = "新增失败,Err:" + err.Error()
  555. return
  556. }
  557. br.Ret = 200
  558. br.Success = true
  559. br.Msg = "操作成功"
  560. }