Some checks failed
		
		
	
	Build / build (push) Has been cancelled
				
			CodeQL / Analyze (go) (push) Has been cancelled
				
			build / Build (push) Has been cancelled
				
			GitHub Actions Mirror / mirror_to_gitee (push) Has been cancelled
				
			GitHub Actions Mirror / mirror_to_gitlab (push) Has been cancelled
				
			Issue Close Require / issue-close-require (push) Has been cancelled
				
			Issue Check Inactive / issue-check-inactive (push) Has been cancelled
				
			
		
			
				
	
	
		
			255 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			255 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package dto
 | |
| 
 | |
| import (
 | |
| 	"errors"
 | |
| 	"go-admin/app/admin/models"
 | |
| 	"go-admin/common/dto"
 | |
| 	common "go-admin/common/models"
 | |
| 	"go-admin/common/statuscode"
 | |
| 	"time"
 | |
| 
 | |
| 	"github.com/shopspring/decimal"
 | |
| )
 | |
| 
 | |
| type TmRechargeLogGetPageReq struct {
 | |
| 	dto.Pagination `search:"-"`
 | |
| 	Type           int `form:"type" search:"type:exact;column:type;table:tm_recharge_log"`
 | |
| 	Status         int `form:"status" search:"type:exact;column:status;table:tm_recharge_log"`
 | |
| 	PlatformId     int `form:"platformId" search:"type:exact;column:platform_id;table:tm_recharge_log"`
 | |
| 	TmRechargeLogOrder
 | |
| }
 | |
| 
 | |
| type TmRechargeLogOrder struct {
 | |
| 	Id      string `form:"idOrder"  search:"type:order;column:id;table:tm_platform"`
 | |
| 	PayTime string `form:"payTimeOrder"  search:"type:order;column:pay_time;table:tm_platform"`
 | |
| }
 | |
| 
 | |
| func (m *TmRechargeLogGetPageReq) GetNeedSearch() interface{} {
 | |
| 	return *m
 | |
| }
 | |
| 
 | |
| type TmRechargeLogInsertReq struct {
 | |
| 	Id             int             `json:"-" comment:"平台id"`
 | |
| 	MemberId       int             `json:"memberId" comment:"会员id"`
 | |
| 	PlatformId     int             `json:"platformId" comment:"平台id"`
 | |
| 	Amount         decimal.Decimal `json:"amount" comment:"充值金额"`
 | |
| 	TotalChars     int             `json:"totalChars" comment:"总字数"`
 | |
| 	ReceiveChannel string          `json:"receiveChannel" comment:"充值渠道"`
 | |
| 	Status         int             `json:"status" comment:"充值状态"`
 | |
| 
 | |
| 	common.ControlBy
 | |
| }
 | |
| 
 | |
| func (s *TmRechargeLogInsertReq) Generate(model *models.TmPlatform) {
 | |
| 	if s.Id == 0 {
 | |
| 		model.Model = common.Model{Id: s.Id}
 | |
| 	}
 | |
| 
 | |
| 	model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
 | |
| }
 | |
| 
 | |
| func (s *TmRechargeLogInsertReq) GetId() interface{} {
 | |
| 	return s.Id
 | |
| }
 | |
| 
 | |
| type TmRechargeLogListResp struct {
 | |
| 	Id       int             `json:"id"`
 | |
| 	ShowName string          `json:"showName"`
 | |
| 	Code     string          `json:"code"`
 | |
| 	Price    decimal.Decimal `json:"price"`
 | |
| }
 | |
| 
 | |
| // TmPlatformGetReq 功能获取请求参数
 | |
| type TmRechargeLogGetReq struct {
 | |
| 	Id int `uri:"id"`
 | |
| }
 | |
| 
 | |
| func (s *TmRechargeLogGetReq) GetId() interface{} {
 | |
| 	return s.Id
 | |
| }
 | |
| 
 | |
| // TmPlatformDeleteReq 功能删除请求参数
 | |
| type TmRechargeLogDeleteReq struct {
 | |
| 	Ids []int `json:"ids"`
 | |
| }
 | |
| 
 | |
| func (s *TmRechargeLogDeleteReq) GetId() interface{} {
 | |
| 	return s.Ids
 | |
| }
 | |
| 
 | |
