taaccount.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. package taaccount
  2. import (
  3. "mtp2_if/controllers/order"
  4. "mtp2_if/db"
  5. "mtp2_if/global/app"
  6. "mtp2_if/global/e"
  7. "mtp2_if/logger"
  8. "mtp2_if/models"
  9. "net/http"
  10. "strconv"
  11. "strings"
  12. "github.com/gin-gonic/gin"
  13. )
  14. // GetTaAccountsReq 获取资金账户请求参数
  15. type GetTaAccountsReq struct {
  16. LoginID int `form:"loginID" binding:"required"`
  17. TaAccountType int `form:"taAccountType"`
  18. }
  19. // GetTaAccounts 获取资金账户信息
  20. // @Summary 获取资金账户信息
  21. // @Produce json
  22. // @Security ApiKeyAuth
  23. // @Param loginID query int true "登录账户"
  24. // @Param taAccountType query int false "账号类型 - 1:外部账号 2:内部账号 3:内部做市自营账号 4:内部做市接单账号"
  25. // @Success 200 {object} models.Taaccount
  26. // @Failure 500 {object} app.Response
  27. // @Router /TaAccount/GetTaAccounts [get]
  28. // @Tags 资金账户
  29. func GetTaAccounts(c *gin.Context) {
  30. appG := app.Gin{C: c}
  31. // 获取请求参数
  32. var req GetTaAccountsReq
  33. if err := appG.C.ShouldBindQuery(&req); err != nil {
  34. logger.GetLogger().Errorf("GetTaAccounts failed: %s", err.Error())
  35. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  36. return
  37. }
  38. // 查询数据
  39. taAccounts, err := models.GetTaAccountsByLoginID(req.LoginID, req.TaAccountType)
  40. if err != nil {
  41. // 查询失败
  42. logger.GetLogger().Errorf("GetTaAccounts failed: %s", err.Error())
  43. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  44. return
  45. }
  46. // 如果是母账户,要从对冲外部资金账户表获取资金信息
  47. for i := range taAccounts {
  48. item := &taAccounts[i]
  49. if item.Ismain == 1 {
  50. hedgeOutTaAccount, _ := models.GetHedgeOutTaAccount(int(item.Accountid))
  51. if hedgeOutTaAccount != nil {
  52. item.Balance = hedgeOutTaAccount.Prebalance
  53. item.Currentbalance = hedgeOutTaAccount.Balance
  54. item.Usedmargin = hedgeOutTaAccount.Usedmargin
  55. item.Freezemargin = hedgeOutTaAccount.Freezemargin
  56. item.Freezecharge = hedgeOutTaAccount.Freezecharge
  57. item.Otherfreezemargin = hedgeOutTaAccount.Otherfreezemargin
  58. item.Inamount = hedgeOutTaAccount.Inamount
  59. item.Outamount = hedgeOutTaAccount.Outamount
  60. item.Paycharge = hedgeOutTaAccount.Paycharge
  61. item.Closepl = hedgeOutTaAccount.Closepl
  62. }
  63. }
  64. // 取币种小数位
  65. if item.Currencyid > 0 {
  66. var decimalplace int = 2
  67. currencyEnums, _ := models.GetEnumDicItem("currency", int(item.Currencyid))
  68. if len(currencyEnums) > 0 {
  69. num, err := strconv.Atoi(currencyEnums[0].Param1)
  70. if err == nil {
  71. decimalplace = num
  72. }
  73. }
  74. item.CurrencyDecimalplace = int32(decimalplace)
  75. }
  76. }
  77. if len(taAccounts) > 0 {
  78. // 查融资额
  79. var a models.InStrBuilder
  80. for i := range taAccounts {
  81. a.Add(taAccounts[i].Accountid)
  82. }
  83. mRemainAmount := models.QhjContractRemainAmount{FilterAccId: a.InStr()}
  84. if d, err := mRemainAmount.GetData(); err == nil {
  85. for _, v := range d {
  86. for i := range taAccounts {
  87. if v.ACCOUNTID == taAccounts[i].Accountid {
  88. taAccounts[i].REMAINAMOUNT = v.REMAINACOUNT
  89. }
  90. }
  91. }
  92. }
  93. // 查总市值
  94. if rst, bRet := order.GetTradePosition(a.InStr(), ""); bRet {
  95. for i := range taAccounts {
  96. for _, v := range rst {
  97. if taAccounts[i].Accountid == v.AccountID {
  98. taAccounts[i].CURAMOUNT += v.MarketAmount
  99. }
  100. }
  101. }
  102. }
  103. }
  104. // 查询成功
  105. logger.GetLogger().Debugln("GetTaAccounts successed: %v", taAccounts)
  106. appG.Response(http.StatusOK, e.SUCCESS, taAccounts)
  107. }
  108. // QueryAmountLogReq 资金流水查询(当前)请求参数
  109. type QueryAmountLogReq struct {
  110. app.PageInfo
  111. AccountID string `form:"accountID"` // 资金账户
  112. OperateType string `form:"operateType"` // 资金操作类型
  113. }
  114. // QueryAmountLogRsp 资金流水查询(当前)返回模型
  115. type QueryAmountLogRsp struct {
  116. models.Taaccountlog `xorm:"extends"`
  117. MarketName string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
  118. TradeMode uint32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
  119. GoodsCode string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  120. GoodsName string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  121. AGoodsCode string `json:"agoodscode" xorm:"'AGOODSCODE'"` // 竞拍商品代码
  122. AGoodsName string `json:"agoodsname" xorm:"'GOODSNAME'"` // 竞拍商品名称
  123. DGoodsCode string `json:"dgoodscode" xorm:"'DGOODSCODE'"` // 交割商品代码
  124. DGoodsName string `json:"dgoodsname" xorm:"'DGOODSNAME'"` // 交割商品名称
  125. OperateTypeName string `json:"operatetypename" xorm:"OPERATETYPENAME"` // 资金操作类型名称(显示)
  126. OPERATETYPENAMEEN string `json:"operatetypenameen" xorm:"'OPERATETYPENAMEEN'"` // 枚举项名称 - 英文
  127. OPERATETYPENAME_TW string `json:"operatetypename_tw" xorm:"'OPERATETYPENAME_TW'"` // 枚举项名称 - 繁体
  128. OPERATETYPENAMETH string `json:"operatetypenameth" xorm:"'OPERATETYPENAMETH'"` // 枚举项名称 - 泰文
  129. OPERATETYPENAMEVI string `json:"operatetypenamevi" xorm:"'OPERATETYPENAMEVI'"` // 枚举项名称 - 越南语
  130. }
  131. // QueryAmountLog 资金流水查询(当前)
  132. // @Summary 资金流水查询(当前)
  133. // @Produce json
  134. // @Security ApiKeyAuth
  135. // @Param page query int false "页码"
  136. // @Param pagesize query int false "每页条数"
  137. // @Param pageflag query int false "分页标志 0-page从0开始 1-page从1开始"
  138. // @Param accountID query string true "资金账户 - 格式:1,2,3"
  139. // @Param operateType query string false "资金操作类型 - 格式:1,2,3"
  140. // @Success 200 {object} QueryAmountLogRsp
  141. // @Failure 500 {object} app.Response
  142. // @Router /TaAccount/QueryAmountLog [get]
  143. // @Tags 资金账户
  144. // 参考通用查询:QueryClientAmountLog
  145. func QueryAmountLog(c *gin.Context) {
  146. appG := app.Gin{C: c}
  147. // 获取请求参数
  148. var req QueryAmountLogReq
  149. if err := appG.C.ShouldBindQuery(&req); err != nil {
  150. logger.GetLogger().Errorf("QueryAmountLog failed: %s", err.Error())
  151. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  152. return
  153. }
  154. // 查询数据
  155. datas := make([]QueryAmountLogRsp, 0)
  156. engine := db.GetEngine()
  157. accountIDs := strings.Split(req.AccountID, ",")
  158. // OPERATETYPENAME 显示时,旧的号段用operateType, 新的使用accountBusinessCode
  159. s := engine.Table("TAACCOUNTLOG").
  160. Join("INNER", "ENUMDICITEM", "ENUMDICITEM.ENUMITEMSTATUS = 1 and ENUMDICITEM.ENUMDICCODE = 'accountBusinessCode' and ENUMDICITEM.ENUMITEMNAME = TAACCOUNTLOG.BUSINESSCODE").
  161. Join("LEFT", "ENUMDICITEMEX", "ENUMDICITEM.ENUMDICCODE = ENUMDICITEMEX.ENUMDICCODE AND ENUMDICITEM.ENUMITEMNAME = ENUMDICITEMEX.ENUMITEMNAME").
  162. Join("LEFT", "ENUMDICITEM E", "E.ENUMDICCODE = 'operateType' and E.ENUMITEMNAME = TAACCOUNTLOG.OPERATETYPE").
  163. Join("LEFT", "ENUMDICITEMEX EX", "E.ENUMDICCODE = EX.ENUMDICCODE AND E.ENUMITEMNAME = EX.ENUMITEMNAME").
  164. Join("LEFT", "MARKET", "MARKET.MARKETID = TAACCOUNTLOG.MARKETID").
  165. Join("LEFT", "GOODS", "GOODS.GOODSID = TAACCOUNTLOG.GOODSID").
  166. Join("LEFT", "AUCTION_ORDERINFO", "AUCTION_ORDERINFO.GOODSID = TAACCOUNTLOG.GOODSID").
  167. Join("LEFT", "DELIVERYGOODS", "DELIVERYGOODS.DELIVERYGOODSID = TAACCOUNTLOG.GOODSID").
  168. Select(`to_char(TAACCOUNTLOG.RELATIONORDERID) as RELATIONORDERID, TAACCOUNTLOG.*,
  169. MARKET.MARKETNAME, MARKET.TRADEMODE,
  170. GOODS.GOODSCODE, GOODS.GOODSNAME,
  171. AUCTION_ORDERINFO.GOODSCODE AS AGOODSCODE, AUCTION_ORDERINFO.GOODSNAME AS AGOODSNAME,
  172. DELIVERYGOODS.DELIVERYGOODSCODE AS DGOODSCODE, DELIVERYGOODS.DELIVERYGOODSNAME AS DGOODSNAME,
  173. CASE
  174. WHEN (TAACCOUNTLOG.BUSINESSCODE > 700 AND TAACCOUNTLOG.BUSINESSCODE < 800) OR (TAACCOUNTLOG.BUSINESSCODE > 1900)
  175. THEN DECODE(TAACCOUNTLOG.BUSINESSCODE, NULL, '--', 0, '系统', ENUMDICITEM.ENUMDICNAME)
  176. ELSE
  177. DECODE(TAACCOUNTLOG.OPERATETYPE, NULL, '--', 0, '系统', E.ENUMDICNAME)
  178. END AS OPERATETYPENAME,
  179. CASE
  180. WHEN (TAACCOUNTLOG.BUSINESSCODE > 700 AND
  181. TAACCOUNTLOG.BUSINESSCODE < 800) OR
  182. (TAACCOUNTLOG.BUSINESSCODE > 1900) THEN
  183. DECODE(TAACCOUNTLOG.BUSINESSCODE,
  184. NULL,
  185. '--',
  186. 0,
  187. 'System',
  188. ENUMDICITEMEX.ENUMDICNAMEEN)
  189. ELSE
  190. DECODE(TAACCOUNTLOG.OPERATETYPE,
  191. NULL,
  192. '--',
  193. 0,
  194. 'System',
  195. EX.ENUMDICNAMEEN)
  196. END AS OPERATETYPENAMEEN,
  197. CASE
  198. WHEN (TAACCOUNTLOG.BUSINESSCODE > 700 AND
  199. TAACCOUNTLOG.BUSINESSCODE < 800) OR
  200. (TAACCOUNTLOG.BUSINESSCODE > 1900) THEN
  201. DECODE(TAACCOUNTLOG.BUSINESSCODE,
  202. NULL,
  203. '--',
  204. 0,
  205. 'System',
  206. ENUMDICITEMEX.ENUMDICNAMEZH_TW)
  207. ELSE
  208. DECODE(TAACCOUNTLOG.OPERATETYPE,
  209. NULL,
  210. '--',
  211. 0,
  212. 'System',
  213. EX.ENUMDICNAMEZH_TW)
  214. END AS OPERATETYPENAME_TW,
  215. CASE
  216. WHEN (TAACCOUNTLOG.BUSINESSCODE > 700 AND
  217. TAACCOUNTLOG.BUSINESSCODE < 800) OR
  218. (TAACCOUNTLOG.BUSINESSCODE > 1900) THEN
  219. DECODE(TAACCOUNTLOG.BUSINESSCODE,
  220. NULL,
  221. '--',
  222. 0,
  223. 'System',
  224. ENUMDICITEMEX.ENUMDICNAMEVI)
  225. ELSE
  226. DECODE(TAACCOUNTLOG.OPERATETYPE,
  227. NULL,
  228. '--',
  229. 0,
  230. 'System',
  231. EX.ENUMDICNAMEVI)
  232. END AS OPERATETYPENAMEVI,
  233. CASE
  234. WHEN (TAACCOUNTLOG.BUSINESSCODE > 700 AND
  235. TAACCOUNTLOG.BUSINESSCODE < 800) OR
  236. (TAACCOUNTLOG.BUSINESSCODE > 1900) THEN
  237. DECODE(TAACCOUNTLOG.BUSINESSCODE,
  238. NULL,
  239. '--',
  240. 0,
  241. 'System',
  242. ENUMDICITEMEX.ENUMDICNAMETH)
  243. ELSE
  244. DECODE(TAACCOUNTLOG.OPERATETYPE,
  245. NULL,
  246. '--',
  247. 0,
  248. 'System',
  249. EX.ENUMDICNAMETH)
  250. END AS OPERATETYPENAMETH`).
  251. // Where(fmt.Sprintf("TAACCOUNTLOG.AMOUNT <> 0 and TAACCOUNTLOG.ACCOUNTID in (%s)", req.AccountID)).
  252. Where("TAACCOUNTLOG.AMOUNT <> 0").
  253. In("TAACCOUNTLOG.ACCOUNTID", accountIDs).
  254. Desc("TAACCOUNTLOG.AUTOID")
  255. if len(req.OperateType) > 0 {
  256. // s = s.And(fmt.Sprintf("TAACCOUNTLOG.OPERATETYPE in (%s)", req.OperateType))
  257. operateTypes := strings.Split(req.OperateType, ",")
  258. s = s.In("TAACCOUNTLOG.OPERATETYPE", operateTypes)
  259. }
  260. if err := s.Find(&datas); err != nil {
  261. // 查询失败
  262. logger.GetLogger().Errorf("QueryAmountLog failed: %s", err.Error())
  263. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  264. return
  265. }
  266. // 查询成功返回
  267. if req.PageSize > 0 {
  268. // 分页
  269. var rst []QueryAmountLogRsp
  270. // 开始上标
  271. // 终端分页1开始
  272. p := req.Page
  273. if req.PageFlag != 0 {
  274. p -= 1
  275. if p < 0 {
  276. p = 0
  277. }
  278. }
  279. start := p * req.PageSize
  280. // 结束下标
  281. end := start + req.PageSize
  282. if start <= len(datas) {
  283. // 判断结束下标是否越界
  284. if end > len(datas) {
  285. end = len(datas)
  286. }
  287. rst = datas[start:end]
  288. } else {
  289. rst = datas[0:0]
  290. }
  291. logger.GetLogger().Debugln("QueryAmountLog successed: %v", rst)
  292. appG.ResponseByPage(http.StatusOK, e.SUCCESS, rst, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: len(datas)})
  293. } else {
  294. // 不分页
  295. logger.GetLogger().Debugln("QueryAmountLog successed: %v", datas)
  296. appG.Response(http.StatusOK, e.SUCCESS, datas)
  297. }
  298. }
  299. // QueryHisAmountLogReq 资金流水查询(历史)请求参数
  300. type QueryHisAmountLogReq struct {
  301. app.PageInfo
  302. AccountID string `form:"accountID"` // 资金账户
  303. OperateType string `form:"operateType"` // 资金操作类型
  304. StartDate string `form:"startDate"` // 开始时间
  305. EndDate string `form:"endDate"` // 结束时间
  306. }
  307. // QueryHisAmountLogRsp 资金流水查询(历史)返回模型
  308. type QueryHisAmountLogRsp struct {
  309. models.Histaaccountlog `xorm:"extends"`
  310. MarketName string `json:"marketname" xorm:"'MARKETNAME'"` // 市场名称
  311. TradeMode uint32 `json:"trademode" xorm:"'TRADEMODE'"` // 交易模式
  312. GoodsCode string `json:"goodscode" xorm:"'GOODSCODE'"` // 商品代码
  313. GoodsName string `json:"goodsname" xorm:"'GOODSNAME'"` // 商品名称
  314. AGoodsCode string `json:"agoodscode" xorm:"'AGOODSCODE'"` // 竞拍商品代码
  315. AGoodsName string `json:"agoodsname" xorm:"'GOODSNAME'"` // 竞拍商品名称
  316. DGoodsCode string `json:"dgoodscode" xorm:"'DGOODSCODE'"` // 交割商品代码
  317. DGoodsName string `json:"dgoodsname" xorm:"'DGOODSNAME'"` // 交割商品名称
  318. OperateTypeName string `json:"operatetypename" xorm:"OPERATETYPENAME"` // 资金操作类型名称(显示)
  319. }
  320. // QueryHisAmountLog 资金流水查询(历史)
  321. // @Summary 资金流水查询(历史)
  322. // @Produce json
  323. // @Security ApiKeyAuth
  324. // @Param page query int false "页码"
  325. // @Param pagesize query int false "每页条数"
  326. // @Param pageflag query int false "分页标志 0-page从0开始 1-page从1开始"
  327. // @Param accountID query string true "资金账户 - 格式:1,2,3"
  328. // @Param operateType query string false "资金操作类型 - 格式:1,2,3"
  329. // @Param startDate query string false "开始时间 - 闭区间,格式:yyyy-MM-dd"
  330. // @Param endDate query string false "结束时间 - 闭区间,格式:yyyy-MM-dd"
  331. // @Success 200 {object} QueryHisAmountLogRsp
  332. // @Failure 500 {object} app.Response
  333. // @Router /TaAccount/QueryHisAmountLog [get]
  334. // @Tags 资金账户
  335. // 参考通用查询:Client_QueryHis_taaccountlog
  336. func QueryHisAmountLog(c *gin.Context) {
  337. appG := app.Gin{C: c}
  338. // 获取请求参数
  339. var req QueryHisAmountLogReq
  340. if err := appG.C.ShouldBindQuery(&req); err != nil {
  341. logger.GetLogger().Errorf("QueryHisAmountLog failed: %s", err.Error())
  342. appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
  343. return
  344. }
  345. // 查询数据
  346. datas := make([]QueryHisAmountLogRsp, 0)
  347. engine := db.GetEngine()
  348. // OPERATETYPENAME 显示时,旧的号段用operateType, 新的使用accountBusinessCode
  349. s := engine.Table("HIS_TAACCOUNTLOG").
  350. Join("INNER", "ENUMDICITEM", "ENUMDICITEM.ENUMITEMSTATUS = 1 and ENUMDICITEM.ENUMDICCODE = 'accountBusinessCode' and ENUMDICITEM.ENUMITEMNAME = HIS_TAACCOUNTLOG.BUSINESSCODE").
  351. Join("LEFT", "ENUMDICITEM E", "E.ENUMDICCODE = 'operateType' and E.ENUMITEMNAME = HIS_TAACCOUNTLOG.OPERATETYPE").
  352. Join("LEFT", "MARKET", "MARKET.MARKETID = HIS_TAACCOUNTLOG.MARKETID").
  353. Join("LEFT", "GOODS", "GOODS.GOODSID = HIS_TAACCOUNTLOG.GOODSID").
  354. Join("LEFT", "HIS_AUCTION_ORDERINFO", "HIS_AUCTION_ORDERINFO.GOODSID = HIS_TAACCOUNTLOG.GOODSID and HIS_AUCTION_ORDERINFO.ISVALIDDATA = 1").
  355. Join("LEFT", "DELIVERYGOODS", "DELIVERYGOODS.DELIVERYGOODSID = HIS_TAACCOUNTLOG.GOODSID").
  356. Select(`to_char(HIS_TAACCOUNTLOG.RELATIONORDERID) as RELATIONORDERID, HIS_TAACCOUNTLOG.*,
  357. MARKET.MARKETNAME, MARKET.TRADEMODE,
  358. GOODS.GOODSCODE, GOODS.GOODSNAME,
  359. HIS_AUCTION_ORDERINFO.GOODSCODE AS AGOODSCODE, HIS_AUCTION_ORDERINFO.GOODSNAME AS AGOODSNAME,
  360. DELIVERYGOODS.DELIVERYGOODSCODE AS DGOODSCODE, DELIVERYGOODS.DELIVERYGOODSNAME AS DGOODSNAME,
  361. CASE
  362. WHEN (HIS_TAACCOUNTLOG.BUSINESSCODE > 700 AND HIS_TAACCOUNTLOG.BUSINESSCODE < 800) OR (HIS_TAACCOUNTLOG.BUSINESSCODE > 1900)
  363. THEN DECODE(HIS_TAACCOUNTLOG.BUSINESSCODE, NULL, '--', 0, '系统', ENUMDICITEM.ENUMDICNAME)
  364. ELSE
  365. DECODE(HIS_TAACCOUNTLOG.OPERATETYPE, NULL, '--', 0, '系统', E.ENUMDICNAME)
  366. END AS OPERATETYPENAME`).
  367. Where("HIS_TAACCOUNTLOG.ISVALIDDATA = 1 and HIS_TAACCOUNTLOG.AMOUNT <> 0").
  368. In("HIS_TAACCOUNTLOG.ACCOUNTID", strings.Split(req.AccountID, ",")).
  369. Desc("HIS_TAACCOUNTLOG.AUTOID")
  370. if len(req.OperateType) > 0 {
  371. s = s.In("HIS_TAACCOUNTLOG.OPERATETYPE", strings.Split(req.OperateType, ","))
  372. }
  373. if len(req.StartDate) > 0 {
  374. // s = s.And("to_date(HIS_TAACCOUNTLOG.HISTRADEDATE,'yyyyMMdd') >= to_date(?,'yyyy-MM-dd')", req.StartDate)
  375. s = s.And("HIS_TAACCOUNTLOG.HISTRADEDATE >= ?", strings.Replace(req.StartDate, "-", "", -1))
  376. }
  377. if len(req.EndDate) > 0 {
  378. // s = s.And("to_date(HIS_TAACCOUNTLOG.HISTRADEDATE,'yyyyMMdd') <= to_date(?,'yyyy-MM-dd')", req.EndDate)
  379. s = s.And("HIS_TAACCOUNTLOG.HISTRADEDATE <= ?", strings.Replace(req.EndDate, "-", "", -1))
  380. }
  381. if err := s.Find(&datas); err != nil {
  382. // 查询失败
  383. logger.GetLogger().Errorf("QueryHisAmountLog failed: %s", err.Error())
  384. appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
  385. return
  386. }
  387. // 查询成功返回
  388. if req.PageSize > 0 {
  389. // 分页
  390. var rst []QueryHisAmountLogRsp
  391. // 开始上标
  392. // 终端分页1开始
  393. p := req.Page
  394. if req.PageFlag != 0 {
  395. p -= 1
  396. if p < 0 {
  397. p = 0
  398. }
  399. }
  400. start := p * req.PageSize
  401. // 结束下标
  402. end := start + req.PageSize
  403. if start <= len(datas) {
  404. // 判断结束下标是否越界
  405. if end > len(datas) {
  406. end = len(datas)
  407. }
  408. rst = datas[start:end]
  409. } else {
  410. rst = datas[0:0]
  411. }
  412. logger.GetLogger().Debugln("QueryHisAmountLog successed: %v", rst)
  413. appG.ResponseByPage(http.StatusOK, e.SUCCESS, rst, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: len(datas)})
  414. } else {
  415. // 不分页
  416. logger.GetLogger().Debugln("QueryHisAmountLog successed: %v", datas)
  417. appG.Response(http.StatusOK, e.SUCCESS, datas)
  418. }
  419. }
  420. // QueryRelatedTaAccount
  421. // @Summary 查询关联资金账户信息
  422. // @Produce json
  423. // @Security ApiKeyAuth
  424. // @Param relateduserid query int true "关联UserID"
  425. // @Success 200 {array} models.RelatedTaAccount
  426. // @Failure 500 {object} app.Response
  427. // @Router /TaAccount/QueryRelatedTaAccount [get]
  428. // @Tags 资金账户
  429. func QueryRelatedTaAccount(c *gin.Context) {
  430. a := app.GinUtils{Gin: app.Gin{C: c}}
  431. m := models.RelatedTaAccount{}
  432. a.DoBindReq(&m)
  433. a.DoGetDataI(&m)
  434. }
  435. // GetGtwithholdsigninfo
  436. // @Summary 获取代扣签约信息表
  437. // @Produce json
  438. // @Param userid query int true "用户ID"
  439. // @Success 200 {array} models.Gtwithholdsigninfo
  440. // @Failure 500 {object} app.Response
  441. // @Router /TaAccount/GetGtwithholdsigninfo [get]
  442. // @Tags 资金账户
  443. func GetGtwithholdsigninfo(c *gin.Context) {
  444. a := app.GinUtils{Gin: app.Gin{C: c}}
  445. m := models.Gtwithholdsigninfo{}
  446. a.DoBindReq(&m)
  447. a.DoGetDataEx(&m)
  448. }
  449. // QueryTHJFriends
  450. // @Summary 查询代扣入金申请表
  451. // @Produce json
  452. // @Security ApiKeyAuth
  453. // @Param userid query int true "用户ID"
  454. // @Param begindate query string false "开始交易日(yyyymmdd)"
  455. // @Param enddate query string false "结束交易日(yyyymmdd)"
  456. // @Param billresult query int false "批扣结果 - 0-扣费成功、1-扣费失败"
  457. // @Param page query int false "页码"
  458. // @Param pagesize query int false "每页条数"
  459. // @Success 200 {array} models.Gtwithholddepositapply
  460. // @Failure 500 {object} app.Response
  461. // @Router /TaAccount/QueryGtwithholddepositapply [get]
  462. // @Tags 资金账户
  463. func QueryGtwithholddepositapply(c *gin.Context) {
  464. a := app.GinUtils{Gin: app.Gin{C: c}}
  465. m := models.Gtwithholddepositapply{}
  466. a.DoBindReq(&m)
  467. a.DoGetDataByPage(&m)
  468. }