214 lines
6.3 KiB
Go
214 lines
6.3 KiB
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/api/enterprise/controller/user"
|
|
"SciencesServer/app/basic/api"
|
|
"SciencesServer/app/session"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type User struct{}
|
|
|
|
type ()
|
|
|
|
func (*User) Info(c *gin.Context) {
|
|
data := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).Info()
|
|
api.APISuccess(data)(c)
|
|
}
|
|
|
|
func (*User) BindMobile(c *gin.Context) {
|
|
form := &struct {
|
|
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
|
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewInstance()(api.GetSession()(c).(*session.Enterprise)).BindMobile(form.Mobile, form.Captcha)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) IdentityBasic(c *gin.Context) {
|
|
data, err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Basic()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) IdentityDetail(c *gin.Context) {
|
|
data, err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Detail()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) IdentitySwitch(c *gin.Context) {
|
|
form := &struct {
|
|
Identity int `json:"identity" form:"identity" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewIdentity()(api.GetSession()(c).(*session.Enterprise)).Switch(form.Identity)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) Back(c *gin.Context) {
|
|
data, err := user.NewBank()(api.GetSession()(c).(*session.Enterprise)).List()
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) BackBind(c *gin.Context) {
|
|
form := &struct {
|
|
Name string `json:"name" form:"name" binding:"required"`
|
|
IDCard string `json:"id_card" form:"id_card" binding:"required"`
|
|
BackCard string `json:"back_card" form:"back_card" binding:"required"`
|
|
BackName string `json:"back_name" form:"back_name" binding:"required"`
|
|
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewBank()(api.GetSession()(c).(*session.Enterprise)).Bind(&user.BankParams{
|
|
Name: form.Name, IDCard: form.IDCard, BankCard: form.BackCard, BankName: form.BackName,
|
|
}, form.Captcha)
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) BackUnbind(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewBank()(api.GetSession()(c).(*session.Enterprise)).Unbind(form.Convert())
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) Bill(c *gin.Context) {
|
|
form := &struct {
|
|
OrderNo string `json:"order_no" form:"order_no"`
|
|
CreatedAt string `json:"created_at" form:"created_at"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewBill()(api.GetSession()(c).(*session.Enterprise)).Instance(form.OrderNo, form.CreatedAt,
|
|
form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) BillTicket(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewBill()(api.GetSession()(c).(*session.Enterprise)).Ticket(form.Convert())
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) BillTicketIssue(c *gin.Context) {
|
|
form := &struct {
|
|
api.IDStringForm
|
|
Kind int `json:"kind" form:"kind" binding:"required"`
|
|
Name string `json:"name" form:"name" binding:"required"`
|
|
DutyParagraph string `json:"duty_paragraph" form:"duty_paragraph" binding:"required"`
|
|
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
|
Email string `json:"email" form:"email" binding:"required"`
|
|
Address string `json:"address" form:"address"`
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewBill()(api.GetSession()(c).(*session.Enterprise)).TicketIssue(form.Convert(), &user.BillTicketParams{
|
|
Kind: form.Kind, Name: form.Name, DutyParagraph: form.DutyParagraph, Mobile: form.Mobile,
|
|
Email: form.Email, Address: form.Address,
|
|
})
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
func (*User) Consume(c *gin.Context) {
|
|
form := &struct {
|
|
Source int `json:"source" form:"source"`
|
|
CreatedAt string `json:"created_at" form:"created_at"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewConsume()(api.GetSession()(c).(*session.Enterprise), "").Instance(form.Source,
|
|
form.CreatedAt, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) ConsumeExchange(c *gin.Context) {
|
|
form := &struct {
|
|
OrderNo string `json:"order_no" form:"order_no"`
|
|
CreatedAt string `json:"created_at" form:"created_at"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewConsume()(api.GetSession()(c).(*session.Enterprise), "").Exchange(form.OrderNo,
|
|
form.CreatedAt, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) ConsumeDelete(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewConsume()(api.GetSession()(c).(*session.Enterprise), "").Delete(form.Convert())
|
|
api.APIResponse(err)(c)
|
|
}
|
|
|
|
// 提现管理
|
|
|
|
func (*User) Withdrawal(c *gin.Context) {
|
|
form := &struct {
|
|
Status int `json:"status" form:"status"`
|
|
CreatedAt string `json:"created_at" form:"created_at"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewWithdrawal()(api.GetSession()(c).(*session.Enterprise)).Instance(form.Status,
|
|
form.CreatedAt, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) WithdrawalTransfer(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := user.NewWithdrawal()(api.GetSession()(c).(*session.Enterprise)).Transfer(form.Convert())
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*User) WithdrawalDelete(c *gin.Context) {
|
|
form := new(api.IDStringForm)
|
|
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := user.NewWithdrawal()(api.GetSession()(c).(*session.Enterprise)).Delete(form.Convert())
|
|
api.APIResponse(err)(c)
|
|
}
|