Compare commits

..

2 Commits

Author SHA1 Message Date
2a931eb15c (1)ip改成读取配置文件;
(2)短期会员金额改成测试金额;
(3)员工邀请码地址修改,改成demo服务器地址;
(4)修改Makefile文件,添加demo编辑指令;
(5)添加demo配置文件,修改dev配置文件;
(6)修改AppAccessToken,读取配置信息,不再硬编码;
2024-01-22 11:38:31 +08:00
c30fd5713d (1)ip改成读取配置文件;
(2)短期会员金额改成测试金额;
(3)员工邀请码地址修改,改成demo服务器地址;
(4)修改Makefile文件,添加demo编辑指令;
(5)添加demo配置文件,修改dev配置文件;
(6)修改AppAccessToken,读取配置信息,不再硬编码;
2024-01-22 11:37:47 +08:00
11 changed files with 127 additions and 66 deletions

View File

@ -13,6 +13,9 @@ build-sqlite:
#docker: #docker:
# docker build . -t go-admin:latest # docker build . -t go-admin:latest
demo:
GOOS=linux GOARCH=amd64 go build -o demo_hm_server main.go
dev: dev:
GOOS=linux GOARCH=amd64 go build -o dev_hm_server main.go GOOS=linux GOARCH=amd64 go build -o dev_hm_server main.go

View File

