This commit is contained in:
jingganjiaoyu 2024-08-18 23:10:09 +08:00
parent 20c58fd1d0
commit 7a3d5f238d
27 changed files with 585 additions and 213 deletions

View File

@ -15,11 +15,6 @@ type Table struct {
func (s Table) Inputs(m *ice.Message, arg ...string) {
switch arg[0] {
case model.STORE_TYPE:
for k, v := range StoreTypeList {
m.Push(arg[0], k).Push(model.NAME, v)
}
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
case model.USER_STORE_ROLE:
for k, v := range UserStoreRoleList {
if k != UserStoreCreator && k != UserStoreVisitor {
@ -27,6 +22,16 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
}
}
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
case model.STORE_TYPE:
for k, v := range StoreTypeList {
m.Push(arg[0], k).Push(model.NAME, v)
}
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
case model.PRODUCT_TYPE:
for k, v := range ProductTypeList {
m.Push(arg[0], k).Push(model.NAME, v)
}
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
case model.FROM_STORE_UID, model.TO_STORE_UID:
m.Cmdy(userStore{}, m.Option(model.USER_UID)).Cut(model.STORE_UID, model.STORE_NAME).DisplayInputKeyNameIconTitle()
m.RenameAppend(model.STORE_UID, arg[0])
@ -39,10 +44,17 @@ func (s Table) Inputs(m *ice.Message, arg ...string) {
}
func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
m.RewriteAppend(func(value, key string, index int) string {
kit.If(key == model.STORE_TYPE, func() { value = StoreType(kit.Int(value)).String() })
kit.If(key == model.USER_STORE_ROLE, func() { value = UserStoreRole(kit.Int(value)).String() })
kit.If(key == model.STORE_TYPE, func() { value = StoreType(kit.Int(value)).String() })
kit.If(key == model.PRODUCT_TYPE, func() { value = ProductType(kit.Int(value)).String() })
kit.If(key == model.ORDER_TYPE, func() { value = OrderType(kit.Int(value)).String() })
kit.If(key == model.ORDER_STATUS, func() { value = OrderStatus(kit.Int(value)).String() })
kit.If(key == model.PAYMENT_STATUS, func() { value = PaymentStatus(kit.Int(value)).String() })
kit.If(key == model.EXPRESS_STATUS, func() { value = ExpressStatus(kit.Int(value)).String() })
kit.If(key == model.RETURN_STATUS, func() { value = ReturnStatus(kit.Int(value)).String() })
kit.If(key == model.REFUND_STATUS, func() { value = RefundStatus(kit.Int(value)).String() })
kit.If(key == model.PRICE, func() { value = kit.Format("%0.2f", float64(kit.Int(value))/100) })
kit.If(key == model.AMOUNT, func() { value = kit.Format("%0.2f", float64(kit.Int(value))/100) })
return value
})
return s.Table.RewriteAppend(m)
@ -72,10 +84,21 @@ func (s Table) userStoreRole(m *ice.Message, arg ...string) UserStoreRole {
return -1
}
}
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Message {
func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
user_uid := m.Option(model.USER_UID)
msg := s.Select(m.Spawn(), "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
if msg.Append(model.FROM_USER_UID) != "" && msg.Append(model.TO_USER_UID) != "" && user_uid != msg.Append(model.FROM_USER_UID) && user_uid != msg.Append(model.TO_USER_UID) {
return false
}
return true
}
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) {
s.Table.RecordEvent(m, m.Option(model.STORE_UID), info, kit.Select(m.Option(model.UID), arg, 0))
return m
}
func (s Table) recordEventWithUID(m *ice.Message, info string, arg ...string) {
uid := kit.Select(m.Result(), m.Option(model.UID))
kit.If(info == "", func() { info = m.ActionCmdTitle() })
s.recordEvent(m, kit.JoinWord(info, kit.Cut(uid, 6), m.Option(model.NAME)), uid)
}
type Tables struct{ Table }

View File

@ -1,8 +1,32 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
type express struct{ Table }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type express struct {
Table
order Order
}
func (s express) List(m *ice.Message, arg ...string) {
s.Tables(m, s.order).FieldsWithCreatedAT(m, s,
s.AS(model.TO_USER_UID, model.USER_UID), model.EXPRESS_STATUS,
model.COMPANY_UID, model.OPEN_ID,
model.ORDER_UID,
)
if len(arg) == 1 {
s.Select(m, s.Key(s.order, model.FROM_STORE_UID), arg[0]).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s.order, model.FROM_STORE_UID), arg[0], s.Key(s, model.UID), arg[1])
} else {
return
}
s.SelectJoinCompany(m)
s.SelectJoinUser(m)
}
func init() { ice.TeamCtxCmd(express{}) }

View File

@ -0,0 +1,11 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.company_name), msg.Option("_share_content", value.open_id) }
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name}, can.onimport.textView(can, value, "express_status", mdb.STATUS)]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
{view: html.STATUS, list: [{text: value.company_name}, {text: ": "}, {text: value.open_id}]},
{view: html.STATUS, list: [{text: "订单: "}, {text: value.order_uid.slice(0, 6)}, {text: "金额: "}, {text: value.amount||"0"}, {text: "数量: "}, {text: value.total||"0"}]},
] })
},
})

View File

@ -1,10 +0,0 @@
package gongyinglian
import "shylinux.com/x/ice"
type garage struct{ Tables }
func (s garage) List(m *ice.Message, arg ...string) {
}
func init() { ice.TeamCtxCmd(garage{}) }

View File

