This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-09-19 20:58:50 +08:00
parent 20c60016fc
commit 9f7c06404d
26 changed files with 170 additions and 217 deletions

View File

@ -1,7 +1,15 @@
package gongyinglian package gongyinglian
import "shylinux.com/x/ice" import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
)
type brand struct{ Value } type brand struct{ Value }
func (s brand) List(m *ice.Message, arg ...string) {
s.Value.List(m, arg...)
kit.If(!s.IsBoss(m), func() { m.PushAction().Action().SetResult() })
}
func init() { ice.TeamCtxCmd(brand{}) } func init() { ice.TeamCtxCmd(brand{}) }

View File

@ -1,7 +1,6 @@
package gongyinglian package gongyinglian
import ( import (
"path"
"shylinux.com/x/ice" "shylinux.com/x/ice"
kit "shylinux.com/x/toolkits" kit "shylinux.com/x/toolkits"
@ -70,32 +69,6 @@ func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message {
m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserStoreCreator.String())...), role.String()) m.WarnNotRight(!kit.IsIn(role.String(), append(arg, UserStoreCreator.String())...), role.String())
return m return m
} }
func (s Table) checkRole(m *ice.Message, arg ...UserStoreRole) bool {
kit.If(len(arg) == 0, func() { arg = append(arg, UserStoreBoss) })
role := s.userStoreRole(m, m.Option(model.STORE_UID))
for _, v := range append(arg, UserStoreCreator) {
if role == v {
return true
}
}
return false
}
func (s Table) userStoreRole(m *ice.Message, arg ...string) UserStoreRole {
msg := m.Spawn()
userStore{}.Fields(msg, model.ROLE)
msg = msg.Cmd(userStore{}, s.Select, model.STORE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
if msg.Length() > 0 {
return UserStoreRole(kit.Int(msg.Append(model.ROLE)))
} else {
return -1
}
}
func (s Table) checkListRole(m *ice.Message, arg ...string) bool {
if (len(arg) == 0 && m.Option(model.STORE_UID) != "" && !s.checkRole(m, UserStoreBoss)) || (len(arg) == 1 && !s.checkRole(m.Options(model.STORE_UID, arg[0]), UserStoreBoss)) {
return false
}
return true
}
func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool { func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
user_uid := m.Option(model.USER_UID) user_uid := m.Option(model.USER_UID)
msg := m.Cmd(Order{}, s.Select, "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1]) msg := m.Cmd(Order{}, s.Select, "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
@ -104,6 +77,13 @@ func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
} }
return true return true
} }
func (s Table) IsBoss(m *ice.Message) bool {
return s.IsLeader(m)
}
func (s Table) IsWorker(m *ice.Message) bool {
role := UserStoreRole(kit.Int(m.Option(model.USER_ROLE)))
return role == UserStoreCreator || role == UserStoreWorker
}
type Tables struct{ Table } type Tables struct{ Table }
@ -111,29 +91,17 @@ func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
type Value struct { type Value struct {
Table Table
fields string `data:"name,info"` fields string `data:"name,info,user_uid"`
create string `name:"create name info" role:"boss"` create string `name:"create name info" role:"boss"`
modify string `name:"modify name info" role:"boss"` modify string `name:"modify name info" role:"boss"`
remove string `name:"remove" role:"boss"` remove string `name:"remove" role:"boss"`
} }
func (s Value) Create(m *ice.Message, arg ...string) { func (s Value) Create(m *ice.Message, arg ...string) {
s.Table.ValueCreate(m, s.transPrice(m, arg...)...) s.ValueCreate(m, s.transPrice(m, arg...)...)
} }
func (s Value) Modify(m *ice.Message, arg ...string) { func (s Value) Modify(m *ice.Message, arg ...string) {
s.Table.ValueModify(m, s.transPrice(m, arg...)...) s.ValueModify(m, s.transPrice(m, arg...)...)
}
func (s Value) Remove(m *ice.Message, arg ...string) {
s.Table.ValueRemove(m, arg...)
}
func (s Value) List(m *ice.Message, arg ...string) {
s.Table.ValueList(m, arg)
if m.Length() == 0 {
m.EchoInfoButton("")
}
if m.Exists(path.Join(path.Dir(kit.FileLines(1)), m.CommandKey()+".js")) {
m.Display(m.CommandKey() + ".js")
}
} }
func (s Value) transPrice(m *ice.Message, arg ...string) []string { func (s Value) transPrice(m *ice.Message, arg ...string) []string {
for i := 0; i < len(arg); i += 2 { for i := 0; i < len(arg); i += 2 {
@ -148,11 +116,11 @@ func (s Value) transPrice(m *ice.Message, arg ...string) []string {
type Relative struct{ Table } type Relative struct{ Table }
func (s Relative) List(m *ice.Message, arg ...string) { func (s Relative) List(m *ice.Message, arg ...string) {
if !s.checkListRole(m, arg...) { if !s.IsBoss(m) && !s.IsWorker(m) {
return return
} }
order := Order{} order := Order{}
s.Tables(m, Order{}).FieldsWithCreatedAT(m, order, s.Tables(m, Order{}).FieldsWithCreatedAT(m, m.CommandKey(),
s.AS(model.TO_USER_UID, model.USER_UID), m.CommandKey()+"_"+model.STATUS, s.AS(model.TO_USER_UID, model.USER_UID), m.CommandKey()+"_"+model.STATUS,
s.Key(order, model.AMOUNT), s.Key(order, model.TOTAL), s.Key(order, model.AMOUNT), s.Key(order, model.TOTAL),
model.COMPANY_UID, model.OPEN_ID, model.ORDER_UID, model.COMPANY_UID, model.OPEN_ID, model.ORDER_UID,

View File

@ -9,19 +9,15 @@ import (
type expense struct { type expense struct {
Value Value
fields string `data:"expense_type,amount,name,info"` fields string `data:"expense_type,amount,name,info,from_user_uid,to_user_uid AS user_uid"`
create string `name:"create expense_type* amount* name info" role:"boss"` create string `name:"create expense_type* amount* name info" role:"boss,worker"`
modify string `name:"modify amount* name info" role:"boss"` modify string `name:"modify amount* name info" role:"boss,worker"`
list string `name:"list store_uid uid auto" role:"boss,worker"`
} }
func (s expense) Create(m *ice.Message, arg ...string) { func (s expense) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.EXPENSE_TYPE, model.TYPE) arg = kit.TransArgKeys(s.transPrice(m, arg...), model.EXPENSE_TYPE, model.TYPE)
s.Value.Create(m, kit.Simple(arg, model.FROM_USER_UID, m.Option(model.USER_UID))...) s.Insert(m, kit.Simple(arg, model.FROM_USER_UID, m.Option(model.USER_UID), m.OptionSimple(model.STORE_UID))...)
}
func (s expense) List(m *ice.Message, arg ...string) {
if s.checkListRole(m, arg...) {
s.Value.List(m, arg...)
}
} }
func init() { ice.TeamCtxCmd(expense{}) } func init() { ice.TeamCtxCmd(expense{}) }

View File

@ -1,8 +1,8 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "express_status", mdb.STATUS)]}, {view: html.TITLE, list: [value.user_name]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.company_name+":", value.open_id]}, {view: html.STATUS, list: [value.company_name+":", value.open_id]},
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, {view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
] }) ] })

