This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-06-17 14:54:43 +08:00
parent c2a4a69883
commit eaf75a1b7a
11 changed files with 148 additions and 83 deletions

View File

@ -427,11 +427,13 @@ func (s Table) Link(m *ice.Message, arg ...string) string {
return m.Cmdx(s.PrefixPortal(m), s.Link, arg)
}
func (s Table) WaitWorkerCreate(m *ice.Message, help string) {
kit.If(help == "", func() { help = m.GetCommand().Help })
kit.If(!s.IsWorker(m), func() {
kit.If(m.Action().Length() == 0, func() { m.SetResult("请等待「工作人员」创建" + help) })
})
}
func (s Table) WaitLeaderCreate(m *ice.Message, help string) {
kit.If(help == "", func() { help = m.GetCommand().Help })
kit.If(!s.IsLeader(m), func() {
kit.If(m.Action().Length() == 0, func() { m.SetResult("请等待「管理人员」创建" + help) })
})

View File

@ -15,6 +15,11 @@ $action div.item.text.filter i { padding-left:10px; }
$action div.item.text.filter span { right:5px; }
$action div.item.text.filter input { border-radius:20px; border:none; padding-left:32px; padding-right:32px; width:100%; }
$action div.item.text.filter input:focus { border:var(--box-border); }
$action div.item.user_info img { height:32px; border-radius:20px; margin-left:10px; }
$action div.item.user_info { padding:10px; }
$action div.item.user_info>div.name { display:flex; flex-direction:column; align-items:end; }
$action div.item.user_info>div.name>span.time { font-size:10px; color:var(--disable-fg-color); }
$action div.item.space { flex-grow:1; }
fieldset>div.output>div.tabs { display:flex; }
fieldset.input.key>div.output>div.tabs { display:none; }
fieldset>div.output>div.tabs>div.item { padding:5px; line-height:20px; }
@ -48,6 +53,7 @@ $output>div>div.list>div.output>div.item.index span { font-size:12px; white-spac
$output>div>div.list div.code { text-align:center; }
$output>div>div.list div.code input { background-color:var(--notice-bg-color); color:var(--notice-fg-color); font-size:18px; margin:auto; margin-top:10px; min-width:200px; display:block; }
$output>div>div.list fieldset.story>div.output { background-color:var(--plugin-bg-color); }
$output.public>div>div.list.myplace { position:sticky; top:0; z-index:3; }
$output>div>div.list.myplace>div.output { max-height:320px; }
$output>div>div.list.myplace>div.output>div.item>div.output div.title { margin-bottom:5px; }
$output:not(.public)>div>div.list.myplace>div.output>div.item { padding:0 10px; }
@ -154,6 +160,7 @@ $output fieldset.story>form.option { display:none; }
$output fieldset.story>div.action { display:none; }
$output fieldset.story>div.status { display:none; }
$output fieldset.story>div.output { background-color:var(--plugin-bg-color); }
$output fieldset.story>div.output>div.place_info { position:sticky; top:0; z-index:3; }
$output fieldset.story>div.output table.content td { box-shadow:none; }
$output fieldset.story>div.output table.content.detail td:last-child { text-align:left; }
$output fieldset.story>div.output table.content td img { max-width:100%; }
@ -168,7 +175,7 @@ $output fieldset.story>div.output>div.code div.item.button input[type=button] {
$output fieldset.story>div.output>div.code div.item.button input[type=button][name=cancel] { border:var(--box-border); background-color:var(--danger-bg-color); color:var(--danger-fg-color); }
$output fieldset.story>div.output>div.code div.item.button.danger input[type=button] { background-color:var(--danger-bg-color); color:var(--danger-fg-color); }
$output fieldset.story>div.output>div.info>input[type=button] { box-shadow:var(--box-shadow); border:none; background-color:var(--notice-bg-color); color:var(--notice-fg-color); font-size:20px; height:48px; width:100%; max-width:320px; }
$output fieldset.story>div.output>div.info { padding:10px 20px; text-align:center; }
$output fieldset.story>div.output>div.info { padding:10px 20px; text-align:center; white-space:pre; }
$output>fieldset.story>div.output div.item.card>div.output { padding:10px; width:100%; }
$output>fieldset.story>div.output div.item.card>div.output div.output { padding:5px 0; white-space:pre-line; }
$output>fieldset.story>div.output div.item.card.loaded>div.output { background-color:var(--plugin-bg-color); }

View File

@ -93,6 +93,7 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
}()
m.OptionDefault(model.FROM_USER_UID, m.Option(ice.MSG_USERUID))
m.OptionDefault(model.TO_USER_UID, m.Option(model.USER_UID))
m.OptionDefault(model.TO_USER_UID, m.Option(ice.MSG_USERUID))
m.Option(model.USER_UID, m.Option(ice.MSG_USERUID))
m.Option(model.PLACE_UID, m.Option(s.Keys(s.Place, model.UID)))
m.Option(model.COMMAND_UID, CommandUID(m, arg[0]))

View File

@ -25,6 +25,9 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
}
func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
m.RewriteAppend(func(value, key string, index int) string {
if _, e := strconv.ParseInt(value, 10, 64); e != nil {
return value
}
switch key {
case model.USER_{{.Option "CLASS"}}_ROLE:
value = User{{.Option "Class"}}Role(kit.Int(value)).String()

View File

@ -14,11 +14,17 @@ type account struct {
create string `name:"create account_type*" role:"leader"`
createDefault string `name:"createDefault" role:"leader" help:"开通默认账户"`
remove string `name:"remove" role:"leader"`
recharge string `name:"recharge amount*" role:"leader" help:"充值"`
transfer string `name:"transfer amount* to_account_uid*:select" role:"leader" help:"转账"`
withdraw string `name:"withdraw amount*" role:"leader" help:"提现"`
recharge string `name:"recharge amount* title content" role:"leader" help:"充值"`
transfer string `name:"transfer amount* to_account_uid*:select title content" role:"leader" help:"转账"`
withdraw string `name:"withdraw amount* title content" role:"leader" help:"提现"`
}
func (s account) SelectDefault(m *ice.Message, arg ...string) {
s.Tables(m, Auth{}, "LEFT JOIN user_auths ON auths.uid = user_auths.auth_uid")
s.Fields(m, s.Key(s, model.UID), s.Key(Auth{}, model.NAME), s.Key(Auth{}, model.AVATAR), model.AUTH_STATUS, model.AUTH_TYPE)
s.Select(m, "user_auths.user_uid = ? AND (role = 1 OR role = 2)", arg[0])
s.authSort(m)
}
func (s account) CreateDefault(m *ice.Message, arg ...string) {
s.ValueCreate(m, arg...)
}

View File

@ -27,10 +27,18 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
s.InputsList(m, AuthStatusList, arg...)
case model.ACCOUNT_TYPE:
s.InputsList(m, AccountTypeList, arg...)
case model.TRANSITION_TYPE:
s.InputsList(m, TransitionTypeList, arg...)
case model.FROM_UID:
if AuthType(kit.Int(m.Option(model.AUTH_TYPE))) == AuthRoot {
m.Push(arg[0], aaa.ROOT)
}
case model.FROM_ACCOUNT_UID:
m.Cmdy(account{}, "selectDefault", m.Option(model.FROM_USER_UID))
m.Display("account_inputs.js").Option("_input_args", model.UID, model.NAME, model.AVATAR)
case model.TO_ACCOUNT_UID:
m.Cmdy(account{}, "selectDefault", m.Option(model.TO_USER_UID))
m.Display("account_inputs.js").Option("_input_args", model.UID, model.NAME, model.AVATAR)
default:
s.Table.Inputs(m, arg...)
}
@ -51,6 +59,8 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
value = CertStatus(kit.Int(value)).String()
case model.TRANSITION_TYPE:
value = TransitionType(kit.Int(value)).String()
case model.TRANSITION_AMOUNT:
value = kit.Format("%.2f", kit.Float(value)/100)
}
return value
})

