Explorar el Código

update

master
shenjiachi hace 5 días
padre
commit
80297be035
Se han modificado 7 ficheros con 42 adiciones y 64 borrados
  1. +21
    -4
      app/hdl/hdl_wallet.go
  2. +1
    -4
      app/md/md.wallet.go
  3. +4
    -4
      app/mw/mw_limiter.go
  4. +1
    -14
      docs/docs.go
  5. +1
    -14
      docs/swagger.json
  6. +1
    -11
      docs/swagger.yaml
  7. +13
    -13
      etc/cfg.yml

+ 21
- 4
app/hdl/hdl_wallet.go Ver fichero

@@ -25,6 +25,7 @@ import (
"github.com/go-pay/gopay"
alipay2 "github.com/go-pay/gopay/alipay"
"github.com/jinzhu/copier"
"github.com/tidwall/gjson"
"time"
)

@@ -595,13 +596,29 @@ func BindWxPayAccount(c *gin.Context) {
return
}

appid := svc.GetSysCfgStr("wechat_appid")
secret := svc.GetSysCfgStr("wechat_secret")

wxUrl := fmt.Sprintf("https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code", appid, secret, req.Code)
wechatResp, err := utils.CurlGet(wxUrl, nil)
if err != nil {
e.OutErr(c, 400, e.NewErr(400, "获取微信信息失败"))
return
}
utils.FilePutContents("WithdrawalBinding", utils.SerializeStr(wechatResp))
openId := gjson.Get(string(wechatResp), "openid").String()
wechatToken := gjson.Get(string(wechatResp), "access_token").String()
wechatInfoUrl := "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s"
wechatInfoUrl = fmt.Sprintf(wechatInfoUrl, wechatToken, openId)
wechatInfoResp, _ := utils.CurlGet(wechatInfoUrl, nil)

now := time.Now()
newWxUserInfo := model.WxUserInfo{
Uid: user.Id,
UserId: req.UserId,
OpenId: req.OpenId,
AppId: req.AppId,
Ext: req.Ext,
OpenId: openId,
UserId: gjson.Get(string(wechatResp), "unionid").String(),
UserName: gjson.Get(string(wechatInfoResp), "nickname").String(),
AppId: appid,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}


+ 1
- 4
app/md/md.wallet.go Ver fichero

@@ -48,8 +48,5 @@ type BindAlipayAccountReq struct {
}

type BindWxPayAccountReq struct {
UserId string `json:"user_id"` // 微信用户 id
OpenId string `json:"open_id"` // 微信用户 open_id
AppId string `json:"app_id"` // 微信应用 appid
Ext string `json:"ext" ` // 拓展字段
Code string `json:"code"`
}

+ 4
- 4
app/mw/mw_limiter.go Ver fichero

@@ -16,10 +16,10 @@ func Limiter(c *gin.Context) {
limit := 500 // 限流次数
ttl := 2 // 限流过期时间
ip := utils.GetIP(c.Request)
if ip != "221.4.210.167" {
e.OutErr(c, e.ERR, "系统维护中~")
return
}
//if ip != "221.4.210.167" {
// e.OutErr(c, e.ERR, "系统维护中~")
// return
//}
// 读取token或者ip
token := c.GetHeader("Authorization")
// 判断是否已经超出限额次数


+ 1
- 14
docs/docs.go Ver fichero

@@ -4618,20 +4618,7 @@ const docTemplate = `{
"md.BindWxPayAccountReq": {
"type": "object",
"properties": {
"app_id": {
"description": "微信应用 appid",
"type": "string"
},
"ext": {
"description": "拓展字段",
"type": "string"
},
"open_id": {
"description": "微信用户 open_id",
"type": "string"
},
"user_id": {
"description": "微信用户 id",
"code": {
"type": "string"
}
}


+ 1
- 14
docs/swagger.json Ver fichero

@@ -4612,20 +4612,7 @@
"md.BindWxPayAccountReq": {
"type": "object",
"properties": {
"app_id": {
"description": "微信应用 appid",
"type": "string"
},
"ext": {
"description": "拓展字段",
"type": "string"
},
"open_id": {
"description": "微信用户 open_id",
"type": "string"
},
"user_id": {
"description": "微信用户 id",
"code": {
"type": "string"
}
}


+ 1
- 11
docs/swagger.yaml Ver fichero

@@ -308,17 +308,7 @@ definitions:
type: object
md.BindWxPayAccountReq:
properties:
app_id:
description: 微信应用 appid
type: string
ext:
description: 拓展字段
type: string
open_id:
description: 微信用户 open_id
type: string
user_id:
description: 微信用户 id
code:
type: string
type: object
md.CollegeDetailReq:


+ 13
- 13
etc/cfg.yml Ver fichero

@@ -10,26 +10,26 @@ redis_addr: '127.0.0.1:6379'
redis_password: ''


#db:
# host: '119.23.182.117:3306'
# name: 'egg'
# user: 'root'
# psw: 'Fnuo123com@'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'
db:
host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
host: '119.23.182.117:3306'
name: 'egg'
user: 'canal'
psw: 'DengBiao@1997'
user: 'root'
psw: 'Fnuo123com@'
show_log: true
max_lifetime: 30
max_open_conns: 100
max_idle_conns: 100
path: 'tmp/%s.log'
#db:
# host: 'advertisement-db.rwlb.rds.aliyuncs.com:3306'
# name: 'egg'
# user: 'canal'
# psw: 'DengBiao@1997'
# show_log: true
# max_lifetime: 30
# max_open_conns: 100
# max_idle_conns: 100
# path: 'tmp/%s.log'

#db_back:
# host: '119.23.182.117:3306'


Cargando…
Cancelar
Guardar