| type TmRechargeLogResp struct {
 | |
| 	Id int `json:"id"`
 | |
| 
 | |
| 	OrderNo        string          `json:"orderNo"`
 | |
| 	Type           int             `json:"type"`
 | |
| 	MemberId       int             `json:"memberId"`
 | |
| 	UserId         int             `json:"userId"`
 | |
| 	PlatformId     int             `json:"platformId"`
 | |
| 	Amount         decimal.Decimal `json:"amount"`
 | |
| 	TotalChars     int             `json:"totalChars"`
 | |
| 	ReceiveChannel string          `json:"receiveChannel"`
 | |
| 	Status         int             `json:"status"`
 | |
| 	TxHash         string          `json:"txHash"`
 | |
| 	PayTime        string          `json:"payTime"`
 | |
| 	CreatedAt      string          `json:"createdAt"`
 | |
| }
 | |
| 
 | |
| // 后台-用户充值订单创建请求参数
 | |
| type TmRechargeCreateOrderReq struct {
 | |
| 	Type           int             `json:"type" comment:"充值类型 1-用户充值 2-平台充值"`
 | |
| 	MemberId       int             `json:"memberId" comment:"会员id"`
 | |
| 	UserId         int             `json:"userId" comment:"用户id"`
 | |
| 	PlatformId     int             `json:"platformId" comment:"平台id"`
 | |
| 	TotalChars     int             `json:"totalChars" comment:"总字数"`
 | |
| 	ReceiveChannel string          `json:"receiveChannel" comment:"充值渠道"`
 | |
| 	ReceiveAddress string          `json:"receiveAddress" comment:"充值地址"`
 | |
| 	TxHash         string          `json:"txHash" comment:"交易hash"`
 | |
| 	Amount         decimal.Decimal `json:"amount" comment:"充值金额"`
 | |
| 	ExpireDays     int             `json:"expireDays" comment:"过期天数"`
 | |
| 	common.ControlBy
 | |
| }
 | |
| 
 | |
| // 后台扣除字符
 | |
| type TmRechargeManageDeductReq struct {
 | |
| 	MemberId   int             `json:"memberId" comment:"会员id"`
 | |
| 	UserId     int             `json:"userId" comment:"用户id"`
 | |
| 	PlatformId int             `json:"platformId" comment:"平台id"`
 | |
| 	TotalChars decimal.Decimal `json:"totalChars" comment:"扣减字符"`
 | |
| }
 | |
| 
 | |
