diff --git a/common/model/corp.go b/common/model/corp.go index 0e25917..c641f28 100644 --- a/common/model/corp.go +++ b/common/model/corp.go @@ -10,10 +10,17 @@ type CorpConfig struct { ApproveSecret string `json:"approve_secret"` PaySecret string `json:"pay_secret"` PayAgent string `json:"pay_agent"` - TplIdCheckin string `json:"tplid_checkin"` - TplIdRefund string `json:"tplid_refund"` - TplIdVacation string `json:"tplid_vacation"` - TplIdPayment string `json:"tplid_payment"` + 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"` + TplIdRefund string `json:"tplid_refund"` + TplIdVacation string `json:"tplid_vacation"` + TplIdPayment string `json:"tplid_payment"` SocialDeduct string `json:"social_deduct"` HouseDeduct string `json:"house_deduct"` diff --git a/conf/wxpay/apiclient_cert.pem b/conf/wxpay/batiao_cert.pem similarity index 100% rename from conf/wxpay/apiclient_cert.pem rename to conf/wxpay/batiao_cert.pem diff --git a/conf/wxpay/apiclient_key.pem b/conf/wxpay/batiao_key.pem similarity index 100% rename from conf/wxpay/apiclient_key.pem rename to conf/wxpay/batiao_key.pem diff --git a/server/controller/qyweixin.go b/server/controller/qyweixin.go index b22f029..4b67ed8 100644 --- a/server/controller/qyweixin.go +++ b/server/controller/qyweixin.go @@ -71,7 +71,11 @@ func (q *QyWeixin) HandleRefund(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") amount := cast.ToInt64(ctx.Query("amount")) title := ctx.Query("title") @@ -80,13 +84,6 @@ func (q *QyWeixin) Pay(ctx *gin.Context) { 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() // 获取openid @@ -110,11 +107,11 @@ func (q *QyWeixin) Pay(ctx *gin.Context) { Corpid: cfg.CorpId, Secret: cfg.PaySecret, Agent: cfg.PayAgent, - SerialNumber: config.GetConfig().WxPay.PaySerialNumber, - ApiKey: config.GetConfig().WxPay.PayApiKeyV2, - MchId: config.GetConfig().WxPay.PayMchId, - CertPem: config.GetConfig().WxPay.PayCertPem, - KeyPem: config.GetConfig().WxPay.PayKeyPem, + SerialNumber: cfg.PaySerialNumber, + ApiKey: cfg.PayApiKeyV2, + MchId: cfg.PayMchid, + CertPem: cfg.PayCertPem, + KeyPem: cfg.PayKeyPem, }) if err = qyPay.PayMoney(&req); err != nil {