@ -1,10 +1,23 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
type goods struct{ Tables }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type goods struct {
Product
create string `name:"create shop_uid*:select name* info price stock unit" role:"boss"`
}
func (s goods) Create(m *ice.Message, arg ...string) {
m.Cmdy(s.Product, s.Create, model.PRODUCT_TYPE, ProductGoods, arg)
}
func (s goods) List(m *ice.Message, arg ...string) {
m.Cmdy(s.Product, arg, kit.Dict(model.PRODUCT_TYPE, kit.Format(ProductGoods)))
m.PushAction(s.SetShop, s.Modify, s.Remove)
}
func init() { ice.TeamCtxCmd(goods{}) }

View File

@ -1,10 +1,23 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
type material struct{ Tables }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type material struct {
Product
create string `name:"create warehouse_uid*:select name* info price stock unit" role:"boss"`
}
func (s material) Create(m *ice.Message, arg ...string) {
m.Cmdy(s.Product, s.Create, model.PRODUCT_TYPE, ProductMaterial, arg)
}
func (s material) List(m *ice.Message, arg ...string) {
m.Cmdy(s.Product, arg, kit.Dict(model.PRODUCT_TYPE, kit.Format(ProductMaterial)))
m.PushAction(s.SetWarehouse, s.Modify, s.Remove)
}
func init() { ice.TeamCtxCmd(material{}) }

View File

