package gonganxitong import ( "shylinux.com/x/ice" kit "shylinux.com/x/toolkits" "shylinux.com/x/community/src/gonganxitong/model" ) type paymentlist struct { Table order string `data:"92"` auth string `data:"issued"` role string `data:"leader,worker"` fields string `data:"amount,title,content,paymentlist_status,goodslist_uid,user_uid"` create string `name:"create amount* title* content" role:"leader"` request string `name:"request" help:"支付" style:"notice" role:"void"` response string `name:"response" role:"void"` } func (s paymentlist) Create(m *ice.Message, arg ...string) { s.Insert(m, kit.Simple(s.TransPrice(m, arg, model.AMOUNT), m.OptionSimple(model.PLACE_UID, model.USER_UID))...) s.RecordEventWithName(m, "") } func (s paymentlist) List(m *ice.Message, arg ...string) { if len(arg) == 1 { s.Select(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID)) } else if len(arg) == 2 { s.SelectDetail(m, model.PLACE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID), model.UID, arg[1]) if PaymentStatus(kit.Int(m.Append(model.PAYMENTLIST_STATUS))) == PaymentCreate { if !m.IsWeixinUA() { m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1])).Echo("请用微信扫码支付") } } else { m.SetAppend().Cmdy(s.Prefix(m, spendlist{}), arg).Action() return } } else { return } m.Table(func(value ice.Maps) { switch PaymentStatus(kit.Int(value[model.PAYMENTLIST_STATUS])) { case PaymentCreate: m.PushButton(s.Request) case PaymentSuccess: m.PushButton() default: m.PushButton() } }).Display("").Action() s.SelectJoinUser(m) } func (s paymentlist) Request(m *ice.Message, arg ...string) { s.cmdy(m, m.ActionKey(), kit.Simple(kit.Select(m.PrefixKey(), arg, 0), kit.Select("", arg, 1), kit.Select(m.Option(model.PLACE_UID), arg, 2), kit.Select(m.Option(model.UID), arg, 3), kit.Slice(arg, 4))...) } func (s paymentlist) Response(m *ice.Message, arg ...string) { if !s.cmdy(m, m.ActionKey(), arg...).IsErr() { s.Update(m, kit.Dict(model.STATUS, PaymentSuccess), model.PLACE_UID, arg[0], model.UID, arg[1]) } } func init() { ice.TeamCtxCmd(paymentlist{Table: newTable()}) } func (s paymentlist) cmdy(m *ice.Message, action ice.Any, arg ...string) *ice.Message { return m.Cmdy(PaymentVendor, action, arg) } type PaymentStatus int const ( PaymentCreate PaymentStatus = iota PaymentSuccess PaymentFailure ) var PaymentStatusList = map[PaymentStatus]string{ PaymentCreate: "create", PaymentSuccess: "success", PaymentFailure: "failure", } func (s PaymentStatus) String() string { return PaymentStatusList[s] } var PaymentVendor interface { Request(m *ice.Message, arg ...string) Response(m *ice.Message, arg ...string) }