View File

@ -10,18 +10,18 @@ import (
type goods struct { type goods struct {
Product Product
create string `name:"create shop_uid*:select name* info price stock unit" role:"boss"` create string `name:"create shop_uid*:select name* info price stock unit" role:"boss"`
market string `name:"market domain_uid* title* content" role:"boss"` marketInsert string `name:"marketInsert domain_uid* title* content" role:"boss"`
} }
func (s goods) Create(m *ice.Message, arg ...string) { func (s goods) Create(m *ice.Message, arg ...string) {
s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductGoods, arg)...) s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductGoods, arg)...)
} }
func (s goods) Market(m *ice.Message, arg ...string) {
s.MarketInsert(m, arg...)
}
func (s goods) List(m *ice.Message, arg ...string) { func (s goods) List(m *ice.Message, arg ...string) {
s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductGoods)), arg...) s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductGoods)), arg...)
kit.If(s.checkListRole(m, arg...), func() { m.PushAction(s.Market, s.SetShop, s.SetBrand, s.SetQuality, s.Modify, s.Remove) }) kit.If(s.IsBoss(m), func() {
m.PushAction(s.MarketInsert, s.SetShop, s.SetBrand, s.SetQuality, s.Modify, s.Remove).Action(s.Create)
s.Button(m, "")
})
} }
func init() { ice.TeamCtxCmd(goods{}) } func init() { ice.TeamCtxCmd(goods{}) }

View File

@ -12,17 +12,13 @@ type loan struct {
fields string `data:"loan_type,amount,name,info"` fields string `data:"loan_type,amount,name,info"`
create string `name:"create loan_type* amount name info" role:"boss"` create string `name:"create loan_type* amount name info" role:"boss"`
modify string `name:"modify name info amount" role:"boss"` modify string `name:"modify name info amount" role:"boss"`
list string `name:"list store_uid uid auto" role:"boss"`
} }
func (s loan) Create(m *ice.Message, arg ...string) { func (s loan) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.LOAN_TYPE, model.TYPE) arg = kit.TransArgKeys(s.transPrice(m, arg...), model.LOAN_TYPE, model.TYPE)
s.Value.Create(m, kit.Simple(arg, model.TO_USER_UID, m.Option(model.USER_UID))...) s.Value.Create(m, kit.Simple(arg, model.TO_USER_UID, m.Option(model.USER_UID))...)
} }
func (s loan) List(m *ice.Message, arg ...string) {
if s.checkListRole(m, arg...) {
s.Value.List(m, arg...)
}
}
func init() { ice.TeamCtxCmd(loan{}) } func init() { ice.TeamCtxCmd(loan{}) }

View File

@ -16,10 +16,11 @@ func (s material) Create(m *ice.Message, arg ...string) {
s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductMaterial, arg)...) s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductMaterial, arg)...)
} }
func (s material) List(m *ice.Message, arg ...string) { func (s material) List(m *ice.Message, arg ...string) {
if s.checkListRole(m, arg...) {
s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductMaterial)), arg...) s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductMaterial)), arg...)
m.PushAction(s.SetWarehouse, s.Modify, s.Remove) kit.If(s.IsBoss(m), func() {
} m.PushAction(s.SetWarehouse, s.Modify, s.Remove).Action(s.Create)
s.Button(m, "")
})
} }
func init() { ice.TeamCtxCmd(material{}) } func init() { ice.TeamCtxCmd(material{}) }

View File