@ -11,12 +11,16 @@ const (
STATUS = "status"
TITLE = "title"
CONTENT = "content"
ADDRESS = "address"
OPEN_ID = "open_id"
USER_UID = "user_uid"
USER_STORE_ROLE = "user_store_role"
STORE_UID = "store_uid"
STORE_NAME = "store_name"
STORE_TYPE = "store_type"
WAREHOUSE_NAME = "warehouse_name"
SHOP_NAME = "shop_name"
PRODUCT_TYPE = "product_type"
ORDER_UID = "order_uid"
ORDER_TYPE = "order_type"
ORDER_STATUS = "order_status"
@ -36,6 +40,8 @@ const (
PRODUCT_UID = "product_uid"
COMPANY_UID = "company_uid"
CITY_UID = "city_uid"
AMOUNT = "amount"
TOTAL = "total"
PRICE = "price"
STOCK = "stock"
COUNT = "count"
@ -54,22 +60,41 @@ type Store struct {
Name string `gorm:"type:char(64)"`
Type uint8
}
type Product struct {
type Shop struct {
db.ModelWithUID
StoreUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:char(64)"`
Info string
Price uint `gorm:"default:0"`
Stock uint `gorm:"default:0"`
Unit string `gorm:"type:char(8)"`
Address string `gorm:"type:varchar(255)"`
}
type Warehouse struct {
db.ModelWithUID
StoreUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:char(64)"`
Address string `gorm:"type:varchar(255)"`
}
type Product struct {
db.ModelWithUID
StoreUID string `gorm:"type:char(32);index"`
ShopUID string `gorm:"type:char(32);index"`
WarehouseUID string `gorm:"type:char(32);index"`
Name string `gorm:"type:char(64)"`
Info string
Type uint8
Price uint `gorm:"default:0"`
Stock uint `gorm:"default:0"`
Unit string `gorm:"type:char(8)"`
}
type Order struct {
db.ModelWithUID
Name string `gorm:"type:char(64)"`
Info string
Amount int
Total int
Status uint8
FromStoreUID string `gorm:"type:char(32);index"`
FromUserUID string `gorm:"type:char(32);index"`
ToStoreUID string `gorm:"type:char(32);index"`
ToUserUID string `gorm:"type:char(32);index"`
Status uint8
PaymentStatus uint8
ExpressStatus uint8
ReturnStatus uint8
@ -81,6 +106,7 @@ type Order struct {
}
type OrderDetail struct {
db.ModelWithUID
StoreUID string `gorm:"type:char(32);index"`
OrderUID string `gorm:"type:char(32);index"`
ProductUID string `gorm:"type:char(32);index"`
Price uint `gorm:"default:0"`
@ -118,5 +144,5 @@ type Refund struct {
}
func init() {
db.CmdModels("", &UserStore{}, &Store{}, &Product{}, &Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{})
db.CmdModels("", &UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Product{}, &Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{})
}

View File

@ -9,78 +9,96 @@ import (
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type order struct {
type Order struct {
Table
product product
userStore userStore
product Product
orderDetail orderDetail
sell string `name:"sell" role:"boss"`
purchase string `name:"purchase" role:"boss"`
models string `data:"order"`
sell string `name:"sell name info" role:"boss"`
process string `name:"process name info" role:"boss"`
purchase string `name:"purchase name info" role:"boss"`
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"`
confirmSell string `name:"confirmSell from_store_uid" role:"void"`
confirmProcess string `name:"confirmProcess" role:"void"`
confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"`
produce string `name:"produce" role:"void"`
payment string `name:"payment company_uid* open_id*" role:"void"`
confirmPayment string `name:"confirmPayment" 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"`
refund string `name:"refund company_uid* open_id*" role:"void"`
confirmRefund string `name:"confirmRefund" role:"void"`
}
func (s order) Init(m *ice.Message, arg ...string) {
func (s Order) Init(m *ice.Message, arg ...string) {
aaa.White(m.Message, kit.Keys(m.PrefixKey(), ctx.ACTION, s.Return))
m.Design(s.Return, "", "company_uid* open_id*")
s.Table.Init(m, arg...)
}
func (s order) Sell(m *ice.Message, arg ...string) {
s.Create(m, model.FROM_STORE_UID, m.Option(model.STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID))
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))...)
m.ProcessRewrite(model.UID, m.Result())
}
func (s order) Purchase(m *ice.Message, arg ...string) {
s.Create(m, model.TO_STORE_UID, m.Option(model.STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID))
func (s Order) Process(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),
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) {
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))...)
m.ProcessRewrite(model.UID, m.Result())
}
func (s Order) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
return
}
role := UserStoreVisitor
m.Options(model.STORE_UID, arg[0])
if msg := m.Cmd(userStore{}, s.Select, m.OptionSimple(model.STORE_UID, model.USER_UID)); msg.Length() > 0 {
role = UserStoreRole(kit.Int(msg.Append(model.ROLE)))
}
if user_uid := m.Option(model.USER_UID); len(arg) == 1 {
if role := s.userStoreRole(m.Spawn(), arg[0]); len(arg) == 1 {
if role != UserStoreCreator && role != UserStoreBoss {
return
}
s.Select(m, "from_store_uid = ? OR to_store_uid = ?", arg[0], arg[0]).Table(func(value ice.Maps) {
if value[model.FROM_STORE_UID] == arg[0] {
switch OrderType(kit.Int(m.Option(model.ORDER_TYPE))) {
case OrderSell:
s.Select(m, "from_store_uid = ? AND (to_store_uid IS NULL OR to_store_uid != ?)", arg[0], arg[0])
case OrderProcess:
s.Select(m, "from_store_uid = ? AND to_store_uid = ?", arg[0], arg[0])
case OrderPurchase:
s.Select(m, "(from_store_uid IS NULL OR from_store_uid != ?) AND to_store_uid = ?", arg[0], arg[0])
default:
s.Select(m, "from_store_uid = ? OR to_store_uid = ?", arg[0], arg[0])
}
m.Table(func(value ice.Maps) {
if value[model.FROM_STORE_UID] == arg[0] && value[model.TO_STORE_UID] == arg[0] {
m.Push(model.USER_UID, value[model.TO_USER_UID])
m.Push(model.ORDER_TYPE, s.Sell)
m.Push(model.ORDER_TYPE, OrderProcess)
} else if value[model.FROM_STORE_UID] == arg[0] {
m.Push(model.USER_UID, value[model.TO_USER_UID])
m.Push(model.ORDER_TYPE, OrderSell)
} else {
m.Push(model.USER_UID, value[model.FROM_USER_UID])
m.Push(model.ORDER_TYPE, s.Purchase)
m.Push(model.ORDER_TYPE, OrderPurchase)
}
}).RenameAppend(model.STATUS, model.ORDER_STATUS).Action(s.Sell, s.Purchase)
}).RenameAppend(model.STATUS, model.ORDER_STATUS).Action().Display("")
s.SelectJoinUser(m)
m.Display("order.js")
} else if len(arg) == 2 {
user_uid := m.Option(model.USER_UID)
msg := s.Select(m.Spawn(), "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
if msg.Append(model.FROM_USER_UID) != "" && msg.Append(model.TO_USER_UID) != "" &&
user_uid != msg.Append(model.FROM_USER_UID) && user_uid != msg.Append(model.TO_USER_UID) {
return
}
s.ClearOption(m)
if m.Cmdy(s.orderDetail, arg); m.Length() == 0 {
m.EchoInfoButton(m.Trans("please insert product", "请添加品"), s.Insert)
kit.If(!m.IsErr(), func() { m.EchoInfoButton(m.Trans("please insert product", "请添加产品"), s.Insert) })
return
}
m.RenameAppend(model.UID, model.ORDER_DETAIL_UID).Action()
switch OrderStatus(kit.Int(msg.Append(model.STATUS))) {
case OrderCreate:
if role == UserStoreCreator || role == UserStoreBoss {
if user_uid == msg.Append(model.FROM_USER_UID) || user_uid == msg.Append(model.TO_USER_UID) {
m.PushAction(s.Update, s.Delete).Action(s.Insert).EchoButton(s.Cancel, s.Submit)
}
case OrderSubmit:
@ -88,20 +106,24 @@ func (s order) List(m *ice.Message, arg ...string) {
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.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1]))
} else if msg.Append(model.TO_USER_UID) == "" {
m.EchoButton(s.ConfirmPurchase)
} else if msg.Append(model.FROM_USER_UID) == "" {
m.EchoButton(s.ConfirmSell)
} else if msg.Append(model.TO_USER_UID) == "" {
m.EchoButton(s.ConfirmPurchase)
} else if msg.Append(model.FROM_USER_UID) == msg.Append(model.TO_USER_UID) {
m.EchoButton(s.ConfirmProcess)
}
case OrderConfirm:
if msg.Append(model.TO_USER_UID) == user_uid {
if msg.Append(model.FROM_USER_UID) == msg.Append(model.TO_USER_UID) {
m.EchoButton(s.Produce)
} else if user_uid == msg.Append(model.TO_USER_UID) {
if PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) == PaymentUnknown {
m.EchoButton(s.Payment)
}
if ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) == ExpressRecv {
m.EchoButton(s.ConfirmExpress)
}
} else if msg.Append(model.FROM_USER_UID) == user_uid {
} else if user_uid == msg.Append(model.FROM_USER_UID) {
if PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) == PaymentSuccess {
m.EchoButton(s.ConfirmPayment)
}
@ -112,14 +134,14 @@ func (s order) List(m *ice.Message, arg ...string) {
}
}
case OrderDeal:
if msg.Append(model.TO_USER_UID) == user_uid {
if user_uid == msg.Append(model.TO_USER_UID) {
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnUnknown {
m.EchoButton(s.Return)
}
if RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) == RefundSuccess {
m.EchoButton(s.ConfirmRefund)
}
} else if msg.Append(model.FROM_USER_UID) == user_uid {
} else if user_uid == msg.Append(model.FROM_USER_UID) {
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnRecv {
m.EchoButton(s.ConfirmReturn)
}
@ -130,43 +152,44 @@ func (s order) List(m *ice.Message, arg ...string) {
}
}
}
m.RenameAppend(model.UID, model.ORDER_DETAIL_UID).Action()
}
}
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))
if !m.WarnNotFound(msg.Length() == 0) {
m.Cmd(s.orderDetail, s.Create, arg, msg.AppendSimple(model.PRICE), model.ORDER_UID, m.Option(model.UID))
}
m.Cmd(s.orderDetail, s.Create, arg, msg.AppendSimple(model.PRICE), model.ORDER_UID, m.Option(model.UID))
}
func (s order) Delete(m *ice.Message, arg ...string) {
m.Cmd(s.orderDetail, s.Delete, model.ORDER_UID, m.Option(model.UID), model.UID, m.Option(model.ORDER_DETAIL_UID))
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))
}
func (s order) Update(m *ice.Message, arg ...string) {
m.Cmdy(s.orderDetail, s.Update, model.UID, m.Option(model.ORDER_DETAIL_UID))
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))
}
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)...)
}
func (s order) Submit(m *ice.Message, arg ...string) {
func (s Order) Submit(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(model.STATUS, OrderSubmit), m.OptionSimple(model.UID)...)
// s.sendTemplate(m, "", m.Trans("order submit", "订单已提交"))
}
func (s order) ConfirmSell(m *ice.Message, arg ...string) {
func (s Order) ConfirmSell(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderSubmit, model.FROM_USER_UID, func(msg *ice.Message) {
s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm, m.OptionSimple(model.FROM_STORE_UID), model.FROM_USER_UID, m.Option(model.USER_UID)), m.OptionSimple(model.UID)...)
m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID))
})
// s.sendTemplate(m, model.TO_USER_UID, m.Trans("order confirm", "订单已接收"))
}
func (s order) ConfirmPurchase(m *ice.Message, arg ...string) {
func (s Order) ConfirmProcess(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderSubmit, model.FROM_USER_UID, func(msg *ice.Message) {
s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm), m.OptionSimple(model.UID)...)
})
}
func (s Order) ConfirmPurchase(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderSubmit, model.TO_USER_UID, func(msg *ice.Message) {
s.Table.Update(m, kit.Dict(model.STATUS, OrderConfirm, m.OptionSimple(model.TO_STORE_UID), model.TO_USER_UID, m.Option(model.USER_UID)), m.OptionSimple(model.UID)...)
m.Option(model.FROM_USER_UID, msg.Option(model.FROM_USER_UID))
})
// s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order confirm", "订单已接收"))
}
func (s order) Payment(m *ice.Message, arg ...string) {
func (s Order) Produce(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderConfirm, model.FROM_USER_UID, func(msg *ice.Message) {
})
}
func (s Order) Payment(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderConfirm, model.TO_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) != PaymentUnknown) {
return
@ -177,17 +200,15 @@ func (s order) Payment(m *ice.Message, arg ...string) {
})
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order payment", "订单已付款"))
}
func (s order) ConfirmPayment(m *ice.Message, arg ...string) {
func (s Order) ConfirmPayment(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderConfirm, model.FROM_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) != PaymentSuccess) {
return
}
s.Table.Update(m, kit.Dict(model.PAYMENT_STATUS, PaymentConfirm), m.OptionSimple(model.UID)...)
m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID))
})
// s.sendTemplate(m, model.TO_USER_UID, m.Trans("order confirm payment", "订单已确认收款"))
}
func (s order) Express(m *ice.Message, arg ...string) {
func (s Order) Express(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderConfirm, model.FROM_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) != PaymentConfirm) {
return
@ -201,7 +222,7 @@ func (s order) Express(m *ice.Message, arg ...string) {
})
s.sendTemplate(m, model.TO_USER_UID, m.Trans("order express", "订单已发货"))
}
func (s order) ConfirmExpress(m *ice.Message, arg ...string) {
func (s Order) ConfirmExpress(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderConfirm, model.TO_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) != ExpressRecv) {
return
@ -211,7 +232,7 @@ func (s order) ConfirmExpress(m *ice.Message, arg ...string) {
})
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) {
s.changeStatusFrom(m, OrderDeal, model.TO_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) != ExpressConfirm) {
return
@ -225,17 +246,15 @@ func (s order) Return(m *ice.Message, arg ...string) {
})
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order return", "订单已发起退货"))
}
func (s order) ConfirmReturn(m *ice.Message, arg ...string) {
func (s Order) ConfirmReturn(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderDeal, model.FROM_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) != ReturnRecv) {
return
}
s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnConfirm), m.OptionSimple(model.UID)...)
m.Option(model.TO_USER_UID, msg.Option(model.TO_USER_UID))
})
// s.sendTemplate(m, model.TO_USER_UID, m.Trans("order confirm return", "订单已确认退货"))
}
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) {
if m.WarnNotValid(PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) != PaymentConfirm) {
return
@ -249,7 +268,7 @@ func (s order) Refund(m *ice.Message, arg ...string) {
})
s.sendTemplate(m, model.TO_USER_UID, m.Trans("order refund", "订单已发起退款"))
}
func (s order) ConfirmRefund(m *ice.Message, arg ...string) {
func (s Order) ConfirmRefund(m *ice.Message, arg ...string) {
s.changeStatusFrom(m, OrderDeal, model.TO_USER_UID, func(msg *ice.Message) {
if m.WarnNotValid(RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) != RefundSuccess) {
return
@ -259,7 +278,7 @@ func (s order) ConfirmRefund(m *ice.Message, arg ...string) {
})
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order confirm refund", "订单已确认退款"))
}
func (s order) CheckRole(m *ice.Message, arg ...string) {
func (s Order) CheckRole(m *ice.Message, arg ...string) {
role := UserStoreRole(kit.Int(m.Cmd(userStore{}, s.Select, m.OptionSimple(model.STORE_UID, model.USER_UID)).Append(model.ROLE)))
if m.WarnNotRight(!kit.IsIn(role.String(), append(kit.Split(kit.JoinWord(arg...)), UserStoreCreator.String())...)) || m.Option(model.UID) == "" {
return
@ -268,9 +287,9 @@ func (s order) CheckRole(m *ice.Message, arg ...string) {
m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != OrderCreate)
}
func init() { ice.TeamCtxCmd(order{Table: newTable()}) }
func init() { ice.TeamCtxCmd(Order{Table: newTable()}) }
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() {
msg := s.SelectForUpdate(m.Spawn(), m.OptionSimple(model.UID)...)
@ -283,15 +302,31 @@ func (s order) changeStatusFrom(m *ice.Message, from OrderStatus, which string,
cb(msg)
})
}
func (s order) sendTemplate(m *ice.Message, to string, title string) {
title2 := title
s.recordEvent(m, kit.Cut(m.Option(model.UID), 6)+" "+title)
kit.If(to == model.TO_USER_UID, func() { title2, title = "进货"+title, "出货"+title })
kit.If(to == model.FROM_USER_UID, func() { title2, title = "出货"+title, "进货"+title })
kit.If(to != "" && m.Option(to) != "", func() { s.SendTemplate(m, "", m.Option(to), title2) })
// s.SendTemplate(m, "", "", title)
func (s Order) sendTemplate(m *ice.Message, to string, title string) {
s.recordEvent(m, kit.JoinWord(kit.Cut(m.Option(model.UID), 6), title))
kit.If(to == model.TO_USER_UID, func() { title = "进货" + title })
kit.If(to == model.FROM_USER_UID, func() { title = "出货" + title })
kit.If(to != "" && m.Option(to) != "", func() { s.SendTemplate(m, "", m.Option(to), title) })
}
type OrderType int
const (
OrderUnknown OrderType = iota
OrderSell
OrderProcess
OrderPurchase
)
var OrderTypeList = map[OrderType]string{
OrderUnknown: "unknown",
OrderSell: "sell",
OrderProcess: "process",
OrderPurchase: "purchase",
}
func (s OrderType) String() string { return OrderTypeList[s] }
type OrderStatus int
const (

View File

@ -1,12 +1,13 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name||"待确认"}, can.onimport.textView(can, value, "order_type", mdb.TYPE)]},
{view: html.TITLE, list: [{text: value.name||value.user_name||"待确认"}, can.onimport.textView(can, value, "order_type", mdb.TYPE)]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}, can.onimport.textView(can, value, "order_status", mdb.STATUS)]},
value.payment_success_time && {view: html.STATUS, list: [{text: "收款时间: "}, {text: can.base.TimeTrim(value.payment_success_time)}]},
value.express_recv_time && {view: html.STATUS, list: [{text: "收货时间: "}, {text: can.base.TimeTrim(value.express_recv_time)}]},
value.return_recv_time && {view: html.STATUS, list: [{text: "退货时间: "}, {text: can.base.TimeTrim(value.return_recv_time)}]},
value.refund_success_time && {view: html.STATUS, list: [{text: "退款时间: "}, {text: can.base.TimeTrim(value.refund_success_time)}]},
value.info && {view: html.OUTPUT, list: [{text: value.info}]},
] })
},
})

