This commit is contained in:
jiangyong27 2025-03-10 13:17:58 +08:00
parent 7c4fb5e207
commit 66d4338b40
4 changed files with 21 additions and 17 deletions

View File

@ -10,6 +10,13 @@ type CorpConfig struct {
ApproveSecret string `json:"approve_secret"` ApproveSecret string `json:"approve_secret"`
PaySecret string `json:"pay_secret"` PaySecret string `json:"pay_secret"`
PayAgent string `json:"pay_agent"` PayAgent string `json:"pay_agent"`
PayMchid string `json:"pay_mchid"`
PaySerialNumber string `json:"pay_serial_number"`
PayApiKeyV3 string `json:"pay_api_key_v3"`
PayApiKeyV2 string `json:"pay_api_key_v2"`
PayCertPem string `json:"pay_cert_pem"`
PayKeyPem string `json:"pay_key_pem"`
TplIdCheckin string `json:"tplid_checkin"` TplIdCheckin string `json:"tplid_checkin"`
TplIdRefund string `json:"tplid_refund"` TplIdRefund string `json:"tplid_refund"`
TplIdVacation string `json:"tplid_vacation"` TplIdVacation string `json:"tplid_vacation"`

View File

@ -71,7 +71,11 @@ func (q *QyWeixin) HandleRefund(ctx *gin.Context) {
} }
func (q *QyWeixin) Pay(ctx *gin.Context) { func (q *QyWeixin) Pay(ctx *gin.Context) {
cid := cast.ToInt64(ctx.Param("cid")) sess := ctx.Keys[session.ContextSession].(*session.AdminSession)
corp, err := dao.NewCorpDao().GetByHost(sess.GetHeader().Host)
session.CheckDBError(err)
session.CheckNilError(corp, "域名未绑定")
userid := ctx.Query("userid") userid := ctx.Query("userid")
amount := cast.ToInt64(ctx.Query("amount")) amount := cast.ToInt64(ctx.Query("amount"))
title := ctx.Query("title") title := ctx.Query("title")
@ -80,13 +84,6 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
panic("password error") panic("password error")
} }
corp, err := dao.NewCorpDao().Get(cid)
if err != nil {
panic(config.ErrDb.New().Append(err))
}
if corp == nil {
panic(config.ErrInternal.New())
}
cfg := corp.GetConfig() cfg := corp.GetConfig()
// 获取openid // 获取openid
@ -110,11 +107,11 @@ func (q *QyWeixin) Pay(ctx *gin.Context) {
Corpid: cfg.CorpId, Corpid: cfg.CorpId,
Secret: cfg.PaySecret, Secret: cfg.PaySecret,
Agent: cfg.PayAgent, Agent: cfg.PayAgent,
SerialNumber: config.GetConfig().WxPay.PaySerialNumber, SerialNumber: cfg.PaySerialNumber,
ApiKey: config.GetConfig().WxPay.PayApiKeyV2, ApiKey: cfg.PayApiKeyV2,
MchId: config.GetConfig().WxPay.PayMchId, MchId: cfg.PayMchid,
CertPem: config.GetConfig().WxPay.PayCertPem, CertPem: cfg.PayCertPem,
KeyPem: config.GetConfig().WxPay.PayKeyPem, KeyPem: cfg.PayKeyPem,
}) })
if err = qyPay.PayMoney(&req); err != nil { if err = qyPay.PayMoney(&req); err != nil {