View File

@ -3,59 +3,61 @@ package model
import "shylinux.com/x/mysql-story/src/db"
const (
UID = "uid"
NAME = "name"
INFO = "info"
TYPE = "type"
ROLE = "role"
STATUS = "status"
AMOUNT = "amount"
SCORE = "score"
TITLE = "title"
CONTENT = "content"
AVATAR = "avatar"
BACKGROUND = "background"
USER_UID = "user_uid"
USER_AUTH_ROLE = "user_auth_role"
AUTH_UID = "auth_uid"
AUTH_NAME = "auth_name"
AUTH_INFO = "auth_info"
AUTH_TYPE = "auth_type"
AUTH_STATUS = "auth_status"
AUTH_AVATAR = "auth_avatar"
CERT_UID = "cert_uid"
CERT_STATUS = "cert_status"
ACCOUNT_TYPE = "account_type"
FROM_ACCOUNT_UID = "from_account_uid"
TO_ACCOUNT_UID = "to_account_uid"
TRANSITION_TYPE = "transition_type"
PLACE_NAME = "place_name"
STREET_NAME = "street_name"
COMPANY_UID = "company_uid"
COMPANY_NAME = "company_name"
CITY_UID = "city_uid"
CITY_NAME = "city_name"
FROM_UID = "from_uid"
FROM_USER_UID = "from_user_uid"
TO_USER_UID = "to_user_uid"
PLACE_UID = "place_uid"
VALUE_UID = "value_uid"
SERVICE_UID = "service_uid"
DASHBOARD_UID = "dashboard_uid"
STORAGE_UID = "storage_uid"
SPACE = "space"
INDEX = "index"
VALUE = "value"
PATH = "path"
NUMBER = "number"
BIRTH = "birth"
PERIOD = "period"
PERSON = "person"
AUTHOR = "author"
ADDRESS = "address"
MOBILE = "mobile"
VERIFY = "verify"
VENDOR = "vendor"
UID = "uid"
ICON = "icon"
NAME = "name"
INFO = "info"
TYPE = "type"
ROLE = "role"
STATUS = "status"
AMOUNT = "amount"
SCORE = "score"
TITLE = "title"
CONTENT = "content"
AVATAR = "avatar"
BACKGROUND = "background"
USER_UID = "user_uid"
USER_AUTH_ROLE = "user_auth_role"
AUTH_UID = "auth_uid"
AUTH_NAME = "auth_name"
AUTH_INFO = "auth_info"
AUTH_TYPE = "auth_type"
AUTH_STATUS = "auth_status"
AUTH_AVATAR = "auth_avatar"
CERT_UID = "cert_uid"
CERT_STATUS = "cert_status"
ACCOUNT_TYPE = "account_type"
FROM_ACCOUNT_UID = "from_account_uid"
TO_ACCOUNT_UID = "to_account_uid"
TRANSITION_TYPE = "transition_type"
TRANSITION_AMOUNT = "transition_amount"
PLACE_NAME = "place_name"
STREET_NAME = "street_name"
COMPANY_UID = "company_uid"
COMPANY_NAME = "company_name"
CITY_UID = "city_uid"
CITY_NAME = "city_name"
FROM_UID = "from_uid"
FROM_USER_UID = "from_user_uid"
TO_USER_UID = "to_user_uid"
PLACE_UID = "place_uid"
VALUE_UID = "value_uid"
SERVICE_UID = "service_uid"
DASHBOARD_UID = "dashboard_uid"
STORAGE_UID = "storage_uid"
SPACE = "space"
INDEX = "index"
VALUE = "value"
PATH = "path"
NUMBER = "number"
BIRTH = "birth"
PERIOD = "period"
PERSON = "person"
AUTHOR = "author"
ADDRESS = "address"
MOBILE = "mobile"
VERIFY = "verify"
VENDOR = "vendor"
)
type UserAuth struct {
@ -93,7 +95,7 @@ type Cert struct {
Verify string `gorm:"type:varchar(16)"`
}
type Account struct {
db.ModelWithUID
db.ModelContent
AuthUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"`
Type uint8 `gorm:"default:0"`
@ -101,7 +103,7 @@ type Account struct {
Amount int `gorm:"default:0"`
}
type Transition struct {
db.ModelWithUID
db.ModelContent
AuthUID string `gorm:"type:char(32);index"`
UserUID string `gorm:"type:char(32);index"`
FromAccountUID string `gorm:"type:char(32);index"`

View File

@ -26,6 +26,9 @@
"auth_name": "认证主体",
"auth_type": "认证类型",
"auth_status": "认证状态",
"transition_type": "流水类型",
"from_account_uid": "来自",
"to_account_uid": "转给",
"mobile": "手机号",
"verify": "验证码",
"from_uid": "认证机构",

View File

@ -11,6 +11,7 @@ import (
type profile struct {
Auth
order string `data:"3"`
role string `data:""`
modify string `name:"modify info" role:"leader"`
upload string `name:"upload" role:"leader"`
authList string `name:"authList" role:"void"`

View File

@ -2,35 +2,61 @@ package renzhengshouquan
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/renzhengshouquan/model"
)
type transition struct {
Table
order string `data:"5"`
auth string `data:"issued"`
role string `data:"leader,worker"`
fields string `data:"transition_type,status,amount,from_account_uid,to_account_uid"`
create string `name:"create transition_type* amount* from_account_uid to_account_uid" role:"leader"`
remove string `name:"remove" role:"leader"`
testMarket string `name:"testMarket domain_uid*:select title* content price" style:"notice" role:"leader"`
testMessage string `name:"testMessage from_user_uid*:select to_user_uid*:select title* content price" style:"notice" role:"worker"`
testTemplate string `name:"testMessage from_user_uid*:select to_user_uid*:select title*" style:"notice" role:"worker"`
order string `data:"5"`
auth string `data:"issued"`
role string `data:"leader,worker"`
create string `name:"create transition_type* amount* title content from_account_uid to_account_uid" role:"leader"`
remove string `name:"remove" role:"leader"`
}
func (s transition) List(m *ice.Message, arg ...string) {
s.ValueList(m, arg).Display("")
m.PushAction(s.TestMessage, s.TestMarket, s.TestTemplate)
}
func (s transition) TestMarket(m *ice.Message, arg ...string) {
s.MarketInsert(m, arg...)
}
func (s transition) TestMessage(m *ice.Message, arg ...string) {
s.SendMessage(m, m.Option(model.FROM_USER_UID), m.Option(model.TO_USER_UID), arg...)
}
func (s transition) TestTemplate(m *ice.Message, arg ...string) {
s.SendTemplate(m, "", m.Option(model.TO_USER_UID), m.Option(model.TITLE))
s.Tables(m,
"LEFT JOIN accounts AS to_accounts ON to_account_uid = to_accounts.uid",
"LEFT JOIN auths AS to_auths ON to_accounts.auth_uid = to_auths.uid",
"LEFT JOIN accounts AS from_accounts ON from_account_uid = from_accounts.uid",
"LEFT JOIN auths AS from_auths ON from_accounts.auth_uid = from_auths.uid",
).FieldsWithCreatedAT(m, s,
"transition_type", "transition_status", s.Key(s, model.AMOUNT), s.Key(s, model.USER_UID),
"from_account_uid", "from_auths.uid AS from_auth_uid", "from_auth_name", "from_auth_type", "from_auth_avatar",
"to_account_uid", "to_auths.uid AS to_auth_uid", "to_auth_name", "to_auth_type", "to_auth_avatar",
)
if len(arg) == 1 {
if !s.IsWorker(m) {
return
}
s.Select(m, "to_auths.uid = ? OR from_auths.uid = ?", arg[0], arg[0])
} else {
s.Select(m, "transitions.uid = ? AND (to_auths.uid = ? OR from_auths.uid = ?)", arg[1], arg[0], arg[0])
}
m.Table(func(value ice.Maps) {
switch TransitionType(kit.Int(value["transition_type"])) {
case TransitionRecharge:
m.Push(model.NAME, value["to_auth_name"])
m.Push(model.AUTH_TYPE, value["to_auth_type"])
m.Push(model.ICON, value["to_auth_avatar"])
case TransitionTransfer:
if value["from_auth_uid"] == arg[0] {
m.Push(model.NAME, value["to_auth_name"])
m.Push(model.AUTH_TYPE, value["to_auth_type"])
m.Push(model.ICON, value["to_auth_avatar"])
} else {
m.Push(model.NAME, value["from_auth_name"])
m.Push(model.AUTH_TYPE, value["from_auth_type"])
m.Push(model.ICON, value["from_auth_avatar"])
}
case TransitionWithdraw:
m.Push(model.NAME, value["from_auth_name"])
m.Push(model.AUTH_TYPE, value["from_auth_type"])
m.Push(model.ICON, value["from_auth_avatar"])
}
}).Action().Display("").DisplayCSS("")
}
func init() { ice.TeamCtxCmd(transition{}) }

View File

@ -1,9 +1,13 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.title||value.name||value.user_name, value.transition_type, value.amount, can.onimport.titleAction(can, value)]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]},
{view: html.OUTPUT, list: [value.content||value.info]},
can.onimport.myView(can, msg, function(value) { value._style = [value.transition_type, value.transition_type == "转账"? value.from_auth_uid == can.Option("auth_uid")? "转给": "来自": ""]; return [
{view: html.TITLE, list: [value.title, value.transition_type,
value.transition_type == "转账"? value.from_auth_uid == can.Option("auth_uid")? "转给": "来自": "",
can.onimport.textView(can, value, "auth_type"),
value.transition_type == "转账"? value.name: "",
can.onimport.moneyView(can, value),
]}, can.onimport.metaView(can, value),
{view: html.OUTPUT, list: [value.content]}, can.onimport.titleAction(can, value),
] })
},
})