| func (e *TmRechargeManageDeductReq) Generate(entity *models.TmRechargeLog) error {
 | |
| 	if entity == nil {
 | |
| 		entity = &models.TmRechargeLog{}
 | |
| 	}
 | |
| 
 | |
| 	if e.MemberId <= 0 {
 | |
| 		return errors.New("会员不存在")
 | |
| 	}
 | |
| 
 | |
| 	if e.PlatformId <= 0 {
 | |
| 		return errors.New("平台不存在")
 | |
| 	}
 | |
| 
 | |
| 	entity.MemberId = e.MemberId
 | |
| 	entity.UserId = e.UserId
 | |
| 	entity.PlatformId = e.PlatformId
 | |
| 	entity.Type = 3
 | |
| 
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // 用户充值订单创建请求参数
 | |
| type CustomCreateOrderReq struct {
 | |
| 	UserId     int `json:"userId" comment:"用户id"`
 | |
| 	PlatformId int `json:"platformId" comment:"平台id"`
 | |
| 	Count      int `json:"count" comment:"购买数量"`
 | |
| }
 | |
| 
 | |
| func (e *CustomCreateOrderReq) Validate() int {
 | |
| 	if e.Count <= 0 {
 | |
| 		return statuscode.RechargeNumberMustBeGreaterThanZero
 | |
| 	}
 | |
| 
 | |
| 	if e.PlatformId <= 0 {
 | |
| 		return statuscode.PlatformNotSupport
 | |
| 	}
 | |
| 
 | |
| 	return statuscode.Success
 | |
| }
 | |
| 
 | |
| type CustomCreateOrderResp struct {
 | |
| 	OrderNo        string `json:"orderNo"`
 | |
| 	Amount         string `json:"amount"`
 | |
| 	BlockChain     string `json:"blockChain"`
 | |
| 	ReceiveAddress string `json:"receiveAddress"`
 | |
| 	ExpireUnix     int64  `json:"expireUnix" comment:"过期时间戳 秒"`
 | |
| }
 | |
| 
 | |
| func (e *TmRechargeCreateOrderReq) Validate() error {
 | |
| 	if e.ExpireDays <= 0 {
 | |
| 		return errors.New("过期天数必须大于0")
 | |
| 	}
 | |
| 
 | |
| 	if e.MemberId <= 0 {
 | |
| 		return errors.New("会员不存在")
 | |
| 	}
 | |
| 
 | |
| 	if e.PlatformId <= 0 {
 | |
| 		return errors.New("平台不存在")
 | |
| 	}
 | |
| 
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| func (e *TmRechargeCreateOrderReq) Generate(model *models.TmRechargeLog) {
 | |
| 	if model == nil {
 | |
| 		model = &models.TmRechargeLog{}
 | |
| 	}
 | |
| 
 | |
| 	model.PlatformId = e.PlatformId
 | |
| 	model.MemberId = e.MemberId
 | |
| 	model.UserId = e.UserId
 | |
| 	model.Type = e.Type
 | |
| 	model.TotalChars = e.TotalChars * 10000
 | |
| 	model.Amount = e.Amount
 | |
| 	model.Status = 1
 | |
| 	model.ReceiveChannel = e.ReceiveChannel
 | |
| 	model.ReceiveAddress = e.ReceiveAddress
 | |
| 	model.TxHash = e.TxHash
 | |
| 	model.CreateBy = e.CreateBy
 | |
| 	model.CreatedAt = time.Now()
 | |
| }
 | |
| 
 | |
| // 用户充值订单创建参数
 | |
| type TmRechargeLogInsertOrUpdateReq struct {
 | |
| 	MemberId       int    `json:"memberId" comment:"会员id"`
 | |
| 	PlatformId     int    `json:"platformId" comment:"平台id"`
 | |
| 	PlatformKey    string `json:"platformKey" comment:"平台key"`
 | |
| 	RemainCharater int    `json:"remainChars" comment:"剩余字数"`
 | |
| }
 | |
| 
 | |
| type TmRechargeLogFrontReq struct {
 | |
| 	PlatformId int `json:"platformId" query:"platformId" form:"platformId" comment:"平台id"`
 | |
| }
 | |
| 
 | |
| type TmRechargeLogFrontResp struct {
 | |
| 	Id             int    `json:"id"`
 | |
| 	OrderNo        string `json:"orderNo"`
 | |
| 	PlatformName   string `json:"platformName"`
 | |
| 	ExpireUnix     int64  `json:"expireUnix"`
 | |
| 	TotalCharater  int    `json:"totalCharater"`
 | |
| 	RemainCharater int    `json:"remainCharater"`
 | |
| }
 | |
| 
 | |
| // TRC20Transfer 结构体用于解析 TRC20 转账记录
 | |
| type TRC20Transfer struct {
 | |
| 	TransactionID string `json:"transaction_id"`
 | |
| 	BlockNumber   int64  `json:"block_number"`
 | |
| 	Timestamp     int64  `json:"block_timestamp"`
 | |
| 	FromAddress   string `json:"from"`
 | |
| 	ToAddress     string `json:"to"`
 | |
| 	Value         string `json:"value"`
 | |
| 	TokenInfo     struct {
 | |
| 		Symbol   string `json:"symbol"`
 | |
| 		Address  string `json:"address"`
 | |
| 		Decimals int    `json:"decimals"`
 | |
| 	} `json:"token_info"`
 | |
| }
 | |
| 
 | |
| type TmRechargeCallbackReq struct {
 | |
| 	PayableAmount decimal.Decimal `json:"payable_amount"`
 | |
| 	FromAddress   string          `json:"from_address"`
 | |
| 	ToAddress     string          `json:"to_address"`
 | |
| 	TxHash        string          `json:"tx_hash"`
 | |
| }
 | |
| 
 | |
| type TmRechargeLogGetOrderInfoReq struct {
 | |
| 	OrderNo string `json:"orderNo" form:"orderNo" query:"orderNo" comment:"订单号"`
 | |
| }
 | |
| 
 | |
| type TmRechargeLogGetOrderInfoResp struct {
 | |
| 	Id      int    `json:"id"`
 | |
| 	OrderNo string `json:"orderNo"`
 | |
| 	Status  int    `json:"status"`
 | |
| }
 |