From d73ed5b838327c67ec7656f3a14f9d232619e1f4 Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 6 Dec 2024 09:00:24 +0800 Subject: [PATCH] add some --- src/gonganxitong/common.go | 12 +++- src/gonganxitong/contract.go | 2 +- src/gonganxitong/document.go | 2 +- src/gonganxitong/goodslist.go | 62 ++++++++++++------- src/gonganxitong/goodslist.js | 9 +++ src/gonganxitong/meeting.go | 2 +- src/gonganxitong/model/model.go | 7 ++- src/gonganxitong/paymentlist.go | 2 +- src/gonganxitong/photo.go | 2 +- src/gonganxitong/portal.json | 6 +- src/gonganxitong/quotalist.go | 35 +++++++++-- src/gonganxitong/user.go | 33 +++++++--- .../tencentdocument/tencentdocument.go | 7 ++- src/template/web.code.autogen/demo.go | 6 +- 14 files changed, 136 insertions(+), 51 deletions(-) diff --git a/src/gonganxitong/common.go b/src/gonganxitong/common.go index 8d1c460..baf5e0a 100644 --- a/src/gonganxitong/common.go +++ b/src/gonganxitong/common.go @@ -118,6 +118,14 @@ 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 { + for i := 0; i < len(arg)-1; i += 2 { + if kit.IndexOf(field, arg[0]) > -1 { + arg[i+1] = kit.Format(kit.Int(kit.Float(arg[i+1]) * 100)) + } + } + return arg +} func (s Table) ValueModel(m *ice.Message, action ice.Any, arg ...string) *ice.Message { defer m.Options(db.DB, m.Configv(db.DB)).Set(ice.MSG_OPTION, db.DB) defer m.Options(db.MODEL, m.Configv(db.MODEL)).Set(ice.MSG_OPTION, db.MODEL) @@ -563,8 +571,8 @@ func PortalCmd(portal ice.Any) { } cmd("portal", portal) cmd("goodslist", goodslist{Table: table}) - cmd("quotalist", goodslist{Table: table}) - cmd("spendlist", goodslist{Table: table}) + cmd("quotalist", quotalist{Table: table}) + cmd("spendlist", spendlist{Table: table}) cmd("paymentlist", paymentlist{Table: table}) cmd("meeting", meeting{Table: table}) cmd("document", document{Table: table}) diff --git a/src/gonganxitong/contract.go b/src/gonganxitong/contract.go index ec0a8b0..76e6a1b 100644 --- a/src/gonganxitong/contract.go +++ b/src/gonganxitong/contract.go @@ -4,7 +4,7 @@ import "shylinux.com/x/ice" type contract struct { Table - order string `data:"94"` + order string `data:"95"` fields string `data:"title"` create string `name:"create title*" role:"leader"` remove string `name:"remove" role:"leader"` diff --git a/src/gonganxitong/document.go b/src/gonganxitong/document.go index ba335eb..b01b15d 100644 --- a/src/gonganxitong/document.go +++ b/src/gonganxitong/document.go @@ -9,7 +9,7 @@ import ( type document struct { Table - order string `data:"93"` + order string `data:"94"` fields string `data:"folder_id,vendor,user_uid"` open string `name:"open" style:"notice" role:"void"` } diff --git a/src/gonganxitong/goodslist.go b/src/gonganxitong/goodslist.go index e989eff..dd10951 100644 --- a/src/gonganxitong/goodslist.go +++ b/src/gonganxitong/goodslist.go @@ -12,36 +12,56 @@ type goodslist struct { Table order string `data:"91"` fields string `data:"name,price,title,content,user_uid"` - create string `name:"create name* title* content*" role:"leader"` + create string `name:"create name* price* title* content*" role:"leader"` remove string `name:"remove" role:"leader"` payfor string `name:"payfor" help:"购买" style:"notice" role:"worker"` } func (s goodslist) AfterMigrate(m *ice.Message, arg ...string) { s.Table.AfterMigrate(m, arg...) - s.insert(m, "service", "2-1", "1000", "初级版") - s.insert(m, "service", "2-2", "3000", "高级版") - s.insert(m, "service", "2-3", "5000", "旗舰版") - s.insert(m, "company", "5-1", "10000", "企业初级版") - s.insert(m, "company", "5-2", "30000", "企业高级版") - s.insert(m, "company", "5-3", "50000", "企业旗舰版") + s.insert(m, "service", "3-1", "1000", "初级版") + s.insert(m, "service", "3-2", "3000", "高级版") + s.insert(m, "service", "3-3", "5000", "旗舰版") + s.insert(m, "company", "4-1", "10000", "企业初级版") + s.insert(m, "company", "4-2", "30000", "企业高级版") + s.insert(m, "company", "4-3", "50000", "企业旗舰版") + s.insert(m, "school", "5-1", "10000", "教育初级版") + s.insert(m, "school", "5-2", "30000", "教育高级版") + s.insert(m, "school", "5-3", "50000", "教育旗舰版") +} +func (s goodslist) Create(m *ice.Message, arg ...string) { + s.ValueCreate(m, s.TransPrice(m, arg, model.PRICE)...) } func (s goodslist) List(m *ice.Message, arg ...string) { - if s.PrefixPortal(m) == api.RENZHENGSHOUQUAN_PORTAL { - msg := m.Cmd(api.RENZHENGSHOUQUAN_AUTH, s.Select, model.UID, arg[0]) - switch kit.Int(msg.Append(model.AUTH_TYPE)) { - case 3: - s.Select(m, model.PLACE_UID, "service") - case 4: - s.Select(m, model.PLACE_UID, "company") - } - m.PushAction(s.Payfor).Action() - } else { - s.Select(m, model.PLACE_UID, "service") - m.PushAction(s.Payfor).Action() - if s.IsLeader(m) { - m.Action(s.Create) + if len(arg) == 1 { + if s.PrefixPortal(m) == api.RENZHENGSHOUQUAN_PORTAL { + msg := m.Cmd(api.RENZHENGSHOUQUAN_AUTH, s.Table.Select, model.UID, arg[0]) + switch kit.Int(msg.Append(model.AUTH_TYPE)) { + case 3: + s.Table.Select(m, model.PLACE_UID, "service") + case 4: + s.Table.Select(m, model.PLACE_UID, "company") + case 5: + s.Table.Select(m, model.PLACE_UID, "school") + } + m.PushAction(s.Payfor).Action() + } else { + if s.IsLeader(m) { + s.Table.Select(m, model.PLACE_UID, "service") + m.PushAction(s.Payfor).Action() + } + msg := s.Table.Select(m.Spawn(), model.PLACE_UID, arg[0]) + if s.IsLeader(m) { + msg.PushAction(s.Payfor, s.Table.Remove).Action(s.Table.Create) + } else { + msg.PushAction(s.Payfor).Action() + } + m.Copy(msg) + s.SelectJoinUser(m) } + } else if len(arg) == 2 { + m.Cmdy(quotalist{}, s.Select, model.GOODSLIST_UID, arg[1]) + m.Action(s.Payfor) } m.Display("") } diff --git a/src/gonganxitong/goodslist.js b/src/gonganxitong/goodslist.js index d6582a0..3caae34 100644 --- a/src/gonganxitong/goodslist.js +++ b/src/gonganxitong/goodslist.js @@ -1,5 +1,14 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { + if (can.Option(UID)) { + can.onimport.myView(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.vendor]}, + {view: html.OUTPUT, list: [value.total+"M"]}, + ] }, function() { + + }) + return + } can.onimport.myView(can, msg, function(value) { return [ {view: html.TITLE, list: [value.title, "¥ "+value.price/100+" / 月", can.onimport.titleAction(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), value.user_name]}, diff --git a/src/gonganxitong/meeting.go b/src/gonganxitong/meeting.go index 80e8f03..96be029 100644 --- a/src/gonganxitong/meeting.go +++ b/src/gonganxitong/meeting.go @@ -10,7 +10,7 @@ import ( type meeting struct { Table - order string `data:"92"` + order string `data:"93"` role string `data:"leader,worker"` fields string `data:"user_id,vendor"` config string `name:"config place_uid* user_uid* user_id* vendor*"` diff --git a/src/gonganxitong/model/model.go b/src/gonganxitong/model/model.go index 5f5aefe..d6d8044 100644 --- a/src/gonganxitong/model/model.go +++ b/src/gonganxitong/model/model.go @@ -112,6 +112,8 @@ const ( ACCESS_TOKEN = "access_token" EXPIRE_TIME = "expire_time" PRICE = "price" + TOTAL = "total" + GOODSLIST_UID = "goodslist_uid" ) type Sess struct { @@ -157,16 +159,17 @@ type Quotalist struct { db.ModelWithUID PlaceUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32)"` - GoodslistUID string `gorm:"type:char(32)"` + GoodslistUID string `gorm:"type:char(32);index"` Vendor string `gorm:"type:varchar(128)"` Total int - Count int } type Spendlist struct { db.ModelWithUID PlaceUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32)"` QuotalistUID string `gorm:"type:char(32)"` + Vendor string `gorm:"type:varchar(128)"` + Total int Count int } type Paymentlist struct { diff --git a/src/gonganxitong/paymentlist.go b/src/gonganxitong/paymentlist.go index e03b569..a567f58 100644 --- a/src/gonganxitong/paymentlist.go +++ b/src/gonganxitong/paymentlist.go @@ -9,7 +9,7 @@ import ( type paymentlist struct { Table - order string `data:"91"` + order string `data:"92"` auth_uid string `data:""` fields string `data:"title,content,amount,paymentlist_status,user_uid"` create string `name:"create amount* title* content" role:"leader"` diff --git a/src/gonganxitong/photo.go b/src/gonganxitong/photo.go index 3e31ca8..63b6749 100644 --- a/src/gonganxitong/photo.go +++ b/src/gonganxitong/photo.go @@ -9,7 +9,7 @@ import ( type photo struct { Table - order string `data:"95"` + order string `data:"96"` fields string `data:"space_id,access_token,expire_time,vendor"` remove string `name:"remove" role:"worker"` upload string `name:"upload" role:"worker"` diff --git a/src/gonganxitong/portal.json b/src/gonganxitong/portal.json index 7a71755..069d4f0 100644 --- a/src/gonganxitong/portal.json +++ b/src/gonganxitong/portal.json @@ -14,10 +14,6 @@ "auth": "认证", "authCreate": "认证申请", "authCity": "城市认证", "authPersonal": "个人认证", "authService": "服务认证", "authCompany": "公司认证", "config": "配置", "code": "编程", "data": "数据", "cache": "缓存", "icons": { - "user": "https://img.icons8.com/officel/80/qr-code.png", - "city": "https://img.icons8.com/officel/80/qr-code.png", - "street": "https://img.icons8.com/officel/80/qr-code.png", - "goodslist": "https://img.icons8.com/officel/80/online-store.png", "paymentlist": "https://img.icons8.com/officel/80/online-payment-with-a-credit-card.png", "meeting": "https://img.icons8.com/officel/80/video-conference.png", @@ -100,7 +96,7 @@ "creator": "创建人", "landlord": "房东", "tenant": "租客", - "admin": "管理员", + "admin": "管家", "style": { "creator": "danger", "landlord": "danger" diff --git a/src/gonganxitong/quotalist.go b/src/gonganxitong/quotalist.go index a94fdb1..c1e8461 100644 --- a/src/gonganxitong/quotalist.go +++ b/src/gonganxitong/quotalist.go @@ -1,15 +1,42 @@ package gonganxitong -import "shylinux.com/x/ice" +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" + + "shylinux.com/x/community/src/api" + "shylinux.com/x/community/src/gonganxitong/model" +) type quotalist struct { Table - fields string `data:"title,content,user_uid"` - create string `name:"create title* content*" role:"leader"` - remove string `name:"remove" role:"leader"` + fields string `data:"vendor,total"` } +func (s quotalist) AfterMigrate(m *ice.Message, arg ...string) { + s.Table.AfterMigrate(m, arg...) + s.insert(m, "service", "3-1", "1000", api.GONGANXITONG_DOCUMENT) + s.insert(m, "service", "3-1", "1000", api.GONGANXITONG_PHOTO) +} +func (s quotalist) insert(m *ice.Message, auth, level, total string, arg ...string) { + s.Insert(m, model.UID, kit.Hashs(auth, level, kit.Select(m.PrefixKey(), arg, 0)), model.GOODSLIST_UID, kit.Hashs(auth, level), model.PLACE_UID, auth, + model.TOTAL, total, model.VENDOR, kit.Select(m.PrefixKey(), arg, 0)) +} func (s quotalist) List(m *ice.Message, arg ...string) { + s.Select(m, model.PLACE_UID, arg[0]) + if s.PrefixPortal(m) == api.RENZHENGSHOUQUAN_PORTAL { + msg := m.Cmd(api.RENZHENGSHOUQUAN_AUTH, s.Table.Select, model.UID, arg[0]) + switch kit.Int(msg.Append(model.AUTH_TYPE)) { + case 3: + s.Table.Select(m, model.PLACE_UID, "service") + case 4: + s.Table.Select(m, model.PLACE_UID, "company") + case 5: + s.Table.Select(m, model.PLACE_UID, "school") + } + } else { + + } } func init() { ice.TeamCtxCmd(quotalist{Table: newTable()}) } diff --git a/src/gonganxitong/user.go b/src/gonganxitong/user.go index 25090ef..738c182 100644 --- a/src/gonganxitong/user.go +++ b/src/gonganxitong/user.go @@ -1,11 +1,14 @@ package gonganxitong import ( + "net/http" "time" "shylinux.com/x/ice" "shylinux.com/x/icebergs/base/aaa" + "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" + "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/gonganxitong/model" @@ -13,12 +16,14 @@ import ( type user struct { Table - setting setting - template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"` - create string `name:"create open_id* avatar usernick"` - modify string `name:"modify info" role:"void"` - list string `name:"list uid auto" role:"void"` - email string `name:"email email*"` + setting setting + template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"` + create string `name:"create open_id* avatar usernick"` + modify string `name:"modify info" role:"void"` + list string `name:"list uid auto" role:"void"` + email string `name:"email email*"` + setCookie string `name:"setCookie" help:"切换" role:"void"` + sendCookie string `name:"sendCookie" help:"授权" role:"void"` } func (s user) Create(m *ice.Message, arg ...string) { @@ -37,17 +42,24 @@ func (s user) Modify(m *ice.Message, arg ...string) { func (s user) Remove(m *ice.Message, arg ...string) { s.Delete(m, m.OptionSimple(model.UID)...) } +func (s user) SelectTotal(m *ice.Message, arg ...string) string { + msg := m.Spawn() + s.Fields(msg, "count(*) AS total") + return s.Select(msg, arg...).Append("total") +} func (s user) List(m *ice.Message, arg ...string) { if len(arg) == 0 { if m.IsTech() { s.Limit(m, 100) s.Select(m, arg...).Table(func(value ice.Maps) { if value[model.UID] != m.Option(model.USER_UID) { - m.PushButton(s.SetCookie, s.Remove) + m.PushButton(s.SetCookie) } else { m.PushButton() } }) + m.EchoQRCode(m.MergePodCmd("", m.PrefixKey()+"/action/sendCookie", ice.FROM_DAEMON, m.Option(ice.MSG_DAEMON))).Echo("
").Echo("请扫码授权") + m.StatusTimeCount(mdb.TOTAL, s.SelectTotal(m)) } } else { s.SelectDetail(m, model.UID, arg[0]) @@ -67,6 +79,13 @@ func (s user) SendTemplate(m *ice.Message, arg ...string) { // from uid url type "time11", time.Now().Format("2006年01月02日 15:04"), "thing18", kit.Select(kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)), arg, 0), ) } +func (s user) SendCookie(m *ice.Message, arg ...string) { + if m.Option(ice.MSG_METHOD) == http.MethodGet { + m.EchoInfoButton("请确认授权", s.SendCookie) + } else { + m.Cmd(web.SPACE, m.Option(ice.FROM_DAEMON), "cookie", m.Option(model.USER_UID), model.USER_UID) + } +} func (s user) SetCookie(m *ice.Message, arg ...string) { m.ProcessCookie(model.USER_UID, m.Option(model.UID)) } diff --git a/src/renzhengshouquan/external/tencentdocument/tencentdocument.go b/src/renzhengshouquan/external/tencentdocument/tencentdocument.go index aa65fb3..20e9fcd 100644 --- a/src/renzhengshouquan/external/tencentdocument/tencentdocument.go +++ b/src/renzhengshouquan/external/tencentdocument/tencentdocument.go @@ -7,6 +7,7 @@ import ( "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/tencentdocument/model" @@ -46,7 +47,7 @@ func (s tencentdocument) List(m *ice.Message, arg ...string) { } } func (s tencentdocument) Config(m *ice.Message, arg ...string) { - m.Cmdy("web.team.gonganxitong.document", s.Config, m.OptionSimple(model.PLACE_UID, model.USER_UID, model.FOLDER_ID), model.VENDOR, m.PrefixKey()) + m.Cmdy(api.GONGANXITONG_DOCUMENT, s.Config, m.OptionSimple(model.PLACE_UID, model.USER_UID, model.FOLDER_ID), model.VENDOR, m.PrefixKey()) } func (s tencentdocument) Folder(m *ice.Message, arg ...string) *ice.Message { msg := s.Select(m.Spawn(), model.AUTH_UID, arg[0]) @@ -69,13 +70,13 @@ func (s tencentdocument) Auth(m *ice.Message, arg ...string) { if m.Option("code") == "" { m.ProcessOpen(kit.MergeURL("https://docs.qq.com/oauth/v2/authorize", model.CLIENT_ID, m.Config(model.CLIENT_ID), - "redirect_uri", m.MergePodCmd("", m.PrefixKey()+"/action/auth"), + "redirect_uri", m.MergePodCmd("", m.PrefixKey()+"/action/"+m.ActionKey()), "response_type", "code", "scope", "all", "state", m.Option(model.AUTH_UID), )) } else { m.Cmdy(web.SPIDE, ice.DEV, kit.MergeURL("https://docs.qq.com/oauth/v2/token", model.CLIENT_ID, m.Config(model.CLIENT_ID), model.CLIENT_SECRET, m.Config(model.CLIENT_SECRET), - "redirect_uri", m.MergePodCmd("", m.PrefixKey()+"/action/auth"), + "redirect_uri", m.MergePodCmd("", m.PrefixKey()+"/action/"+m.ActionKey()), "grant_type", "authorization_code", "code", m.Option("code"), )) if m.IsErr() { diff --git a/src/template/web.code.autogen/demo.go b/src/template/web.code.autogen/demo.go index e115ec0..3eecd76 100644 --- a/src/template/web.code.autogen/demo.go +++ b/src/template/web.code.autogen/demo.go @@ -3,12 +3,14 @@ package {{.Option "zone"}} import "shylinux.com/x/ice" type {{.Option "name"}} struct { - Table + Tables fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"leader"` remove string `name:"remove" role:"leader"` } -func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } +func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) { + // s.ValueList(m, arg).Display("") +} func init() { ice.TeamCtxCmd({{.Option "name"}}{}) }