View File

@ -9,7 +9,7 @@ import (
type orderDetail struct {
Table
product product
product Product
}
func (s orderDetail) Update(m *ice.Message, arg ...string) {
@ -17,6 +17,9 @@ func (s orderDetail) Update(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(m.OptionSimple(model.PRICE, model.COUNT)), arg...)
}
func (s orderDetail) List(m *ice.Message, arg ...string) {
if !s.checkOrderRole(m.Spawn(), arg...) {
return
}
s.Tables(m, s.product).FieldsWithCreatedAT(m, s,
model.NAME, model.INFO, s.Key(s, model.PRICE), s.Key(s, model.COUNT), model.UNIT,
)

View File

@ -1,6 +1,5 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
msg.Option("_share_title", can.Option("uid").slice(0, 6))
_init: function(can, msg) { msg.Option("_share_title", can.Option("uid").slice(0, 6))
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.name}]},
{view: html.STATUS, list: [{text: "单价 "+value.price+" 元"}, {text: "数量 "+value.count+" "+value.unit}]},

View File

@ -1,8 +1,32 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
type payment struct{ Table }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type payment struct {
Table
order Order
}
func (s payment) List(m *ice.Message, arg ...string) {
s.Tables(m, s.order).FieldsWithCreatedAT(m, s,
s.AS(model.TO_USER_UID, model.USER_UID), model.PAYMENT_STATUS,
model.COMPANY_UID, model.OPEN_ID,
model.ORDER_UID, s.Key(s.order, model.AMOUNT), model.TOTAL,
)
if len(arg) == 1 {
s.Select(m, s.Key(s.order, model.FROM_STORE_UID), arg[0]).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s.order, model.FROM_STORE_UID), arg[0], s.Key(s, model.UID), arg[1])
} else {
return
}
s.SelectJoinCompany(m)
s.SelectJoinUser(m)
}
func init() { ice.TeamCtxCmd(payment{}) }

