feat(app): update

This commit is contained in:
Yangtao
2025-11-19 14:24:13 +08:00
parent 1eac66d7fd
commit 0c34585649
329 changed files with 10760 additions and 281 deletions

View File

@ -0,0 +1,110 @@
package request
import (
"errors"
"gitea.ddegame.cn/open/servicebase/pkg/common/HyTools"
"gitea.ddegame.cn/open/servicebase/pkg/constant"
"gitea.ddegame.cn/open/servicebase/pkg/htools"
)
const (
PAY_TYPE_ALIPAY = "alipay"
PAY_TYPE_WEIXIN = "wxpay"
PAY_TYPE_IAP = "iap"
)
// 普通充值 微信 支付宝
type UserRechargeRequest struct {
BaseRequest
ProductId string
ProductPrice string
PayType string // 支付方式
RechargeChannel string // 充值渠道 1 = APP-iOS 2= APP-Android 3= 微信公众号 4= 支付宝服务窗 5=H5
CashAmount string // 自定义金额
}
// IAP充值
type IapRechargeRequest struct {
BaseRequest
ReceiptData string // 苹果支付成功返回的票据
TransactionId string // 本次支付的交易ID
}
// 普通充值 参数校验
func (request *UserRechargeRequest) CheckParameter() (err error) {
if len(request.AccessToken) == 0 {
err = errors.New("AccessToken不能为空")
return
}
if len(request.ProductId) == 0 {
err = errors.New("ProductId不能为空")
return
}
if len(request.ProductPrice) == 0 {
err = errors.New("ProductPrice不能为空")
return
}
if len(request.PayType) == 0 {
err = errors.New("PayType不能为空")
return
}
if len(request.RechargeChannel) == 0 {
err = errors.New("Platform不能为空")
return
}
platformInt := htools.StringToInt(request.RechargeChannel)
if platformInt < 1 || platformInt > 5 {
err = errors.New("Platform非法")
return
}
if request.PayType != PAY_TYPE_ALIPAY && request.PayType != PAY_TYPE_WEIXIN {
err = errors.New("PayType不合法")
return
}
// 自定义充值
if request.ProductId == constant.CustomerProductId {
if len(request.CashAmount) == 0 {
err = errors.New("自定义充值金额不能为空")
return
}
cash := HyTools.StringToInt(request.CashAmount)
if cash < 1 || cash > 80000 {
err = errors.New("自定义充值金额只能1到80000元")
return
}
}
return
}
// IAP充值 参数校验
func (request *IapRechargeRequest) CheckParameter() (err error) {
if len(request.AccessToken) == 0 {
err = errors.New("AccessToken不能为空")
return
}
if len(request.ReceiptData) == 0 {
err = errors.New("ReceiptData不能为空")
return
}
if len(request.TransactionId) == 0 {
err = errors.New("TransactionId不能为空")
return
}
return
}