chore: 初始开源发布
iotlcm-admin-svr:管理后台服务。 - Go module:iotlcm → git.5iot.com/iotlcm-public/iotlcm-admin-svr(729 文件) - 凭据与地址脱敏:JWT signingKey(含代码里的 MustGet 默认值)、 MySQL DSN、Redis 口令、告警邮件发件人邮箱全部改为占位; 私网 IP → 文档地址段;库名 xiujie_admin → iotlcm - 真实手机号/邮箱 → 合法 11 位编造号 / example.com - 移除内部资产:CI 触发器、过时 DDL(sql/db_iotlcm.sql)、 私有依赖 go get 行、明文 registry 登录口令 - 启动 banner 统一 IOTLCM 方块字 + 社区惯例署名 - Dockerfile 改用公共基础镜像 - 拼错的 RADEME.md → README.md,README 重写 - 需要真实数据库的用例改为可用 IOTLCM_TEST_WITH_DB=1 显式启用 - 补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes 数据库 schema 不随本仓发布(生产 DDL 已过时),README 已说明。
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
type AlipayConfig struct {
|
||||
AppId string `json:"appId" yaml:"appId"`
|
||||
PrivateKey string `json:"privateKey" yaml:"privateKey"`
|
||||
AlipayPublicKey string `json:"alipayPublicKey" yaml:"alipayPublicKey"`
|
||||
NotifyUrl string `json:"notifyUrl" yaml:"notifyUrl"`
|
||||
ReturnUrl string `json:"returnUrl" yaml:"returnUrl"`
|
||||
IsProduction bool `json:"isProduction" yaml:"isProduction"`
|
||||
}
|
||||
|
||||
type AlipayPayInput struct {
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
Subject string `json:"subject" dc:"订单标题" v:"required#订单标题不能为空"`
|
||||
TotalAmount string `json:"totalAmount" dc:"支付金额(元)" v:"required#支付金额不能为空"`
|
||||
PayType string `json:"payType" dc:"支付类型:page 电脑网站支付,wap 手机网站支付" d:"page"`
|
||||
BusinessType string `json:"businessType" dc:"业务类型:balanceRecharge 余额充值"`
|
||||
}
|
||||
|
||||
type AlipayPayOutput struct {
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
PayUrl string `json:"payUrl" dc:"支付链接"`
|
||||
}
|
||||
|
||||
type AlipayNotifyInput struct{}
|
||||
|
||||
type AlipayNotifyOutput struct{}
|
||||
|
||||
type AlipayReturnInput struct {
|
||||
RefundAmount string `json:"refundAmount" dc:"退款金额(元)" `
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号" `
|
||||
}
|
||||
|
||||
type AlipayReturnOutput struct {
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号"`
|
||||
TotalAmount string `json:"totalAmount" dc:"交易金额"`
|
||||
Message string `json:"message" dc:"消息"`
|
||||
}
|
||||
|
||||
type AlipayTradeQueryInput struct {
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号"`
|
||||
}
|
||||
|
||||
type AlipayTradeQueryOutput struct {
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号"`
|
||||
TradeStatus string `json:"tradeStatus" dc:"交易状态"`
|
||||
TotalAmount string `json:"totalAmount" dc:"交易金额"`
|
||||
BuyerLogonId string `json:"buyerLogonId" dc:"买家支付宝账号"`
|
||||
BuyerUserId string `json:"buyerUserId" dc:"买家支付宝用户ID"`
|
||||
BuyerOpenId string `json:"buyerOpenId" dc:"买家支付宝OpenID"`
|
||||
SendPayDate string `json:"sendPayDate" dc:"交易付款时间"`
|
||||
}
|
||||
|
||||
type AlipayRefundInput struct {
|
||||
OutRequestNo string `json:"outRequestNo" dc:"退款请求号" v:"required#退款请求号不能为空"`
|
||||
RefundReason string `json:"refundReason" dc:"退款原因"`
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号"`
|
||||
RefundAmount string `json:"refundAmount" dc:"退款金额(元)" v:"required#退款金额不能为空"`
|
||||
}
|
||||
|
||||
type AlipayRefundOutput struct {
|
||||
TradeNo string `json:"tradeNo" dc:"支付宝交易号"`
|
||||
OutTradeNo string `json:"outTradeNo" dc:"商户订单号"`
|
||||
BuyerLogonId string `json:"buyerLogonId" dc:"买家支付宝账号"`
|
||||
RefundFee string `json:"refundFee" dc:"退款总金额(元)"`
|
||||
}
|
||||
|
||||
var alipayRefundAmountPattern = regexp.MustCompile(`^(0|[1-9]\d{0,13})(\.\d{1,2})?$`)
|
||||
|
||||
// AlipayRefundModel is the validated data sent to the Alipay refund SDK.
|
||||
type AlipayRefundModel struct {
|
||||
OutTradeNo string
|
||||
TradeNo string
|
||||
OutRequestNo string
|
||||
RefundAmount string
|
||||
RefundReason string
|
||||
}
|
||||
|
||||
func (in *AlipayRefundInput) Normalize() (*AlipayRefundModel, error) {
|
||||
if in == nil {
|
||||
return nil, gerror.New("退款参数不能为空")
|
||||
}
|
||||
refund := &AlipayRefundModel{
|
||||
OutTradeNo: strings.TrimSpace(in.OutTradeNo),
|
||||
TradeNo: strings.TrimSpace(in.TradeNo),
|
||||
OutRequestNo: strings.TrimSpace(in.OutRequestNo),
|
||||
RefundAmount: strings.TrimSpace(in.RefundAmount),
|
||||
RefundReason: strings.TrimSpace(in.RefundReason),
|
||||
}
|
||||
if refund.OutTradeNo == "" && refund.TradeNo == "" {
|
||||
return nil, gerror.New("商户订单号和支付宝交易号不能同时为空")
|
||||
}
|
||||
if len(refund.OutTradeNo) > 64 || len(refund.TradeNo) > 64 {
|
||||
return nil, gerror.New("商户订单号或支付宝交易号长度不能超过64位")
|
||||
}
|
||||
if !alipayRefundAmountPattern.MatchString(refund.RefundAmount) || refund.RefundAmount == "0" || strings.HasPrefix(refund.RefundAmount, "0.") && strings.Trim(refund.RefundAmount, "0.") == "" {
|
||||
return nil, gerror.New("退款金额格式错误,金额必须大于0且最多两位小数")
|
||||
}
|
||||
if refund.OutRequestNo == "" {
|
||||
refund.OutRequestNo = refund.OutTradeNo
|
||||
if refund.OutRequestNo == "" {
|
||||
refund.OutRequestNo = refund.TradeNo
|
||||
}
|
||||
}
|
||||
return refund, nil
|
||||
}
|
||||
Reference in New Issue
Block a user