|
|
@@ -10,12 +10,13 @@ import (
|
|
|
"github.com/gin-gonic/gin"
|
|
|
)
|
|
|
|
|
|
-// GoodsQueryReq 商品查询请求
|
|
|
+// AccountQueryReq 账户查询请求
|
|
|
type AccountQueryReq struct {
|
|
|
Token string `json:"token" binding:"required"`
|
|
|
AccountID int `json:"accountid" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+// AccountQueryRsp 账户查询响应
|
|
|
type AccountQueryRsp struct {
|
|
|
Accountid int `json:"accountid" binding:"required"`
|
|
|
Userid int `json:"userid" binding:"required"`
|
|
|
@@ -24,6 +25,7 @@ type AccountQueryRsp struct {
|
|
|
Changetime time.Time `json:"changetime" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+// Taaccount 账户表结构定义
|
|
|
type Taaccount struct {
|
|
|
Accountid int `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"`
|
|
|
Userid int `json:"userid" xorm:"'USERID'" binding:"required"`
|
|
|
@@ -32,6 +34,7 @@ type Taaccount struct {
|
|
|
Changetime time.Time `json:"changetime" xorm:"'CHANGETIME'" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+// Reckondaytaaccount 账户结算日照表结构定义
|
|
|
type Reckondaytaaccount struct {
|
|
|
Accountid int `json:"accountid" xorm:"'ACCOUNTID'" binding:"required"`
|
|
|
Userid int `json:"userid" xorm:"'USERID'" binding:"required"`
|
|
|
@@ -40,25 +43,35 @@ type Reckondaytaaccount struct {
|
|
|
Reckondate string `json:"reckondate" xorm:"'RECKONDATE'" binding:"required"`
|
|
|
}
|
|
|
|
|
|
+// TableName 返回表名接口
|
|
|
func (Taaccount) TableName() string {
|
|
|
return "TAACCOUNT"
|
|
|
}
|
|
|
|
|
|
+// TableName 返回表名接口
|
|
|
func (Reckondaytaaccount) TableName() string {
|
|
|
return "RECKON_DAYTAACCOUNT"
|
|
|
}
|
|
|
|
|
|
-func GetReckonAccount(c *gin.Context) {
|
|
|
+// GetAccount 获取账户接口
|
|
|
+func GetAccount(c *gin.Context) {
|
|
|
var account AccountQueryReq
|
|
|
err := c.ShouldBind(&account)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
}
|
|
|
|
|
|
+ var ok bool
|
|
|
+ ok, err = token.CheckToken(account.AccountID, account.Token)
|
|
|
+ if err != nil || !ok {
|
|
|
+ c.JSON(http.StatusBadRequest, gin.H{"token check failed": err.Error()})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
engine := db.GetEngine()
|
|
|
|
|
|
- accountinfo := new(Reckondaytaaccount)
|
|
|
- has, err := engine.Where("accountid=?", account.AccountID).And("reckondate=?", "20200314").Get(accountinfo)
|
|
|
+ accountinfo := new(Taaccount)
|
|
|
+ has, err := engine.Where("accountid=?", account.AccountID).Get(accountinfo)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
return
|
|
|
@@ -74,28 +87,23 @@ func GetReckonAccount(c *gin.Context) {
|
|
|
Userid: accountinfo.Userid,
|
|
|
Currencyid: accountinfo.Currencyid,
|
|
|
Changeflag: accountinfo.Changeflag,
|
|
|
+ Changetime: accountinfo.Changetime,
|
|
|
}
|
|
|
c.SecureJSON(http.StatusOK, ret)
|
|
|
}
|
|
|
|
|
|
-func GetAccount(c *gin.Context) {
|
|
|
+// GetReckonAccount 获取日照账户接口
|
|
|
+func GetReckonAccount(c *gin.Context) {
|
|
|
var account AccountQueryReq
|
|
|
err := c.ShouldBind(&account)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
}
|
|
|
|
|
|
- var ok bool
|
|
|
- ok, err = token.CheckToken(account.AccountID, account.Token)
|
|
|
- if err != nil || !ok {
|
|
|
- c.JSON(http.StatusBadRequest, gin.H{"token check failed": err.Error()})
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
engine := db.GetEngine()
|
|
|
|
|
|
- accountinfo := new(Taaccount)
|
|
|
- has, err := engine.Where("accountid=?", account.AccountID).Get(accountinfo)
|
|
|
+ accountinfo := new(Reckondaytaaccount)
|
|
|
+ has, err := engine.Where("accountid=?", account.AccountID).And("reckondate=?", "20200314").Get(accountinfo)
|
|
|
if err != nil {
|
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
|
return
|
|
|
@@ -111,7 +119,6 @@ func GetAccount(c *gin.Context) {
|
|
|
Userid: accountinfo.Userid,
|
|
|
Currencyid: accountinfo.Currencyid,
|
|
|
Changeflag: accountinfo.Changeflag,
|
|
|
- Changetime: accountinfo.Changetime,
|
|
|
}
|
|
|
c.SecureJSON(http.StatusOK, ret)
|
|
|
}
|