@ -11,7 +11,8 @@ import (
type config struct { type config struct {
Env string Env string
ServerPort int ServerPort int
ServerClientIp string
JwtUserAccessKey string JwtUserAccessKey string
JwtUserRefreshKey string JwtUserRefreshKey string
@ -60,8 +61,6 @@ type config struct {
RedisPassword string RedisPassword string
RedisDB int RedisDB int
//LotteryHost string
//LotteryPort int
XianMaiBaseUrl string XianMaiBaseUrl string
} }
@ -102,7 +101,8 @@ func initConfig() {
AppConfig = config{ AppConfig = config{
Env: viper.GetString("ENV"), Env: viper.GetString("ENV"),
ServerPort: viper.GetInt("server.port"), ServerPort: viper.GetInt("server.port"),
ServerClientIp: viper.GetString("server.client_ip"),
JwtUserAccessKey: viper.GetString("jwt.user.access_key"), JwtUserAccessKey: viper.GetString("jwt.user.access_key"),
JwtUserRefreshKey: viper.GetString("jwt.user.refresh_key"), JwtUserRefreshKey: viper.GetString("jwt.user.refresh_key"),
@ -129,10 +129,7 @@ func initConfig() {
WxAppSecret: viper.GetString("wx.app_secret"), WxAppSecret: viper.GetString("wx.app_secret"),
WxMchID: viper.GetString("wx.app_mchId"), WxMchID: viper.GetString("wx.app_mchId"),
WxMchSecret: viper.GetString("wx.app_mchSecret"), WxMchSecret: viper.GetString("wx.app_mchSecret"),
//WxCertFile: viper.GetString("wx.wx_pay.cert_file"),
//WxKeyFile: viper.GetString("wx.wx_pay.key_file"),
//WxRootCaFile: viper.GetString("wx.wx_pay.root_ca_file"),
//WxPayCallBackUrl: viper.GetString("wx.wx_pay.callback_url"),
WxCertFile: viper.GetString("wx_pay.cert_file"), WxCertFile: viper.GetString("wx_pay.cert_file"),
WxKeyFile: viper.GetString("wx_pay.key_file"), WxKeyFile: viper.GetString("wx_pay.key_file"),
WxRootCaFile: viper.GetString("wx_pay.root_ca_file"), WxRootCaFile: viper.GetString("wx_pay.root_ca_file"),
@ -156,5 +153,5 @@ func initConfig() {
XianMaiBaseUrl: viper.GetString("xianmai_base_url"), XianMaiBaseUrl: viper.GetString("xianmai_base_url"),
} }
//fmt.Printf("%+v", AppConfig) fmt.Printf("%+v", AppConfig)
} }

View File

@ -22,6 +22,7 @@ import (
) )
const AppletCodeBaseUrl = "http://switch.deovo.com:8000/img/applet_code/" const AppletCodeBaseUrl = "http://switch.deovo.com:8000/img/applet_code/"
const AppletcodebaseurlDev = "http://dev.switch.deovo.com:8000/img/applet_code/"
func GetWxAccessToken(appId, secret string) string { func GetWxAccessToken(appId, secret string) string {
//https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET //https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
@ -182,7 +183,7 @@ func GenDrawShareCode(Did string, appId, secret string, userID ...uint32) (strin
logger.Error("err:", err) logger.Error("err:", err)
} }
//jpeg.Encode(f, resp, nil) //写入文件 //jpeg.Encode(f, resp, nil) //写入文件
return AppletCodeBaseUrl + fileName, nil return AppletcodebaseurlDev + fileName, nil
} }
return "", errors.New(fmt.Sprintf("%d%s", res.Errcode, res.Errmsg)) return "", errors.New(fmt.Sprintf("%d%s", res.Errcode, res.Errmsg))

View File

@ -37,8 +37,9 @@ import (
const ( const (
//clientIp = "120.229.60.77" //clientIp = "120.229.60.77"
clientIp = "39.108.188.218" demoClientIp = "112.33.14.191" // demo服务器ip地址
domain = "switch.deovo.com:8001" clientIp = "39.108.188.218"
domain = "switch.deovo.com:8001"
//wxPayNotifyUrl = "api/v1/wxpay/notice" //wxPayNotifyUrl = "api/v1/wxpay/notice"
wxPayNotifyUrl = "/api/v1/wxpay/notice" wxPayNotifyUrl = "/api/v1/wxpay/notice"
@ -63,7 +64,7 @@ const (
HmPayApiUrl = "https://hmpay.sandpay.com.cn/gateway/api" HmPayApiUrl = "https://hmpay.sandpay.com.cn/gateway/api"
) )
//web 微信支付 // web 微信支付
func WebPay(orderId string, totalFee uint32, openId, profitSharing, attach, notifyUrl string) (*Sextuple, error) { func WebPay(orderId string, totalFee uint32, openId, profitSharing, attach, notifyUrl string) (*Sextuple, error) {
now := time.Now().Local() now := time.Now().Local()
strTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second()) strTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second())
@ -97,7 +98,7 @@ func WebPay(orderId string, totalFee uint32, openId, profitSharing, attach, noti
FeeType: "CNY", FeeType: "CNY",
TotalFee: strconv.Itoa(int(totalFee)), TotalFee: strconv.Itoa(int(totalFee)),
//SpbillCreateIp: config.AppConfig.IP, //SpbillCreateIp: config.AppConfig.IP,
SpbillCreateIp: clientIp, SpbillCreateIp: config.AppConfig.ServerClientIp,
//NotifyUrl: "https://" + config.AppConfig.Domain + config.AppConfig.WxPayNotifyUrl, //NotifyUrl: "https://" + config.AppConfig.Domain + config.AppConfig.WxPayNotifyUrl,
//NotifyUrl: "https://" + domain + wxPayNotifyUrl, //NotifyUrl: "https://" + domain + wxPayNotifyUrl,
//NotifyUrl: configInfo.NotifyUrl, //NotifyUrl: configInfo.NotifyUrl,
@ -893,17 +894,18 @@ const (
WxAppId = "wx806c079463b5b56c" WxAppId = "wx806c079463b5b56c"
WxAppSecret = "3d7335cf0b9fa1d70aa7eb079526ebf0" WxAppSecret = "3d7335cf0b9fa1d70aa7eb079526ebf0"
WxAppMchId = "1609877389" WxAppMchId = "1609877389"
WxAppMchSecret = "DeovoMingHuiRengTianTang45675456" WxAppMchSecret = "DeovoMingHuiRengTianTang45675456"
WxCheckName = "NO_CHECK" WxCheckName = "NO_CHECK"
SpbilCreateIp = "39.108.188.218" DemoSpbilCreateIp = "112.33.14.191" // demo服务器ip地址
WxTransferUrl = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers" SpbilCreateIp = "39.108.188.218"
WxTransferUrl = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"
WxKeyFile = "./configs/merchant/apiclient_key.pem" WxKeyFile = "./configs/merchant/apiclient_key.pem"
WxRootCaFile = "./configs/merchant/apiclient_cert.pem" WxRootCaFile = "./configs/merchant/apiclient_cert.pem"
) )
//https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2 // https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
type WxTransferReq struct { type WxTransferReq struct {
XMLName xml.Name `xml:"xml"` //xml标签 XMLName xml.Name `xml:"xml"` //xml标签
MchAppid string `xml:"mch_appid" json:"mch_appid"` //微信分配的小程序ID必须 MchAppid string `xml:"mch_appid" json:"mch_appid"` //微信分配的小程序ID必须
@ -930,7 +932,7 @@ type WxTransferResp struct {
PaymentNo string `xml:"payment_no,CDATA"` PaymentNo string `xml:"payment_no,CDATA"`
} }
//给用户打款 // 给用户打款
func Transfer(amount uint32, openId, desc string) (*WxTransferResp, error) { func Transfer(amount uint32, openId, desc string) (*WxTransferResp, error) {
tradeNO := GenTradeNo() tradeNO := GenTradeNo()
nonce := GenRandStr(NonceStringLength) nonce := GenRandStr(NonceStringLength)
@ -946,7 +948,7 @@ func Transfer(amount uint32, openId, desc string) (*WxTransferResp, error) {
CheckName: WxCheckName, CheckName: WxCheckName,
Amount: fmt.Sprintf("%d", amount), Amount: fmt.Sprintf("%d", amount),
Desc: desc, Desc: desc,
SpbillCreateIp: SpbilCreateIp, SpbillCreateIp: config.AppConfig.ServerClientIp,
} }
wxResp := WxTransferResp{} wxResp := WxTransferResp{}
@ -1122,7 +1124,7 @@ type HmPayUnifiedOrderRsp struct {
Sign string `json:"sign"` Sign string `json:"sign"`
} }
//hm 微信支付 // hm 微信支付
func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, notifyUrl string) (*HmPayUnifiedOrderPayData, error) { func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, notifyUrl string) (*HmPayUnifiedOrderPayData, error) {
now := time.Now().Local() now := time.Now().Local()
strTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(), strTime := fmt.Sprintf("%04d%02d%02d%02d%02d%02d", now.Year(), now.Month(), now.Day(), now.Hour(),
@ -1160,7 +1162,7 @@ func HmJsPayUnifiedOrder(orderId string, totalFee uint32, openId, notifyUrl stri
Body: "服务费", Body: "服务费",
MerAppId: WxAppId, MerAppId: WxAppId,
MerBuyerId: openId, MerBuyerId: openId,
CreateIp: clientIp, CreateIp: config.AppConfig.ServerClientIp,
CreateTime: strTime, CreateTime: strTime,
ExpireTime: strExpireTime, ExpireTime: strExpireTime,
//LimitPay: "NO_CREDIT", //LimitPay: "NO_CREDIT",

View File

@ -83,7 +83,7 @@ func MemberConfigInfo() ([]MemberConfig, error) {
} }
func GetMemberConfig(level uint32, genre uint32) (*MemberConfig, error) { func GetMemberConfig(level uint32, genre uint32) (*MemberConfig, error) {
if level == 3 { if level == 3 { // 短期会员
level = 2 level = 2
} }
if level == 2 && genre != 0 { // 判断是否为黄金短期会员 if level == 2 && genre != 0 { // 判断是否为黄金短期会员
@ -107,38 +107,38 @@ func GetMemberConfig(level uint32, genre uint32) (*MemberConfig, error) {
return nil, errors.New("level err") return nil, errors.New("level err")
} }
// 会员费配置 // ShortMemberConfigMap 会员费配置
// 测试,金额小
//var ShortMemberConfigMap = map[uint32]*MemberConfig{
// 201: {
// MemberLever: 2,
// MemberFee: 1,
// MemberDeposit: 3,
// CardMax: 1,
// },
// 202: {
// MemberLever: 2,
// MemberFee: 2,
// MemberDeposit: 3,
// CardMax: 1,
// },
//}
var ShortMemberConfigMap = map[uint32]*MemberConfig{ var ShortMemberConfigMap = map[uint32]*MemberConfig{
201: { //短期黄金会员-90天 201: {
MemberLever: 2, MemberLever: 2,
MemberFee: 19900, MemberFee: 1,
MemberDeposit: 30000, MemberDeposit: 1,
CardMax: 1, CardMax: 1,
}, },
202: { //短期黄金会员-180天 202: {
MemberLever: 2, MemberLever: 2,
MemberFee: 29900, MemberFee: 2,
MemberDeposit: 30000, MemberDeposit: 1,
CardMax: 1, CardMax: 1,
}, },
} }
//var ShortMemberConfigMap = map[uint32]*MemberConfig{
// 201: { //短期黄金会员-90天
// MemberLever: 2,
// MemberFee: 19900,
// MemberDeposit: 30000,
// CardMax: 1,
// },
// 202: { //短期黄金会员-180天
// MemberLever: 2,
// MemberFee: 29900,
// MemberDeposit: 30000,
// CardMax: 1,
// },
//}
type MemberVmConfig struct { type MemberVmConfig struct {
MemberLever uint32 `json:"member_lever"` // 会员等级 MemberLever uint32 `json:"member_lever"` // 会员等级
MemberVm uint32 `json:"member_vm"` MemberVm uint32 `json:"member_vm"`

View File

@ -14,6 +14,7 @@ import (
) )
const ( const (
// WxPublicAppId WxPublicAppSecret todo 待确认
WxPublicAppId = "wxfdb1c5654f681c7e" WxPublicAppId = "wxfdb1c5654f681c7e"
WxPublicAppSecret = "6e1908a71f31a80849ef0e59d90b7147" WxPublicAppSecret = "6e1908a71f31a80849ef0e59d90b7147"
) )
@ -28,13 +29,6 @@ func AccessToken() (string, error) {
Errmsg string `json:"errmsg"` Errmsg string `json:"errmsg"`
}{} }{}
//config.AppConfig.WxAppId = "wxfdb1c5654f681c7e"
//config.AppConfig.WxAppSecret = "6e1908a71f31a80849ef0e59d90b7147"
//config.AppConfig.WxAppId = "wx806c079463b5b56c"
//config.AppConfig.WxAppSecret = "cb125688bf4e482f66e8c46062d568fc"
//fmt.Println("WxAppId:", config.AppConfig.WxAppId)
//fmt.Println("WxAppSecret:", config.AppConfig.WxAppSecret)
fmt.Println("WxAppId:", WxPublicAppId) fmt.Println("WxAppId:", WxPublicAppId)
fmt.Println("WxAppSecret:", WxPublicAppSecret) fmt.Println("WxAppSecret:", WxPublicAppSecret)
if err := requests.GetAndParseJson("https://api.weixin.qq.com/cgi-bin/token", map[string]string{ if err := requests.GetAndParseJson("https://api.weixin.qq.com/cgi-bin/token", map[string]string{
@ -64,13 +58,10 @@ func AppAccessToken() (string, error) {
Errmsg string `json:"errmsg"` Errmsg string `json:"errmsg"`
}{} }{}
//config.AppConfig.WxAppId = "wxfdb1c5654f681c7e" // 读取配置信息,不再硬编码
//config.AppConfig.WxAppSecret = "6e1908a71f31a80849ef0e59d90b7147" //config.AppConfig.WxAppId = "wx806c079463b5b56c"
config.AppConfig.WxAppId = "wx806c079463b5b56c" //config.AppConfig.WxAppSecret = "cb125688bf4e482f66e8c46062d568fc"
config.AppConfig.WxAppSecret = "cb125688bf4e482f66e8c46062d568fc"
//fmt.Println("WxAppId:", config.AppConfig.WxAppId)
//fmt.Println("WxAppSecret:", config.AppConfig.WxAppSecret)
fmt.Println("WxAppId:", config.AppConfig.WxAppId) fmt.Println("WxAppId:", config.AppConfig.WxAppId)
fmt.Println("WxAppSecret:", config.AppConfig.WxAppSecret) fmt.Println("WxAppSecret:", config.AppConfig.WxAppSecret)
if err := requests.GetAndParseJson("https://api.weixin.qq.com/cgi-bin/token", map[string]string{ if err := requests.GetAndParseJson("https://api.weixin.qq.com/cgi-bin/token", map[string]string{

View File

@ -19,7 +19,7 @@ type User struct {
Model Model
Uid uint32 `json:"uid" gorm:"column:uid;unique_index"` Uid uint32 `json:"uid" gorm:"column:uid;unique_index"`
MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-黄金会员 4-白金会员 5-黑金会员 MemberLevel uint32 `json:"member_level"` // 会员等级 1-用户 2-黄金会员 3-短期会员 4-白金会员 5-黑金会员
MemberGenre uint32 `json:"member_genre"` // 会员类型 MemberGenre uint32 `json:"member_genre"` // 会员类型
MemberExpire time.Time `json:"member_expire"` // 会员到期时间 MemberExpire time.Time `json:"member_expire"` // 会员到期时间
OpenMemberTime time.Time `json:"open_member_time"` // 开通会员 OpenMemberTime time.Time `json:"open_member_time"` // 开通会员
@ -28,7 +28,7 @@ type User struct {
WxAvatar string `json:"wx_avatar"` // 头像 WxAvatar string `json:"wx_avatar"` // 头像
WxOpenID string `json:"wx_open_id"` // 微信openid WxOpenID string `json:"wx_open_id"` // 微信openid
AppOpenID string `json:"app_open_id"` // AppOpenID string `json:"app_open_id"` //
WxUnionID string `json:"wx_union_id"` // 微信uniodid WxUnionID string `json:"wx_union_id"` // 微信unionId
Tel string `json:"tel"` // 电话 Tel string `json:"tel"` // 电话
Gender uint8 `json:"gender"` // 性别 Gender uint8 `json:"gender"` // 性别
City string `json:"city"` // 城市 City string `json:"city"` // 城市

View File

@ -0,0 +1,67 @@
{
"server": {
"port": 8001,
"client_ip": "112.33.14.191"
},
"jwt": {
"user": {
"access_key": "oOqYrhCNQRvVNAaEo4h4osoW",
"refresh_key": "oOqYrhCadQRvVNAaEo4h4osW",
"access_expire": 259200,
"refresh_expire": 360000
},
"admin": {
"access_key": "oOqYrhCcQRvVNAaEo4h4osoW",
"refresh_key": "oOqYahCadQRvVNAaEo4h4osW",
"access_expire": 3600,
"refresh_expire": 129600
}
},
"log": {
"path": "log_server",
"file": "server",
"level": 0
},
"db": {
"driver": "mysql",
"host": "112.33.14.191",
"port": 3306,
"user": "mh_demo",
"password": "kTGGtddsmGdYRbxP",
"db_name": "mh_demo"
},
"wx": {
"app_id": "wxe1963282cfe4840c",
"app_secret": "27e4dd0c628168d781d8ee45a6415405",
"app_mchId": "1494954322",
"app_mchSecret": "6c9eozed9Hq0hmXPzh5QTcO1KwrJbG3z"
},
"app": {
"app_id": "wxe1963282cfe4840c",
"app_secret": "27e4dd0c628168d781d8ee45a6415405",
"app_mchId": "1494954322",
"app_mchSecret": "6c9eozed9Hq0hmXPzh5QTcO1KwrJbG3z"
},
"wx_pay": {
"callback_url": "https://demo.switch.deovo.com:9004/api/v1/wxpay_refund/notice",
"cert_file":"/Users/li/mh/mh_server/pack/configs/merchant/apiclient_cert.p12",
"key_file":"/Users/li/mh/mh_server/pack/configs/merchant/apiclient_key.pem",
"root_ca_file":"/Users/li/mh/mh_server/pack/configs/merchant/apiclient_cert.pem"
},
"ali_pay": {
"callback_url": ""
},
"sms": {
"access_key_id": "LTAI5atZsVv9y2MJ",
"access_key_secret": "shFlHKZDZshcAHJpwMYFojfoD7pQiX",
"sign_name": "明慧",
"template_code": "SMS_167675071"
},
"redis": {
"host": "127.0.0.1",
"port": 6379,
"password": "",
"db": 100
},
"xianmai_base_url": "https://testh5.xianmai.net.cn"
}

View File

@ -23,10 +23,10 @@
}, },
"db": { "db": {
"driver": "mysql", "driver": "mysql",
"host": "39.108.188.218", "host": "112.33.14.191",
"port": 3306, "port": 3306,
"user": "mh_dev", "user": "mh_dev",
"password": "m5h4parZsXjbeiFh", "password": "d9qy46ONI0ZTF9eH",
"db_name": "mh_dev" "db_name": "mh_dev"
}, },
"wx": { "wx": {
@ -63,4 +63,4 @@
"db": 100 "db": 100
}, },
"xianmai_base_url": "https://testh5.xianmai.net.cn" "xianmai_base_url": "https://testh5.xianmai.net.cn"
} }

Binary file not shown.

Binary file not shown.