@ -11,8 +11,8 @@ const (
STATUS = "status" STATUS = "status"
TITLE = "title" TITLE = "title"
CONTENT = "content" CONTENT = "content"
AUTH_UID = "auth_uid"
USER_UID = "user_uid" USER_UID = "user_uid"
USER_ROLE = "user_role"
USER_STORE_ROLE = "user_store_role" USER_STORE_ROLE = "user_store_role"
STORE_UID = "store_uid" STORE_UID = "store_uid"
STORE_NAME = "store_name" STORE_NAME = "store_name"
@ -73,6 +73,16 @@ type Warehouse struct {
StoreUID string `gorm:"type:char(32);index"` StoreUID string `gorm:"type:char(32);index"`
Address string `gorm:"type:varchar(255)"` Address string `gorm:"type:varchar(255)"`
} }
type Quality struct {
db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"`
StoreUID string `gorm:"type:char(32);index"`
}
type Brand struct {
db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"`
StoreUID string `gorm:"type:char(32);index"`
}
type Product struct { type Product struct {
db.ModelNameInfo db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`
@ -101,9 +111,9 @@ type Order struct {
RefundSuccessTime db.Time RefundSuccessTime db.Time
Name string `gorm:"type:varchar(64)"` Name string `gorm:"type:varchar(64)"`
Info string Info string
Total int `gorm:"default:0"`
Amount int `gorm:"default:0"`
Status uint8 `gorm:"default:0"` Status uint8 `gorm:"default:0"`
Amount int `gorm:"default:0"`
Total int `gorm:"default:0"`
} }
type OrderDetail struct { type OrderDetail struct {
db.ModelWithUID db.ModelWithUID
@ -134,22 +144,12 @@ type Refund struct {
func init() { func init() {
db.CmdModels("", db.CmdModels("",
&UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Product{}, &UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Quality{}, &Brand{}, &Product{},
&Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{}, &Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{},
&Brand{}, &Quality{}, &Expense{}, &Loan{}, &Expense{}, &Loan{},
) )
} }
type Brand struct {
db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"`
StoreUID string `gorm:"type:char(32);index"`
}
type Quality struct {
db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"`
StoreUID string `gorm:"type:char(32);index"`
}
type Expense struct { type Expense struct {
db.ModelNameInfo db.ModelNameInfo
UserUID string `gorm:"type:char(32);index"` UserUID string `gorm:"type:char(32);index"`

View File

@ -1,6 +1,8 @@
package gongyinglian package gongyinglian
import ( import (
"math"
"shylinux.com/x/ice" "shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
@ -13,17 +15,17 @@ type Order struct {
Table Table
userStore userStore userStore userStore
store store store store
orderDetail orderDetail
product Product product Product
orderDetail orderDetail
models string `data:"order"` models string `data:"order"`
sell string `name:"sell name info" role:"boss" help:"出货"` sell string `name:"sell name info" help:"出货" role:"boss,worker"`
produce string `name:"produce name info" role:"boss" help:"加工"` produce string `name:"produce name info" help:"加工" role:"boss,worker"`
purchase string `name:"purchase name info" role:"boss" help:"进货"` purchase string `name:"purchase name info" help:"进货" role:"boss,worker"`
insert string `name:"insert product_uid*:select count*" role:"boss"` insert string `name:"insert product_uid*:select count*" role:"boss,worker"`
update string `name:"update price* count*" role:"boss"` update string `name:"update count* price*" role:"boss,worker"`
delete string `name:"delete" role:"boss"` delete string `name:"delete" role:"boss,worker"`
cancel string `name:"cancel" role:"boss"` cancel string `name:"cancel" role:"boss,worker"`
submit string `name:"submit" role:"boss"` submit string `name:"submit" role:"boss,worker"`
confirmSell string `name:"confirmSell from_store_uid" role:"void"` confirmSell string `name:"confirmSell from_store_uid" role:"void"`
confirmProduce string `name:"confirmProduce" role:"void"` confirmProduce string `name:"confirmProduce" role:"void"`
confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"` confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"`
@ -32,6 +34,7 @@ type Order struct {
payment string `name:"payment company_uid* open_id*" role:"void"` payment string `name:"payment company_uid* open_id*" role:"void"`
express string `name:"express company_uid* open_id*" role:"void"` express string `name:"express company_uid* open_id*" role:"void"`
refund string `name:"refund company_uid* open_id*" role:"void"` refund string `name:"refund company_uid* open_id*" role:"void"`
// return string `name:"return company_uid* open_id*" role:"void"`
confirmPayment string `name:"confirmPayment" role:"void"` confirmPayment string `name:"confirmPayment" role:"void"`
confirmExpress string `name:"confirmExpress" role:"void"` confirmExpress string `name:"confirmExpress" role:"void"`
confirmReturn string `name:"confirmReturn" role:"void"` confirmReturn string `name:"confirmReturn" role:"void"`
@ -44,24 +47,24 @@ func (s Order) Init(m *ice.Message, arg ...string) {
s.Table.Init(m, arg...) s.Table.Init(m, arg...)
} }
func (s Order) Sell(m *ice.Message, arg ...string) { func (s Order) Sell(m *ice.Message, arg ...string) {
s.Create(m, kit.Simple(arg, model.FROM_STORE_UID, m.Option(model.STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID))...) s.Table.Insert(m, kit.Simple(arg, model.FROM_STORE_UID, m.Option(model.STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID))...)
m.ProcessRewrite(model.UID, m.Result()) m.ProcessRewrite(model.UID, m.Result())
} }
func (s Order) Produce(m *ice.Message, arg ...string) { func (s Order) Produce(m *ice.Message, arg ...string) {
s.Create(m, kit.Simple(arg, s.Table.Insert(m, kit.Simple(arg,
model.FROM_STORE_UID, m.Option(model.STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID), model.FROM_STORE_UID, m.Option(model.STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID),
model.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID), model.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID),
)...) )...)
m.ProcessRewrite(model.UID, m.Result()) m.ProcessRewrite(model.UID, m.Result())
} }
func (s Order) Purchase(m *ice.Message, arg ...string) { func (s Order) Purchase(m *ice.Message, arg ...string) {
s.Create(m, kit.Simple(arg, model.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID))...) s.Table.Insert(m, kit.Simple(arg, model.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID))...)
m.ProcessRewrite(model.UID, m.Result()) m.ProcessRewrite(model.UID, m.Result())
} }
func (s Order) List(m *ice.Message, arg ...string) { func (s Order) List(m *ice.Message, arg ...string) {
m.Display("") m.Display("")
if len(arg) == 1 { if len(arg) == 1 {
if !s.checkListRole(m, arg...) { if !s.IsBoss(m) && !s.IsWorker(m) {
return return
} }
switch OrderType(kit.Int(m.Option(model.ORDER_TYPE))) { switch OrderType(kit.Int(m.Option(model.ORDER_TYPE))) {
@ -136,10 +139,10 @@ func (s Order) List(m *ice.Message, arg ...string) {
} }
case OrderSubmit: case OrderSubmit:
if user_uid == msg.Append(model.FROM_USER_UID) && msg.Append(model.TO_USER_UID) == "" { if user_uid == msg.Append(model.FROM_USER_UID) && msg.Append(model.TO_USER_UID) == "" {
m.Echo("请让经销商扫码确认订单") m.Echo("请让买家扫码确认订单")
m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1])) m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1]))
} else if user_uid == msg.Append(model.TO_USER_UID) && msg.Append(model.FROM_USER_UID) == "" { } else if user_uid == msg.Append(model.TO_USER_UID) && msg.Append(model.FROM_USER_UID) == "" {
m.Echo("请让供货商扫码确认订单") m.Echo("请让卖家扫码确认订单")
m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1])) m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1]))
} else if msg.Append(model.FROM_USER_UID) == "" { } else if msg.Append(model.FROM_USER_UID) == "" {
m.EchoButton(s.ConfirmSell) m.EchoButton(s.ConfirmSell)
@ -197,17 +200,17 @@ func (s Order) Amount(m *ice.Message, arg ...string) {
} }
func (s Order) Insert(m *ice.Message, arg ...string) { func (s Order) Insert(m *ice.Message, arg ...string) {
msg := m.Cmd(s.product, m.Option(model.STORE_UID), m.Option(model.PRODUCT_UID)) msg := m.Cmd(s.product, m.Option(model.STORE_UID), m.Option(model.PRODUCT_UID))
m.Cmd(s.orderDetail, s.Create, arg, msg.AppendSimple(model.PRICE), model.ORDER_UID, m.Option(model.UID)) m.Cmd(s.orderDetail, s.Insert, arg, msg.AppendSimple(model.PRICE), model.ORDER_UID, m.Option(model.UID))
s.Amount(m)
}
func (s Order) Delete(m *ice.Message, arg ...string) {
m.Cmd(s.orderDetail, s.Delete, model.UID, m.Option(model.ORDER_DETAIL_UID), model.ORDER_UID, m.Option(model.UID))
s.Amount(m) s.Amount(m)
} }
func (s Order) Update(m *ice.Message, arg ...string) { func (s Order) Update(m *ice.Message, arg ...string) {
m.Cmdy(s.orderDetail, s.Update, model.UID, m.Option(model.ORDER_DETAIL_UID), model.ORDER_UID, m.Option(model.UID)) m.Cmdy(s.orderDetail, s.Update, model.UID, m.Option(model.ORDER_DETAIL_UID), model.ORDER_UID, m.Option(model.UID))
s.Amount(m) s.Amount(m)
} }
func (s Order) Delete(m *ice.Message, arg ...string) {
m.Cmd(s.orderDetail, s.Delete, model.UID, m.Option(model.ORDER_DETAIL_UID), model.ORDER_UID, m.Option(model.UID))
s.Amount(m)
}
func (s Order) Cancel(m *ice.Message, arg ...string) { func (s Order) Cancel(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(model.STATUS, OrderCancel), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.STATUS, OrderCancel), m.OptionSimple(model.UID)...)
} }
@ -236,9 +239,9 @@ func (s Order) ConfirmPurchase(m *ice.Message, arg ...string) {
} }
func (s Order) Again(m *ice.Message, arg ...string) { func (s Order) Again(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderDeal, "", func(msg *ice.Message) { s.changeStatusFrom(m, OrderDeal, "", func(msg *ice.Message) {
s.Create(m, kit.Simple(model.STATUS, OrderConfirm, msg.AppendSimple(model.FROM_STORE_UID, model.FROM_USER_UID, model.TO_STORE_UID, model.TO_USER_UID))...) s.Table.Insert(m, kit.Simple(model.STATUS, OrderConfirm, msg.AppendSimple(model.FROM_STORE_UID, model.FROM_USER_UID, model.TO_STORE_UID, model.TO_USER_UID))...)
m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) { m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) {
m.Cmd(s.orderDetail, s.Create, model.STORE_UID, detail[model.STORE_UID], model.ORDER_UID, m.Result(), m.Cmd(s.orderDetail, s.Insert, model.STORE_UID, detail[model.STORE_UID], model.ORDER_UID, m.Result(),
model.PRODUCT_UID, detail[model.PRODUCT_UID], model.PRICE, detail[model.PRICE], model.COUNT, detail[model.COUNT], model.PRODUCT_UID, detail[model.PRODUCT_UID], model.PRICE, detail[model.PRICE], model.COUNT, detail[model.COUNT],
) )
}) })
@ -254,6 +257,12 @@ func (s Order) Process(m *ice.Message, arg ...string) {
} }
m.Cmd(s.product, m.Option(model.STORE_UID), detail[model.PRODUCT_UID]).Table(func(product ice.Maps) { m.Cmd(s.product, m.Option(model.STORE_UID), detail[model.PRODUCT_UID]).Table(func(product ice.Maps) {
count, stock := kit.Int(detail[model.COUNT]), kit.Int(product[model.STOCK]) count, stock := kit.Int(detail[model.COUNT]), kit.Int(product[model.STOCK])
switch ProductType(kit.Int(product[model.PRODUCT_TYPE])) {
case ProductGoods:
count = kit.Int(math.Abs(float64(count)))
case ProductMaterial:
count = -kit.Int(math.Abs(float64(count)))
}
if m.Warn(count < 0 && -count > stock, product[model.NAME], "库存不足") { if m.Warn(count < 0 && -count > stock, product[model.NAME], "库存不足") {
return return
} }
@ -285,10 +294,9 @@ func (s Order) Payment(m *ice.Message, arg ...string) {
return return
} }
} }
m.Cmdy(payment{}, s.Create, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, PaymentSuccess) m.Cmdy(payment{}, s.Insert, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, PaymentSuccess)
s.Table.Update(m, kit.Dict(model.PAYMENT_STATUS, PaymentSuccess, model.PAYMENT_SUCCESS_TIME, m.Time()), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.PAYMENT_STATUS, PaymentSuccess, model.PAYMENT_SUCCESS_TIME, m.Time()), m.OptionSimple(model.UID)...)
m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID)) m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID))
Portal{}.DashboardUpdate(m)
}) })
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order payment", "订单已付款")) s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order payment", "订单已付款"))
} }
@ -308,7 +316,7 @@ func (s Order) Express(m *ice.Message, arg ...string) {
if m.WarnNotValid(ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) != ExpressUnknown) { if m.WarnNotValid(ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) != ExpressUnknown) {
return return
} }
m.Cmdy(express{}, s.Create, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, ExpressRecv) m.Cmdy(express{}, s.Insert, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, ExpressRecv)
s.Table.Update(m, kit.Dict(model.EXPRESS_STATUS, ExpressRecv), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.EXPRESS_STATUS, ExpressRecv), m.OptionSimple(model.UID)...)
m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID)) m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID))
}) })
@ -324,8 +332,8 @@ func (s Order) ConfirmExpress(m *ice.Message, arg ...string) {
} }
s.Table.Update(m, kit.Dict(model.STATUS, OrderDeal, model.EXPRESS_STATUS, ExpressConfirm, model.EXPRESS_RECV_TIME, m.Time()), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.STATUS, OrderDeal, model.EXPRESS_STATUS, ExpressConfirm, model.EXPRESS_RECV_TIME, m.Time()), m.OptionSimple(model.UID)...)
m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID)) m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID))
Portal{}.DashboardUpdate(m)
}) })
s.DashboardUpdate(m)
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order confirm express", "订单已确认收货")) s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order confirm express", "订单已确认收货"))
} }
func (s Order) Return(m *ice.Message, arg ...string) { func (s Order) Return(m *ice.Message, arg ...string) {
@ -336,7 +344,7 @@ func (s Order) Return(m *ice.Message, arg ...string) {
if m.WarnNotValid(ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) != ReturnUnknown) { if m.WarnNotValid(ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) != ReturnUnknown) {
return return
} }
m.Cmdy(Return{}, s.Create, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, ReturnRecv) m.Cmdy(Return{}, s.Insert, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, ReturnRecv)
s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnRecv, model.RETURN_RECV_TIME, m.Time()), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnRecv, model.RETURN_RECV_TIME, m.Time()), m.OptionSimple(model.UID)...)
m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID)) m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID))
}) })
@ -356,6 +364,7 @@ func (s Order) ConfirmReturn(m *ice.Message, arg ...string) {
s.ReturnProduct(m) s.ReturnProduct(m)
s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnConfirm), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnConfirm), m.OptionSimple(model.UID)...)
}) })
s.DashboardUpdate(m)
} }
func (s Order) Refund(m *ice.Message, arg ...string) { func (s Order) Refund(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, -1, model.FROM_USER_UID, func(msg *ice.Message) { s.changeStatusFrom(m, -1, model.FROM_USER_UID, func(msg *ice.Message) {
@ -365,7 +374,7 @@ func (s Order) Refund(m *ice.Message, arg ...string) {
if m.WarnNotValid(RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) != RefundUnknown) { if m.WarnNotValid(RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) != RefundUnknown) {
return return
} }
m.Cmdy(refund{}, s.Create, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, RefundSuccess) m.Cmdy(refund{}, s.Insert, model.ORDER_UID, m.Option(model.UID), m.OptionSimple(model.COMPANY_UID, model.OPEN_ID), model.STATUS, RefundSuccess)
s.Table.Update(m, kit.Dict(model.REFUND_STATUS, RefundSuccess, model.REFUND_SUCCESS_TIME, m.Time()), m.OptionSimple(model.UID)...) s.Table.Update(m, kit.Dict(model.REFUND_STATUS, RefundSuccess, model.REFUND_SUCCESS_TIME, m.Time()), m.OptionSimple(model.UID)...)
m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID)) m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID))
}) })
@ -393,7 +402,6 @@ func (s Order) CheckRole(m *ice.Message, arg ...string) {
func init() { ice.TeamCtxCmd(Order{}) } func init() { ice.TeamCtxCmd(Order{}) }
func (s Order) changeStatusFrom(m *ice.Message, from OrderStatus, which string, cb func(*ice.Message)) { func (s Order) changeStatusFrom(m *ice.Message, from OrderStatus, which string, cb func(*ice.Message)) {
defer m.ToastProcess()()
s.Transaction(m, func() { s.Transaction(m, func() {
msg := s.SelectForUpdate(m.Spawn(), m.OptionSimple(model.UID)...) msg := s.SelectForUpdate(m.Spawn(), m.OptionSimple(model.UID)...)
if from != -1 && m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != from) { if from != -1 && m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != from) {

View File

@ -1,8 +1,8 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.name||value.user_name||"待确认", can.onimport.textView(can, value, "order_type", mdb.TYPE)]}, {view: html.TITLE, list: [value.name||value.user_name||"待确认", can.onimport.textView(can, value, "order_type")]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value, "order_status", mdb.STATUS)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: ["数量:", value.total, "件", "总额:", value.amount, "元"]}, {view: html.STATUS, list: ["数量:", value.total, "件", "总额:", value.amount, "元"]},
value.payment_success_time && {view: html.STATUS, list: ["收款时间:", can.base.TimeTrim(value.payment_success_time)]}, value.payment_success_time && {view: html.STATUS, list: ["收款时间:", can.base.TimeTrim(value.payment_success_time)]},
value.express_recv_time && {view: html.STATUS, list: ["收货时间:", can.base.TimeTrim(value.express_recv_time)]}, value.express_recv_time && {view: html.STATUS, list: ["收货时间:", can.base.TimeTrim(value.express_recv_time)]},

View File

@ -21,7 +21,7 @@ func (s orderDetail) Amount(m *ice.Message, arg ...string) {
s.Select(m, model.ORDER_UID, arg[0]) s.Select(m, model.ORDER_UID, arg[0])
} }
func (s orderDetail) List(m *ice.Message, arg ...string) { func (s orderDetail) List(m *ice.Message, arg ...string) {
if !s.checkOrderRole(m.Spawn(), arg...) { if !s.checkOrderRole(m, arg[0], arg[1]) {
return return
} }
m.Display("") m.Display("")

View File

@ -1,8 +1,7 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
msg.Option("_share_title", can.Option("uid").slice(0, 6))
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type", mdb.TYPE)]}, {view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type")]},
{view: html.STATUS, list: ["单价: ", value.price, " 元", "数量: ", value.count, " ", value.unit]}, {view: html.STATUS, list: ["单价: ", value.price, " 元", "数量: ", value.count, " ", value.unit]},
{view: html.OUTPUT, list: [value.info]}, {view: html.OUTPUT, list: [value.info]},
] }, function(event) {}) ] }, function(event) {})

View File

@ -1,9 +1,9 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "payment_status", mdb.STATUS)]}, {view: html.TITLE, list: [value.user_name]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.company_name, ": ", value.open_id]}, {view: html.STATUS, list: [value.company_name+":", value.open_id]},
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, {view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
] }) ] })
}, },

View File

@ -13,11 +13,11 @@ type Portal struct {
guanlixitong.Portal guanlixitong.Portal
product Product product Product
order Order order Order
placeCreate string `name:"placeCreate city_name* company_name* store_type*:select store_name*" role:"void"` placeCreate string `name:"placeCreate city_name* company_name* store_name* store_type*:select" role:"void"`
} }
func (s Portal) AfterPlaceAuth(m *ice.Message, arg ...string) { func (s Portal) AfterPlaceAuth(m *ice.Message, arg ...string) {
s.DashboardCreate(m, "") defer s.DashboardCreate(m, "")()
s.DashboardInsert(m, "1", "订单总额", s.order, "SUM(amount) / 100.0", model.FROM_STORE_UID, m.Option(model.STORE_UID), model.STATUS, kit.Format(OrderDeal)) s.DashboardInsert(m, "1", "订单总额", s.order, "SUM(amount) / 100.0", model.FROM_STORE_UID, m.Option(model.STORE_UID), model.STATUS, kit.Format(OrderDeal))
s.DashboardInsert(m, "2", "订单数量", s.order, "", model.FROM_STORE_UID, m.Option(model.STORE_UID), model.STATUS, kit.Format(OrderDeal)) s.DashboardInsert(m, "2", "订单数量", s.order, "", model.FROM_STORE_UID, m.Option(model.STORE_UID), model.STATUS, kit.Format(OrderDeal))
s.DashboardInsert(m, "3", "库存数量", s.product, "SUM(stock)") s.DashboardInsert(m, "3", "库存数量", s.product, "SUM(stock)")

View File

@ -1,11 +1,11 @@
{ {
"portal": "供应链", "portal": "供应链", "member": "生意伙伴",
"goods": "商品", "sell": "出货", "purchase": "进货", "expense": "开支", "goods": "商品", "sell": "出货", "produce": "加工", "purchase": "进货", "material": "原材",
"payment": "付款", "express": "寄货", "return": "退贷", "refund": "退款", "payment": "付款", "express": "寄货", "expense": "开支", "return": "退贷", "refund": "退款",
"process": "生产", "again": "再来一单", "shop": "店铺", "warehouse": "仓库", "quality": "质检", "brand": "贴牌", "loan": "借贷外债",
"material": "原材", "produce": "加工", "quality": "质检", "brand": "贴牌", "product": "货物", "order": "订单",
"product": "货物", "order": "订单", "shop": "店铺", "warehouse": "仓库", "again": "再来一单",
"member": "生意伙伴", "loan": "借贷外债", "process": "加工",
"confirmSell": "确认出货", "confirmSell": "确认出货",
"confirmProduce": "确认加工", "confirmProduce": "确认加工",
"confirmPurchase": "确认进货", "confirmPurchase": "确认进货",
@ -20,40 +20,39 @@
"icons": { "icons": {
"goods": "https://img.icons8.com/officel/80/product.png", "goods": "https://img.icons8.com/officel/80/product.png",
"sell": "https://img.icons8.com/officel/80/handle-with-care.png", "sell": "https://img.icons8.com/officel/80/handle-with-care.png",
"produce": "https://img.icons8.com/officel/80/cnc-machine.png",
"purchase": "https://img.icons8.com/officel/80/paid.png", "purchase": "https://img.icons8.com/officel/80/paid.png",
"expense": "https://img.icons8.com/officel/80/cash-in-hand.png", "material": "https://img.icons8.com/officel/80/wood.png",
"payment": "https://img.icons8.com/officel/80/fund-accounting.png", "payment": "https://img.icons8.com/officel/80/fund-accounting.png",
"express": "https://img.icons8.com/officel/80/in-transit.png", "express": "https://img.icons8.com/officel/80/in-transit.png",
"expense": "https://img.icons8.com/officel/80/cash-in-hand.png",
"return": "https://img.icons8.com/officel/80/deliver-food.png", "return": "https://img.icons8.com/officel/80/deliver-food.png",
"refund": "https://img.icons8.com/officel/80/refund-2.png", "refund": "https://img.icons8.com/officel/80/refund-2.png",
"material": "https://img.icons8.com/officel/80/wood.png",
"produce": "https://img.icons8.com/officel/80/cnc-machine.png",
"quality": "https://img.icons8.com/officel/80/test-partial-passed.png",
"brand": "https://img.icons8.com/officel/80/add-tag.png",
"product": "https://img.icons8.com/officel/80/warehouse.png",
"order": "https://img.icons8.com/officel/80/receipt.png",
"shop": "https://img.icons8.com/officel/80/shop.png", "shop": "https://img.icons8.com/officel/80/shop.png",
"warehouse": "https://img.icons8.com/officel/80/garage-closed.png", "warehouse": "https://img.icons8.com/officel/80/garage-closed.png",
"loan": "https://img.icons8.com/officel/80/bank-building.png" "quality": "https://img.icons8.com/officel/80/test-partial-passed.png",
"brand": "https://img.icons8.com/officel/80/add-tag.png",
"loan": "https://img.icons8.com/officel/80/bank-building.png",
"product": "https://img.icons8.com/officel/80/warehouse.png",
"order": "https://img.icons8.com/officel/80/receipt.png"
}, },
"input": { "input": {
"My Store": "我的生意", "My Store": "我的生意",
"user_store_role": "用户角色", "user_store_role": "用户角色",
"store_uid": "生意", "store_uid": "生意",
"store_type": "生意类型",
"store_name": "生意名称", "store_name": "生意名称",
"store_type": "生意类型",
"shop_uid": "店铺", "shop_uid": "店铺",
"shop_name": "店铺名称", "shop_name": "店铺名称",
"warehouse_uid": "仓库", "warehouse_uid": "仓库",
"warehouse_name": "仓库名称", "warehouse_name": "仓库名称",
"quality_name": "质检名称", "quality_name": "质检名称",
"brand_name": "品牌名称", "brand_name": "品牌名称",
"order_type": "订单类型",
"product_uid": "产品", "product_uid": "产品",
"product_type": "产品类型", "product_type": "产品类型",
"company_uid": "公司", "order_type": "订单类型",
"to_store_uid": "收货店铺",
"from_store_uid":"出货店铺", "from_store_uid":"出货店铺",
"to_store_uid": "收货店铺",
"payment_status": "付款状态", "payment_status": "付款状态",
"express_status": "快递状态", "express_status": "快递状态",
"return_status": "退货状态", "return_status": "退货状态",
@ -72,7 +71,8 @@
"boss": "老板", "boss": "老板",
"worker": "员工", "worker": "员工",
"vendor": "供货商", "vendor": "供货商",
"custom": "经销商", "channel": "经销商",
"custom": "顾客",
"style": { "style": {
"creator": "danger", "creator": "danger",
"boss": "danger" "boss": "danger"
@ -80,9 +80,11 @@
}, },
"store_type": { "store_type": {
"shop": "店铺", "shop": "店铺",
"channel": "渠道",
"factory": "工厂", "factory": "工厂",
"icons": { "icons": {
"shop": "https://img.icons8.com/officel/80/shop.png", "shop": "https://img.icons8.com/officel/80/shop.png",
"channel": "https://img.icons8.com/officel/80/sales-channels.png",
"factory": "https://img.icons8.com/officel/80/cnc-machine.png" "factory": "https://img.icons8.com/officel/80/cnc-machine.png"
} }
}, },
@ -122,25 +124,25 @@
"payment_status": { "payment_status": {
"create": "🕑 已发起付款", "create": "🕑 已发起付款",
"failure": "❌ 付款失败", "failure": "❌ 付款失败",
"success": "🕑 待确认收款", "success": "✅ 已付款",
"confirm": "✅ 已确认收款" "confirm": "✅ 已确认收款"
}, },
"express_status": { "express_status": {
"create": "🕑 已发起寄货", "create": "🕑 已发起寄货",
"send": "🕑 已寄货", "send": "🕑 已寄货",
"recv": "🕑 待确认收货", "recv": "✅ 已收货",
"confirm": "✅ 已确认收货" "confirm": "✅ 已确认收货"
}, },
"return_status": { "return_status": {
"create": "🕑 已发起退货", "create": "🕑 已发起退货",
"send": "🕑 已寄货", "send": "🕑 已寄货",
"recv": "🕑 待确认退货", "recv": "✅ 已收货",
"confirm": "✅ 已确认退货" "confirm": "✅ 已确认退货"
}, },
"refund_status": { "refund_status": {
"create": "🕑 已发起退款", "create": "🕑 已发起退款",
"failure": "❌ 退款失败", "failure": "❌ 退款失败",
"success": "🕑 待确认收款", "success": "✅ 已退款",
"confirm": "✅ 已确认收款" "confirm": "✅ 已确认收款"
}, },
"expense_type": { "expense_type": {

View File

@ -1,38 +0,0 @@
chapter "供应链"
field web.code.mysql.client
field web.code.mysql.query args `mysql gongyinglian`
field web.code.db.models
order `
userStore.go
store.go
product.go
product.js
order.go
order.js
orderDetail.go
orderDetail.js
payment.go
express.go
return.go
refund.go
model
common.go
portal.go
portal.json
portal.shy
goods.go
sell.go
purchase.go
material.go
produce.go
quality.go
brand.go
shop.go
warehouse.go
expense.go
loan.go
`

View File

@ -16,6 +16,7 @@ type Product struct {
models string `data:"product"` models string `data:"product"`
create string `name:"create product_type*:select name* info price stock unit" role:"boss"` create string `name:"create product_type*:select name* info price stock unit" role:"boss"`
modify string `name:"modify name* info price stock unit" role:"boss"` modify string `name:"modify name* info price stock unit" role:"boss"`
remove string `name:"remove" role:"boss"`
setShop string `name:"setShop shop_uid*" role:"boss"` setShop string `name:"setShop shop_uid*" role:"boss"`
setWarehouse string `name:"setWarehouse warehouse_uid*" role:"boss"` setWarehouse string `name:"setWarehouse warehouse_uid*" role:"boss"`
setQuality string `name:"setQuality quality_uid*" role:"boss"` setQuality string `name:"setQuality quality_uid*" role:"boss"`
@ -23,11 +24,10 @@ type Product struct {
} }
func (s Product) Create(m *ice.Message, arg ...string) { func (s Product) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE) s.Value.Create(m, kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE)...)
s.Value.Create(m, arg...)
} }
func (s Product) List(m *ice.Message, arg ...string) { func (s Product) List(m *ice.Message, arg ...string) {
if m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) && !s.checkListRole(m, arg...) { if m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) && s.IsVisitor(m) {
return return
} }
if len(arg) == 0 { if len(arg) == 0 {
@ -45,13 +45,12 @@ func (s Product) List(m *ice.Message, arg ...string) {
kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, s.Key(s, model.TYPE), p) }) kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, s.Key(s, model.TYPE), p) })
if len(arg) == 1 { if len(arg) == 1 {
s.Select(m, args...) s.Select(m, args...)
s.Button(m, "")
} else if len(arg) == 2 { } else if len(arg) == 2 {
s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...) s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...)
} else { } else {
return return
} }
m.PushAction(s.Modify, s.Remove).Display("") m.Action().Display("")
} }
func (s Product) SetShop(m *ice.Message, arg ...string) { s.Value.Modify(m, arg...) } func (s Product) SetShop(m *ice.Message, arg ...string) { s.Value.Modify(m, arg...) }
func (s Product) SetWarehouse(m *ice.Message, arg ...string) { s.Value.Modify(m, arg...) } func (s Product) SetWarehouse(m *ice.Message, arg ...string) { s.Value.Modify(m, arg...) }

View File

@ -1,7 +1,7 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type", mdb.TYPE)]}, {view: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type")]},
{view: html.STATUS, list: ["单价:", value.price, "元", "库存:", value.stock, value.unit, value.shop_name||"", value.warehouse_name||""]}, {view: html.STATUS, list: ["单价:", value.price, "元", "库存:", value.stock, value.unit, value.shop_name||"", value.warehouse_name||""]},
{view: html.OUTPUT, list: [value.info]}, {view: html.OUTPUT, list: [value.info]},
] }) ] })

View File

@ -1,7 +1,15 @@
package gongyinglian package gongyinglian
import "shylinux.com/x/ice" import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
)
type quality struct{ Value } type quality struct{ Value }
func (s quality) List(m *ice.Message, arg ...string) {
s.Value.List(m, arg...)
kit.If(!s.IsBoss(m), func() { m.PushAction().Action().SetResult() })
}
func init() { ice.TeamCtxCmd(quality{}) } func init() { ice.TeamCtxCmd(quality{}) }

View File

@ -1,9 +1,9 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "refund_status", mdb.STATUS)]}, {view: html.TITLE, list: [value.user_name]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.company_name, ": ", value.open_id]}, {view: html.STATUS, list: [value.company_name+":", value.open_id]},
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, {view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
] }) ] })
}, },

View File

@ -1,8 +1,8 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { _init: function(can, msg) {
can.onimport.myView(can, msg, function(value) { return [ can.onimport.myView(can, msg, function(value) { return [
{view: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "return_status", mdb.STATUS)]}, {view: html.TITLE, list: [value.user_name]},
{view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value)]},
{view: html.STATUS, list: [value.company_name+":", value.open_id]}, {view: html.STATUS, list: [value.company_name+":", value.open_id]},
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, {view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
] }) ] })

View File

@ -1,14 +1,20 @@
package gongyinglian package gongyinglian
import "shylinux.com/x/ice" import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
)
type Shop struct { type Shop struct {
Value Value
fields string `data:"name,address"` fields string `data:"name,address,user_uid"`
create string `name:"create name* address" role:"boss"` create string `name:"create name* address" role:"boss"`
modify string `name:"modify name* address" role:"boss"` modify string `name:"modify name* address" role:"boss"`
remove string `name:"remove" role:"boss"`
} }
func (s Shop) List(m *ice.Message, arg ...string) { s.ValueList(m, arg) } func (s Shop) List(m *ice.Message, arg ...string) {
s.Value.List(m, arg...)
kit.If(!s.IsBoss(m), func() { m.PushAction().Action().SetResult() })
}
func init() { ice.TeamCtxCmd(Shop{}) } func init() { ice.TeamCtxCmd(Shop{}) }

View File

@ -18,11 +18,13 @@ type StoreType int
const ( const (
StoreShop StoreType = iota StoreShop StoreType = iota
StoreChannel
StoreFactory StoreFactory
) )
var StoreTypeList = map[StoreType]string{ var StoreTypeList = map[StoreType]string{
StoreShop: "shop", StoreShop: "shop",
StoreChannel: "channel",
StoreFactory: "factory", StoreFactory: "factory",
} }

View File

@ -14,6 +14,7 @@ const (
UserStoreBoss UserStoreBoss
UserStoreWorker UserStoreWorker
UserStoreVendor UserStoreVendor
UserStoreChannel
UserStoreCustom UserStoreCustom
) )
@ -23,6 +24,7 @@ var UserStoreRoleList = map[UserStoreRole]string{
UserStoreBoss: "boss", UserStoreBoss: "boss",
UserStoreWorker: "worker", UserStoreWorker: "worker",
UserStoreVendor: "vendor", UserStoreVendor: "vendor",
UserStoreChannel: "channel",
UserStoreCustom: "custom", UserStoreCustom: "custom",
} }

View File

@ -4,13 +4,11 @@ import "shylinux.com/x/ice"
type promotion struct { type promotion struct {
Table Table
fields string `data:"title,content"` fields string `data:"title,content,user_uid"`
create string `name:"create title* content*" role:"leader"` create string `name:"create title* content*" role:"leader"`
remove string `name:"remove" role:"leader"` remove string `name:"remove" role:"leader"`
} }
func (s promotion) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) }
func (s promotion) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) }
func (s promotion) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func (s promotion) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") }
func init() { ice.TeamCtxCmd(promotion{}) } func init() { ice.TeamCtxCmd(promotion{}) }

View File

@ -4,13 +4,11 @@ import "shylinux.com/x/ice"
type investment struct { type investment struct {
Table Table
fields string `data:"title,content"` fields string `data:"title,content,user_uid"`
create string `name:"create title* content*" role:"leader"` create string `name:"create title* content*" role:"leader"`
remove string `name:"remove" role:"leader"` remove string `name:"remove" role:"leader"`
} }
func (s investment) Create(m *ice.Message, arg ...string) { s.ValueCreate(m, arg...) }
func (s investment) Remove(m *ice.Message, arg ...string) { s.ValueRemove(m, arg...) }
func (s investment) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") } func (s investment) List(m *ice.Message, arg ...string) { s.ValueList(m, arg).Display("") }
func init() { ice.TeamCtxCmd(investment{}) } func init() { ice.TeamCtxCmd(investment{}) }