View File

@ -0,0 +1,11 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.company_name), msg.Option("_share_content", value.open_id) }
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name}, can.onimport.textView(can, value, "payment_status", mdb.STATUS)]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
{view: html.STATUS, list: [{text: value.company_name}, {text: ": "}, {text: value.open_id}]},
{view: html.STATUS, list: [{text: "订单: "}, {text: value.order_uid.slice(0, 6)}, {text: "金额: "}, {text: value.amount||"0"}, {text: "数量: "}, {text: value.total||"0"}]},
] })
},
})

View File

@ -1,31 +1,37 @@
{
"portal": "供应链", "placeCreate": "创建生意", "placeRemove": "删除生意",
"goods": "商品", "expense": "开支",
"material": "材料", "process": "加工",
"quality": "质检", "brand": "贴牌",
"shop": "店铺", "garage": "仓库", "express": "物流", "payment": "账本",
"product": "货物列表", "order": "订单列表", "member": "生意伙伴", "loan": "借贷外债",
"sell": "出货", "confirmSell": "确认出货",
"purchase": "进货", "confirmPurchase": "确认进货",
"payment": "付款", "confirmPayment": "确认收款",
"express": "寄件", "confirmExpress": "确认收件",
"return": "发起退货", "confirmReturn": "确认收到退货",
"refund": "发起退款", "confirmRefund": "确认收到退款",
"goods": "商品", "sell": "出货", "purchase": "进货", "expense": "开支",
"payment": "付款", "express": "寄货", "return": "退贷", "refund": "退款",
"material": "原材", "process": "加工", "quality": "质检", "brand": "贴牌",
"product": "货物", "order": "订单", "shop": "店铺", "warehouse": "仓库",
"member": "生意伙伴", "loan": "借贷外债", "support": "系统客服",
"produce": "生产",
"confirmSell": "确认出货",
"confirmProcess": "确认加工",
"confirmPurchase": "确认进货",
"confirmPayment": "确认收款",
"confirmExpress": "确认收件",
"confirmReturn": "确认收到退货",
"confirmRefund": "确认收到退款",
"setShop": "店铺", "setWarehouse": "仓库",
"icons": {
"goods": "https://img.icons8.com/officel/80/product.png",
"sell": "https://img.icons8.com/officel/80/handle-with-care.png",
"purchase": "https://img.icons8.com/officel/80/paid.png",
"expense": "https://img.icons8.com/officel/80/cash-in-hand.png",
"payment": "https://img.icons8.com/officel/80/fund-accounting.png",
"express": "https://img.icons8.com/officel/80/in-transit.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",
"process": "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",
"shop": "https://img.icons8.com/officel/80/shop.png",
"garage": "https://img.icons8.com/officel/80/garage-closed.png",
"express": "https://img.icons8.com/officel/80/in-transit.png",
"payment": "https://img.icons8.com/officel/80/spiral-bound-booklet.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",
"support": "https://img.icons8.com/officel/80/customer-support.png",
"loan": "https://img.icons8.com/officel/80/bank-building.png"
},
"input": {
@ -34,9 +40,19 @@
"store_uid": "生意",
"store_type": "生意类型",
"store_name": "生意名称",
"shop_uid": "店铺",
"shop_name": "店铺名称",
"warehouse_uid": "仓库",
"warehouse_name": "仓库名称",
"order_type": "订单类型",
"product_uid": "商品",
"product_uid": "产品",
"product_type": "产品类型",
"company_uid": "公司",
"payment_status": "付款状态",
"express_status": "快递状态",
"return_status": "退货状态",
"refund_status": "退款状态",
"stock": "库存量",
"price": "单价(元)",
"unit": "单位"
},
@ -46,7 +62,7 @@
"visitor": "访客",
"boss": "老板",
"worker": "员工",
"vendor": "供商",
"vendor": "供商",
"custom": "经销商",
"style": {
"creator": "danger",
@ -54,15 +70,26 @@
}
},
"store_type": {
"shop": "铺",
"shop": "铺",
"factory": "工厂",
"icons": {
"shop": "https://img.icons8.com/officel/80/shop.png",
"factory": "https://img.icons8.com/officel/80/cnc-machine.png"
}
},
"product_type": {
"both": "产品",
"goods": "商品",
"material": "原材",
"icons": {
"both": "https://img.icons8.com/officel/80/warehouse.png",
"goods": "https://img.icons8.com/officel/80/product.png",
"material": "https://img.icons8.com/officel/80/wood.png"
}
},
"order_type": {
"sell": "出货单",
"process": "加工单",
"purchase": "进货单",
"style": {
"purchase": "danger"
@ -71,9 +98,34 @@
"order_status": {
"create": "🕑 待提交",
"cancel": "❌ 已取消",
"submit": "已提交",
"confirm": "✅ 已确认",
"finish": "已完成"
"submit": "🕑 待确认",
"confirm": "🕑 待交易",
"deal": "✅ 已交易",
"done": "❌ 已终结"
},
"payment_status": {
"create": "🕑 已发起付款",
"failure": "❌ 付款失败",
"success": "🕑 待确认收款",
"confirm": "✅ 已确认收款"
},
"express_status": {
"create": "🕑 已发起寄货",
"send": "🕑 已寄货",
"recv": "🕑 待确认收货",
"confirm": "✅ 已确认收货"
},
"return_status": {
"create": "🕑 已发起退货",
"send": "🕑 已寄货",
"recv": "🕑 待确认退货",
"confirm": "✅ 已确认退货"
},
"refund_status": {
"create": "🕑 已发起退款",
"failure": "❌ 退款失败",
"success": "🕑 待确认收款",
"confirm": "✅ 已确认收款"
}
}
}

