mirror of
https://shylinux.com/x/enterprise
synced 2025-04-25 09:08:06 +08:00
opt some
This commit is contained in:
parent
12d8b743d0
commit
05f8c3e6a9
76
src/gongyinglian/common.go
Normal file
76
src/gongyinglian/common.go
Normal file
@ -0,0 +1,76 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
"shylinux.com/x/enterprise/src/guanlixitong"
|
||||
)
|
||||
|
||||
type Table struct {
|
||||
guanlixitong.Table
|
||||
list string `name:"list store_uid uid auto" role:"void"`
|
||||
}
|
||||
|
||||
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 {
|
||||
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])
|
||||
case model.COMPANY_UID:
|
||||
m.Cmdy(guanlixitong.Company{}, s.Select).Cut(model.UID, model.NAME).DisplayInputKeyNameIconTitle()
|
||||
m.RenameAppend(model.UID, arg[0])
|
||||
default:
|
||||
s.Table.Inputs(m, arg...)
|
||||
}
|
||||
}
|
||||
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.ORDER_STATUS, func() { value = OrderStatus(kit.Int(value)).String() })
|
||||
kit.If(key == model.PRICE, func() { value = kit.Format("%0.2f", float64(kit.Int(value))/100) })
|
||||
return value
|
||||
})
|
||||
return s.Table.RewriteAppend(m)
|
||||
}
|
||||
func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message {
|
||||
role := UserStoreRole(kit.Int(m.Cmd(userStore{}, s.Select, m.OptionSimple(model.STORE_UID, model.USER_UID)).Append(model.ROLE)))
|
||||
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) })
|
||||
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)))
|
||||
for _, v := range append(arg, UserStoreCreator) {
|
||||
if role == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return !m.WarnNotRight(true)
|
||||
}
|
||||
func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Message {
|
||||
s.Table.RecordEvent(m, m.Option(model.STORE_UID), info, kit.Select(m.Option(model.UID), arg, 0))
|
||||
return m
|
||||
}
|
||||
|
||||
type Tables struct{ Table }
|
||||
|
||||
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
|
||||
|
||||
func newTable() Table { return Table{Table: guanlixitong.NewTable(userStore{}, store{})} }
|
10
src/gongyinglian/expense.go
Normal file
10
src/gongyinglian/expense.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type expense struct{ Tables }
|
||||
|
||||
func (s expense) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(expense{}) }
|
27
src/gongyinglian/express.go
Normal file
27
src/gongyinglian/express.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type express struct{ Table }
|
||||
|
||||
func init() { ice.TeamCtxCmd(express{}) }
|
||||
|
||||
type ExpressStatus int
|
||||
|
||||
const (
|
||||
ExpressUnknown ExpressStatus = iota
|
||||
ExpressCreate
|
||||
ExpressSend
|
||||
ExpressRecv
|
||||
ExpressConfirm
|
||||
)
|
||||
|
||||
var ExpressStatusList = map[ExpressStatus]string{
|
||||
ExpressUnknown: "unknown",
|
||||
ExpressCreate: "create",
|
||||
ExpressSend: "send",
|
||||
ExpressRecv: "recv",
|
||||
ExpressConfirm: "confirm",
|
||||
}
|
||||
|
||||
func (s ExpressStatus) String() string { return ExpressStatusList[s] }
|
10
src/gongyinglian/garage.go
Normal file
10
src/gongyinglian/garage.go
Normal file
@ -0,0 +1,10 @@
|
||||
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{}) }
|
10
src/gongyinglian/goods.go
Normal file
10
src/gongyinglian/goods.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type goods struct{ Tables }
|
||||
|
||||
func (s goods) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(goods{}) }
|
10
src/gongyinglian/loan.go
Normal file
10
src/gongyinglian/loan.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type loan struct{ Tables }
|
||||
|
||||
func (s loan) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(loan{}) }
|
10
src/gongyinglian/material.go
Normal file
10
src/gongyinglian/material.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type material struct{ Tables }
|
||||
|
||||
func (s material) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(material{}) }
|
121
src/gongyinglian/model/model.go
Normal file
121
src/gongyinglian/model/model.go
Normal file
@ -0,0 +1,121 @@
|
||||
package model
|
||||
|
||||
import "shylinux.com/x/mysql-story/src/db"
|
||||
|
||||
const (
|
||||
UID = "uid"
|
||||
NAME = "name"
|
||||
INFO = "info"
|
||||
TYPE = "type"
|
||||
ROLE = "role"
|
||||
STATUS = "status"
|
||||
TITLE = "title"
|
||||
CONTENT = "content"
|
||||
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"
|
||||
FROM_STORE_UID = "from_store_uid"
|
||||
FROM_USER_UID = "from_user_uid"
|
||||
TO_STORE_UID = "to_store_uid"
|
||||
TO_USER_UID = "to_user_uid"
|
||||
ORDER_UID = "order_uid"
|
||||
ORDER_TYPE = "order_type"
|
||||
ORDER_STATUS = "order_status"
|
||||
ORDER_DETAIL_UID = "order_detail_uid"
|
||||
PAYMENT_STATUS = "payment_status"
|
||||
EXPRESS_STATUS = "express_status"
|
||||
RETURN_STATUS = "return_status"
|
||||
REFUND_STATUS = "refund_status"
|
||||
PAYMENT_SUCCESS_TIME = "payment_success_time"
|
||||
EXPRESS_RECV_TIME = "express_recv_time"
|
||||
RETURN_RECV_TIME = "return_recv_time"
|
||||
REFUND_SUCCESS_TIME = "refund_success_time"
|
||||
PRODUCT_UID = "product_uid"
|
||||
COMPANY_UID = "company_uid"
|
||||
CITY_UID = "city_uid"
|
||||
PRICE = "price"
|
||||
COUNT = "count"
|
||||
UNIT = "unit"
|
||||
)
|
||||
|
||||
type UserStore struct {
|
||||
db.ModelWithUID
|
||||
UserUID string `gorm:"type:char(32);index"`
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
Role uint8
|
||||
}
|
||||
type Store struct {
|
||||
db.ModelWithUID
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:char(64)"`
|
||||
Type uint8
|
||||
}
|
||||
type Product 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)"`
|
||||
}
|
||||
type Order struct {
|
||||
db.ModelWithUID
|
||||
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
|
||||
RefundStatus uint8
|
||||
PaymentSuccessTime db.Time
|
||||
ExpressRecvTime db.Time
|
||||
ReturnRecvTime db.Time
|
||||
RefundSuccessTime db.Time
|
||||
}
|
||||
type OrderDetail struct {
|
||||
db.ModelWithUID
|
||||
OrderUID string `gorm:"type:char(32);index"`
|
||||
ProductUID string `gorm:"type:char(32);index"`
|
||||
Price uint `gorm:"default:0"`
|
||||
Count uint `gorm:"default:0"`
|
||||
}
|
||||
type Payment struct {
|
||||
db.ModelWithUID
|
||||
OrderUID string `gorm:"type:char(32);index"`
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
OpenID string `gorm:"type:varchar(128);index"`
|
||||
Status uint8
|
||||
}
|
||||
type Express struct {
|
||||
db.ModelWithUID
|
||||
OrderUID string `gorm:"type:char(32);index"`
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
OpenID string `gorm:"type:varchar(128);index"`
|
||||
Status uint8
|
||||
}
|
||||
type Return struct {
|
||||
db.ModelWithUID
|
||||
OrderUID string `gorm:"type:char(32);index"`
|
||||
ExpressUID string `gorm:"type:char(32);index"`
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
OpenID string `gorm:"type:varchar(128);index"`
|
||||
Status uint8
|
||||
}
|
||||
type Refund struct {
|
||||
db.ModelWithUID
|
||||
OrderUID string `gorm:"type:char(32);index"`
|
||||
PaymentUID string `gorm:"type:char(32);index"`
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
OpenID string `gorm:"type:varchar(128);index"`
|
||||
Status uint8
|
||||
}
|
||||
|
||||
func init() {
|
||||
db.CmdModels("", &UserStore{}, &Store{}, &Product{}, &Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{})
|
||||
}
|
315
src/gongyinglian/order.go
Normal file
315
src/gongyinglian/order.go
Normal file
@ -0,0 +1,315 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type order struct {
|
||||
Table
|
||||
product product
|
||||
orderDetail orderDetail
|
||||
sell string `name:"sell" role:"boss"`
|
||||
purchase string `name:"purchase" 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"`
|
||||
confirmPurchase string `name:"confirmPurchase to_store_uid" 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"`
|
||||
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) {
|
||||
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))
|
||||
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))
|
||||
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 != 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] {
|
||||
m.Push(model.USER_UID, value[model.TO_USER_UID])
|
||||
m.Push(model.ORDER_TYPE, s.Sell)
|
||||
} else {
|
||||
m.Push(model.USER_UID, value[model.FROM_USER_UID])
|
||||
m.Push(model.ORDER_TYPE, s.Purchase)
|
||||
}
|
||||
}).RenameAppend(model.STATUS, model.ORDER_STATUS).Action(s.Sell, s.Purchase)
|
||||
s.SelectJoinUser(m)
|
||||
m.Display("order.js")
|
||||
} else if len(arg) == 2 {
|
||||
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
|
||||
}
|
||||
if m.Cmdy(s.orderDetail, arg); m.Length() == 0 {
|
||||
m.EchoInfoButton(m.Trans("please insert product", "请添加商品"), s.Insert)
|
||||
return
|
||||
}
|
||||
switch OrderStatus(kit.Int(msg.Append(model.STATUS))) {
|
||||
case OrderCreate:
|
||||
if role == UserStoreCreator || role == UserStoreBoss {
|
||||
m.PushAction(s.Update, s.Delete).Action(s.Insert).EchoButton(s.Cancel, s.Submit)
|
||||
}
|
||||
case OrderSubmit:
|
||||
if user_uid == msg.Append(model.FROM_USER_UID) && msg.Append(model.TO_USER_UID) == "" {
|
||||
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)
|
||||
}
|
||||
case OrderConfirm:
|
||||
if msg.Append(model.TO_USER_UID) == 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 {
|
||||
if PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) == PaymentSuccess {
|
||||
m.EchoButton(s.ConfirmPayment)
|
||||
}
|
||||
if PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) == PaymentConfirm {
|
||||
if ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) == ExpressUnknown {
|
||||
m.EchoButton(s.Express)
|
||||
}
|
||||
}
|
||||
}
|
||||
case OrderDeal:
|
||||
if msg.Append(model.TO_USER_UID) == 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 {
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnRecv {
|
||||
m.EchoButton(s.ConfirmReturn)
|
||||
}
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnConfirm {
|
||||
if RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) == RefundUnknown {
|
||||
m.EchoButton(s.Refund)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.RenameAppend(model.UID, model.ORDER_DETAIL_UID).Action()
|
||||
}
|
||||
}
|
||||
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))
|
||||
}
|
||||
}
|
||||
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) Update(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s.orderDetail, s.Update, model.UID, m.Option(model.ORDER_DETAIL_UID))
|
||||
}
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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
|
||||
}
|
||||
m.Cmdy(payment{}, s.Create, 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))
|
||||
})
|
||||
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order payment", "订单已付款"))
|
||||
}
|
||||
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) {
|
||||
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
|
||||
}
|
||||
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)
|
||||
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))
|
||||
})
|
||||
s.sendTemplate(m, model.TO_USER_UID, m.Trans("order express", "订单已发货"))
|
||||
}
|
||||
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
|
||||
}
|
||||
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))
|
||||
})
|
||||
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order confirm express", "订单已确认收货"))
|
||||
}
|
||||
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
|
||||
}
|
||||
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)
|
||||
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))
|
||||
})
|
||||
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order return", "订单已发起退货"))
|
||||
}
|
||||
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) {
|
||||
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
|
||||
}
|
||||
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)
|
||||
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))
|
||||
})
|
||||
s.sendTemplate(m, model.TO_USER_UID, m.Trans("order refund", "订单已发起退款"))
|
||||
}
|
||||
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
|
||||
}
|
||||
s.Table.Update(m, kit.Dict(model.REFUND_STATUS, RefundConfirm, model.STATUS, OrderDone), 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 refund", "订单已确认退款"))
|
||||
}
|
||||
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
|
||||
}
|
||||
msg := s.Select(m, "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", m.Option(model.STORE_UID), m.Option(model.STORE_UID), m.Option(model.UID))
|
||||
m.WarnNotValid(OrderStatus(kit.Int(msg.Append(model.STATUS))) != OrderCreate)
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(order{Table: newTable()}) }
|
||||
|
||||
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) {
|
||||
return
|
||||
}
|
||||
if which != "" && msg.Append(which) != "" && m.WarnNotRight(m.Option(model.USER_UID) != msg.Append(which)) {
|
||||
return
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
type OrderStatus int
|
||||
|
||||
const (
|
||||
OrderCreate OrderStatus = iota
|
||||
OrderCancel
|
||||
OrderSubmit
|
||||
OrderConfirm
|
||||
OrderDeal
|
||||
OrderDone
|
||||
)
|
||||
|
||||
var OrderStatusList = map[OrderStatus]string{
|
||||
OrderCreate: "create",
|
||||
OrderCancel: "cancel",
|
||||
OrderSubmit: "submit",
|
||||
OrderConfirm: "confirm",
|
||||
OrderDeal: "deal",
|
||||
OrderDone: "done",
|
||||
}
|
||||
|
||||
func (s OrderStatus) String() string { return OrderStatusList[s] }
|
12
src/gongyinglian/order.js
Normal file
12
src/gongyinglian/order.js
Normal file
@ -0,0 +1,12 @@
|
||||
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.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)}]},
|
||||
] })
|
||||
},
|
||||
})
|
29
src/gongyinglian/orderDetail.go
Normal file
29
src/gongyinglian/orderDetail.go
Normal file
@ -0,0 +1,29 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type orderDetail struct {
|
||||
Table
|
||||
product product
|
||||
}
|
||||
|
||||
func (s orderDetail) Update(m *ice.Message, arg ...string) {
|
||||
m.Option(model.PRICE, kit.Int(kit.Float(m.Option(model.PRICE))*100))
|
||||
s.Table.Update(m, kit.Dict(m.OptionSimple(model.PRICE, model.COUNT)), arg...)
|
||||
}
|
||||
func (s orderDetail) List(m *ice.Message, arg ...string) {
|
||||
s.Tables(m, s.product).FieldsWithCreatedAT(m, s,
|
||||
model.NAME, model.INFO, s.Key(s, model.PRICE), s.Key(s, model.COUNT), model.UNIT,
|
||||
)
|
||||
if len(arg) == 2 {
|
||||
s.Select(m, model.ORDER_UID, arg[1])
|
||||
} else if len(arg) == 3 {
|
||||
s.SelectDetail(m, model.ORDER_UID, arg[1], model.UID, arg[2])
|
||||
}
|
||||
}
|
||||
func init() { ice.TeamCtxCmd(orderDetail{}) }
|
10
src/gongyinglian/orderDetail.js
Normal file
10
src/gongyinglian/orderDetail.js
Normal file
@ -0,0 +1,10 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_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: html.OUTPUT, list: [{text: value.info}]},
|
||||
] }, function(event) {})
|
||||
},
|
||||
})
|
27
src/gongyinglian/payment.go
Normal file
27
src/gongyinglian/payment.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type payment struct{ Table }
|
||||
|
||||
func init() { ice.TeamCtxCmd(payment{}) }
|
||||
|
||||
type PaymentStatus int
|
||||
|
||||
const (
|
||||
PaymentUnknown PaymentStatus = iota
|
||||
PaymentCreate
|
||||
PaymentFailure
|
||||
PaymentSuccess
|
||||
PaymentConfirm
|
||||
)
|
||||
|
||||
var PaymentStatusList = map[PaymentStatus]string{
|
||||
PaymentUnknown: "unknown",
|
||||
PaymentCreate: "create",
|
||||
PaymentFailure: "failure",
|
||||
PaymentSuccess: "success",
|
||||
PaymentConfirm: "confirm",
|
||||
}
|
||||
|
||||
func (s PaymentStatus) String() string { return PaymentStatusList[s] }
|
15
src/gongyinglian/portal.go
Normal file
15
src/gongyinglian/portal.go
Normal file
@ -0,0 +1,15 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/community/src/gonganxitong"
|
||||
"shylinux.com/x/enterprise/src/guanlixitong"
|
||||
)
|
||||
|
||||
type Portal struct {
|
||||
gonganxitong.Portal
|
||||
placeCreate string `name:"placeCreate city_name* company_name* store_name*" role:"void"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
gonganxitong.PortalCmd(Portal{Portal: gonganxitong.NewPortal(userStore{}, store{}, guanlixitong.Company{})})
|
||||
}
|
78
src/gongyinglian/portal.json
Normal file
78
src/gongyinglian/portal.json
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"portal": "供应链", "placeCreate": "创建生意", "placeRemove": "删除生意",
|
||||
"product": "产品列表", "order": "订单列表", "member": "生意伙伴",
|
||||
|
||||
"sell": "出货", "confirmSell": "确认出货",
|
||||
"purchase": "进货", "confirmPurchase": "确认进货",
|
||||
"payment": "付款", "confirmPayment": "确认收款",
|
||||
"express": "寄件", "confirmExpress": "确认收件",
|
||||
"return": "发起退货", "confirmReturn": "确认收到退货",
|
||||
"refund": "发起退款", "confirmRefund": "确认收到退款",
|
||||
"material": "材料", "process": "加工", "goods": "商品",
|
||||
"garage": "仓库",
|
||||
"loan": "借贷", "expense": "开支",
|
||||
"express": "物流",
|
||||
"payment": "账本",
|
||||
"shop": "店铺",
|
||||
"style": {
|
||||
"purchase": "danger"
|
||||
},
|
||||
"icons": {
|
||||
"loan": "https://img.icons8.com/officel/80/bank-building.png",
|
||||
"expense": "https://img.icons8.com/officel/80/cash-in-hand.png",
|
||||
"purchase": "https://img.icons8.com/officel/80/paid.png",
|
||||
"material": "https://img.icons8.com/officel/80/wood.png",
|
||||
"process": "https://img.icons8.com/officel/80/cnc-machine.png",
|
||||
"goods": "https://img.icons8.com/officel/80/product.png",
|
||||
"shop": "https://img.icons8.com/officel/80/shop.png",
|
||||
"sell": "https://img.icons8.com/officel/80/handle-with-care.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",
|
||||
"garage": "https://img.icons8.com/officel/80/garage-closed.png",
|
||||
"order": "https://img.icons8.com/officel/80/receipt.png"
|
||||
},
|
||||
"input": {
|
||||
"My Store": "我的生意",
|
||||
"user_store_role": "用户角色",
|
||||
"store_uid": "生意",
|
||||
"store_type": "生意类型",
|
||||
"store_name": "生意名称",
|
||||
"order_type": "订单类型",
|
||||
"product_uid": "商品",
|
||||
"company_uid": "公司",
|
||||
"price": "单价(元)",
|
||||
"unit": "单位"
|
||||
},
|
||||
"value": {
|
||||
"user_store_role": {
|
||||
"creator": "创建人",
|
||||
"visitor": "访客",
|
||||
"boss": "老板",
|
||||
"worker": "员工",
|
||||
"vendor": "供应商",
|
||||
"custom": "经销商",
|
||||
"style": {
|
||||
"creator": "danger",
|
||||
"boss": "danger"
|
||||
}
|
||||
},
|
||||
"store_type": {
|
||||
"normal": "普通"
|
||||
},
|
||||
"order_type": {
|
||||
"sell": "出货单",
|
||||
"purchase": "进货单",
|
||||
"style": {
|
||||
"purchase": "danger"
|
||||
}
|
||||
},
|
||||
"order_status": {
|
||||
"create": "🕑 待提交",
|
||||
"cancel": "❌ 已取消",
|
||||
"submit": "已提交",
|
||||
"confirm": "✅ 已确认",
|
||||
"finish": "已完成"
|
||||
}
|
||||
}
|
||||
}
|
10
src/gongyinglian/process.go
Normal file
10
src/gongyinglian/process.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type process struct{ Tables }
|
||||
|
||||
func (s process) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(process{}) }
|
49
src/gongyinglian/product.go
Normal file
49
src/gongyinglian/product.go
Normal file
@ -0,0 +1,49 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
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 ", "创建商品 ")+m.Option(model.NAME), m.Result())
|
||||
}
|
||||
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.STORE_UID, model.UID)...)
|
||||
}
|
||||
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 ", "删除商品 ")+m.Option(model.NAME), m.Option(model.UID))
|
||||
}
|
||||
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 len(arg) == 1 {
|
||||
s.Select(m, model.STORE_UID, arg[0])
|
||||
} else if len(arg) == 2 {
|
||||
s.SelectDetail(m, model.STORE_UID, arg[0], model.UID, arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
msg := m.Cmd(s.userStore, s.Select, model.STORE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
|
||||
role := UserStoreRole(kit.Int(msg.Append(model.ROLE)))
|
||||
if msg.Length() > 0 && (role == UserStoreCreator || role == UserStoreBoss) {
|
||||
m.PushAction(s.Modify, s.Delete)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(product{}) }
|
10
src/gongyinglian/product.js
Normal file
10
src/gongyinglian/product.js
Normal file
@ -0,0 +1,10 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
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.OUTPUT, list: [{text: value.info}]},
|
||||
] })
|
||||
},
|
||||
})
|
24
src/gongyinglian/purchase.go
Normal file
24
src/gongyinglian/purchase.go
Normal file
@ -0,0 +1,24 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type purchase struct {
|
||||
Tables
|
||||
order 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)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(purchase{}) }
|
27
src/gongyinglian/refund.go
Normal file
27
src/gongyinglian/refund.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type refund struct{ Table }
|
||||
|
||||
func init() { ice.TeamCtxCmd(refund{}) }
|
||||
|
||||
type RefundStatus int
|
||||
|
||||
const (
|
||||
RefundUnknown RefundStatus = iota
|
||||
RefundCreate
|
||||
RefundFailure
|
||||
RefundSuccess
|
||||
RefundConfirm
|
||||
)
|
||||
|
||||
var RefundStatusList = map[RefundStatus]string{
|
||||
RefundUnknown: "unknown",
|
||||
RefundCreate: "create",
|
||||
RefundFailure: "failure",
|
||||
RefundSuccess: "success",
|
||||
RefundConfirm: "confirm",
|
||||
}
|
||||
|
||||
func (s RefundStatus) String() string { return RefundStatusList[s] }
|
27
src/gongyinglian/return.go
Normal file
27
src/gongyinglian/return.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type Return struct{ Table }
|
||||
|
||||
func init() { ice.TeamCtxCmd(Return{}) }
|
||||
|
||||
type ReturnStatus int
|
||||
|
||||
const (
|
||||
ReturnUnknown ReturnStatus = iota
|
||||
ReturnCreate
|
||||
ReturnSend
|
||||
ReturnRecv
|
||||
ReturnConfirm
|
||||
)
|
||||
|
||||
var ReturnStatusList = map[ReturnStatus]string{
|
||||
ReturnUnknown: "unknown",
|
||||
ReturnCreate: "create",
|
||||
ReturnSend: "send",
|
||||
ReturnRecv: "recv",
|
||||
ReturnConfirm: "confirm",
|
||||
}
|
||||
|
||||
func (s ReturnStatus) String() string { return ReturnStatusList[s] }
|
24
src/gongyinglian/sell.go
Normal file
24
src/gongyinglian/sell.go
Normal file
@ -0,0 +1,24 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type sell struct {
|
||||
Tables
|
||||
order 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)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(sell{}) }
|
10
src/gongyinglian/shop.go
Normal file
10
src/gongyinglian/shop.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type shop struct{ Tables }
|
||||
|
||||
func (s shop) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(shop{}) }
|
19
src/gongyinglian/store.go
Normal file
19
src/gongyinglian/store.go
Normal file
@ -0,0 +1,19 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type store struct{ Table }
|
||||
|
||||
func init() { ice.TeamCtxCmd(store{}) }
|
||||
|
||||
type StoreType int
|
||||
|
||||
const (
|
||||
StoreNormal StoreType = iota
|
||||
)
|
||||
|
||||
var StoreTypeList = map[StoreType]string{
|
||||
StoreNormal: "normal",
|
||||
}
|
||||
|
||||
func (s StoreType) String() string { return StoreTypeList[s] }
|
64
src/gongyinglian/userStore.go
Normal file
64
src/gongyinglian/userStore.go
Normal file
@ -0,0 +1,64 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type userStore struct {
|
||||
Table
|
||||
store store
|
||||
}
|
||||
|
||||
func (s userStore) User(m *ice.Message, arg ...string) {
|
||||
s.FieldsWithCreatedAT(m, s, model.USER_UID, model.ROLE)
|
||||
if len(arg) == 1 {
|
||||
s.Select(m, model.STORE_UID, arg[0])
|
||||
} else if len(arg) == 2 {
|
||||
s.SelectDetail(m, model.STORE_UID, arg[0], model.UID, arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
m.RenameAppend(model.ROLE, model.USER_STORE_ROLE)
|
||||
s.SelectJoinUser(m)
|
||||
}
|
||||
func (s userStore) List(m *ice.Message, arg ...string) {
|
||||
s.Tables(m, s.store).FieldsWithCreatedAT(m, s,
|
||||
model.STORE_NAME, model.STORE_TYPE, model.USER_STORE_ROLE,
|
||||
model.COMPANY_UID, model.STORE_UID,
|
||||
)
|
||||
if len(arg) == 1 {
|
||||
s.Select(m, model.USER_UID, arg[0])
|
||||
} else if len(arg) == 2 {
|
||||
s.SelectDetail(m, model.USER_UID, arg[0], s.Key(s, model.STORE_UID), arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
s.SelectJoinCompany(m)
|
||||
s.SelectJoinCity(m)
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(userStore{}) }
|
||||
|
||||
type UserStoreRole int
|
||||
|
||||
const (
|
||||
UserStoreCreator UserStoreRole = iota
|
||||
UserStoreVisitor
|
||||
UserStoreBoss
|
||||
UserStoreWorker
|
||||
UserStoreVendor
|
||||
UserStoreCustom
|
||||
)
|
||||
|
||||
var UserStoreRoleList = map[UserStoreRole]string{
|
||||
UserStoreCreator: "creator",
|
||||
UserStoreVisitor: "visitor",
|
||||
UserStoreBoss: "boss",
|
||||
UserStoreWorker: "worker",
|
||||
UserStoreVendor: "vendor",
|
||||
UserStoreCustom: "custom",
|
||||
}
|
||||
|
||||
func (s UserStoreRole) String() string { return UserStoreRoleList[s] }
|
10
src/gongyinglian/warehouse.go
Normal file
10
src/gongyinglian/warehouse.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type warehouse struct{ Tables }
|
||||
|
||||
func (s warehouse) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(warehouse{}) }
|
@ -11,7 +11,6 @@ type target struct {
|
||||
Table
|
||||
group group
|
||||
userGroup userGroup
|
||||
portal string `data:"true"`
|
||||
create string `name:"create title* content*" role:"void"`
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,9 @@ import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
_ "shylinux.com/x/enterprise/src/guanlixitong"
|
||||
_ "shylinux.com/x/enterprise/src/gongyinglian"
|
||||
)
|
||||
|
||||
func main() { print(ice.Run()) }
|
||||
|
||||
func init() { ice.Info.Titles = "云办公" }
|
||||
func init() { ice.Info.Titles = "云办公" }
|
@ -2,12 +2,9 @@ package {{.Option "zone"}}
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type {{.Option "name"}} struct {
|
||||
Table
|
||||
}
|
||||
type {{.Option "name"}} struct{ Tables }
|
||||
|
||||
func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) {
|
||||
s.Table.List(m, arg...)
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd({{.Option "name"}}{}) }
|
||||
|
10
src/template/web.code.js/demo.js
Normal file
10
src/template/web.code.js/demo.js
Normal file
@ -0,0 +1,10 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
if (msg.IsDetail()) { var value = msg.TableDetail(); msg.Option("_share_title", value.title), msg.Option("_share_content", value.content) }
|
||||
can.onimport.itemcards(can, msg, function(value) { return [
|
||||
{view: html.TITLE, list: [{text: value.title}]},
|
||||
{view: html.STATUS, list: [{text: value.uid.slice(0, 6)}, {text: can.base.TimeTrim(value.created_at)}, {text: value.user_name}]},
|
||||
{view: html.OUTPUT, list: [{text: value.content}]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -13,6 +13,34 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"05e48a9a424e6d99fef79990c230b581": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.apply",
|
||||
"time": "2024-08-16 11:28:20.828",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"087e7a803e40e88ea61c61c349fe41c3": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.member",
|
||||
"time": "2024-08-16 11:28:20.813",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"0d7a8facc1e00b44b9f8454ce05fb8fe": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.portal",
|
||||
"time": "2024-08-16 11:28:20.823",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"0f80f21a32e8c7cfaed80329f87f84fc": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.qrcode",
|
||||
"time": "2024-08-16 11:28:20.839",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"153c93456004ec2ca692d3bac2223167": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.service",
|
||||
@ -41,6 +69,27 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"30bfa47cab4cd689901fd2e1b87eb235": {
|
||||
"meta": {
|
||||
"index": "web.team.guanlixitong.allow",
|
||||
"time": "2024-08-16 10:46:56.289",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"3fbe370e7a861c4cfadad08c7d867851": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.service",
|
||||
"time": "2024-08-16 11:28:20.817",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"4a465f3eb7d4d8b0d3f3a27fbf950227": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.event",
|
||||
"time": "2024-08-16 11:28:20.843",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"4b1e97b62a44419c00caf65e297abd18": {
|
||||
"meta": {
|
||||
"index": "web.team.guanlixitong.portal",
|
||||
@ -48,6 +97,13 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"4b6a1e2cd77eba90c8cd66fd2ae1245e": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.allow",
|
||||
"time": "2024-08-16 11:28:20.833",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"5695d50b28872804a01d7c923ee91cd1": {
|
||||
"meta": {
|
||||
"index": "web.team.guanlixitong.member",
|
||||
@ -83,6 +139,20 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"8a1d16fd43624a99bbafd83bcd5505bd": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.store",
|
||||
"time": "2024-08-16 11:28:20.836",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"8ce4dfb877e04e3be5144253fdd5d8ff": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.allow",
|
||||
"time": "2024-08-16 10:46:56.263",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"91dd0e9590d3021944f14f3ec8653beb": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.order",
|
||||
@ -90,6 +160,13 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"974355b9ec8c9176da2a542d46eb3ef4": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.product",
|
||||
"time": "2024-08-16 11:28:20.820",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"9c18032c5bc252f2986e1b20e7e77db7": {
|
||||
"meta": {
|
||||
"index": "web.team.guanlixitong.event",
|
||||
@ -118,6 +195,13 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"b6429917b76d95ea2615d61454a0c1e0": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.order",
|
||||
"time": "2024-08-16 12:11:41.434",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"ba00879066bbcea83e30cda292d28a91": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.user",
|
||||
@ -146,6 +230,20 @@
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"c6520dba0442a3f84f5be9cb3ceb7a34": {
|
||||
"meta": {
|
||||
"index": "web.team.shengyixitong.userStore",
|
||||
"time": "2024-08-16 11:28:20.847",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"d6a7c2908e838d6af1db45a55a1ad98f": {
|
||||
"meta": {
|
||||
"index": "web.team.gongyinglian.portal",
|
||||
"time": "2024-08-17 08:31:38.670",
|
||||
"type": "hash"
|
||||
}
|
||||
},
|
||||
"d8443c1034bfe5917c52126a3306c328": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.city",
|
||||
|
@ -10,7 +10,7 @@
|
||||
"153c93456004ec2ca692d3bac2223167": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"index": "web.team.gonganxitong.service",
|
||||
"order": "100",
|
||||
@ -21,7 +21,7 @@
|
||||
"27c6988eeb07c78cbb49aa15c577cfa4": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"icons": "https://img.icons8.com/officel/80/edit-property.png",
|
||||
"index": "web.team.gonganxitong.apply",
|
||||
@ -34,7 +34,7 @@
|
||||
"58724bdcc3cae3e26700cb3199e0602c": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"index": "web.team.gonganxitong.placeUser",
|
||||
"order": "5",
|
||||
@ -42,10 +42,21 @@
|
||||
"time": "2024-08-04 09:53:53.601"
|
||||
}
|
||||
},
|
||||
"8ce4dfb877e04e3be5144253fdd5d8ff": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"index": "web.team.gonganxitong.allow",
|
||||
"order": "4",
|
||||
"role": "creator",
|
||||
"time": "2024-08-16 10:46:56.564"
|
||||
}
|
||||
},
|
||||
"91dd0e9590d3021944f14f3ec8653beb": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"c3664559e4eedd9536961010d2108a96"
|
||||
],
|
||||
"icons": "https://img.icons8.com/officel/80/receipt-approved.png",
|
||||
"index": "web.team.gonganxitong.order",
|
||||
@ -74,7 +85,7 @@
|
||||
"bdec92d5849b2a60a8811cff494f2391": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"icons": "https://img.icons8.com/officel/80/property-with-timer.png",
|
||||
"index": "web.team.gonganxitong.event",
|
||||
@ -95,7 +106,7 @@
|
||||
"e2117b53c036a72fe7e4885449488a6f": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"index": "web.team.gonganxitong.qrcode",
|
||||
"order": "1",
|
||||
@ -114,7 +125,7 @@
|
||||
"fd86aad80a667152781bb188fb1249a2": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"index": "web.team.gonganxitong.email",
|
||||
"name": "邮箱配置",
|
||||
|
@ -2,7 +2,7 @@
|
||||
"030e2a53ca3561a0d0d123c133a88b59": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/qr-code.png",
|
||||
@ -16,7 +16,7 @@
|
||||
"057616b7366e1930ef4e4a921fe45f1f": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/activity-grid.png",
|
||||
@ -24,13 +24,27 @@
|
||||
"name": "系统服务",
|
||||
"order": "100",
|
||||
"role": "creator",
|
||||
"time": "2024-08-06 18:40:48.488"
|
||||
"time": "2024-08-16 11:24:44.777"
|
||||
}
|
||||
},
|
||||
"30bfa47cab4cd689901fd2e1b87eb235": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/receipt-approved.png",
|
||||
"index": "web.team.guanlixitong.allow",
|
||||
"name": "权限审批",
|
||||
"order": "4",
|
||||
"role": "creator,leader",
|
||||
"time": "2024-08-16 10:46:56.590"
|
||||
}
|
||||
},
|
||||
"5695d50b28872804a01d7c923ee91cd1": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/person-at-home.png",
|
||||
@ -44,7 +58,7 @@
|
||||
"9c18032c5bc252f2986e1b20e7e77db7": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/property-with-timer.png",
|
||||
@ -55,24 +69,10 @@
|
||||
"time": "2024-08-05 01:14:22.409"
|
||||
}
|
||||
},
|
||||
"a4e85767b176b6a07751156a6b73fa94": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/receipt-approved.png",
|
||||
"index": "web.team.guanlixitong.order",
|
||||
"name": "权限审批",
|
||||
"order": "4",
|
||||
"role": "creator,leader",
|
||||
"time": "2024-08-05 01:14:22.399"
|
||||
}
|
||||
},
|
||||
"c36d47e2611b0d1e7a14088bc3293d04": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/edit-property.png",
|
||||
@ -86,7 +86,7 @@
|
||||
"fa5ff99e330772f88b929de7762a36f1": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
"bce41a045572f2db8c9d1597bb346487"
|
||||
"676dc2fe62465fda43e60578252c4c75"
|
||||
],
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/goal--v1.png",
|
||||
|
Loading…
x
Reference in New Issue
Block a user