hsby.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. package hsby
  2. import (
  3. "mtp2_if/global/app"
  4. "mtp2_if/global/e"
  5. "mtp2_if/logger"
  6. "mtp2_if/models"
  7. "net/http"
  8. "sort"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // QueryHsbyTopGoodsesReq 查询热门商品列表请求参数
  12. type QueryHsbyTopGoodsesReq struct {
  13. app.PageInfo
  14. MarketIDs string `form:"marketIDs" binding:"required"`
  15. DescProvinceID int `form:"descProvinceID"`
  16. DescCityID int `form:"descCityID"`
  17. }
  18. // QueryHsbyTopGoodses 查询热卖商品列表(二级市场挂牌点选)
  19. // @Summary 查询热卖商品列表(二级市场挂牌点选)
  20. // @Description 说明:查询结果已按Hotindex(景点热度)从大到小排序
  21. // @Produce json
  22. // @Security ApiKeyAuth
  23. // @Param page query int false "页码"
  24. // @Param pagesize query int false "每页条数"
  25. // @Param marketIDs query string true "市场ID列表,格式:1,2,3"
  26. // @Param DescProvinceID query int false "目的地(省)ID"
  27. // @Param DescCityID query int false "目的地(市)ID"
  28. // @Success 200 {object} models.HsbyTopGoods
  29. // @Failure 500 {object} app.Response
  30. // @Router /HSBY/QueryHsbyTopGoodses [get]
  31. // @Tags 定制【海商报业】
  32. func QueryHsbyTopGoodses(c *gin.Context) {
  33. appG := app.Gin{C: c}
  34. // 获取请求参数
  35. var req QueryHsbyTopGoodsesReq
  36. if err := appG.C.ShouldBindQuery(&req); err != nil {
  37. logger.GetLogger().Errorf("QueryHsbyTopGoodses failed: %s", err.Error())
  38. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  39. return
  40. }
  41. // 获取数据
  42. topGoodses, err := models.GetHsbyTopGoodses(req.MarketIDs, req.DescProvinceID, req.DescCityID)
  43. if err != nil {
  44. // 查询失败
  45. logger.GetLogger().Errorf("QueryHsbyTopGoodses failed: %s", err.Error())
  46. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  47. return
  48. }
  49. // 排序
  50. sort.Slice(topGoodses, func(i int, j int) bool {
  51. return topGoodses[i].Hotindex > topGoodses[j].Hotindex
  52. })
  53. // 分页
  54. total := len(topGoodses)
  55. if req.PageSize > 0 {
  56. rstByPage := make([]models.HsbyTopGoods, 0)
  57. // 开始上标
  58. start := req.Page * req.PageSize
  59. // 结束下标
  60. end := start + req.PageSize
  61. if start <= len(topGoodses) {
  62. // 判断结束下标是否越界
  63. if end > len(topGoodses) {
  64. end = len(topGoodses)
  65. }
  66. rstByPage = topGoodses[start:end]
  67. } else {
  68. rstByPage = topGoodses[0:0]
  69. }
  70. topGoodses = rstByPage
  71. }
  72. // 查询成功返回
  73. if req.PageSize > 0 {
  74. logger.GetLogger().Debugln("QueryHsbyTopGoodses successed: %v", topGoodses)
  75. appG.ResponseByPage(http.StatusOK, e.SUCCESS, topGoodses, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
  76. } else {
  77. logger.GetLogger().Debugln("QueryHsbyTopGoodses successed: %v", topGoodses)
  78. appG.Response(http.StatusOK, e.SUCCESS, topGoodses)
  79. }
  80. }
  81. // QueryHsbyListingGoodsDetailReq 查询二级市场(挂牌点选)商品信息详情请求参数
  82. type QueryHsbyListingGoodsDetailReq struct {
  83. GoodsID int `form:"goodsID" binding:"required"`
  84. }
  85. // QueryHsbyListingGoodsDetail 查询二级市场(挂牌点选)商品信息详情
  86. // @Summary 查询二级市场(挂牌点选)商品信息详情
  87. // @Produce json
  88. // @Security ApiKeyAuth
  89. // @Param goodsID query int true "商品ID"
  90. // @Success 200 {object} models.HsbyListingGoodsDetail
  91. // @Failure 500 {object} app.Response
  92. // @Router /HSBY/QueryHsbyListingGoodsDetail [get]
  93. // @Tags 定制【海商报业】
  94. func QueryHsbyListingGoodsDetail(c *gin.Context) {
  95. appG := app.Gin{C: c}
  96. // 获取请求参数
  97. var req QueryHsbyListingGoodsDetailReq
  98. if err := appG.C.ShouldBindQuery(&req); err != nil {
  99. logger.GetLogger().Errorf("QueryHsbyListingGoodsDetail failed: %s", err.Error())
  100. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  101. return
  102. }
  103. // 获取数据
  104. goodsInfo, err := models.GetHsbyListingGoodsDetail(req.GoodsID)
  105. if err != nil {
  106. // 查询失败
  107. logger.GetLogger().Errorf("QueryHsbyListingGoodsDetail failed: %s", err.Error())
  108. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  109. return
  110. }
  111. // 查询成功返回
  112. logger.GetLogger().Debugln("QueryHsbyListingGoodsDetail successed: %v", goodsInfo)
  113. appG.Response(http.StatusOK, e.SUCCESS, goodsInfo)
  114. }
  115. // QueryHsbyGoodsOrderDetailsReq 查询二级市场(挂牌点选)商品对应的挂牌委托单信息请求参数
  116. type QueryHsbyGoodsOrderDetailsReq struct {
  117. GoodsID int `form:"goodsID" binding:"required"`
  118. BuyOrSell int `form:"buyOrSell"`
  119. Price float64 `form:"price"`
  120. Speed int `form:"speed"`
  121. }
  122. // QueryHsbyGoodsOrderDetails 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
  123. // @Summary 查询二级市场(挂牌点选)商品对应的挂牌委托单信息
  124. // @Description 说明:查询结果已按委托价格和委托时间排序
  125. // @Produce json
  126. // @Security ApiKeyAuth
  127. // @Param goodsID query int true "商品ID"
  128. // @Param buyOrSell query int false "委托单方向。0:买 1:卖。不传则默认为买"
  129. // @Param price query number false " 参考价格。买方向委托单则价格大于等于(站在摘牌人的角度);卖方向委托单则价格小于等于"
  130. // @Param speed query int false "档位,不传则默认为3档"
  131. // @Success 200 {object} models.HsbyGoodsOrderDetail
  132. // @Failure 500 {object} app.Response
  133. // @Router /HSBY/QueryHsbyGoodsOrderDetails [get]
  134. // @Tags 定制【海商报业】
  135. func QueryHsbyGoodsOrderDetails(c *gin.Context) {
  136. appG := app.Gin{C: c}
  137. // 获取请求参数
  138. var req QueryHsbyGoodsOrderDetailsReq
  139. if err := appG.C.ShouldBindQuery(&req); err != nil {
  140. logger.GetLogger().Errorf("QueryHsbyGoodsOrderDetails failed: %s", err.Error())
  141. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  142. return
  143. }
  144. // 获取数据
  145. orderDetails, err := models.GetHsbyGoodsOrderDetails(req.GoodsID, req.BuyOrSell, req.Price)
  146. if err != nil {
  147. // 查询失败
  148. logger.GetLogger().Errorf("QueryHsbyGoodsOrderDetails failed: %s", err.Error())
  149. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  150. return
  151. }
  152. // 按时间和价格排序
  153. if req.BuyOrSell == 0 {
  154. // 买方向
  155. sort.Slice(orderDetails, func(i int, j int) bool {
  156. // 委托价格一样则按时间顺序排
  157. if orderDetails[i].Orderprice == orderDetails[j].Orderprice {
  158. return orderDetails[i].Ordertime.Before(orderDetails[j].Ordertime)
  159. }
  160. // 站在摘牌者的角度,买方向的委托单价格高的在前面
  161. return orderDetails[i].Orderprice > orderDetails[j].Orderprice
  162. })
  163. } else {
  164. // 卖方向
  165. sort.Slice(orderDetails, func(i int, j int) bool {
  166. // 委托价格一样则按时间顺序排
  167. if orderDetails[i].Orderprice == orderDetails[j].Orderprice {
  168. return orderDetails[i].Ordertime.Before(orderDetails[j].Ordertime)
  169. }
  170. return orderDetails[i].Orderprice < orderDetails[j].Orderprice
  171. })
  172. }
  173. // 取N档,默认3档
  174. if req.Speed == 0 {
  175. req.Speed = 3
  176. }
  177. // 判断结束下标是否越界
  178. end := req.Speed
  179. if req.Speed > len(orderDetails) {
  180. end = len(orderDetails)
  181. }
  182. orderDetails = orderDetails[0:end]
  183. // 查询成功返回
  184. logger.GetLogger().Debugln("QueryHsbyGoodsOrderDetails successed: %v", orderDetails)
  185. appG.Response(http.StatusOK, e.SUCCESS, orderDetails)
  186. }
  187. // QueryHsbyMyBuyOrderDetailsReq 查询“我的订单”信息请求参数
  188. type QueryHsbyMyBuyOrderDetailsReq struct {
  189. AccountIDs string `form:"accountIDs" binding:"required"`
  190. MyBuyStatus int `form:"myBuyStatus"`
  191. }
  192. // QueryHsbyMyBuyOrderDetails 查询“我的订单”信息
  193. // @Summary 查询“我的订单”信息
  194. // @Description 说明: 全部:一二级市场买委托;抢购中:一级市场买摘; 求购中:二级市场买挂; 3:已完成:一二级市场已完成买委托;
  195. // @Produce json
  196. // @Security ApiKeyAuth
  197. // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
  198. // @Param myBuyStatus query int false "'我的订单'状态, 1:抢购中 2:求购中 3:已完成;不传则为'全部'"
  199. // @Success 200 {object} models.HybsMyBuyOrderDetail
  200. // @Failure 500 {object} app.Response
  201. // @Router /HSBY/QueryHsbyMyBuyOrderDetails [get]
  202. // @Tags 定制【海商报业】
  203. func QueryHsbyMyBuyOrderDetails(c *gin.Context) {
  204. appG := app.Gin{C: c}
  205. // 获取请求参数
  206. var req QueryHsbyMyBuyOrderDetailsReq
  207. if err := appG.C.ShouldBindQuery(&req); err != nil {
  208. logger.GetLogger().Errorf("QueryHsbyMyBuyOrderDetails failed: %s", err.Error())
  209. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  210. return
  211. }
  212. // 获取数据
  213. myOrderDetails, err := models.GetHsbyBuyMyOrderDetails(req.AccountIDs, req.MyBuyStatus)
  214. if err != nil {
  215. // 查询失败
  216. logger.GetLogger().Errorf("QueryHsbyMyBuyOrderDetails failed: %s", err.Error())
  217. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  218. return
  219. }
  220. // 按时间排序
  221. sort.Slice(myOrderDetails, func(i int, j int) bool {
  222. return myOrderDetails[i].Ordertime.After(myOrderDetails[j].Ordertime)
  223. })
  224. // 查询成功返回
  225. logger.GetLogger().Debugln("QueryHsbyMyBuyOrderDetails successed: %v", myOrderDetails)
  226. appG.Response(http.StatusOK, e.SUCCESS, myOrderDetails)
  227. }
  228. // QueryHsbyMyGoodsReq 查询“我的商品”请求参数
  229. type QueryHsbyMyGoodsReq struct {
  230. AccountIDs string `form:"accountIDs" binding:"required"`
  231. }
  232. // QueryHsbyMyGoods 查询“我的商品”信息
  233. // @Summary 查询“我的商品”信息
  234. // @Produce json
  235. // @Security ApiKeyAuth
  236. // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
  237. // @Success 200 {object} models.HsbyMyGoods
  238. // @Failure 500 {object} app.Response
  239. // @Router /HSBY/QueryHsbyMyGoods [get]
  240. // @Tags 定制【海商报业】
  241. func QueryHsbyMyGoods(c *gin.Context) {
  242. appG := app.Gin{C: c}
  243. // 获取请求参数
  244. var req QueryHsbyMyGoodsReq
  245. if err := appG.C.ShouldBindQuery(&req); err != nil {
  246. logger.GetLogger().Errorf("QueryHsbyMyGoods failed: %s", err.Error())
  247. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  248. return
  249. }
  250. // 获取数据
  251. myGoodses, err := models.GetHsbyMyGoods(req.AccountIDs)
  252. if err != nil {
  253. // 查询失败
  254. logger.GetLogger().Errorf("QueryHsbyMyGoods failed: %s", err.Error())
  255. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  256. return
  257. }
  258. // 查询成功返回
  259. logger.GetLogger().Debugln("QueryHsbyMyGoods successed: %v", myGoodses)
  260. appG.Response(http.StatusOK, e.SUCCESS, myGoodses)
  261. }
  262. // QueryHsbyPreGoodsesReq 查询新品上市商品列表请求参数
  263. type QueryHsbyPreGoodsesReq struct {
  264. app.PageInfo
  265. MarketIDs string `form:"marketIDs" binding:"required"`
  266. DescProvinceID int `form:"descProvinceID"`
  267. DescCityID int `form:"descCityID"`
  268. }
  269. // QueryHsbyPreGoodses 查询新品上市商品列表(一级市场产能预售)
  270. // @Summary 查询新品上市商品列表(一级市场产能预售)
  271. // @Description 说明:结果已先显示已开始商品(按结束时间顺序排),再显示未开始商品(按开始时间顺序排)
  272. // @Produce json
  273. // @Security ApiKeyAuth
  274. // @Param page query int false "页码"
  275. // @Param pagesize query int false "每页条数"
  276. // @Param marketIDs query string true "市场ID列表,格式:1,2,3"
  277. // @Param DescProvinceID query int false "目的地(省)ID"
  278. // @Param DescCityID query int false "目的地(市)ID"
  279. // @Success 200 {object} models.HsbyPreGoods
  280. // @Failure 500 {object} app.Response
  281. // @Router /HSBY/QueryHsbyPreGoodses [get]
  282. // @Tags 定制【海商报业】
  283. func QueryHsbyPreGoodses(c *gin.Context) {
  284. appG := app.Gin{C: c}
  285. // 获取请求参数
  286. var req QueryHsbyPreGoodsesReq
  287. if err := appG.C.ShouldBindQuery(&req); err != nil {
  288. logger.GetLogger().Errorf("QueryHsbyPreGoodses failed: %s", err.Error())
  289. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  290. return
  291. }
  292. // 获取数据
  293. preGoodses, err := models.GetHsbyPreGoodses(req.MarketIDs, req.DescProvinceID, req.DescCityID)
  294. if err != nil {
  295. // 查询失败
  296. logger.GetLogger().Errorf("QueryHsbyPreGoodses failed: %s", err.Error())
  297. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  298. return
  299. }
  300. // 排序,先显示已开始商品(按结束时间顺序排),再显示未开始商品(按开始时间顺序排)
  301. sort.Slice(preGoodses, func(i int, j int) bool {
  302. if preGoodses[i].Goodsstatus == 3 && preGoodses[j].Goodsstatus == 2 {
  303. // 先显示已开始商品
  304. return true
  305. } else if preGoodses[i].Goodsstatus == 3 && preGoodses[j].Goodsstatus == 3 {
  306. // 已开始商品按结束时间顺序排
  307. return preGoodses[i].Endtime.Before(preGoodses[j].Endtime)
  308. } else if preGoodses[i].Goodsstatus == 2 && preGoodses[j].Goodsstatus == 2 {
  309. // 未开始商品按开始时间顺序排
  310. return preGoodses[i].Starttime.Before(preGoodses[j].Starttime)
  311. }
  312. return false
  313. })
  314. // 分页
  315. total := len(preGoodses)
  316. if req.PageSize > 0 {
  317. rstByPage := make([]models.HsbyPreGoods, 0)
  318. // 开始上标
  319. start := req.Page * req.PageSize
  320. // 结束下标
  321. end := start + req.PageSize
  322. if start <= len(preGoodses) {
  323. // 判断结束下标是否越界
  324. if end > len(preGoodses) {
  325. end = len(preGoodses)
  326. }
  327. rstByPage = preGoodses[start:end]
  328. } else {
  329. rstByPage = preGoodses[0:0]
  330. }
  331. preGoodses = rstByPage
  332. }
  333. // 查询成功返回
  334. if req.PageSize > 0 {
  335. logger.GetLogger().Debugln("QueryHsbyPreGoodses successed: %v", preGoodses)
  336. appG.ResponseByPage(http.StatusOK, e.SUCCESS, preGoodses, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
  337. } else {
  338. logger.GetLogger().Debugln("QueryHsbyPreGoodses successed: %v", preGoodses)
  339. appG.Response(http.StatusOK, e.SUCCESS, preGoodses)
  340. }
  341. }
  342. // QueryHsbyPreGoodsDetailReq 查询一级市场(产能预售)商品信息详情请求参数
  343. type QueryHsbyPreGoodsDetailReq struct {
  344. GoodsID int `form:"goodsID" binding:"required"`
  345. }
  346. // QueryHsbyPreGoodsDetail 查询一级市场(产能预售)商品信息详情
  347. // @Summary 查询一级市场(产能预售)商品信息详情
  348. // @Produce json
  349. // @Security ApiKeyAuth
  350. // @Param goodsID query int true "商品ID"
  351. // @Success 200 {object} models.HsbyPreGoodsDetail
  352. // @Failure 500 {object} app.Response
  353. // @Router /HSBY/QueryHsbyPreGoodsDetail [get]
  354. // @Tags 定制【海商报业】
  355. func QueryHsbyPreGoodsDetail(c *gin.Context) {
  356. appG := app.Gin{C: c}
  357. // 获取请求参数
  358. var req QueryHsbyPreGoodsDetailReq
  359. if err := appG.C.ShouldBindQuery(&req); err != nil {
  360. logger.GetLogger().Errorf("QueryHsbyPreGoodsDetail failed: %s", err.Error())
  361. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  362. return
  363. }
  364. // 获取数据
  365. goodsInfo, err := models.GetHsbyPreGoodsDetail(req.GoodsID)
  366. if err != nil {
  367. // 查询失败
  368. logger.GetLogger().Errorf("QueryHsbyPreGoodsDetail failed: %s", err.Error())
  369. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  370. return
  371. }
  372. // 查询成功返回
  373. logger.GetLogger().Debugln("QueryHsbyPreGoodsDetail successed: %v", goodsInfo)
  374. appG.Response(http.StatusOK, e.SUCCESS, goodsInfo)
  375. }
  376. // QueryHsbySellMyDetailReq 查询"我的闲置"单据信息请求参数
  377. type QueryHsbySellMyDetailReq struct {
  378. app.PageInfo
  379. AccountIDs string `form:"accountIDs" binding:"required"`
  380. OrderType int `form:"orderType"`
  381. }
  382. // QueryHsbySellMyDetails 查询"我的闲置"单据信息
  383. // @Summary 查询"我的闲置"单据信息
  384. // @Description 说明:已发布 - 二级市场卖挂,3:委托成功、7:部分成交; 已完成 - 二级市场成交单,包括历史数据。查询结果已按时间从近到远排序
  385. // @Produce json
  386. // @Security ApiKeyAuth
  387. // @Param page query int false "页码"
  388. // @Param pagesize query int false "每页条数"
  389. // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
  390. // @Param orderType query int false "单据类型:0 - 已发布(默认), 1 - 已完成"
  391. // @Success 200 {object} models.HsbySellMyDetail
  392. // @Failure 500 {object} app.Response
  393. // @Router /HSBY/QueryHsbySellMyDetails [get]
  394. // @Tags 定制【海商报业】
  395. func QueryHsbySellMyDetails(c *gin.Context) {
  396. appG := app.Gin{C: c}
  397. // 获取请求参数
  398. var req QueryHsbySellMyDetailReq
  399. if err := appG.C.ShouldBindQuery(&req); err != nil {
  400. logger.GetLogger().Errorf("QueryHsbySellMyDetails failed: %s", err.Error())
  401. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  402. return
  403. }
  404. // 获取数据
  405. var orders []models.HsbySellMyDetail
  406. if req.OrderType == 0 {
  407. // 已发布
  408. var err error
  409. orders, err = models.GetHsbySellMyOrderDetails(req.AccountIDs)
  410. if err != nil {
  411. // 查询失败
  412. logger.GetLogger().Errorf("QueryHsbySellMyDetails failed: %s", err.Error())
  413. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  414. return
  415. }
  416. } else {
  417. // 已完成
  418. var err error
  419. orders, err = models.GetHsbySellMyTradeDetails(req.AccountIDs)
  420. if err != nil {
  421. // 查询失败
  422. logger.GetLogger().Errorf("QueryHsbySellMyDetails failed: %s", err.Error())
  423. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  424. return
  425. }
  426. }
  427. // 排序
  428. sort.Slice(orders, func(i int, j int) bool {
  429. return orders[i].Time.After(orders[j].Time)
  430. })
  431. // 分页
  432. total := len(orders)
  433. if req.PageSize > 0 {
  434. rstByPage := make([]models.HsbySellMyDetail, 0)
  435. // 开始上标
  436. start := req.Page * req.PageSize
  437. // 结束下标
  438. end := start + req.PageSize
  439. if start <= len(orders) {
  440. // 判断结束下标是否越界
  441. if end > len(orders) {
  442. end = len(orders)
  443. }
  444. rstByPage = orders[start:end]
  445. } else {
  446. rstByPage = orders[0:0]
  447. }
  448. orders = rstByPage
  449. }
  450. // 查询成功返回
  451. if req.PageSize > 0 {
  452. logger.GetLogger().Debugln("QueryHsbySellMyDetails successed: %v", orders)
  453. appG.ResponseByPage(http.StatusOK, e.SUCCESS, orders, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
  454. } else {
  455. logger.GetLogger().Debugln("QueryHsbySellMyDetails successed: %v", orders)
  456. appG.Response(http.StatusOK, e.SUCCESS, orders)
  457. }
  458. }
  459. // QueryHsbyMyPackagesReq 查询我的包裹信息请求参数
  460. type QueryHsbyMyPackagesReq struct {
  461. AccountIDs string `form:"accountIDs" binding:"required"`
  462. TakeOrderStatus int `form:"takeOrderStatus"`
  463. }
  464. // QueryHsbyMyPackages 查询我的包裹信息
  465. // @Summary 查询我的包裹信息
  466. // @Produce json
  467. // @Security ApiKeyAuth
  468. // @Param accountIDs query string true "资金账户列表,格式:1,2,3"
  469. // @Param takeOrderStatus query int false "提货状态 - 1:待发货 2:已发货 3:已收货"
  470. // @Success 200 {object} models.HsbyMyPackage
  471. // @Failure 500 {object} app.Response
  472. // @Router /HSBY/QueryHsbyMyPackages [get]
  473. // @Tags 定制【海商报业】
  474. func QueryHsbyMyPackages(c *gin.Context) {
  475. appG := app.Gin{C: c}
  476. // 获取请求参数
  477. var req QueryHsbyMyPackagesReq
  478. if err := appG.C.ShouldBindQuery(&req); err != nil {
  479. logger.GetLogger().Errorf("QueryHsbyMyPackages failed: %s", err.Error())
  480. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  481. return
  482. }
  483. // 获取数据
  484. goodsInfo, err := models.GetHsbyMyPackages(req.AccountIDs, req.TakeOrderStatus)
  485. if err != nil {
  486. // 查询失败
  487. logger.GetLogger().Errorf("QueryHsbyMyPackages failed: %s", err.Error())
  488. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  489. return
  490. }
  491. // 查询成功返回
  492. logger.GetLogger().Debugln("QueryHsbyMyPackages successed: %v", goodsInfo)
  493. appG.Response(http.StatusOK, e.SUCCESS, goodsInfo)
  494. }
  495. // SetHsbyMyPackagesStatusReq 设置我的包裹已收货状态
  496. type SetHsbyMyPackagesStatusReq struct {
  497. TakeOrderID string `form:"takeOrderID" binding:"required"`
  498. AccountID int `form:"accountID" binding:"required"`
  499. }
  500. // SetHsbyMyPackagesStatus 设置我的包裹已收货状态
  501. // @Summary 设置我的包裹已收货状态
  502. // @Produce json
  503. // @Security ApiKeyAuth
  504. // @Param takeOrderID query string true "提货单号"
  505. // @Param accountID query int true "资金账号"
  506. // @Success 200 {object} app.Response
  507. // @Failure 500 {object} app.Response
  508. // @Router /HSBY/SetHsbyMyPackagesStatus [post]
  509. // @Tags 定制【海商报业】
  510. func SetHsbyMyPackagesStatus(c *gin.Context) {
  511. appG := app.Gin{C: c}
  512. // 获取请求参数
  513. var req SetHsbyMyPackagesStatusReq
  514. if err := appG.C.ShouldBind(&req); err != nil {
  515. logger.GetLogger().Errorf("SetHsbyMyPackagesStatus failed: %s", err.Error())
  516. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  517. return
  518. }
  519. // 3 - 已收货
  520. if err := models.SetHsbyMyPackagesStatus(req.TakeOrderID, req.AccountID, 3); err != nil {
  521. // 执行失败
  522. logger.GetLogger().Errorf("SetHsbyMyPackagesStatus failed: %s", err.Error())
  523. appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
  524. return
  525. }
  526. // 执行成功
  527. logger.GetLogger().Debugln("SetHsbyMyPackagesStatus successed: %v", "ok")
  528. appG.Response(http.StatusOK, e.SUCCESS, "")
  529. }