View File

@ -12,21 +12,22 @@ express.go
return.go
refund.go
sell.go
purchase.go
process.go
quality.go
expense.go
material.go
goods.go
warehouse.go
garage.go
shop.go
loan.go
model
common.go
portal.go
portal.json
portal.shy
goods.go
sell.go
purchase.go
material.go
process.go
quality.go
brand.go
shop.go
warehouse.go
expense.go
loan.go
`

View File

@ -1,10 +1,17 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
type process struct{ Tables }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type process struct{ Order }
func (s process) List(m *ice.Message, arg ...string) {
m.Cmdy(s.Order, arg, kit.Dict(model.ORDER_TYPE, kit.Format(OrderProcess)))
kit.If(len(arg) == 1, func() { m.Action(s.Process) })
}
func init() { ice.TeamCtxCmd(process{}) }
func init() { ice.TeamCtxCmd(process{Order: Order{Table: newTable()}}) }

View File

@ -7,43 +7,82 @@ import (
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type product struct {
type Product struct {
Table
userStore userStore
create string `name:"create name* info* price stock unit" role:"boss"`
modify string `name:"modify name* info* price stock unit" role:"boss"`
delete string `name:"delete" role:"boss"`
shop Shop
warehouse Warehouse
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:"delete" role:"boss"`
setShop string `name:"setShop shop_uid*" role:"boss"`
setWarehouse string `name:"setWarehouse warehouse_uid*" role:"boss"`
}
func (s product) Create(m *ice.Message, arg ...string) {
s.Table.Create(m, kit.Simple(arg, model.PRICE, kit.Int(kit.Float(m.Option(model.PRICE))*100), m.OptionSimple(model.STORE_UID))...)
s.recordEvent(m, m.Trans("create product ", "创建商品 ")+kit.Cut(m.Result(), 6)+" "+m.Option(model.NAME), m.Result())
func (s Product) Create(m *ice.Message, arg ...string) {
arg = kit.TransArgKeys(arg, model.PRODUCT_TYPE, model.TYPE)
s.Table.Create(m, kit.Simple(arg, model.PRICE, s.transPrice(m), m.OptionSimple(model.STORE_UID))...)
s.recordEventWithUID(m, "")
}
func (s product) Modify(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(arg, model.PRICE, kit.Int(kit.Float(m.Option(model.PRICE))*100)), m.OptionSimple(model.UID, model.STORE_UID)...)
func (s Product) Modify(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(arg, model.PRICE, s.transPrice(m)), m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s product) Delete(m *ice.Message, arg ...string) {
s.Table.Delete(m, m.OptionSimple(model.STORE_UID, model.UID)...)
s.recordEvent(m, m.Trans("delete product ", "删除商品 ")+kit.Cut(m.Option(model.UID), 6)+" "+m.Option(model.NAME), m.Option(model.UID))
func (s Product) Remove(m *ice.Message, arg ...string) {
s.Table.Delete(m, m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s product) List(m *ice.Message, arg ...string) {
func (s Product) SetShop(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s Product) SetWarehouse(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s Product) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
s.Select(m, m.OptionSimple(model.STORE_UID)...)
return
}
s.Fields(m, model.UID, model.NAME, model.INFO, model.PRICE, model.COUNT, model.UNIT)
if role := s.userStoreRole(m, arg[0]); role != UserStoreCreator && role != UserStoreBoss && m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) {
return
}
s.Tables(m, s.warehouse, s.shop).FieldsWithCreatedAT(m, s,
s.Key(s, model.NAME), model.INFO, model.PRODUCT_TYPE,
model.PRICE, model.STOCK, model.UNIT, model.WAREHOUSE_NAME, model.SHOP_NAME,
)
args := []string{s.Key(s, model.STORE_UID), arg[0]}
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, model.STORE_UID, arg[0])
s.Select(m, args...)
kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Create) })
} else if len(arg) == 2 {
s.SelectDetail(m, model.STORE_UID, arg[0], model.UID, arg[1])
s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...)
} else {
return
}
if role := s.userStoreRole(m, arg[0]); role == UserStoreCreator || role == UserStoreBoss {
m.PushAction(s.Modify, s.Delete).Action(s.Create)
} else {
m.Action()
}
m.PushAction(s.SetShop, s.SetWarehouse, s.Modify, s.Remove).Display("")
}
func init() { ice.TeamCtxCmd(product{}) }
func init() { ice.TeamCtxCmd(Product{}) }
func (s Product) transPrice(m *ice.Message) int {
return kit.Int(kit.Float(m.Option(model.PRICE)) * 100)
}
type ProductType int
const (
ProductBoth ProductType = iota
ProductGoods
ProductMaterial
)
var ProductTypeList = map[ProductType]string{
ProductBoth: "both",
ProductGoods: "goods",
ProductMaterial: "material",
}
func (s ProductType) String() string { return ProductTypeList[s] }

