package gonganxitong import ( "strings" "shylinux.com/x/ice" kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/gonganxitong/model" ) type spendlist struct { Table fields string `data:"vendor,total,count,expire_time"` } func (s spendlist) List(m *ice.Message, arg ...string) { if len(arg) == 2 { s.Tables(m, quotalist{}) s.Fields(m, "quotalists.title,quotalists.content,expire_time,spendlists.vendor,spendlists.total,count") s.Select(m, s.Key(s, model.PLACE_UID), arg[0], model.PAYMENTLIST_UID, arg[1]).Display("") } } func init() { ice.TeamCtxCmd(spendlist{Table: newTable()}) } func (s Table) SpendlistCheck(m *ice.Message, size int) bool { if size == 0 && m.Length() == 0 { return true } if size == 0 && m.Result() != "" { return true } msg := m.Cmd(s.Prefix(m, spendlist{}), s.Select, m.OptionSimple(model.PLACE_UID), model.VENDOR, m.PrefixKey()) m.Echo("%s / %s", strings.TrimSuffix(kit.FmtSize(kit.Int(msg.Append(model.COUNT))), "B"), strings.TrimSuffix(kit.FmtSize(kit.Int(msg.Append(model.TOTAL))), "B"), ) m.Option(model.SPENDLIST_UID, msg.Option(model.UID)) if kit.Int(msg.Append(model.COUNT))+size >= kit.Int(msg.Append(model.TOTAL)) { if !m.Warn(size > 0, "存储空间不足,请及时续费或清理空间") { m.SetResult() m.Echo("存储空间不足,请及时续费或清理空间").Action() } return false } kit.If(size > 0, func() { s.SpendlistCount(m, size) }) return true } func (s Table) SpendlistCount(m *ice.Message, size int) { m.Cmd(s.Prefix(m, spendlist{}), s.AddCount, model.COUNT, size, m.Option(model.SPENDLIST_UID)) } func (s Table) SpendlistUpdate(m *ice.Message, size string) { msg := m.Cmd(s.Prefix(m, spendlist{}), s.Select, model.PLACE_UID, m.Option(model.PLACE_UID), model.VENDOR, m.PrefixKey()) m.Options(model.UID, msg.Append(model.UID)).Cmd(s.Prefix(m, spendlist{}), s.Modify, model.COUNT, size) }