From 9f7c06404dd1296073f982f0cf9e9dbf3b4657aa Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 19 Sep 2024 20:58:50 +0800 Subject: [PATCH] add some --- src/gongyinglian/brand.go | 10 ++++- src/gongyinglian/common.go | 56 +++++------------------ src/gongyinglian/expense.go | 16 +++---- src/gongyinglian/express.js | 4 +- src/gongyinglian/goods.go | 12 ++--- src/gongyinglian/loan.go | 8 +--- src/gongyinglian/material.go | 9 ++-- src/gongyinglian/model/model.go | 30 ++++++------- src/gongyinglian/order.go | 74 +++++++++++++++++-------------- src/gongyinglian/order.js | 4 +- src/gongyinglian/orderDetail.go | 2 +- src/gongyinglian/orderDetail.js | 3 +- src/gongyinglian/payment.js | 6 +-- src/gongyinglian/portal.go | 4 +- src/gongyinglian/portal.json | 50 +++++++++++---------- src/gongyinglian/portal.shy | 38 ---------------- src/gongyinglian/product.go | 9 ++-- src/gongyinglian/product.js | 2 +- src/gongyinglian/quality.go | 10 ++++- src/gongyinglian/refund.js | 6 +-- src/gongyinglian/return.js | 4 +- src/gongyinglian/shop.go | 14 ++++-- src/gongyinglian/store.go | 2 + src/gongyinglian/userStore.go | 2 + src/shichangyingxiao/promotion.go | 6 +-- src/zijinlian/investment.go | 6 +-- 26 files changed, 170 insertions(+), 217 deletions(-) delete mode 100644 src/gongyinglian/portal.shy diff --git a/src/gongyinglian/brand.go b/src/gongyinglian/brand.go index 7bdc460..0a5935f 100644 --- a/src/gongyinglian/brand.go +++ b/src/gongyinglian/brand.go @@ -1,7 +1,15 @@ package gongyinglian -import "shylinux.com/x/ice" +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" +) 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{}) } diff --git a/src/gongyinglian/common.go b/src/gongyinglian/common.go index 412772b..1aff60a 100644 --- a/src/gongyinglian/common.go +++ b/src/gongyinglian/common.go @@ -1,7 +1,6 @@ package gongyinglian import ( - "path" "shylinux.com/x/ice" 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()) 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 { 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]) @@ -104,6 +77,13 @@ func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool { } 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 } @@ -111,29 +91,17 @@ func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {} type Value struct { Table - fields string `data:"name,info"` + fields string `data:"name,info,user_uid"` create string `name:"create name info" role:"boss"` modify string `name:"modify name info" role:"boss"` remove string `name:"remove" role:"boss"` } 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) { - s.Table.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") - } + s.ValueModify(m, s.transPrice(m, arg...)...) } func (s Value) transPrice(m *ice.Message, arg ...string) []string { 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 } func (s Relative) List(m *ice.Message, arg ...string) { - if !s.checkListRole(m, arg...) { + if !s.IsBoss(m) && !s.IsWorker(m) { return } 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.Key(order, model.AMOUNT), s.Key(order, model.TOTAL), model.COMPANY_UID, model.OPEN_ID, model.ORDER_UID, diff --git a/src/gongyinglian/expense.go b/src/gongyinglian/expense.go index a1b0fab..76a8e88 100644 --- a/src/gongyinglian/expense.go +++ b/src/gongyinglian/expense.go @@ -9,19 +9,15 @@ import ( type expense struct { Value - fields string `data:"expense_type,amount,name,info"` - create string `name:"create expense_type* amount* name info" role:"boss"` - modify string `name:"modify amount* name info" role:"boss"` + 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,worker"` + 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) { - arg = kit.TransArgKeys(arg, model.EXPENSE_TYPE, model.TYPE) - s.Value.Create(m, kit.Simple(arg, model.FROM_USER_UID, m.Option(model.USER_UID))...) -} -func (s expense) List(m *ice.Message, arg ...string) { - if s.checkListRole(m, arg...) { - s.Value.List(m, arg...) - } + arg = kit.TransArgKeys(s.transPrice(m, arg...), model.EXPENSE_TYPE, model.TYPE) + s.Insert(m, kit.Simple(arg, model.FROM_USER_UID, m.Option(model.USER_UID), m.OptionSimple(model.STORE_UID))...) } func init() { ice.TeamCtxCmd(expense{}) } diff --git a/src/gongyinglian/express.js b/src/gongyinglian/express.js index 8a6cdc3..6eeedba 100644 --- a/src/gongyinglian/express.js +++ b/src/gongyinglian/express.js @@ -1,8 +1,8 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, + {view: html.TITLE, list: [value.user_name]}, + {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.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, ] }) diff --git a/src/gongyinglian/goods.go b/src/gongyinglian/goods.go index 8c186f9..9a5187c 100644 --- a/src/gongyinglian/goods.go +++ b/src/gongyinglian/goods.go @@ -9,19 +9,19 @@ import ( type goods struct { Product - create string `name:"create shop_uid*:select name* info price stock unit" role:"boss"` - market string `name:"market domain_uid* title* content" role:"boss"` + create string `name:"create shop_uid*:select name* info price stock unit" role:"boss"` + marketInsert string `name:"marketInsert domain_uid* title* content" role:"boss"` } func (s goods) Create(m *ice.Message, arg ...string) { 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) { 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{}) } diff --git a/src/gongyinglian/loan.go b/src/gongyinglian/loan.go index 6e0d8b7..cd550e1 100644 --- a/src/gongyinglian/loan.go +++ b/src/gongyinglian/loan.go @@ -12,17 +12,13 @@ type loan struct { fields string `data:"loan_type,amount,name,info"` create string `name:"create loan_type* amount name info" 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) { - 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))...) } -func (s loan) List(m *ice.Message, arg ...string) { - if s.checkListRole(m, arg...) { - s.Value.List(m, arg...) - } -} func init() { ice.TeamCtxCmd(loan{}) } diff --git a/src/gongyinglian/material.go b/src/gongyinglian/material.go index 7686c29..13d3d0a 100644 --- a/src/gongyinglian/material.go +++ b/src/gongyinglian/material.go @@ -16,10 +16,11 @@ func (s material) Create(m *ice.Message, arg ...string) { s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductMaterial, arg)...) } 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...) - m.PushAction(s.SetWarehouse, s.Modify, s.Remove) - } + s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductMaterial)), arg...) + 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{}) } diff --git a/src/gongyinglian/model/model.go b/src/gongyinglian/model/model.go index 9f6590e..dede4ba 100644 --- a/src/gongyinglian/model/model.go +++ b/src/gongyinglian/model/model.go @@ -11,8 +11,8 @@ const ( STATUS = "status" TITLE = "title" CONTENT = "content" - AUTH_UID = "auth_uid" USER_UID = "user_uid" + USER_ROLE = "user_role" USER_STORE_ROLE = "user_store_role" STORE_UID = "store_uid" STORE_NAME = "store_name" @@ -73,6 +73,16 @@ type Warehouse struct { StoreUID string `gorm:"type:char(32);index"` 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 { db.ModelNameInfo UserUID string `gorm:"type:char(32);index"` @@ -101,9 +111,9 @@ type Order struct { RefundSuccessTime db.Time Name string `gorm:"type:varchar(64)"` Info string - Total int `gorm:"default:0"` - Amount int `gorm:"default:0"` Status uint8 `gorm:"default:0"` + Amount int `gorm:"default:0"` + Total int `gorm:"default:0"` } type OrderDetail struct { db.ModelWithUID @@ -134,22 +144,12 @@ type Refund struct { func init() { db.CmdModels("", - &UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Product{}, + &UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Quality{}, &Brand{}, &Product{}, &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 { db.ModelNameInfo UserUID string `gorm:"type:char(32);index"` diff --git a/src/gongyinglian/order.go b/src/gongyinglian/order.go index 2aa32aa..ab58087 100644 --- a/src/gongyinglian/order.go +++ b/src/gongyinglian/order.go @@ -1,6 +1,8 @@ package gongyinglian import ( + "math" + "shylinux.com/x/ice" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" @@ -13,17 +15,17 @@ type Order struct { Table userStore userStore store store - orderDetail orderDetail product Product + orderDetail orderDetail models string `data:"order"` - sell string `name:"sell name info" role:"boss" help:"出货"` - produce string `name:"produce name info" role:"boss" help:"加工"` - purchase string `name:"purchase name info" role:"boss" help:"进货"` - insert string `name:"insert product_uid*:select count*" role:"boss"` - update string `name:"update price* count*" role:"boss"` - delete string `name:"delete" role:"boss"` - cancel string `name:"cancel" role:"boss"` - submit string `name:"submit" role:"boss"` + sell string `name:"sell name info" help:"出货" role:"boss,worker"` + produce string `name:"produce name info" help:"加工" role:"boss,worker"` + purchase string `name:"purchase name info" help:"进货" role:"boss,worker"` + insert string `name:"insert product_uid*:select count*" role:"boss,worker"` + update string `name:"update count* price*" role:"boss,worker"` + delete string `name:"delete" role:"boss,worker"` + cancel string `name:"cancel" role:"boss,worker"` + submit string `name:"submit" role:"boss,worker"` confirmSell string `name:"confirmSell from_store_uid" role:"void"` confirmProduce string `name:"confirmProduce" role:"void"` confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"` @@ -32,10 +34,11 @@ type Order struct { payment string `name:"payment 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"` - confirmPayment string `name:"confirmPayment" role:"void"` - confirmExpress string `name:"confirmExpress" role:"void"` - confirmReturn string `name:"confirmReturn" role:"void"` - confirmRefund string `name:"confirmRefund" role:"void"` + // return string `name:"return company_uid* open_id*" role:"void"` + confirmPayment string `name:"confirmPayment" role:"void"` + confirmExpress string `name:"confirmExpress" role:"void"` + confirmReturn string `name:"confirmReturn" role:"void"` + confirmRefund string `name:"confirmRefund" role:"void"` } func (s Order) Init(m *ice.Message, arg ...string) { @@ -44,24 +47,24 @@ func (s Order) Init(m *ice.Message, arg ...string) { s.Table.Init(m, arg...) } 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()) } 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.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID), )...) m.ProcessRewrite(model.UID, m.Result()) } 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()) } func (s Order) List(m *ice.Message, arg ...string) { m.Display("") if len(arg) == 1 { - if !s.checkListRole(m, arg...) { + if !s.IsBoss(m) && !s.IsWorker(m) { return } switch OrderType(kit.Int(m.Option(model.ORDER_TYPE))) { @@ -136,10 +139,10 @@ func (s Order) List(m *ice.Message, arg ...string) { } case OrderSubmit: 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])) } 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])) } else if msg.Append(model.FROM_USER_UID) == "" { 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) { 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)) - 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)) + m.Cmd(s.orderDetail, s.Insert, arg, msg.AppendSimple(model.PRICE), model.ORDER_UID, m.Option(model.UID)) s.Amount(m) } 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)) 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) { 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) { 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, 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], ) }) @@ -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) { 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], "库存不足") { return } @@ -285,10 +294,9 @@ func (s Order) Payment(m *ice.Message, arg ...string) { 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)...) 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", "订单已付款")) } @@ -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) { 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)...) 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)...) 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", "订单已确认收货")) } 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) { 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)...) 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.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) { 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) { 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)...) 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 (s Order) changeStatusFrom(m *ice.Message, from OrderStatus, which string, cb func(*ice.Message)) { - defer m.ToastProcess()() s.Transaction(m, func() { msg := s.SelectForUpdate(m.Spawn(), m.OptionSimple(model.UID)...) if from != -1 && m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != from) { diff --git a/src/gongyinglian/order.js b/src/gongyinglian/order.js index 64376f6..775a5f0 100644 --- a/src/gongyinglian/order.js +++ b/src/gongyinglian/order.js @@ -1,8 +1,8 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value), can.onimport.textView(can, value, "order_status", mdb.STATUS)]}, + {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)]}, {view: html.STATUS, list: ["数量:", value.total, "件", "总额:", value.amount, "元"]}, 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)]}, diff --git a/src/gongyinglian/orderDetail.go b/src/gongyinglian/orderDetail.go index 8a27332..1c270c9 100644 --- a/src/gongyinglian/orderDetail.go +++ b/src/gongyinglian/orderDetail.go @@ -21,7 +21,7 @@ func (s orderDetail) Amount(m *ice.Message, arg ...string) { s.Select(m, model.ORDER_UID, arg[0]) } func (s orderDetail) List(m *ice.Message, arg ...string) { - if !s.checkOrderRole(m.Spawn(), arg...) { + if !s.checkOrderRole(m, arg[0], arg[1]) { return } m.Display("") diff --git a/src/gongyinglian/orderDetail.js b/src/gongyinglian/orderDetail.js index 38a4ab8..2d4f6e9 100644 --- a/src/gongyinglian/orderDetail.js +++ b/src/gongyinglian/orderDetail.js @@ -1,8 +1,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { - msg.Option("_share_title", can.Option("uid").slice(0, 6)) 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.OUTPUT, list: [value.info]}, ] }, function(event) {}) diff --git a/src/gongyinglian/payment.js b/src/gongyinglian/payment.js index 2267b0a..6eeedba 100644 --- a/src/gongyinglian/payment.js +++ b/src/gongyinglian/payment.js @@ -1,9 +1,9 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, - {view: html.STATUS, list: [value.company_name, ": ", value.open_id]}, + {view: html.TITLE, list: [value.user_name]}, + {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.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, ] }) }, diff --git a/src/gongyinglian/portal.go b/src/gongyinglian/portal.go index 86fdece..fad7db5 100644 --- a/src/gongyinglian/portal.go +++ b/src/gongyinglian/portal.go @@ -13,11 +13,11 @@ type Portal struct { guanlixitong.Portal product Product 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) { - 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, "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)") diff --git a/src/gongyinglian/portal.json b/src/gongyinglian/portal.json index b42ea98..bad5bc5 100644 --- a/src/gongyinglian/portal.json +++ b/src/gongyinglian/portal.json @@ -1,11 +1,11 @@ { - "portal": "供应链", - "goods": "商品", "sell": "出货", "purchase": "进货", "expense": "开支", - "payment": "付款", "express": "寄货", "return": "退贷", "refund": "退款", - "process": "生产", "again": "再来一单", - "material": "原材", "produce": "加工", "quality": "质检", "brand": "贴牌", - "product": "货物", "order": "订单", "shop": "店铺", "warehouse": "仓库", - "member": "生意伙伴", "loan": "借贷外债", + "portal": "供应链", "member": "生意伙伴", + "goods": "商品", "sell": "出货", "produce": "加工", "purchase": "进货", "material": "原材", + "payment": "付款", "express": "寄货", "expense": "开支", "return": "退贷", "refund": "退款", + "shop": "店铺", "warehouse": "仓库", "quality": "质检", "brand": "贴牌", "loan": "借贷外债", + "product": "货物", "order": "订单", + "again": "再来一单", + "process": "加工", "confirmSell": "确认出货", "confirmProduce": "确认加工", "confirmPurchase": "确认进货", @@ -20,40 +20,39 @@ "icons": { "goods": "https://img.icons8.com/officel/80/product.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", - "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", "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", "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", "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": { "My Store": "我的生意", "user_store_role": "用户角色", "store_uid": "生意", - "store_type": "生意类型", "store_name": "生意名称", + "store_type": "生意类型", "shop_uid": "店铺", "shop_name": "店铺名称", "warehouse_uid": "仓库", "warehouse_name": "仓库名称", "quality_name": "质检名称", "brand_name": "品牌名称", - "order_type": "订单类型", "product_uid": "产品", "product_type": "产品类型", - "company_uid": "公司", - "to_store_uid": "收货店铺", + "order_type": "订单类型", "from_store_uid":"出货店铺", + "to_store_uid": "收货店铺", "payment_status": "付款状态", "express_status": "快递状态", "return_status": "退货状态", @@ -72,7 +71,8 @@ "boss": "老板", "worker": "员工", "vendor": "供货商", - "custom": "经销商", + "channel": "经销商", + "custom": "顾客", "style": { "creator": "danger", "boss": "danger" @@ -80,9 +80,11 @@ }, "store_type": { "shop": "店铺", + "channel": "渠道", "factory": "工厂", "icons": { "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" } }, @@ -122,25 +124,25 @@ "payment_status": { "create": "🕑 已发起付款", "failure": "❌ 付款失败", - "success": "🕑 待确认收款", + "success": "✅ 已付款", "confirm": "✅ 已确认收款" }, "express_status": { "create": "🕑 已发起寄货", "send": "🕑 已寄货", - "recv": "🕑 待确认收货", + "recv": "✅ 已收货", "confirm": "✅ 已确认收货" }, "return_status": { "create": "🕑 已发起退货", "send": "🕑 已寄货", - "recv": "🕑 待确认退货", + "recv": "✅ 已收货", "confirm": "✅ 已确认退货" }, "refund_status": { "create": "🕑 已发起退款", "failure": "❌ 退款失败", - "success": "🕑 待确认收款", + "success": "✅ 已退款", "confirm": "✅ 已确认收款" }, "expense_type": { diff --git a/src/gongyinglian/portal.shy b/src/gongyinglian/portal.shy deleted file mode 100644 index b4131fb..0000000 --- a/src/gongyinglian/portal.shy +++ /dev/null @@ -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 -` diff --git a/src/gongyinglian/product.go b/src/gongyinglian/product.go index bb6a12d..e2e828c 100644 --- a/src/gongyinglian/product.go +++ b/src/gongyinglian/product.go @@ -16,6 +16,7 @@ type Product struct { models string `data:"product"` 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"` + remove string `name:"remove" role:"boss"` setShop string `name:"setShop shop_uid*" role:"boss"` setWarehouse string `name:"setWarehouse warehouse_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) { - arg = kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE) - s.Value.Create(m, arg...) + s.Value.Create(m, kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE)...) } 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 } 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) }) if len(arg) == 1 { s.Select(m, args...) - s.Button(m, "") } else if len(arg) == 2 { s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...) } else { 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) SetWarehouse(m *ice.Message, arg ...string) { s.Value.Modify(m, arg...) } diff --git a/src/gongyinglian/product.js b/src/gongyinglian/product.js index a716364..83aa9a9 100644 --- a/src/gongyinglian/product.js +++ b/src/gongyinglian/product.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.OUTPUT, list: [value.info]}, ] }) diff --git a/src/gongyinglian/quality.go b/src/gongyinglian/quality.go index 0e56da4..0c3a7fc 100644 --- a/src/gongyinglian/quality.go +++ b/src/gongyinglian/quality.go @@ -1,7 +1,15 @@ package gongyinglian -import "shylinux.com/x/ice" +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" +) 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{}) } diff --git a/src/gongyinglian/refund.js b/src/gongyinglian/refund.js index fddabea..6eeedba 100644 --- a/src/gongyinglian/refund.js +++ b/src/gongyinglian/refund.js @@ -1,9 +1,9 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, - {view: html.STATUS, list: [value.company_name, ": ", value.open_id]}, + {view: html.TITLE, list: [value.user_name]}, + {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.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, ] }) }, diff --git a/src/gongyinglian/return.js b/src/gongyinglian/return.js index 69affeb..6eeedba 100644 --- a/src/gongyinglian/return.js +++ b/src/gongyinglian/return.js @@ -1,8 +1,8 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { 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.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, + {view: html.TITLE, list: [value.user_name]}, + {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.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]}, ] }) diff --git a/src/gongyinglian/shop.go b/src/gongyinglian/shop.go index 4aeb364..f21ffba 100644 --- a/src/gongyinglian/shop.go +++ b/src/gongyinglian/shop.go @@ -1,14 +1,20 @@ package gongyinglian -import "shylinux.com/x/ice" +import ( + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" +) type Shop struct { Value - fields string `data:"name,address"` + fields string `data:"name,address,user_uid"` create string `name:"create 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{}) } diff --git a/src/gongyinglian/store.go b/src/gongyinglian/store.go index 86060ca..cc955ff 100644 --- a/src/gongyinglian/store.go +++ b/src/gongyinglian/store.go @@ -18,11 +18,13 @@ type StoreType int const ( StoreShop StoreType = iota + StoreChannel StoreFactory ) var StoreTypeList = map[StoreType]string{ StoreShop: "shop", + StoreChannel: "channel", StoreFactory: "factory", } diff --git a/src/gongyinglian/userStore.go b/src/gongyinglian/userStore.go index 83aa8ad..3927f01 100644 --- a/src/gongyinglian/userStore.go +++ b/src/gongyinglian/userStore.go @@ -14,6 +14,7 @@ const ( UserStoreBoss UserStoreWorker UserStoreVendor + UserStoreChannel UserStoreCustom ) @@ -23,6 +24,7 @@ var UserStoreRoleList = map[UserStoreRole]string{ UserStoreBoss: "boss", UserStoreWorker: "worker", UserStoreVendor: "vendor", + UserStoreChannel: "channel", UserStoreCustom: "custom", } diff --git a/src/shichangyingxiao/promotion.go b/src/shichangyingxiao/promotion.go index f03544d..332ff62 100644 --- a/src/shichangyingxiao/promotion.go +++ b/src/shichangyingxiao/promotion.go @@ -4,13 +4,11 @@ import "shylinux.com/x/ice" type promotion struct { Table - fields string `data:"title,content"` + fields string `data:"title,content,user_uid"` create string `name:"create title* content*" 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{}) } diff --git a/src/zijinlian/investment.go b/src/zijinlian/investment.go index 97223e4..8cae993 100644 --- a/src/zijinlian/investment.go +++ b/src/zijinlian/investment.go @@ -4,13 +4,11 @@ import "shylinux.com/x/ice" type investment struct { Table - fields string `data:"title,content"` + fields string `data:"title,content,user_uid"` create string `name:"create title* content*" 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{}) }