Commit 68357129 authored by wangp's avatar wangp

delete

parent cf805d41
# 声明镜像来源为golang:alpine
FROM golang:latest
# 设置环境变量GO111MODULE为on
ENV GO111MODULE=on
# 设置环境变量GOPROXY为https://goproxy.io,direct
ENV GOPROXY=https://goproxy.cn,direct
# 声明工作目录
WORKDIR /go/src/system_pay
# 拷贝当前工程代码到工作目录
COPY . .
# go env为查看go的环境变量, go build -o server . 为打包项目,二进制
RUN go env && go mod tidy && go build -o server .
# ======= 以下为多阶段构建 =======
# 声明镜像来源为alpine:latest
FROM alpine:latest
ENV TZ=Asia/Shanghai
RUN echo "http://mirrors.aliyun.com/alpine/v3.4/main/" > /etc/apk/repositories \
&& apk --no-cache add tzdata zeromq \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo '$TZ' > /etc/timezone
# 声明工作目录
WORKDIR /go/src/system_pay
# 拷贝打包好的server二进制文件到当前工作目录
COPY --from=0 /go/src/system_pay/server ./
# 拷贝配置文件到当前工作目录
COPY --from=0 /go/src/system_pay/conf ./conf
# 运行打包好的二进制
ENTRYPOINT ./server
\ No newline at end of file
# system_pay
拉卡拉支付系统
-----------
后端仓库 (基于go语言)
\ No newline at end of file
#测试环境
appname = system_pay
runmode = dev
[dev]
autorender = false
copyrequestbody = true
EnableDocs = true
httpport = 14999
sessionon = true
#数据库配置
dbhost = 39.96.85.45
dbport = 3307
dbuser = root
dbpassword = abc123456
dbname = dbc_shop
dbprefix = ecm_
#token秘钥
SecretKey = dbcaespassword00
token = dev-dbc-auth-token
#日志配置
filepath = "./logs"
maxlines = 1000
maxsize = 10240
#图片上传目录
UPLOAD_DIR = "credit_shop"
MAX_FILE_SIZE = 50000000
IMAGE_TYPES = "(jpg|jpeg|png|pdf|gif|zip|rar)"
ACCEPT_FILE_TYPES = IMAGE_TYPES
#OSS配置
OSS_URL = "https://dbc-static.oss-cn-beijing.aliyuncs.com/"
accessKeyID = "LTAIDfwPBC9AnsRt"
accessKeySecret = "Z6FtUptrAk0Sl6H8vrVBGZLbBzXEpO"
endPoint = "oss-cn-beijing.aliyuncs.com"
bucket = "dbc-static"
#e签宝
PROJECT_ID = "7438819206"
PROJECT_SECRET = "64c6e023ee98c82a1a7180107c320d08"
API_HOST = "https://smlo.tsign.cn/opentreaty-service/"
AddPersonUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/person"
AddOrganizeUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/organize/common"
SilentSignUrl = "https://smlo.tsign.cn/opentreaty-service/account/platform/silentsign"
GetUploadurl = "https://smlo.tsign.cn/opentreaty-service/file/uploadurl"
CreateByFileKeyUrl = "https://smlo.tsign.cn/opentreaty-service/template/createbyfilekey"
CreateByTemplateUrl = "https://smlo.tsign.cn/opentreaty-service/doc/createbytemplate"
AddProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/addProcess"
flowGetViewUrl = "https://smlo.tsign.cn/opentreaty-service/flow/get/viewurl"
UserSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/userSignTask"
PlatformSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/platformSignTask"
ArchiveProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/archiveProcess"
OrganAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/orgAuth"
InfoAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/infoAuth-special"
AccessTokenUrl = "https://smlopenapi.esign.cn/v1/oauth2/access_token?appId=7438819206&secret=64c6e023ee98c82a1a7180107c320d08&grantType=client_credentials"
SignflowsUrl = "https://smlopenapi.esign.cn/v1/signflows/"
#短信配置
SMSNAME = dbc
SMSPWD = Dbc38590
EPID = 125060
SIGN = 【谛宝多多】
#IP = 114.255.71.158:8061
IP = "https://tsms.pet-dbc.cn/v1/send"
AESKEY = "dbc2021888000000"
AREACODE = "86"
#退出跳转域名配置
SHOP_HOST = "https://test.pet-dbc.cn"
SHOP_HOST_ADMIN = "https://tadmin.pet-dbc.cn/credit/user"
#es配置
EsUrl = "http://39.97.239.70:9200"
; EsUrl = "http://39.97.234.228:9200"
Index = dev_shop_index
AuthPwd = dbc123456
UserName = shop_search_development
PassWord = dbc_ssdp123
; UserName = elastic
; PassWord = dbc_default_password
#支付配置
frontRedirectUrl = "https://test.pet-dbc.cn/uni/pages/wxpay/wxpay"
backRedirectUrl = "https://test.pet-dbc.cn/uni/api/repayment/RedirectAuth"
payCallBack = "https://test.pet-dbc.cn/uni/api/repayment/PayCallBack"
unifiedOrder = "https://tpay.pet-dbc.cn/v1/pay/unified_order"
backRedirectUrl_month = "https://test.pet-dbc.cn/uni/api/month_repayment/RedirectAuth"
payCallBack_month = "https://test.pet-dbc.cn/uni/api/month_repayment/PayCallBack"
returnUrl = "https://test.pet-dbc.cn"
#微信配置-支付
AppID = wxfb03eda5412dcaae
AppSecret = 10932abb8ca4448d98c52548b321eb2b
#微信配置-分享
AppID_SHARE = wx236414cabd51aefb
AppSecret_SHARE = 454585c9e2d87d64583848e5dbbec290
#微信配置-小程序
AppID_APPLET = wx6ff40a576e2f4ca0
AppSecret_APPLET = 6756d3f0b6b052dab40beb78bc89291d
#微信分享
AccessTokenHost = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx236414cabd51aefb&secret=454585c9e2d87d64583848e5dbbec290"
JsAPITicketHost = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
#阿里云 - 全国快递物流查询
AppCode = 6d1da9eb15b540688a505c1814e0c25f
TimeDuration = 7200
#谛宠有品
DCYP_HOST = "https://tmall.pet-dbc.cn/"
#CRM
CRM_HOST = "https://tcrm.pet-dbc.cn"
#镜像环境
appname = system_pay
runmode = dev
[dev]
autorender = false
copyrequestbody = true
EnableDocs = true
httpport = 9193
sessionon = true
#数据库配置
dbhost = 39.96.85.45
dbport = 3307
dbuser = root
dbpassword = abc123456
dbname = jingxiang_shop
dbprefix = ecm_
#token秘钥
SecretKey = dbcaespassword00
token = mirror-dbc-auth-token
#日志配置
filepath = "logs/"
maxlines = 1000
maxsize = 10240
#图片上传目录
UPLOAD_DIR = "credit_shop"
MAX_FILE_SIZE = 50000000
IMAGE_TYPES = "(jpg|jpeg|png|pdf|gif|zip|rar)"
ACCEPT_FILE_TYPES = IMAGE_TYPES
#OSS配置
OSS_URL = "https://dbc-static.oss-cn-beijing.aliyuncs.com/"
accessKeyID = "LTAIDfwPBC9AnsRt"
accessKeySecret = "Z6FtUptrAk0Sl6H8vrVBGZLbBzXEpO"
endPoint = "oss-cn-beijing.aliyuncs.com"
bucket = "dbc-static"
#e签宝
PROJECT_ID = "7438819206"
PROJECT_SECRET = "64c6e023ee98c82a1a7180107c320d08"
API_HOST = "https://smlo.tsign.cn/opentreaty-service/"
AddPersonUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/person"
AddOrganizeUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/organize/common"
SilentSignUrl = "https://smlo.tsign.cn/opentreaty-service/account/platform/silentsign"
GetUploadurl = "https://smlo.tsign.cn/opentreaty-service/file/uploadurl"
CreateByFileKeyUrl = "https://smlo.tsign.cn/opentreaty-service/template/createbyfilekey"
CreateByTemplateUrl = "https://smlo.tsign.cn/opentreaty-service/doc/createbytemplate"
AddProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/addProcess"
flowGetViewUrl = "https://smlo.tsign.cn/opentreaty-service/flow/get/viewurl"
UserSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/userSignTask"
PlatformSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/platformSignTask"
ArchiveProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/archiveProcess"
OrganAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/orgAuth"
InfoAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/infoAuth-special"
AccessTokenUrl = "https://smlopenapi.esign.cn/v1/oauth2/access_token?appId=7438819206&secret=64c6e023ee98c82a1a7180107c320d08&grantType=client_credentials"
SignflowsUrl = "https://smlopenapi.esign.cn/v1/signflows/"
#短信配置
SMSNAME = dbc
SMSPWD = Dbc38590
EPID = 125060
SIGN = 【谛宝多多】
#IP = 114.255.71.158:8061
IP = "https://tsms.pet-dbc.cn/v1/send"
AESKEY = "dbc2021888000000"
AREACODE = "86"
#退出跳转域名配置
SHOP_HOST = "https://jingxiang.pet-dbc.cn"
SHOP_HOST_ADMIN = "https://jxadmin.pet-dbc.cn/credit/user"
#es配置
EsUrl = "http://39.97.239.70:9200"
Index = dev_shop_index
AuthPwd = dbc123456
UserName = shop_search_development
PassWord = dbc_ssdp
#支付配置
frontRedirectUrl = "https://jingxiang.pet-dbc.cn/uni/pages/wxpay/wxpay"
backRedirectUrl = "https://jingxiang.pet-dbc.cn/uni/api/repayment/RedirectAuth"
payCallBack = "https://jingxiang.pet-dbc.cn/uni/api/repayment/PayCallBack"
unifiedOrder = "https://test.pay.pet-dbc.cn/v1/pay/unified_order"
backRedirectUrl_month = "https://jingxiang.pet-dbc.cn/uni/api/month_repayment/RedirectAuth"
payCallBack_month = "https://jingxiang.pet-dbc.cn/uni/api/month_repayment/PayCallBack"
returnUrl = "https://jingxiang.pet-dbc.cn"
#微信配置-支付
AppID = wxfb03eda5412dcaae
AppSecret = 10932abb8ca4448d98c52548b321eb2b
#微信配置-分享
AppID_SHARE = wx236414cabd51aefb
AppSecret_SHARE = 454585c9e2d87d64583848e5dbbec290
#微信配置-小程序
AppID_APPLET = wx6ff40a576e2f4ca0
AppSecret_APPLET = 6756d3f0b6b052dab40beb78bc89291d
#微信分享
AccessTokenHost = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx236414cabd51aefb&secret=454585c9e2d87d64583848e5dbbec290"
JsAPITicketHost = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
#阿里云 - 全国快递物流查询
AppCode = 6d1da9eb15b540688a505c1814e0c25f
TimeDuration = 7200
#谛宠有品
DCYP_HOST = "https://tmall.pet-dbc.cn/"
#CRM
CRM_HOST = "https://tcrm.pet-dbc.cn"
\ No newline at end of file
#测试环境
appname = system_pay
runmode = dev
[dev]
autorender = false
copyrequestbody = true
EnableDocs = true
httpport = 9197
sessionon = true
#数据库配置
dbhost = rm-2zenl1z0v6209a4jrbo.mysql.rds.aliyuncs.com
dbport = 3306
dbuser = root_shop
dbpassword = DBC_shopqwe
dbname = dbc_shop
dbprefix = ecm_
#token秘钥
SecretKey = dbcaespassword00
token = dbc-auth-token
#日志配置
filepath = "logs/"
maxlines = 1000
maxsize = 10240
#图片上传目录
UPLOAD_DIR = "credit_shop"
MAX_FILE_SIZE = 50000000
IMAGE_TYPES = "(jpg|jpeg|png|pdf|gif|zip|rar)"
ACCEPT_FILE_TYPES = IMAGE_TYPES
#OSS配置
OSS_URL = "https://dbc-static.oss-cn-beijing.aliyuncs.com/"
accessKeyID = "LTAIDfwPBC9AnsRt"
accessKeySecret = "Z6FtUptrAk0Sl6H8vrVBGZLbBzXEpO"
endPoint = "oss-cn-beijing.aliyuncs.com"
bucket = "dbc-static"
#e签宝
PROJECT_ID = "5111575783"
PROJECT_SECRET = "5255e7159b6262b92b03c4e307a23ed2"
API_HOST = "https://o.tsign.cn/opentreaty-service/"
AddPersonUrl = "https://o.tsign.cn/opentreaty-service/account/create/person"
AddOrganizeUrl = "https://o.tsign.cn/opentreaty-service/account/create/organize/common"
SilentSignUrl = "https://o.tsign.cn/opentreaty-service/account/platform/silentsign"
GetUploadurl = "https://o.tsign.cn/opentreaty-service/file/uploadurl"
CreateByFileKeyUrl = "https://o.tsign.cn/opentreaty-service/template/createbyfilekey"
CreateByTemplateUrl = "https://o.tsign.cn/opentreaty-service/doc/createbytemplate"
AddProcessUrl = "https://o.tsign.cn/opentreaty-service/sign/contract/addProcess"
flowGetViewUrl = "https://o.tsign.cn/opentreaty-service/flow/get/viewurl"
UserSignTaskUrl = "https://o.tsign.cn/opentreaty-service/sign/contract/userSignTask"
PlatformSignTaskUrl = "https://o.tsign.cn/opentreaty-service/sign/contract/platformSignTask"
ArchiveProcessUrl = "https://o.tsign.cn/opentreaty-service/sign/contract/archiveProcess"
OrganAuthUrl = "https://openapi2.tsign.cn:8444/realname/rest/external/organ/orgAuth"
InfoAuthUrl = "https://openapi2.tsign.cn:8444/realname/rest/external/organ/infoAuth-special"
AccessTokenUrl = "https://openapi.esign.cn/v1/oauth2/access_token?appId=5111575783&secret=5255e7159b6262b92b03c4e307a23ed2&grantType=client_credentials"
SignflowsUrl = "https://openapi.esign.cn/v1/signflows/"
#短信配置
SMSNAME = dbc
SMSPWD = Dbc38590
EPID = 125060
SIGN = 【谛宝多多】
#IP = 114.255.71.158:8061
IP = "https://sms.pet-dbc.cn/v1/send"
AESKEY = "dbc2021888000000"
AREACODE = "86"
#退出跳转域名配置
SHOP_HOST = "https://shop.pet-dbc.cn"
SHOP_HOST_ADMIN = "https://admin.pet-dbc.cn/credit/user"
#es配置
EsUrl = "http://39.97.239.70:9200"
# EsUrl = "http://39.97.234.228:9200"
Index = prod_shop_index
AuthPwd = dbc_ssp123
UserName = shop_search_production
PassWord = dbc_ssdp123
; UserName = elastic
; PassWord = dbc_default_password
#支付配置
frontRedirectUrl = "https://shop.pet-dbc.cn/uni/pages/wxpay/wxpay"
backRedirectUrl = "https://shop.pet-dbc.cn/uni/api/repayment/RedirectAuth"
payCallBack = "https://shop.pet-dbc.cn/uni/api/repayment/PayCallBack"
unifiedOrder = "https://pay.pet-dbc.cn/v1/pay/unified_order"
returnUrl = "https://shop.pet-dbc.cn"
backRedirectUrl_month = "https://shop.pet-dbc.cn/uni/api/month_repayment/RedirectAuth"
payCallBack_month = "https://shop.pet-dbc.cn/uni/api/month_repayment/PayCallBack"
#微信配置-支付
AppID = wxfb03eda5412dcaae
AppSecret = 10932abb8ca4448d98c52548b321eb2b
#微信配置-分享
AppID_SHARE = wx236414cabd51aefb
AppSecret_SHARE = 1c33fb719d0dd6e0c86fe234def58648
#微信配置-小程序
AppID_APPLET = wx6ff40a576e2f4ca0
AppSecret_APPLET = 6756d3f0b6b052dab40beb78bc89291d
#微信分享
AccessTokenHost = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx236414cabd51aefb&secret=1c33fb719d0dd6e0c86fe234def58648"
JsAPITicketHost = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
#阿里云 - 全国快递物流查询
AppCode = 6d1da9eb15b540688a505c1814e0c25f
TimeDuration = 7200
#谛宠有品
DCYP_HOST = "https://mall.pet-dbc.cn/"
#CRM
CRM_HOST = "https://crm.pet-dbc.cn"
\ No newline at end of file
#测试环境
appname = system_pay
runmode = test
[test]
autorender = false
copyrequestbody = true
EnableDocs = true
httpport = 14999
sessionon = true
#数据库配置
dbhost = 39.96.85.45
dbport = 3307
dbuser = root
dbpassword = abc123456
dbname = dbc_shop
dbprefix = ecm_
#token秘钥
SecretKey = dbcaespassword00
token = dev-dbc-auth-token
#日志配置
filename = "./logs"
maxlines = 1000
maxsize = 10240
#图片上传目录
UPLOAD_DIR = "credit_shop"
MAX_FILE_SIZE = 50000000
IMAGE_TYPES = "(jpg|jpeg|png|pdf|gif|zip|rar)"
ACCEPT_FILE_TYPES = IMAGE_TYPES
#OSS配置
OSS_URL = "https://dbc-static.oss-cn-beijing.aliyuncs.com/"
accessKeyID = "LTAIDfwPBC9AnsRt"
accessKeySecret = "Z6FtUptrAk0Sl6H8vrVBGZLbBzXEpO"
endPoint = "oss-cn-beijing.aliyuncs.com"
bucket = "dbc-static"
#e签宝
PROJECT_ID = "7438819206"
PROJECT_SECRET = "64c6e023ee98c82a1a7180107c320d08"
API_HOST = "https://smlo.tsign.cn/opentreaty-service/"
AddPersonUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/person"
AddOrganizeUrl = "https://smlo.tsign.cn/opentreaty-service/account/create/organize/common"
SilentSignUrl = "https://smlo.tsign.cn/opentreaty-service/account/platform/silentsign"
GetUploadurl = "https://smlo.tsign.cn/opentreaty-service/file/uploadurl"
CreateByFileKeyUrl = "https://smlo.tsign.cn/opentreaty-service/template/createbyfilekey"
CreateByTemplateUrl = "https://smlo.tsign.cn/opentreaty-service/doc/createbytemplate"
AddProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/addProcess"
flowGetViewUrl = "https://smlo.tsign.cn/opentreaty-service/flow/get/viewurl"
UserSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/userSignTask"
PlatformSignTaskUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/platformSignTask"
ArchiveProcessUrl = "https://smlo.tsign.cn/opentreaty-service/sign/contract/archiveProcess"
OrganAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/orgAuth"
InfoAuthUrl = "http://smlrealname.tsign.cn:8080/realname/rest/external/organ/infoAuth-special"
AccessTokenUrl = "https://smlopenapi.esign.cn/v1/oauth2/access_token?appId=7438819206&secret=64c6e023ee98c82a1a7180107c320d08&grantType=client_credentials"
SignflowsUrl = "https://smlopenapi.esign.cn/v1/signflows/"
#短信配置
SMSNAME = dbc
SMSPWD = Dbc38590
EPID = 125060
SIGN = 【谛宝多多】
#IP = 114.255.71.158:8061
IP = "https://tsms.pet-dbc.cn/v1/send"
AESKEY = "dbc2021888000000"
AREACODE = "86"
#退出跳转域名配置
SHOP_HOST = "https://jingxiang.pet-dbc.cn"
SHOP_HOST_ADMIN = "https://jxadmin.pet-dbc.cn/credit/user"
#es配置
EsUrl = "http://39.97.239.70:9200"
# EsUrl = "http://39.97.234.228:9200"
Index = dev_shop_index
AuthPwd = dbc123456
UserName = shop_search_development
PassWord = dbc_ssdp123
; UserName = elastic
; PassWord = dbc_default_password
#支付配置
frontRedirectUrl = "https://test.pet-dbc.cn/uni/pages/wxpay/wxpay"
backRedirectUrl = "https://test.pet-dbc.cn/uni/api/repayment/RedirectAuth"
payCallBack = "https://test.pet-dbc.cn/uni/api/repayment/PayCallBack"
unifiedOrder = "https://tpay.pet-dbc.cn/v1/pay/unified_order"
backRedirectUrl_month = "https://test.pet-dbc.cn/uni/api/month_repayment/RedirectAuth"
payCallBack_month = "https://test.pet-dbc.cn/uni/api/month_repayment/PayCallBack"
returnUrl = "https://test.pet-dbc.cn"
#微信配置-支付
AppID = wxfb03eda5412dcaae
AppSecret = 10932abb8ca4448d98c52548b321eb2b
#微信配置-分享
AppID_SHARE = wx236414cabd51aefb
AppSecret_SHARE = 1c33fb719d0dd6e0c86fe234def58648
#微信配置-小程序
AppID_APPLET = wx6ff40a576e2f4ca0
AppSecret_APPLET = 6756d3f0b6b052dab40beb78bc89291d
#微信分享
AccessTokenHost = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx236414cabd51aefb&secret=1c33fb719d0dd6e0c86fe234def58648"
JsAPITicketHost = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
#阿里云 - 全国快递物流查询
AppCode = 6d1da9eb15b540688a505c1814e0c25f
TimeDuration = 7200
#谛宠有品
DCYP_HOST = "https://tmall.pet-dbc.cn/"
#CRM
CRM_HOST = "https://tcrm.pet-dbc.cn"
\ No newline at end of file
package model
import (
"errors"
"github.com/astaxie/beego/validation"
"reflect"
)
type PlaceAnOrderParamInput struct {
PlatformType uint8 `json:"platform_type" description:"平台类型 1: saas 2: shop 3: shop mobile 4: 收银台"`
PlatformInfo string `json:"platform_info" description:"平台信息"`
GoodsDes string `json:"goods_des" description:"商品描述"`
GoodsDetail string `json:"goods_detail" description:"商品详情"`
AttachInfo string `json:"attach_info" description:"附加信息"`
GoodsPrice float64 `json:"goods_price" description:"商品金额,个位为分"`
NoticeURL string `json:"notice_url" description:"客户端回调的url"`
PayType int `json:"pay_type" description:"1: 微信,2: 支付宝, 3: 拉卡拉 4: 收钱吧"`
SourceCode uint8 `json:"source_code" description:"1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) 9: B2C 10:bk支付宝web 11:bk 支付宝手机"`
OpenID string `json:"open_id" description:"此参数 支付类型是 JS API 的时候 必传"`
WapURL string `json:"wap_url" description:"WAP网站URL地址, 支付方式为微信MWEB时 必传"`
WapName string `json:"wap_name" description:"WAP网站名称, 支付方式为微信MWEB时 必传"`
QuitURL string `json:"quit_url" description:"返回按钮 可用于用户付款中途退出并返回到该参数指定的商户网站地址, 支付方式为 支付宝手机网站时 必传(尽量传)"`
ReturnURL string `json:"return_url" description:"用户在完成支付后,会根据商户在请求支付API中传入的前台回跳地址return_url自动跳转return_url地址页面(必传)"`
AppID string `json:"app_id,omitempty" description:"wxAppId source code 2 小程序支付时必传、同时小程序支付必须关联了商户号支付"`
Operator string `json:"operator" description:"操作员"`
Customer string `json:"customer" description:"顾客信息"`
DynamicID string `json:"dynamic_id" description:"顾客手机条码的内容"`
StoreSn string `json:"store_sn" description:"商户门店编号"`
IsServe uint `json:"is_serve" description:"0直连模式 1服务商模式"`
OrderId string `json:"-" description:"订单号"`
SubMchid string `json:"sub_mchid" description:"通过进件接口申请的支付商户号、这是由微信生成并下发的"`
Nonce string `json:"-"`
ServeNoticeUrl string `json:"-" description:"传递给支付渠道的、而不是业务方的"`
}
func (this *PlaceAnOrderParamInput) ValidPlaceAnOrderParamInput() (err error) {
valid := validation.Validation{}
if b, _ := valid.Valid(this); !b {
//表示获取验证的结构体
st := reflect.TypeOf(PlaceAnOrderParamInput{})
for _, err := range valid.Errors {
//获取验证的字段名和提示信息的别名
filed, _ := st.FieldByName(err.Field)
var alias= filed.Tag.Get("alias")
//返回验证的错误信息
return errors.New(alias + err.Message)
}
}
return nil
}
type LakalaParamInput struct {
Version string `json:"version" description:"版本"`
ReqTime string `json:"req_time" description:"请求时间"`
ReqData LakalaParamData `json:"req_data"`
}
type LakalaParamData struct {
OutOrderNo string `json:"out_order_no" description:"商户订单号"`
MerchantNo string `json:"merchant_no" description:"银联商户号"`
TotalAmount float64 `json:"total_amount" description:"订单金额,单位:分"`
OrderEfficientTime string `json:"order_efficient_time" description:"订单有效期 格式yyyyMMddHHmmss,最大支持下单时间+2天"`
NotifyUrl string `json:"notify_url" description:"订单支付成功后商户接收订单通知的地址 http://xxx.xxx.com"`
CallbackUrl string `json:"callback_url" description:"客户端下单完成支付后返回的商户网页跳转地址"`
OrderInfo string `json:"order_info" description:"订单标题,在使用收银台扫码支付时必输入,交易时送往账户端"`
GoodsMark string `json:"goods_mark" description:"商品信息标识 (1:含商品信息,不填默认不含商品信息)"`
}
\ No newline at end of file
This diff is collapsed.
version: '3.5'
services:
system_pay_dev:
restart: always
build:
context: .
args:
ENVARG: dev
dockerfile: Dockerfile
image: system_pay:dev
ports:
- 14999:14999
environment:
runmode: dev
networks:
- system_pay_network
container_name: system_pay_dev
networks:
system_pay_network:
driver: bridge
module system_pay
go 1.16
require (
github.com/astaxie/beego v1.12.3
github.com/pkg/errors v0.9.1
github.com/smartystreets/goconvey v1.8.0
)
This diff is collapsed.
package languages
var(
ValidationFails = "验证失败"
Nopower = "没有权限"
NoFile = "文件不存在"
Filebig = "文件太大"
NoFileType = "文件类型不允许"
AddError = "添加失败"
Sendfaile = "短信发送失败"
NoData = "没有数据"
EditError = "修改失败"
CodeError = "验证码错误"
HaveExist = "认证信息已存在,不能重复添加"
HasCertified = "已经认证过了"
HasReached = "今日认证次数已到,请您明日再认证"
PaymentFails = "支付失败"
UnequalAmounts = "金额那不相等"
ParamsError = "参数错误"
AssertionFailure = "assertion failure"
NotExistUserId = "用户ID不存在"
AddOrderError = "添加订单失败"
OutTradeNoError = "支付订单获取失败"
DiffPasswordError = "两次输入的密码不一致"
SamePasswordError = "您输入的新密码和原始密码相同,请重新输入"
OldPasswordError = "您输入的原始密码不正确,请重新输入"
ExistMobileError = "您输入的手机号已存在,请重新输入"
SystemError = "系统错误"
IntegralSign = "签到赠送积分"
HadSign = "今天已签到,请明天再来"
NoWXCode = "没有微信小程序登录code"
NoAPPIDOrSECRET = "没有微信小程序APPID或SECRET码"
)
\ No newline at end of file
package languages
import "github.com/astaxie/beego"
var (
IousActivationCode = "你的月结激活码为:"
IousApplyRemind = "您好,您有一条待审核的月结激活数据,请及时前往后台处理,快捷通道" + beego.AppConfig.String("SHOP_HOST_ADMIN")
ChangeActivationCode = "您的修改验证码是:"
ActivationCodeEnd = ".请不要把验证码泄露给其他人."
)
{"/Users/wangp/go/src/system_pay/controllers/index":1687167540586756349}
\ No newline at end of file
package main
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "system_pay/routers"
"system_pay/utils"
)
func main() {
utils.InitValidate() //验证信息的初始化定义
if beego.BConfig.RunMode == "dev" {
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
}
if beego.AppConfig.String("runmode") == "dev" {
orm.Debug = true
}
beego.Run()
}
#!/bin/bash
git pull
docker-compose -f docker-compose.yaml up --build -d
docker image prune -f
\ No newline at end of file
package routers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/context/param"
)
func init() {
beego.GlobalControllerRouter["system_pay/controllers/index:PayController"] = append(beego.GlobalControllerRouter["system_pay/controllers/index:PayController"],
beego.ControllerComments{
Method: "UnifiedOrder",
Router: `/unified_order`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
}
// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers
import (
"github.com/astaxie/beego"
"system_pay/controllers/index"
)
func init() {
ns := beego.NewNamespace("/api",
beego.NSNamespace("/index",
beego.NSInclude(
&index.PayController{},
),
),
)
beego.AddNamespace(ns)
}
export runmode=dev
export BEEGO_MODE=dev
bee run -gendoc=true -downdoc=true
\ No newline at end of file
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z"/>
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z"/>
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
</script>
</body>
</html>
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var isValid, qp, arr;
qp = (window.location.hash || location.search).substring(1);
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}
isValid = qp.state === sentState
if (oauth2.auth.schema.get("flow") === "accessCode" && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback(oauth2.auth);
} else {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: "Authorization failed: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid});
}
window.close();
}
</script>
This diff is collapsed.
{"version":3,"file":"swagger-ui-bundle.js","sources":["webpack:///swagger-ui-bundle.js"],"mappings":"AAAA;AAu/FA;AA6+FA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA;;;;;;AAoIA;AAi7FA;AAmtCA;AAi0IA;AA0oJA;AAgwFA;AAyrGA;AA0lFA;AA4nFA;AA+9CA;AA+gDA;AAwrCA;AA60EA;;;;;AA6oCA;AAsyJA;;;;;;;;;;;;;;AA64EA;AA4mIA;AAquJA;AA2qHA;AA2mGA;AAiiEA;AAq4DA;AAg3DA;AAoPA;;;;;;AAk7FA;AA07FA;;;;;AAi8CA;AAgsFA;AAs2CA;AAglCA;AAu9CA;AAy8EA;AAsiCA;AA+yFA;;;;;;;;;AAgkDA;AA2zIA;AAu7FA;AAmrFA;AAu0EA","sourceRoot":""}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{"version":3,"file":"swagger-ui-standalone-preset.js","sources":["webpack:///swagger-ui-standalone-preset.js"],"mappings":"AAAA;;;;;AA8QA;AAmvGA;AAuxFA;;;;;;AAocA;AAkvFA;AAu+CA;AAo+CA;AAgrCA;AAuyEA","sourceRoot":""}
\ No newline at end of file
This diff is collapsed.
{"version":3,"file":"swagger-ui.css","sources":[],"mappings":"","sourceRoot":""}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
{"version":3,"file":"swagger-ui.js","sources":["webpack:///swagger-ui.js"],"mappings":"AAAA;;;;;;AA0yCA;AAoyHA;AAmyHA;AAykGA;AA+9BA;AA6iCA;AAojCA;AAu5BA","sourceRoot":""}
\ No newline at end of file
{
"swagger": "2.0",
"info": {
"title": "beego Test API",
"description": "beego has a very cool tools to autogenerate documents for your API",
"version": "1.0.0",
"termsOfService": "http://beego.me/",
"contact": {
"email": "astaxie@gmail.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"basePath": "/api",
"paths": {
"/index/unified_order": {
"post": {
"tags": [
"index"
],
"description": "拉卡拉统一支付",
"operationId": "PayController.",
"parameters": [
{
"in": "body",
"name": "data",
"description": "输入项",
"required": true,
"schema": {
"$ref": "#/definitions/model.PlaceAnOrderParamInput"
}
}
],
"responses": {
"200": {
"description": ""
}
}
}
}
},
"definitions": {
"model.PlaceAnOrderParamInput": {
"title": "PlaceAnOrderParamInput",
"type": "object",
"properties": {
"app_id": {
"description": "wxAppId source code 2 小程序支付时必传、同时小程序支付必须关联了商户号支付",
"type": "string"
},
"attach_info": {
"description": "附加信息",
"type": "string"
},
"customer": {
"description": "顾客信息",
"type": "string"
},
"dynamic_id": {
"description": "顾客手机条码的内容",
"type": "string"
},
"goods_des": {
"description": "商品描述",
"type": "string"
},
"goods_detail": {
"description": "商品详情",
"type": "string"
},
"goods_price": {
"description": "商品金额,个位为分",
"type": "number",
"format": "double"
},
"is_serve": {
"description": "0直连模式 1服务商模式",
"type": "integer",
"format": "int32"
},
"notice_url": {
"description": "客户端回调的url",
"type": "string"
},
"open_id": {
"description": "此参数 支付类型是 JS API 的时候 必传",
"type": "string"
},
"operator": {
"description": "操作员",
"type": "string"
},
"pay_type": {
"description": "1: 微信,2: 支付宝, 3: 拉卡拉 4: 收钱吧",
"type": "integer",
"format": "int64"
},
"platform_info": {
"description": "平台信息",
"type": "string"
},
"platform_type": {
"description": "平台类型 1: saas 2: shop 3: shop mobile 4: 收银台",
"type": "integer",
"format": "int32"
},
"quit_url": {
"description": "返回按钮 可用于用户付款中途退出并返回到该参数指定的商户网站地址, 支付方式为 支付宝手机网站时 必传(尽量传)",
"type": "string"
},
"return_url": {
"description": "用户在完成支付后,会根据商户在请求支付API中传入的前台回跳地址return_url自动跳转return_url地址页面(必传)",
"type": "string"
},
"source_code": {
"description": "1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile) 7:alipay(app) 9: B2C 10:bk支付宝web 11:bk 支付宝手机",
"type": "integer",
"format": "int32"
},
"store_sn": {
"description": "商户门店编号",
"type": "string"
},
"sub_mchid": {
"description": "通过进件接口申请的支付商户号、这是由微信生成并下发的",
"type": "string"
},
"wap_name": {
"description": "WAP网站名称, 支付方式为微信MWEB时 必传",
"type": "string"
},
"wap_url": {
"description": "WAP网站URL地址, 支付方式为微信MWEB时 必传",
"type": "string"
}
}
}
},
"tags": [
{
"name": "index",
"description": "拉卡拉统一支付\n"
}
]
}
\ No newline at end of file
swagger: "2.0"
info:
title: beego Test API
description: beego has a very cool tools to autogenerate documents for your API
version: 1.0.0
termsOfService: http://beego.me/
contact:
email: astaxie@gmail.com
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /api
paths:
/index/unified_order:
post:
tags:
- index
description: 拉卡拉统一支付
operationId: PayController.
parameters:
- in: body
name: data
description: 输入项
required: true
schema:
$ref: '#/definitions/model.PlaceAnOrderParamInput'
responses:
"200":
description: ""
definitions:
model.PlaceAnOrderParamInput:
title: PlaceAnOrderParamInput
type: object
properties:
app_id:
description: wxAppId source code 2 小程序支付时必传、同时小程序支付必须关联了商户号支付
type: string
attach_info:
description: 附加信息
type: string
customer:
description: 顾客信息
type: string
dynamic_id:
description: 顾客手机条码的内容
type: string
goods_des:
description: 商品描述
type: string
goods_detail:
description: 商品详情
type: string
goods_price:
description: 商品金额,个位为分
type: number
format: double
is_serve:
description: 0直连模式 1服务商模式
type: integer
format: int32
notice_url:
description: 客户端回调的url
type: string
open_id:
description: 此参数 支付类型是 JS API 的时候 必传
type: string
operator:
description: 操作员
type: string
pay_type:
description: '1: 微信,2: 支付宝, 3: 拉卡拉 4: 收钱吧'
type: integer
format: int64
platform_info:
description: 平台信息
type: string
platform_type:
description: '平台类型 1: saas 2: shop 3: shop mobile 4: 收银台'
type: integer
format: int32
quit_url:
description: 返回按钮 可用于用户付款中途退出并返回到该参数指定的商户网站地址, 支付方式为 支付宝手机网站时 必传(尽量传)
type: string
return_url:
description: 用户在完成支付后,会根据商户在请求支付API中传入的前台回跳地址return_url自动跳转return_url地址页面(必传)
type: string
source_code:
description: '1: 微信 Native 2:微信小程序 3:微信内支付 4:h5 跳微信 5:支付宝(web)-扫码或登录支付宝账户 6:alipay(mobile)
7:alipay(app) 9: B2C 10:bk支付宝web 11:bk 支付宝手机'
type: integer
format: int32
store_sn:
description: 商户门店编号
type: string
sub_mchid:
description: 通过进件接口申请的支付商户号、这是由微信生成并下发的
type: string
wap_name:
description: WAP网站名称, 支付方式为微信MWEB时 必传
type: string
wap_url:
description: WAP网站URL地址, 支付方式为微信MWEB时 必传
type: string
tags:
- name: index
description: |
拉卡拉统一支付
package test
import (
"net/http"
"net/http/httptest"
"path/filepath"
"runtime"
_ "system_pay/routers"
"testing"
"github.com/astaxie/beego"
. "github.com/smartystreets/goconvey/convey"
)
func init() {
_, file, _, _ := runtime.Caller(0)
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(apppath)
}
// TestGet is a sample to run an endpoint test
func TestGet(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/object", nil)
w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r)
beego.Trace("testing", "TestGet", "Code[%d]\n%s", w.Code, w.Body.String())
Convey("Subject: Test Station Endpoint\n", t, func() {
Convey("Status Code Should Be 200", func() {
So(w.Code, ShouldEqual, 200)
})
Convey("The Result Should Not Be Empty", func() {
So(w.Body.Len(), ShouldBeGreaterThan, 0)
})
})
}
exit status 1
\ No newline at end of file
package utils
import (
"github.com/pkg/errors"
)
//Response 结构体
type Response struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func Success(data interface{}) Response {
var result Response
result.Code = 0
result.Message = "SUCCESS"
result.Data = data
return result
}
//拉卡拉返回值
type ResponseLakala struct {
Status int `json:"status"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func SuccessLakala(data interface{}) ResponseLakala {
var result ResponseLakala
result.Status = 0
result.Message = "SUCCESS"
result.Data = data
return result
}
//Response 结构体
type Response2 struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
Page interface{} `json:"page"`
Login int `json:"login_flg"`
Credit int `json:"credit_flg"`
City int `json:"city_flg"`
}
func Success2(data interface{}, page interface{}, login_flg, credit_flg, city_flg int) Response2 {
var result Response2
result.Code = 0
result.Message = "SUCCESS"
result.Data = data
result.Page = page
result.Login = login_flg
result.Credit = credit_flg
result.City = city_flg
return result
}
//Response 结构体
type Response3 struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
Page interface{} `json:"page"`
Login int `json:"login_flg"`
Credit int `json:"credit_flg"`
City int `json:"city_flg"`
RegTime int `json:"reg_time"`
WhiteFlg int `json:"white_flg"`
}
func Success3(data interface{}, page interface{}, login_flg, credit_flg, city_flg, reg_time int, white_flg int) Response3 {
var result Response3
result.Code = 0
result.Message = "SUCCESS"
result.Data = data
result.Page = page
result.Login = login_flg
result.Credit = credit_flg
result.City = city_flg
result.RegTime = reg_time
result.WhiteFlg = white_flg
return result
}
func LoginFaile(err error, msg string ) Response{
var result Response
result.Code = -1
result.Message = errors.Wrap(err, msg).Error()
result.Data = nil
return result
}
func CheckError(err error, msg string ) Response{
var result Response
result.Message = errors.Wrap(err, msg).Error()
result.Code = 1
result.Data = nil
return result
}
func CheckError2(err error, msg string, data interface{}) Response{
var result Response
result.Message = errors.Wrap(err, msg).Error()
result.Code = 1
result.Data = data
return result
}
package utils
import (
"github.com/astaxie/beego/validation"
)
var MessageTmpls = map[string]string{
"Required": "不能为空",
"Min": "最小为 %d",
"Max": "最大为 %d",
"Range": "范围在 %d 至 %d",
"MinSize": "最小长度为 %d",
"MaxSize": "最大长度为 %d",
"Length": "长度必须是 %d",
"Alpha": "必须是有效的字母字符",
"Numeric": "必须是有效的数字字符",
"AlphaNumeric": "必须是有效的字母或数字字符",
"Match": "必须匹配格式 %s",
"NoMatch": "必须不匹配格式 %s",
"AlphaDash": "必须是有效的字母或数字或破折号(-_)字符",
"Email": "必须是有效的邮件地址",
"IP": "必须是有效的IP地址",
"Base64": "必须是有效的base64字符",
"Mobile": "必须是有效手机号码",
"Tel": "必须是有效电话号码",
"Phone": "必须是有效的电话号码或者手机号码",
"ZipCode": "必须是有效的邮政编码",
}
func InitValidate() {
SetDefaultMessage()
}
func SetDefaultMessage() {
if len(MessageTmpls) == 0 {
return
}
//将默认的提示信息转为自定义
for k, _ := range MessageTmpls {
validation.MessageTmpls[k] = MessageTmpls[k]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment