This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-11-23 10:06:51 +08:00
parent fe9ffe1fdc
commit d7a8be98ae
12 changed files with 196 additions and 1 deletions

View File

@ -538,6 +538,7 @@ func PortalCmd(portal ice.Any) {
cmd("portal", portal)
// cmd("search", search{Tables: tables})
cmd("meeting", meeting{Table: table})
cmd("paymentlist", paymentlist{Table: table})
cmd("credit", credit{Tables: tables})
cmd("member", member{Tables: tables})
cmd("setting", setting{Table: table})

View File

@ -166,6 +166,18 @@ type Notice struct {
PlaceUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32)"`
}
type Paymentlist struct {
db.ModelWithUID
PlaceUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"`
VendorUID string `gorm:"type:char(32);index"`
Vendor string `gorm:"type:varchar(128)"`
Title string `gorm:"type:varchar(128)"`
Content string `gorm:"type:varchar(128)"`
Amount int32 `gorm:"default:0"`
Status uint8 `gorm:"default:0"`
Type uint8 `gorm:"default:0"`
}
type Meeting struct {
db.ModelWithUID
PlaceUID string `gorm:"type:char(32);index"`
@ -265,7 +277,7 @@ type Support struct {
func init() {
db.CmdModels("",
&Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{}, &City{},
&Apply{}, &Allow{}, &Event{}, &Notice{}, &Meeting{}, &Setting{},
&Apply{}, &Allow{}, &Event{}, &Notice{}, &Paymentlist{}, &Meeting{}, &Setting{},
&Domain{}, &Market{}, &Thumb{}, &Comment{}, &Favor{},
&Command{}, &Message{}, &Recent{}, &Service{}, &Support{},
)

View File

@ -0,0 +1,48 @@
package gonganxitong
import (
"shylinux.com/x/ice"
"shylinux.com/x/community/src/gonganxitong/model"
)
type paymentlist struct {
Table
order string `data:"92"`
fields string `data:"title,content,amount"`
create string `name:"create title* content amount* vendor_uid" role:"leader"`
remove string `name:"remove" role:"leader"`
payfor string `name:"payfor" role:"void"`
}
func (s paymentlist) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case "vendor_uid":
}
}
func (s paymentlist) List(m *ice.Message, arg ...string) {
s.ValueList(m, arg).Display("")
m.PushAction(s.Payfor)
}
func (s paymentlist) Payfor(m *ice.Message, arg ...string) {
s.cmdy(m, s.PaymentRequest, arg...)
}
func (s paymentlist) PaymentRequest(m *ice.Message, arg ...string) {}
func init() { ice.TeamCtxCmd(paymentlist{Table: newTable()}) }
func (s paymentlist) cmdy(m *ice.Message, action ice.Any, arg ...string) {
m.Option(model.PLACE_UID, m.Option(s.PLACE_UID))
m.Cmdy(paymentVendorKey, action, arg)
}
type PaymentVendor interface {
PaymentRequest(m *ice.Message, arg ...string) *ice.Message
}
var paymentVendorKey string
var paymentVendorList = map[string]PaymentVendor{}
func PaymentVendorAdd(key string, vendor PaymentVendor) {
paymentVendorKey, paymentVendorList[key] = key, vendor
}

View File

@ -0,0 +1,9 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.title, "¥ "+value.amount]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]},
{view: html.OUTPUT, list: [value.content]},
] })
},
})

View File

@ -2,6 +2,7 @@
"portal": "用户场景", "placeCreate": "创建", "placeRemove": "删除",
"credit": "用户名片", "member": "组织成员",
"meeting": "在线会议",
"paymentlist": "在线支付",
"setting": "服务配置", "email": "邮箱配置",
"qrcode": "场景码", "event": "事件流", "apply": "权限申请", "allow": "权限审批", "notice": "通知公告",
"domain": "领域分类", "market": "人民广场", "message": "消息待办", "recent": "最近访问", "service": "服务发现", "support": "客服支持",
@ -17,6 +18,7 @@
"city": "https://img.icons8.com/officel/80/qr-code.png",
"street": "https://img.icons8.com/officel/80/qr-code.png",
"meeting": "https://img.icons8.com/officel/80/video-conference.png",
"paymentlist": "https://img.icons8.com/officel/80/online-payment-with-a-credit-card.png",
"credit": "https://img.icons8.com/officel/80/passport.png",
"member": "https://img.icons8.com/officel/80/person-at-home.png",
"setting": "https://img.icons8.com/officel/80/settings--v1.png",

View File

@ -7,6 +7,10 @@ import (
_ "shylinux.com/x/community/src/huodongzuzhi"
_ "shylinux.com/x/community/src/renzhengshouquan"
_ "shylinux.com/x/community/src/yuehaoxitong"
_ "shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment"
_ "shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment/model"
)
func main() { print(ice.Run()) }

View File