View File

@ -3,7 +3,10 @@ Volcanos(chat.ONIMPORT, {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.name), msg.Option("_share_content", value.info) }
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.name}]},
{view: html.STATUS, list: [{text: "单价 "+value.price+" 元"}, {text: "库存 "+value.count+" "+value.unit}]},
{view: html.STATUS, list: [
{text: "单价 "+value.price+" 元"}, {text: "库存 "+value.stock+" "+value.unit},
value.shop_name && {text: value.shop_name}, value.warehouse_name && {text: value.warehouse_name},
]},
{view: html.OUTPUT, list: [{text: value.info}]},
] })
},

View File

@ -2,23 +2,16 @@ package gongyinglian
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type purchase struct {
Tables
order order
}
type purchase struct{ Order }
func (s purchase) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
m.Cmdy(s.order, s.Select, model.TO_STORE_UID, arg[0])
m.Table(func(value ice.Maps) { m.Push(model.USER_UID, value[model.FROM_USER_UID]) })
s.SelectJoinUser(m)
} else {
m.Cmdy(s.order, arg)
}
m.Cmdy(s.Order, arg, kit.Dict(model.ORDER_TYPE, kit.Format(OrderPurchase)))
kit.If(len(arg) == 1, func() { m.Action(s.Purchase) })
}
func init() { ice.TeamCtxCmd(purchase{}) }
func init() { ice.TeamCtxCmd(purchase{Order: Order{Table: newTable()}}) }

View File

