mirror of
https://shylinux.com/x/community
synced 2025-07-01 21:21:19 +08:00
opt some
This commit is contained in:
parent
12d4b0e24f
commit
f8eca1a0a1
@ -119,6 +119,7 @@ func (s Table) InputsListValue(m *ice.Message, list ice.Any, key string) string
|
||||
return ""
|
||||
}
|
||||
func (s Table) TransPrice(m *ice.Message, arg []string, field ...string) []string {
|
||||
kit.If(len(field) == 0, func() { field = append(field, "price") })
|
||||
for i := 0; i < len(arg)-1; i += 2 {
|
||||
if kit.IndexOf(field, arg[i]) > -1 {
|
||||
arg[i+1] = kit.Format(kit.Int(kit.Float(arg[i+1]) * 100))
|
||||
@ -190,6 +191,9 @@ func (s Table) Select(m *ice.Message, arg ...string) *ice.Message {
|
||||
kit.If(m.Length() > 0, func() { s.UserPlaceInit(m) })
|
||||
return m
|
||||
}
|
||||
func (s Table) InsertIfNeed(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Cmd("", s.Select, arg).Length() == 0, func() { m.Cmd("", s.Insert, arg) })
|
||||
}
|
||||
func (s Table) InsertOrUpdate(m *ice.Message, arg []string, args ...string) {
|
||||
if s.Select(m, args...).Length() > 0 {
|
||||
s.Update(m, arg, args...)
|
||||
|
@ -126,7 +126,7 @@ func (s Portal) List(m *ice.Message, arg ...string) {
|
||||
s.Hash.List(m, kit.Slice(arg, 1)...).PushAction(mdb.DETAIL, s.Hash.Remove).Action().SortInt(mdb.ORDER)
|
||||
return
|
||||
}
|
||||
if m.Option(model.USER_UID) == "" || m.Cmd(s.user, s.Table.Select, model.UID, m.Option(model.USER_UID)).Length() == 0 {
|
||||
if m.Option(model.USER_UID) == "" {
|
||||
if msg := m.Cmd(s.user, s.Table.Select, model.OPEN_ID, m.Option(ice.MSG_USERNAME)); msg.Length() == 0 {
|
||||
msg := m.Cmd(s.user, s.Table.Create, m.Option(ice.MSG_USERNAME), "", m.OptionDefault(ice.MSG_USERNICK, m.Option(ice.MSG_USERNAME)))
|
||||
m.ProcessCookie(model.USER_UID, msg.Result())
|
||||
@ -135,6 +135,13 @@ func (s Portal) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if m.Cmd(s.user, s.Table.Select, model.UID, m.Option(model.USER_UID)).Length() == 0 {
|
||||
m.Cmd(s.user, s.Table.Insert,
|
||||
model.UID, m.Option(model.USER_UID),
|
||||
model.OPEN_ID, m.Option(ice.MSG_USERNAME),
|
||||
model.NAME, m.OptionDefault(ice.MSG_USERNICK, m.Option(ice.MSG_USERNAME)),
|
||||
)
|
||||
}
|
||||
m.Option(model.SERVICE_UID, ServiceUID(m))
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(m.PrefixKey(), s.PlaceList, m.Option(model.USER_UID)).PushAction(s.PlaceRemove).Action(s.PlaceCreate)
|
||||
|
@ -1,9 +1,6 @@
|
||||
package weixinpayment
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/x509"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -16,8 +13,6 @@ import (
|
||||
"shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment/model"
|
||||
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/auth/verifiers"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/notify"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/services/payments/jsapi"
|
||||
"github.com/wechatpay-apiv3/wechatpay-go/utils"
|
||||
@ -67,7 +62,6 @@ func (s weixinpayment) Response(m *ice.Message, arg ...string) {
|
||||
resp, result, err := svc.QueryOrderByOutTradeNo(m, jsapi.QueryOrderByOutTradeNoRequest{
|
||||
Mchid: core.String(msg.Append(model.MCH_ID)),
|
||||
OutTradeNo: core.String(arg[1]),
|
||||
// OutTradeNo: core.String("027581e07da12f52dac052d7a8ef7659"),
|
||||
})
|
||||
m.Info("weixinpayment %s %s %#v", kit.Format(resp), kit.Format(result), err)
|
||||
if err, ok := err.(*core.APIError); ok {
|
||||
@ -77,33 +71,6 @@ func (s weixinpayment) Response(m *ice.Message, arg ...string) {
|
||||
if m.Warn(*resp.TradeState != "SUCCESS") {
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
request, err := http.NewRequest(http.MethodPost, m.MergePodCmd("", m.PrefixKey()), bytes.NewBufferString(m.Option("request.data")))
|
||||
if m.Warn(err) {
|
||||
return
|
||||
}
|
||||
kit.For([]string{
|
||||
"Wechatpay-Serial",
|
||||
"Wechatpay-Signature",
|
||||
"Wechatpay-Nonce",
|
||||
"Wechatpay-Timestamp",
|
||||
"Wechatpay-Signature-Type",
|
||||
}, func(k string) { request.Header.Set(k, m.Option(k)) })
|
||||
content := make(map[string]interface{})
|
||||
|
||||
mchAPIv3Key := msg.Append(model.API_KEY)
|
||||
wechatPayCert, err := utils.LoadCertificate(msg.Append(model.CERT_FILE))
|
||||
if m.Warn(err) {
|
||||
return
|
||||
}
|
||||
certificateVisitor := core.NewCertificateMapWithList([]*x509.Certificate{wechatPayCert})
|
||||
handler := notify.NewNotifyHandler(mchAPIv3Key, verifiers.NewSHA256WithRSAVerifier(certificateVisitor))
|
||||
notifyReq, err := handler.ParseNotifyRequest(m, request, &content)
|
||||
if m.Warn(err) {
|
||||
return
|
||||
}
|
||||
m.Echo(notifyReq.Summary)
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(weixinpayment{}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user