@ -6,4 +6,6 @@ import (
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting"
_ "shylinux.com/x/community/src/renzhengshouquan/external/tencentmeeting/model"
_ "shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment"
_ "shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment/model"
)

View File

@ -0,0 +1,23 @@
package model
import "shylinux.com/x/mysql-story/src/db"
const (
UID = "uid"
TITLE = "title"
OPEN_ID = "open_id"
USER_UID = "user_uid"
PLACE_UID = "place_uid"
AUTH_UID = "auth_uid"
AUTH_STATUS = "auth_status"
)
type Weixinpayment struct {
db.ModelWithUID
AuthUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32)"`
AppID string `gorm:"type:varchar(32)"`
MchID string `gorm:"type:varchar(32)"`
}
func init() { db.CmdModels("", &Weixinpayment{}) }

View File

@ -0,0 +1,71 @@
package weixinpayment
import (
"net/http"
"strings"
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/api"
"shylinux.com/x/community/src/gonganxitong"
"shylinux.com/x/community/src/renzhengshouquan"
"shylinux.com/x/community/src/renzhengshouquan/external/weixinpayment/model"
)
type weixinpayment struct {
renzhengshouquan.Table
order string `data:"11"`
fields string `data:"app_id,mch_id"`
create string `name:"create app_id* mch_id*" role:"leader"`
remove string `name:"remove" role:"leader"`
}
func (s weixinpayment) Init(m *ice.Message, arg ...string) {
gonganxitong.PaymentVendorAdd(m.PrefixKey(), s)
s.Table.Init(m, arg...)
}
func (s weixinpayment) List(m *ice.Message, arg ...string) {
s.ValueList(m, arg).Display("")
kit.If(m.Length() > 0, func() { m.Action() })
}
func (s weixinpayment) PaymentRequest(m *ice.Message, arg ...string) *ice.Message {
m.Option("auth_uid", "4c6a8ccf186816b332ad9dc5655255dd")
return s.spide(m, "POST", "pay/transactions/jsapi",
"payer.openid", m.Cmd(api.GONGANXITONG_USER, s.Select, model.UID, m.Option(model.USER_UID)).Append(model.OPEN_ID),
"amount.total", kit.Int(m.Option("amount")), "amount.currency", "CNY",
"description", m.Option(model.TITLE), "out_trade_no", m.Option(model.UID),
"notify_url", strings.Split(m.MergePodCmd("", m.PrefixKey()), "?")[0]+"/action/response/"+m.Option(model.PLACE_UID)+"/"+m.Option(model.UID))
}
func (s weixinpayment) Response(m *ice.Message, arg ...string) *ice.Message {
m.Echo("hello world")
return m
}
func init() { ice.TeamCtxCmd(weixinpayment{}) }
func (s weixinpayment) spide(m *ice.Message, method, api string, arg ...ice.Any) *ice.Message {
msg := s.Select(m.Spawn(), m.OptionSimple(model.AUTH_UID)...)
if msg.Length() == 0 {
m.Echo("请联系公司管理员,配置微信支付的账号")
return m
}
arg = append(arg, "appid", msg.Append("app_id"), "mchid", msg.Append("mch_id"))
method = kit.Select(http.MethodGet, method)
uri, body, args := kit.MergeURL("/v3/"+api, arg...), "", []string{}
kit.If(kit.IsIn(method, http.MethodPost, http.MethodPut), func() {
uri, body = kit.MergeURL("/v3/"+api), kit.Format(kit.Dict(arg...))
args = []string{web.SPIDE_DATA, body}
})
m.Options(web.SPIDE_HEADER, map[string]string{
"Accept": "application/json", "Authorization": doSignature("", "", method, "", "", uri, body),
}).Cmdy(web.SPIDE, ice.DEV, web.SPIDE_RAW, method, "https://api.mch.weixin.qq.com"+uri, args)
kit.If(kit.IsIn(method, http.MethodPost, http.MethodPut), func() { kit.If(!m.IsErr(), func() { m.ProcessRefresh() }) })
return m
}
func doSignature(secretId string, secretKey string, method string, nonce string, now string, uri string, body string) string {
strings.Join([]string{method, uri, now, nonce, body}, "\n")
return ""
}

View File

@ -0,0 +1,7 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.app_id, "/", value.mch_id]},
] })
},
})

View File

@ -0,0 +1,10 @@
{
"weixinpayment": "微信支付",
"icons": {
"weixinpayment": "https://img.icons8.com/officel/80/weixing.png"
},
"input": {
"app_id": "AppID",
"mch_id": "MchID"
}
}

View File

@ -0,0 +1,6 @@
chapter "微信支付"
refer `
后台 https://pay.weixin.qq.com/index.php/core/cert/api_cert#/
文档 https://pay.weixin.qq.com/doc/v3/merchant/4012525057
签名算法 https://segmentfault.com/a/1190000039301729
`