@ -1,8 +1,32 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
type refund struct{ Table }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type refund struct {
Table
order Order
}
func (s refund) List(m *ice.Message, arg ...string) {
s.Tables(m, s.order).FieldsWithCreatedAT(m, s,
s.AS(model.TO_USER_UID, model.USER_UID), model.REFUND_STATUS,
model.COMPANY_UID, model.OPEN_ID,
model.ORDER_UID, s.Key(s.order, model.AMOUNT), model.TOTAL,
)
if len(arg) == 1 {
s.Select(m, s.Key(s.order, model.FROM_STORE_UID), arg[0]).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s.order, model.FROM_STORE_UID), arg[0], s.Key(s, model.UID), arg[1])
} else {
return
}
s.SelectJoinCompany(m)
s.SelectJoinUser(m)
}
func init() { ice.TeamCtxCmd(refund{}) }

View File

@ -0,0 +1,11 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.company_name), msg.Option("_share_content", value.open_id) }
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name}, can.onimport.textView(can, value, "refund_status", mdb.STATUS)]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
{view: html.STATUS, list: [{text: value.company_name}, {text: ": "}, {text: value.open_id}]},
{view: html.STATUS, list: [{text: "订单: "}, {text: value.order_uid.slice(0, 6)}, {text: "金额: "}, {text: value.amount||"0"}, {text: "数量: "}, {text: value.total||"0"}]},
] })
},
})

View File

@ -1,8 +1,32 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
type Return struct{ Table }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type Return struct {
Table
order Order
}
func (s Return) List(m *ice.Message, arg ...string) {
s.Tables(m, s.order).FieldsWithCreatedAT(m, s,
s.AS(model.TO_USER_UID, model.USER_UID), model.RETURN_STATUS,
model.COMPANY_UID, model.OPEN_ID,
model.ORDER_UID,
)
if len(arg) == 1 {
s.Select(m, s.Key(s.order, model.FROM_STORE_UID), arg[0]).Action()
} else if len(arg) == 2 {
s.SelectDetail(m, s.Key(s.order, model.FROM_STORE_UID), arg[0], s.Key(s, model.UID), arg[1])
} else {
return
}
s.SelectJoinCompany(m)
s.SelectJoinUser(m)
}
func init() { ice.TeamCtxCmd(Return{}) }

View File

@ -0,0 +1,11 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.company_name), msg.Option("_share_content", value.open_id) }
can.onimport.itemcards(can, msg, function(value) { return [
{view: html.TITLE, list: [{text: value.user_name}, can.onimport.textView(can, value, "return_status", mdb.STATUS)]},
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}]},
{view: html.STATUS, list: [{text: value.company_name}, {text: ": "}, {text: value.open_id}]},
{view: html.STATUS, list: [{text: "订单: "}, {text: value.order_uid.slice(0, 6)}, {text: "金额: "}, {text: value.amount||"0"}, {text: "数量: "}, {text: value.total||"0"}]},
] })
},
})

View File

@ -2,23 +2,16 @@ package gongyinglian
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
type sell struct {
Tables
order order
}
type sell struct{ Order }
func (s sell) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
m.Cmdy(s.order, s.Select, model.FROM_STORE_UID, arg[0])
m.Table(func(value ice.Maps) { m.Push(model.USER_UID, value[model.TO_USER_UID]) })
s.SelectJoinUser(m)
} else {
m.Cmdy(s.order, arg)
}
m.Cmdy(s.Order, arg, kit.Dict(model.ORDER_TYPE, kit.Format(OrderSell)))
kit.If(len(arg) == 1, func() { m.Action(s.Sell) })
}
func init() { ice.TeamCtxCmd(sell{}) }
func init() { ice.TeamCtxCmd(sell{Order: Order{Table: newTable()}}) }

View File

@ -1,10 +1,44 @@
package gongyinglian
import "shylinux.com/x/ice"
import (
"shylinux.com/x/ice"
kit "shylinux.com/x/toolkits"
type shop struct{ Tables }
"shylinux.com/x/enterprise/src/gongyinglian/model"
)
func (s shop) List(m *ice.Message, arg ...string) {
type Shop struct {
Table
create string `name:"create name* address" role:"boss"`
modify string `name:"modify name* address" role:"boss"`
remove string `name:"remove" role:"boss"`
}
func init() { ice.TeamCtxCmd(shop{}) }
func (s Shop) Create(m *ice.Message, arg ...string) {
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.STORE_UID))...)
s.recordEventWithUID(m, "")
}
func (s Shop) Modify(m *ice.Message, arg ...string) {
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s Shop) Remove(m *ice.Message, arg ...string) {
s.Table.Delete(m, m.OptionSimple(model.UID, model.STORE_UID)...)
s.recordEventWithUID(m, "")
}
func (s Shop) List(m *ice.Message, arg ...string) {
if len(arg) == 0 {
s.Select(m, m.OptionSimple(model.STORE_UID)...)
return
}
s.FieldsWithCreatedAT(m, "", model.NAME, model.ADDRESS)
if len(arg) == 1 {
s.Select(m, model.STORE_UID, arg[0])
kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Create) })
} else if len(arg) == 2 {
s.SelectDetail(m, model.STORE_UID, arg[0], model.UID, arg[1])
}
m.PushAction(s.Modify, s.Remove)
}
func init() { ice.TeamCtxCmd(Shop{}) }

View File

@ -0,0 +1,10 @@
package gongyinglian
import "shylinux.com/x/ice"
type support struct{ Tables }
func (s support) List(m *ice.Message, arg ...string) {
}
func init() { ice.TeamCtxCmd(support{}) }

View File

@ -2,9 +2,6 @@ package gongyinglian
import "shylinux.com/x/ice"
type warehouse struct{ Tables }
type Warehouse struct{ Shop }
func (s warehouse) List(m *ice.Message, arg ...string) {
}
func init() { ice.TeamCtxCmd(warehouse{}) }
func init() { ice.TeamCtxCmd(Warehouse{}) }