aa
This commit is contained in:
38
controllers/sim_controller.go
Normal file
38
controllers/sim_controller.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.rosy.net.cn/jx-print/model"
|
||||||
|
"git.rosy.net.cn/jx-print/services"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetCardsInfo(c *gin.Context) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
tokenInfo *model.TokenInfo
|
||||||
|
param = &struct {
|
||||||
|
AppID int `json:"app_id" form:"app_id" binding:"required"`
|
||||||
|
PrintNo string `json:"print_no" form:"print_no"` //打印机编号
|
||||||
|
CardStatus int `json:"card_status" form:"card_status"` //卡状态(1.正常 2.停机 3.待激活)
|
||||||
|
IccID string `json:"icc_id" form:"icc_id"`
|
||||||
|
BeginDate string `json:"begin_date" form:"begin_date"` //卡到期时间段 2006-01-01
|
||||||
|
EndDate string `json:"end_date" form:"end_date"` //卡到期时间
|
||||||
|
Offset int `json:"offset" form:"offset"`
|
||||||
|
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||||
|
}{}
|
||||||
|
)
|
||||||
|
if err = c.ShouldBind(¶m); err != nil {
|
||||||
|
buildErrJson(c, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if tokenInfo = checkToken(c); tokenInfo == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = services.GetCardsInfo(tokenInfo, param.AppID, param.PrintNo, param.CardStatus, param.IccID, param.BeginDate, param.EndDate, param.Offset, param.PageSize)
|
||||||
|
return retVal, "", err
|
||||||
|
}) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -30,6 +30,9 @@ func Init(r *gin.Engine) {
|
|||||||
order := v2.Group("/order")
|
order := v2.Group("/order")
|
||||||
order.POST("/createOrder", controllers.CreateOrder)
|
order.POST("/createOrder", controllers.CreateOrder)
|
||||||
order.POST("/pay", controllers.Pay)
|
order.POST("/pay", controllers.Pay)
|
||||||
|
//sim
|
||||||
|
sim := v2.Group("/sim")
|
||||||
|
sim.GET("/getCardsInfo", controllers.GetCardsInfo)
|
||||||
|
|
||||||
//v1是不需要token的
|
//v1是不需要token的
|
||||||
v1 := r.Group("v1")
|
v1 := r.Group("v1")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/tibiotapi"
|
"git.rosy.net.cn/baseapi/platformapi/tibiotapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-print/dao"
|
"git.rosy.net.cn/jx-print/dao"
|
||||||
@@ -113,3 +114,34 @@ func FlowIncome(db *sqlx.DB, iccID string, flow float64, unit string, incomeType
|
|||||||
dao.Insert(db, flowIncome)
|
dao.Insert(db, flowIncome)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetCardsInfo(tokenInfo *model.TokenInfo, appID int, printNo string, cardStatus int, iccID, beginDate, endDate string, offset, pagiSize int) (cardInfo *tibiotapi.BatchQueryCardInfoResult, err error) {
|
||||||
|
var (
|
||||||
|
db = globals.GetDB()
|
||||||
|
)
|
||||||
|
if printNo != "" {
|
||||||
|
printers, _ := dao.GetPrinters(db, appID, printNo, 0, 0, 0)
|
||||||
|
if len(printers) == 0 {
|
||||||
|
err = fmt.Errorf("未在该应用下查到此打印机!app_id: %d, print_no: %s", appID, printNo)
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
iccID = printers[0].IccID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cardInfo, err = api.TibiotAPI.BatchQueryCardInfo(&tibiotapi.BatchQueryCardInfoParam{
|
||||||
|
CardStatus: cardStatus,
|
||||||
|
IccID: iccID,
|
||||||
|
BeginPackageTime: beginDate,
|
||||||
|
EndPackageTime: endDate,
|
||||||
|
PageNum: offset,
|
||||||
|
PageSize: pagiSize,
|
||||||
|
}); err == nil && cardInfo != nil {
|
||||||
|
for _, v := range cardInfo.Records {
|
||||||
|
if printer, err2 := dao.GetPrinter(db, "", v.Iccid); err2 == nil && printer != nil {
|
||||||
|
v.PrintNo = printer.PrintNo
|
||||||
|
v.Name = printer.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cardInfo, err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user