mirror of
https://shylinux.com/x/enterprise
synced 2025-04-25 17:18:06 +08:00
opt some
This commit is contained in:
parent
7a3d5f238d
commit
ad55681d8d
@ -2,9 +2,6 @@ package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type brand struct{ Tables }
|
||||
type brand struct{ TableView }
|
||||
|
||||
func (s brand) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(brand{}) }
|
||||
func init() { ice.TeamCtxCmd(brand{}) }
|
||||
|
@ -2,6 +2,7 @@ package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
@ -16,49 +17,63 @@ type Table struct {
|
||||
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
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()
|
||||
s.InputsListRole(m, UserStoreRoleList, arg...)
|
||||
case model.STORE_TYPE:
|
||||
for k, v := range StoreTypeList {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
s.InputsList(m, StoreTypeList, arg...)
|
||||
case model.PRODUCT_TYPE:
|
||||
for k, v := range ProductTypeList {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
s.InputsList(m, ProductTypeList, arg...)
|
||||
case model.EXPENSE_TYPE:
|
||||
s.InputsList(m, ExpenseTypeList, arg...)
|
||||
case model.LOAN_TYPE:
|
||||
s.InputsList(m, LoanTypeList, arg...)
|
||||
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])
|
||||
m.Cmdy(userStore{}, m.Option(model.USER_UID)).Cut(model.STORE_UID, model.STORE_NAME).RenameAppend(model.STORE_UID, arg[0])
|
||||
m.DisplayInputKeyNameIconTitle()
|
||||
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.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) })
|
||||
switch key {
|
||||
case model.USER_STORE_ROLE:
|
||||
value = UserStoreRole(kit.Int(value)).String()
|
||||
case model.STORE_TYPE:
|
||||
value = StoreType(kit.Int(value)).String()
|
||||
case model.PRODUCT_TYPE:
|
||||
value = ProductType(kit.Int(value)).String()
|
||||
case model.ORDER_TYPE:
|
||||
value = OrderType(kit.Int(value)).String()
|
||||
case model.ORDER_STATUS:
|
||||
value = OrderStatus(kit.Int(value)).String()
|
||||
case model.PAYMENT_STATUS:
|
||||
value = PaymentStatus(kit.Int(value)).String()
|
||||
case model.EXPRESS_STATUS:
|
||||
value = ExpressStatus(kit.Int(value)).String()
|
||||
case model.RETURN_STATUS:
|
||||
value = ReturnStatus(kit.Int(value)).String()
|
||||
case model.REFUND_STATUS:
|
||||
value = RefundStatus(kit.Int(value)).String()
|
||||
case model.EXPENSE_TYPE:
|
||||
value = ExpenseType(kit.Int(value)).String()
|
||||
case model.LOAN_TYPE:
|
||||
value = LoanType(kit.Int(value)).String()
|
||||
case model.AMOUNT, model.PRICE:
|
||||
value = kit.Format("%0.2f", float64(kit.Int(value))/100)
|
||||
}
|
||||
return value
|
||||
})
|
||||
return s.Table.RewriteAppend(m)
|
||||
}
|
||||
func (s TableView) transPrice(m *ice.Message, arg ...string) []string {
|
||||
for i := 0; i < len(arg); i += 2 {
|
||||
switch arg[i] {
|
||||
case model.AMOUNT, model.PRICE:
|
||||
arg[i+1] = kit.Format(kit.Int(kit.Float(arg[i+1]) * 100))
|
||||
}
|
||||
}
|
||||
return arg
|
||||
}
|
||||
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())
|
||||
@ -66,27 +81,33 @@ func (s Table) CheckRole(m *ice.Message, arg ...string) *ice.Message {
|
||||
}
|
||||
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
|
||||
}
|
||||
role := s.userStoreRole(m, m.Option(model.STORE_UID))
|
||||
for _, v := range append(arg, UserStoreCreator) {
|
||||
if role == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return !m.WarnNotRight(true)
|
||||
return false
|
||||
}
|
||||
func (s Table) userStoreRole(m *ice.Message, arg ...string) UserStoreRole {
|
||||
msg := m.Cmd(userStore{}, s.Select, model.STORE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
|
||||
msg := m.Spawn()
|
||||
userStore{}.Fields(msg, model.ROLE)
|
||||
msg = msg.Cmd(userStore{}, s.Select, model.STORE_UID, arg[0], model.USER_UID, m.Option(model.USER_UID))
|
||||
if msg.Length() > 0 {
|
||||
return UserStoreRole(kit.Int(msg.Append(model.ROLE)))
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
func (s Table) checkListRole(m *ice.Message, arg ...string) bool {
|
||||
if (len(arg) == 0 && m.Option(model.STORE_UID) != "" && !s.checkRole(m, UserStoreBoss)) || (len(arg) == 1 && !s.checkRole(m.Options(model.STORE_UID, arg[0]), UserStoreBoss)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
|
||||
user_uid := m.Option(model.USER_UID)
|
||||
msg := s.Select(m.Spawn(), "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
|
||||
msg := m.Cmd(Order{}, s.Select, "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
|
||||
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
|
||||
}
|
||||
@ -95,10 +116,45 @@ func (s Table) checkOrderRole(m *ice.Message, arg ...string) bool {
|
||||
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))
|
||||
}
|
||||
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)
|
||||
func (s Table) recordEventWithName(m *ice.Message, info string) {
|
||||
s.Table.RecordEventWithName(m, m.Option(model.STORE_UID), info)
|
||||
}
|
||||
|
||||
type TableView struct {
|
||||
Table
|
||||
fields string `data:"name,info"`
|
||||
create string `name:"create name info" role:"boss"`
|
||||
modify string `name:"modify name info" role:"boss"`
|
||||
remove string `name:"remove" role:"boss"`
|
||||
}
|
||||
|
||||
func (s TableView) Create(m *ice.Message, arg ...string) {
|
||||
arg = s.transPrice(m, arg...)
|
||||
s.Table.Create(m, kit.Simple(arg, m.OptionSimple(model.STORE_UID))...)
|
||||
s.recordEventWithName(m, "")
|
||||
}
|
||||
func (s TableView) Modify(m *ice.Message, arg ...string) {
|
||||
arg = s.transPrice(m, arg...)
|
||||
s.Table.Update(m, kit.Dict(arg), m.OptionSimple(model.STORE_UID, model.UID)...)
|
||||
s.recordEventWithName(m, "")
|
||||
}
|
||||
func (s TableView) Remove(m *ice.Message, arg ...string) {
|
||||
s.Table.Delete(m, m.OptionSimple(model.STORE_UID, model.UID)...)
|
||||
s.recordEventWithName(m, "")
|
||||
}
|
||||
func (s TableView) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
s.Select(m, m.OptionSimple(model.STORE_UID)...)
|
||||
return
|
||||
}
|
||||
kit.If(m.Config(mdb.FIELDS), func(p string) { s.FieldsWithCreatedAT(m, "", kit.TransArgs(kit.Split(p, ",", ","))...) })
|
||||
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)
|
||||
}
|
||||
|
||||
type Tables struct{ Table }
|
||||
|
@ -1,10 +1,39 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
type expense struct{ Tables }
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type expense struct {
|
||||
TableView
|
||||
fields string `data:"expense_type,amount,name,info"`
|
||||
create string `name:"create expense_type* amount* name info" role:"boss"`
|
||||
modify string `name:"modify amount* name info" role:"boss"`
|
||||
}
|
||||
|
||||
func (s expense) Create(m *ice.Message, arg ...string) {
|
||||
arg = kit.TransArgKeys(arg, model.EXPENSE_TYPE, model.TYPE)
|
||||
s.TableView.Create(m, kit.Simple(arg, model.FROM_USER_UID, m.Option(model.USER_UID))...)
|
||||
}
|
||||
func (s expense) List(m *ice.Message, arg ...string) {
|
||||
if s.checkListRole(m, arg...) {
|
||||
s.TableView.List(m, arg...)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(expense{}) }
|
||||
|
||||
type ExpenseType int
|
||||
|
||||
const (
|
||||
ExpenseTerm ExpenseType = iota
|
||||
)
|
||||
|
||||
var ExpenseTypeList = map[ExpenseType]string{
|
||||
ExpenseTerm: "term",
|
||||
}
|
||||
|
||||
func (s ExpenseType) String() string { return ExpenseTypeList[s] }
|
||||
|
@ -12,15 +12,17 @@ type express struct {
|
||||
}
|
||||
|
||||
func (s express) List(m *ice.Message, arg ...string) {
|
||||
if !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
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,
|
||||
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()
|
||||
s.Select(m, 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])
|
||||
s.SelectDetail(m, model.FROM_STORE_UID, arg[0], s.Key(s, model.UID), arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
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) }
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg, "uid", "amount")
|
||||
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: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "express_status", mdb.STATUS)]},
|
||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at)]},
|
||||
{view: html.STATUS, list: [value.company_name+":", value.open_id]},
|
||||
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -13,11 +13,13 @@ type goods struct {
|
||||
}
|
||||
|
||||
func (s goods) Create(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s.Product, s.Create, model.PRODUCT_TYPE, ProductGoods, arg)
|
||||
s.Product.Create(m, kit.Simple(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)
|
||||
s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductGoods)), arg...)
|
||||
if s.checkListRole(m, arg...) {
|
||||
m.PushAction(s.SetShop, s.SetBrand, s.SetQuality, s.Modify, s.Remove)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(goods{}) }
|
||||
|
@ -1,10 +1,39 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
type loan struct{ Tables }
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
func (s loan) List(m *ice.Message, arg ...string) {
|
||||
type loan struct {
|
||||
TableView
|
||||
fields string `data:"loan_type,amount,name,info"`
|
||||
create string `name:"create loan_type* amount name info" role:"boss"`
|
||||
modify string `name:"modify name info amount" role:"boss"`
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(loan{}) }
|
||||
func (s loan) Create(m *ice.Message, arg ...string) {
|
||||
arg = kit.TransArgKeys(arg, model.LOAN_TYPE, model.TYPE)
|
||||
s.TableView.Create(m, kit.Simple(arg, model.TO_USER_UID, m.Option(model.USER_UID))...)
|
||||
}
|
||||
func (s loan) List(m *ice.Message, arg ...string) {
|
||||
if s.checkListRole(m, arg...) {
|
||||
s.TableView.List(m, arg...)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(loan{}) }
|
||||
|
||||
type LoanType int
|
||||
|
||||
const (
|
||||
LoanTerm LoanType = iota
|
||||
)
|
||||
|
||||
var LoanTypeList = map[LoanType]string{
|
||||
LoanTerm: "term",
|
||||
}
|
||||
|
||||
func (s LoanType) String() string { return LoanTypeList[s] }
|
||||
|
@ -13,11 +13,13 @@ type material struct {
|
||||
}
|
||||
|
||||
func (s material) Create(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s.Product, s.Create, model.PRODUCT_TYPE, ProductMaterial, arg)
|
||||
s.Product.Create(m, kit.Simple(model.PRODUCT_TYPE, ProductMaterial, arg)...)
|
||||
}
|
||||
func (s material) List(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s.Product, arg, kit.Dict(model.PRODUCT_TYPE, kit.Format(ProductMaterial)))
|
||||
m.PushAction(s.SetWarehouse, s.Modify, s.Remove)
|
||||
if s.checkListRole(m, arg...) {
|
||||
s.Product.List(m.Options(model.PRODUCT_TYPE, kit.Format(ProductMaterial)), arg...)
|
||||
m.PushAction(s.SetWarehouse, s.Modify, s.Remove)
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(material{}) }
|
||||
|
@ -18,8 +18,11 @@ const (
|
||||
STORE_UID = "store_uid"
|
||||
STORE_NAME = "store_name"
|
||||
STORE_TYPE = "store_type"
|
||||
WAREHOUSE_NAME = "warehouse_name"
|
||||
SHOP_NAME = "shop_name"
|
||||
WAREHOUSE_NAME = "warehouse_name"
|
||||
QUALITY_NAME = "quality_name"
|
||||
BRAND_NAME = "brand_name"
|
||||
PRODUCT_UID = "product_uid"
|
||||
PRODUCT_TYPE = "product_type"
|
||||
ORDER_UID = "order_uid"
|
||||
ORDER_TYPE = "order_type"
|
||||
@ -37,7 +40,8 @@ const (
|
||||
EXPRESS_RECV_TIME = "express_recv_time"
|
||||
RETURN_RECV_TIME = "return_recv_time"
|
||||
REFUND_SUCCESS_TIME = "refund_success_time"
|
||||
PRODUCT_UID = "product_uid"
|
||||
EXPENSE_TYPE = "expense_type"
|
||||
LOAN_TYPE = "loan_type"
|
||||
COMPANY_UID = "company_uid"
|
||||
CITY_UID = "city_uid"
|
||||
AMOUNT = "amount"
|
||||
@ -57,19 +61,19 @@ type UserStore struct {
|
||||
type Store struct {
|
||||
db.ModelWithUID
|
||||
CompanyUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:char(64)"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Type uint8
|
||||
}
|
||||
type Shop struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:char(64)"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Address string `gorm:"type:varchar(255)"`
|
||||
}
|
||||
type Warehouse struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:char(64)"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Address string `gorm:"type:varchar(255)"`
|
||||
}
|
||||
type Product struct {
|
||||
@ -77,20 +81,17 @@ type Product struct {
|
||||
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)"`
|
||||
QualityUID string `gorm:"type:char(32);index"`
|
||||
BrandUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
Type uint8
|
||||
Price uint `gorm:"default:0"`
|
||||
Stock uint `gorm:"default:0"`
|
||||
Unit string `gorm:"type:char(8)"`
|
||||
Unit string `gorm:"type:varchar(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"`
|
||||
@ -103,14 +104,19 @@ type Order struct {
|
||||
ExpressRecvTime db.Time
|
||||
ReturnRecvTime db.Time
|
||||
RefundSuccessTime db.Time
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
Total int
|
||||
Amount int
|
||||
Status uint8
|
||||
}
|
||||
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"`
|
||||
Count uint `gorm:"default:0"`
|
||||
Price int `gorm:"default:0"`
|
||||
Count int `gorm:"default:0"`
|
||||
}
|
||||
type Payment struct {
|
||||
db.ModelWithUID
|
||||
@ -144,5 +150,42 @@ type Refund struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
db.CmdModels("", &UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Product{}, &Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{})
|
||||
db.CmdModels("",
|
||||
&UserStore{}, &Store{}, &Shop{}, &Warehouse{}, &Product{},
|
||||
&Order{}, &OrderDetail{}, &Payment{}, &Express{}, &Return{}, &Refund{},
|
||||
&Brand{}, &Quality{}, &Expense{}, &Loan{},
|
||||
)
|
||||
}
|
||||
|
||||
type Brand struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
}
|
||||
type Quality struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
}
|
||||
type Expense struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
FromUserUID string `gorm:"type:char(32);index"`
|
||||
ToUserUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
Type uint8
|
||||
Amount int
|
||||
}
|
||||
type Loan struct {
|
||||
db.ModelWithUID
|
||||
StoreUID string `gorm:"type:char(32);index"`
|
||||
FromUserUID string `gorm:"type:char(32);index"`
|
||||
ToUserUID string `gorm:"type:char(32);index"`
|
||||
Name string `gorm:"type:varchar(64)"`
|
||||
Info string
|
||||
Type uint8
|
||||
Amount int
|
||||
}
|
||||
|
@ -12,21 +12,23 @@ import (
|
||||
type Order struct {
|
||||
Table
|
||||
userStore userStore
|
||||
product Product
|
||||
store store
|
||||
orderDetail orderDetail
|
||||
product Product
|
||||
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"`
|
||||
sell string `name:"sell name info" role:"boss" help:"出货"`
|
||||
produce string `name:"produce name info" role:"boss" help:"加工"`
|
||||
purchase string `name:"purchase name info" role:"boss" help:"进货"`
|
||||
insert string `name:"insert product_uid*:select count*" role:"boss"`
|
||||
update string `name:"update price* count*" role:"boss"`
|
||||
delete string `name:"delete" role:"boss"`
|
||||
cancel string `name:"cancel" role:"boss"`
|
||||
submit string `name:"submit" role:"boss"`
|
||||
confirmSell string `name:"confirmSell from_store_uid" role:"void"`
|
||||
confirmProcess string `name:"confirmProcess" role:"void"`
|
||||
confirmProduce string `name:"confirmProduce" role:"void"`
|
||||
confirmPurchase string `name:"confirmPurchase to_store_uid" role:"void"`
|
||||
produce string `name:"produce" role:"void"`
|
||||
process string `name:"process" role:"void"`
|
||||
again string `name:"again" role:"void"`
|
||||
payment string `name:"payment company_uid* open_id*" role:"void"`
|
||||
express string `name:"express company_uid* open_id*" role:"void"`
|
||||
refund string `name:"refund company_uid* open_id*" role:"void"`
|
||||
@ -45,7 +47,7 @@ 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) Process(m *ice.Message, arg ...string) {
|
||||
func (s Order) Produce(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),
|
||||
@ -57,27 +59,27 @@ func (s Order) Purchase(m *ice.Message, arg ...string) {
|
||||
m.ProcessRewrite(model.UID, m.Result())
|
||||
}
|
||||
func (s Order) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
return
|
||||
}
|
||||
if role := s.userStoreRole(m.Spawn(), arg[0]); len(arg) == 1 {
|
||||
if role != UserStoreCreator && role != UserStoreBoss {
|
||||
if len(arg) == 1 {
|
||||
if !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
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:
|
||||
defer func() { kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Sell) }) }()
|
||||
case OrderProduce:
|
||||
s.Select(m, "from_store_uid = ? AND to_store_uid = ?", arg[0], arg[0])
|
||||
defer func() { kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Produce) }) }()
|
||||
case OrderPurchase:
|
||||
s.Select(m, "(from_store_uid IS NULL OR from_store_uid != ?) AND to_store_uid = ?", arg[0], arg[0])
|
||||
defer func() { kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Purchase) }) }()
|
||||
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, OrderProcess)
|
||||
m.Push(model.ORDER_TYPE, OrderProduce)
|
||||
} 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)
|
||||
@ -85,37 +87,69 @@ func (s Order) List(m *ice.Message, arg ...string) {
|
||||
m.Push(model.USER_UID, value[model.FROM_USER_UID])
|
||||
m.Push(model.ORDER_TYPE, OrderPurchase)
|
||||
}
|
||||
})
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
if key == model.STATUS {
|
||||
switch OrderStatus(kit.Int(value)) {
|
||||
case OrderConfirm:
|
||||
if PaymentStatus(kit.Int(m.Appendv(model.PAYMENT_STATUS)[index])) == PaymentUnknown {
|
||||
if OrderType(kit.Int(m.Appendv(model.ORDER_TYPE)[index])) == OrderPurchase {
|
||||
value = kit.Format(OrderPayment)
|
||||
}
|
||||
} else if ExpressStatus(kit.Int(m.Appendv(model.EXPRESS_STATUS)[index])) == ExpressUnknown {
|
||||
if OrderType(kit.Int(m.Appendv(model.ORDER_TYPE)[index])) == OrderSell {
|
||||
value = kit.Format(OrderExpress)
|
||||
}
|
||||
}
|
||||
case OrderDeal:
|
||||
if ReturnStatus(kit.Int(m.Appendv(model.RETURN_STATUS)[index])) != ReturnUnknown {
|
||||
if RefundStatus(kit.Int(m.Appendv(model.REFUND_STATUS)[index])) == RefundUnknown {
|
||||
if OrderType(kit.Int(m.Appendv(model.ORDER_TYPE)[index])) == OrderSell {
|
||||
value = kit.Format(OrderRefund)
|
||||
} else {
|
||||
value = kit.Format(OrderConfirm)
|
||||
}
|
||||
} else {
|
||||
value = kit.Format(OrderDone)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return value
|
||||
}).RenameAppend(model.STATUS, model.ORDER_STATUS).Action().Display("")
|
||||
s.SelectJoinUser(m)
|
||||
} 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])
|
||||
s.ClearOption(m)
|
||||
if m.Cmdy(s.orderDetail, arg); m.Length() == 0 {
|
||||
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))) {
|
||||
msg := s.Select(m.Spawn(), "(from_store_uid = ? OR to_store_uid = ?) AND uid = ?", arg[0], arg[0], arg[1])
|
||||
status := OrderStatus(kit.Int(msg.Append(model.STATUS)))
|
||||
kit.If(status != OrderCreate, func() { m.PushAction().Action() })
|
||||
switch status {
|
||||
case OrderCreate:
|
||||
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:
|
||||
if user_uid == msg.Append(model.FROM_USER_UID) && msg.Append(model.TO_USER_UID) == "" {
|
||||
m.Echo("请让经销商扫码确认订单")
|
||||
m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1]))
|
||||
} else if user_uid == msg.Append(model.TO_USER_UID) && msg.Append(model.FROM_USER_UID) == "" {
|
||||
m.Echo("请让供货商扫码确认订单")
|
||||
m.EchoQRCode(s.Link(m, arg[0], m.PrefixKey(), arg[1]))
|
||||
} 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)
|
||||
m.EchoButton(s.ConfirmProduce)
|
||||
}
|
||||
case OrderConfirm:
|
||||
if msg.Append(model.FROM_USER_UID) == msg.Append(model.TO_USER_UID) {
|
||||
m.EchoButton(s.Produce)
|
||||
m.EchoButton(s.Process)
|
||||
} else if user_uid == msg.Append(model.TO_USER_UID) {
|
||||
if PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) == PaymentUnknown {
|
||||
m.EchoButton(s.Payment)
|
||||
@ -136,16 +170,17 @@ func (s Order) List(m *ice.Message, arg ...string) {
|
||||
case OrderDeal:
|
||||
if user_uid == msg.Append(model.TO_USER_UID) {
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnUnknown {
|
||||
m.EchoButton(s.Return)
|
||||
m.EchoButton(s.Again, s.Return)
|
||||
}
|
||||
if RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) == RefundSuccess {
|
||||
m.EchoButton(s.ConfirmRefund)
|
||||
}
|
||||
} else if user_uid == msg.Append(model.FROM_USER_UID) {
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnRecv {
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnUnknown {
|
||||
m.EchoButton(s.Again)
|
||||
} else if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnRecv {
|
||||
m.EchoButton(s.ConfirmReturn)
|
||||
}
|
||||
if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnConfirm {
|
||||
} else if ReturnStatus(kit.Int(msg.Append(model.RETURN_STATUS))) == ReturnConfirm {
|
||||
if RefundStatus(kit.Int(msg.Append(model.REFUND_STATUS))) == RefundUnknown {
|
||||
m.EchoButton(s.Refund)
|
||||
}
|
||||
@ -169,13 +204,14 @@ func (s Order) Cancel(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.SendMessage(m, m.Option(model.USER_UID), m.Option(model.STORE_UID), m.Option(model.UID))
|
||||
}
|
||||
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)...)
|
||||
})
|
||||
}
|
||||
func (s Order) ConfirmProcess(m *ice.Message, arg ...string) {
|
||||
func (s Order) ConfirmProduce(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)...)
|
||||
})
|
||||
@ -185,14 +221,56 @@ func (s Order) ConfirmPurchase(m *ice.Message, arg ...string) {
|
||||
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)...)
|
||||
})
|
||||
}
|
||||
func (s Order) Produce(m *ice.Message, arg ...string) {
|
||||
func (s Order) Process(m *ice.Message, arg ...string) {
|
||||
s.changeStatusFrom(m, OrderConfirm, model.FROM_USER_UID, func(msg *ice.Message) {
|
||||
s.store.Lock(m)
|
||||
m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) {
|
||||
if m.IsErr() {
|
||||
return
|
||||
}
|
||||
m.Cmd(s.product, m.Option(model.STORE_UID), detail[model.PRODUCT_UID]).Table(func(product ice.Maps) {
|
||||
count, stock := kit.Int(detail[model.COUNT]), kit.Int(product[model.STOCK])
|
||||
if m.Warn(count < 0 && -count > stock, product[model.NAME], "库存不足") {
|
||||
return
|
||||
}
|
||||
m.Cmd(s.product, s.AddCount, model.STOCK, count, detail[model.PRODUCT_UID])
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
func (s Order) Again(m *ice.Message, arg ...string) {
|
||||
s.changeStatusFrom(m, OrderDeal, "", func(msg *ice.Message) {
|
||||
s.Create(m, kit.Simple(model.STATUS, OrderConfirm, msg.AppendSimple(model.FROM_STORE_UID, model.FROM_USER_UID, model.TO_STORE_UID, model.TO_USER_UID))...)
|
||||
m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) {
|
||||
m.Cmd(s.orderDetail, s.Create, model.STORE_UID, detail[model.STORE_UID], model.ORDER_UID, m.Result(),
|
||||
model.PRODUCT_UID, detail[model.PRODUCT_UID], model.PRICE, detail[model.PRICE], model.COUNT, detail[model.COUNT],
|
||||
)
|
||||
})
|
||||
})
|
||||
m.ProcessRewrite(model.UID, m.Result())
|
||||
}
|
||||
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
|
||||
if msg.Append(model.FROM_STORE_UID) == m.Option(model.STORE_UID) {
|
||||
s.store.Lock(m)
|
||||
if m.WarnNotValid(PaymentStatus(kit.Int(msg.Append(model.PAYMENT_STATUS))) != PaymentUnknown) {
|
||||
return
|
||||
}
|
||||
m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) {
|
||||
if m.IsErr() {
|
||||
return
|
||||
}
|
||||
m.Cmd(s.product, m.Option(model.STORE_UID), detail[model.PRODUCT_UID]).Table(func(product ice.Maps) {
|
||||
count, stock := kit.Int(detail[model.COUNT]), kit.Int(product[model.STOCK])
|
||||
if m.Warn(count > stock, product[model.NAME], "库存不足") {
|
||||
return
|
||||
}
|
||||
m.Cmd(s.product, s.AddCount, model.STOCK, -count, detail[model.PRODUCT_UID])
|
||||
})
|
||||
})
|
||||
if m.IsErr() {
|
||||
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)...)
|
||||
@ -227,6 +305,9 @@ func (s Order) ConfirmExpress(m *ice.Message, arg ...string) {
|
||||
if m.WarnNotValid(ExpressStatus(kit.Int(msg.Append(model.EXPRESS_STATUS))) != ExpressRecv) {
|
||||
return
|
||||
}
|
||||
if msg.Append(model.TO_STORE_UID) == m.Option(model.STORE_UID) {
|
||||
s.ReturnProduct(m)
|
||||
}
|
||||
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))
|
||||
})
|
||||
@ -246,11 +327,18 @@ func (s Order) Return(m *ice.Message, arg ...string) {
|
||||
})
|
||||
s.sendTemplate(m, model.FROM_USER_UID, m.Trans("order return", "订单已发起退货"))
|
||||
}
|
||||
func (s Order) ReturnProduct(m *ice.Message, arg ...string) {
|
||||
s.store.Lock(m)
|
||||
m.Cmd(s.orderDetail, m.Option(model.STORE_UID), m.Option(model.UID)).Table(func(detail ice.Maps) {
|
||||
m.Cmd(s.product, s.AddCount, model.STOCK, detail[model.COUNT], detail[model.PRODUCT_UID])
|
||||
})
|
||||
}
|
||||
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.ReturnProduct(m)
|
||||
s.Table.Update(m, kit.Dict(model.RETURN_STATUS, ReturnConfirm), m.OptionSimple(model.UID)...)
|
||||
})
|
||||
}
|
||||
@ -309,19 +397,21 @@ func (s Order) sendTemplate(m *ice.Message, to string, title string) {
|
||||
kit.If(to != "" && m.Option(to) != "", func() { s.SendTemplate(m, "", m.Option(to), title) })
|
||||
}
|
||||
|
||||
func newOrder() Order { return Order{Table: newTable()} }
|
||||
|
||||
type OrderType int
|
||||
|
||||
const (
|
||||
OrderUnknown OrderType = iota
|
||||
OrderSell
|
||||
OrderProcess
|
||||
OrderProduce
|
||||
OrderPurchase
|
||||
)
|
||||
|
||||
var OrderTypeList = map[OrderType]string{
|
||||
OrderUnknown: "unknown",
|
||||
OrderSell: "sell",
|
||||
OrderProcess: "process",
|
||||
OrderProduce: "produce",
|
||||
OrderPurchase: "purchase",
|
||||
}
|
||||
|
||||
@ -336,6 +426,11 @@ const (
|
||||
OrderConfirm
|
||||
OrderDeal
|
||||
OrderDone
|
||||
// dynamic
|
||||
OrderPayment
|
||||
OrderExpress
|
||||
OrderReturn
|
||||
OrderRefund
|
||||
)
|
||||
|
||||
var OrderStatusList = map[OrderStatus]string{
|
||||
@ -345,6 +440,11 @@ var OrderStatusList = map[OrderStatus]string{
|
||||
OrderConfirm: "confirm",
|
||||
OrderDeal: "deal",
|
||||
OrderDone: "done",
|
||||
// dynamic
|
||||
OrderPayment: "payment",
|
||||
OrderExpress: "express",
|
||||
OrderReturn: "return",
|
||||
OrderRefund: "refund",
|
||||
}
|
||||
|
||||
func (s OrderStatus) String() string { return OrderStatusList[s] }
|
||||
|
@ -1,13 +1,13 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg)
|
||||
can.onimport.itemcards(can, msg, function(value) { return [
|
||||
{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: html.TITLE, list: [value.name||value.user_name||"待确认", can.onimport.textView(can, value, "order_type", mdb.TYPE)]},
|
||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at), can.onimport.textView(can, value, "order_status", mdb.STATUS)]},
|
||||
value.payment_success_time && {view: html.STATUS, list: ["收款时间:", can.base.TimeTrim(value.payment_success_time)]},
|
||||
value.express_recv_time && {view: html.STATUS, list: ["收货时间:", can.base.TimeTrim(value.express_recv_time)]},
|
||||
value.return_recv_time && {view: html.STATUS, list: ["退货时间:", can.base.TimeTrim(value.return_recv_time)]},
|
||||
value.refund_success_time && {view: html.STATUS, list: ["退款时间:", can.base.TimeTrim(value.refund_success_time)]},
|
||||
value.info && {view: html.OUTPUT, list: [value.info]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -14,7 +14,7 @@ type orderDetail struct {
|
||||
|
||||
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...)
|
||||
s.Table.Update(m, kit.Dict(m.OptionSimple(model.PRICE), model.COUNT, kit.Int(m.Option(model.COUNT))), arg...)
|
||||
}
|
||||
func (s orderDetail) List(m *ice.Message, arg ...string) {
|
||||
if !s.checkOrderRole(m.Spawn(), arg...) {
|
||||
@ -22,11 +22,13 @@ 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,
|
||||
model.PRODUCT_UID,
|
||||
)
|
||||
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])
|
||||
}
|
||||
m.PushAction(s.Update, s.Remove)
|
||||
}
|
||||
func init() { ice.TeamCtxCmd(orderDetail{}) }
|
||||
|
@ -1,9 +1,9 @@
|
||||
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}]},
|
||||
{view: html.TITLE, list: [value.name]},
|
||||
{view: html.STATUS, list: ["单价: ", value.price, " 元", "数量: ", value.count, " ", value.unit]},
|
||||
{view: html.OUTPUT, list: [value.info]},
|
||||
] }, function(event) {})
|
||||
},
|
||||
})
|
@ -12,15 +12,18 @@ type payment struct {
|
||||
}
|
||||
|
||||
func (s payment) List(m *ice.Message, arg ...string) {
|
||||
if !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
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,
|
||||
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()
|
||||
s.Select(m, 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])
|
||||
s.SelectDetail(m, model.FROM_STORE_UID, arg[0], s.Key(s, model.UID), arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
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) }
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg, "uid", "amount")
|
||||
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: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "payment_status", mdb.STATUS)]},
|
||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at)]},
|
||||
{view: html.STATUS, list: [value.company_name, ": ", value.open_id]},
|
||||
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -2,18 +2,25 @@
|
||||
"portal": "供应链", "placeCreate": "创建生意", "placeRemove": "删除生意",
|
||||
"goods": "商品", "sell": "出货", "purchase": "进货", "expense": "开支",
|
||||
"payment": "付款", "express": "寄货", "return": "退贷", "refund": "退款",
|
||||
"material": "原材", "process": "加工", "quality": "质检", "brand": "贴牌",
|
||||
"again": "再来一单",
|
||||
"material": "原材", "produce": "加工", "quality": "质检", "brand": "贴牌",
|
||||
"product": "货物", "order": "订单", "shop": "店铺", "warehouse": "仓库",
|
||||
"member": "生意伙伴", "loan": "借贷外债", "support": "系统客服",
|
||||
"produce": "生产",
|
||||
"member": "生意伙伴", "loan": "借贷外债",
|
||||
"process": "生产",
|
||||
"confirmSell": "确认出货",
|
||||
"confirmProcess": "确认加工",
|
||||
"confirmProduce": "确认加工",
|
||||
"confirmPurchase": "确认进货",
|
||||
"confirmPayment": "确认收款",
|
||||
"confirmExpress": "确认收件",
|
||||
"confirmReturn": "确认收到退货",
|
||||
"confirmRefund": "确认收到退款",
|
||||
"setShop": "店铺", "setWarehouse": "仓库",
|
||||
"setShop": "店铺",
|
||||
"setWarehouse": "仓库",
|
||||
"setQuality": "质检",
|
||||
"setBrand": "贴牌",
|
||||
"style": {
|
||||
"return": "danger"
|
||||
},
|
||||
"icons": {
|
||||
"goods": "https://img.icons8.com/officel/80/product.png",
|
||||
"sell": "https://img.icons8.com/officel/80/handle-with-care.png",
|
||||
@ -24,14 +31,13 @@
|
||||
"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",
|
||||
"produce": "https://img.icons8.com/officel/80/cnc-machine.png",
|
||||
"quality": "https://img.icons8.com/officel/80/test-partial-passed.png",
|
||||
"brand": "https://img.icons8.com/officel/80/add-tag.png",
|
||||
"product": "https://img.icons8.com/officel/80/warehouse.png",
|
||||
"order": "https://img.icons8.com/officel/80/receipt.png",
|
||||
"shop": "https://img.icons8.com/officel/80/shop.png",
|
||||
"warehouse": "https://img.icons8.com/officel/80/garage-closed.png",
|
||||
"support": "https://img.icons8.com/officel/80/customer-support.png",
|
||||
"loan": "https://img.icons8.com/officel/80/bank-building.png"
|
||||
},
|
||||
"input": {
|
||||
@ -44,6 +50,8 @@
|
||||
"shop_name": "店铺名称",
|
||||
"warehouse_uid": "仓库",
|
||||
"warehouse_name": "仓库名称",
|
||||
"quality_name": "质检名称",
|
||||
"brand_name": "品牌名称",
|
||||
"order_type": "订单类型",
|
||||
"product_uid": "产品",
|
||||
"product_type": "产品类型",
|
||||
@ -52,14 +60,17 @@
|
||||
"express_status": "快递状态",
|
||||
"return_status": "退货状态",
|
||||
"refund_status": "退款状态",
|
||||
"expense_type": "开支类型",
|
||||
"loan_type": "借贷类型",
|
||||
"amount": "总额(元)",
|
||||
"stock": "库存量",
|
||||
"price": "单价(元)",
|
||||
"unit": "单位"
|
||||
},
|
||||
"value": {
|
||||
"user_store_role": {
|
||||
"creator": "创建人",
|
||||
"visitor": "访客",
|
||||
"creator": "创建人",
|
||||
"boss": "老板",
|
||||
"worker": "员工",
|
||||
"vendor": "供货商",
|
||||
@ -81,6 +92,9 @@
|
||||
"both": "产品",
|
||||
"goods": "商品",
|
||||
"material": "原材",
|
||||
"style": {
|
||||
"material": "danger"
|
||||
},
|
||||
"icons": {
|
||||
"both": "https://img.icons8.com/officel/80/warehouse.png",
|
||||
"goods": "https://img.icons8.com/officel/80/product.png",
|
||||
@ -89,7 +103,7 @@
|
||||
},
|
||||
"order_type": {
|
||||
"sell": "出货单",
|
||||
"process": "加工单",
|
||||
"produce": "加工单",
|
||||
"purchase": "进货单",
|
||||
"style": {
|
||||
"purchase": "danger"
|
||||
@ -98,10 +112,14 @@
|
||||
"order_status": {
|
||||
"create": "🕑 待提交",
|
||||
"cancel": "❌ 已取消",
|
||||
"submit": "🕑 待确认",
|
||||
"confirm": "🕑 待交易",
|
||||
"submit": "待确认",
|
||||
"confirm": "待交易",
|
||||
"deal": "✅ 已交易",
|
||||
"done": "❌ 已终结"
|
||||
"done": "❌ 已终结",
|
||||
"payment": "🕑 待付款",
|
||||
"express": "🕑 待寄货",
|
||||
"return": "🕑 待退货",
|
||||
"refund": "🕑 待退款"
|
||||
},
|
||||
"payment_status": {
|
||||
"create": "🕑 已发起付款",
|
||||
@ -126,6 +144,10 @@
|
||||
"failure": "❌ 退款失败",
|
||||
"success": "🕑 待确认收款",
|
||||
"confirm": "✅ 已确认收款"
|
||||
},
|
||||
"expense_type": {
|
||||
},
|
||||
"loan_type": {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
chapter "供应链"
|
||||
field web.code.mysql.query args `mysql gongyinglian`
|
||||
|
||||
order `
|
||||
userStore.go
|
||||
store.go
|
||||
@ -22,7 +25,7 @@ goods.go
|
||||
sell.go
|
||||
purchase.go
|
||||
material.go
|
||||
process.go
|
||||
produce.go
|
||||
quality.go
|
||||
brand.go
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"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{Order: Order{Table: newTable()}}) }
|
17
src/gongyinglian/produce.go
Normal file
17
src/gongyinglian/produce.go
Normal file
@ -0,0 +1,17 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type produce struct{ Order }
|
||||
|
||||
func (s produce) List(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(s.Order, arg, kit.Dict(model.ORDER_TYPE, kit.Format(OrderProduce)))
|
||||
kit.If(len(arg) == 1, func() { m.Action(s.Produce) })
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(produce{Order: newOrder()}) }
|
@ -8,69 +8,61 @@ import (
|
||||
)
|
||||
|
||||
type Product struct {
|
||||
Table
|
||||
TableView
|
||||
shop Shop
|
||||
warehouse Warehouse
|
||||
quality quality
|
||||
brand brand
|
||||
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"`
|
||||
setQuality string `name:"setQuality quality_uid*" role:"boss"`
|
||||
setBrand string `name:"setBrand brand_uid*" role:"boss"`
|
||||
}
|
||||
|
||||
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, s.transPrice(m)), m.OptionSimple(model.UID, model.STORE_UID)...)
|
||||
s.recordEventWithUID(m, "")
|
||||
}
|
||||
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) 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, "")
|
||||
s.TableView.Create(m, arg...)
|
||||
}
|
||||
func (s Product) List(m *ice.Message, arg ...string) {
|
||||
m.Info("what %v", 123)
|
||||
if m.Option(model.PRODUCT_TYPE) != kit.Format(ProductGoods) && !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
m.Info("what %v", 123)
|
||||
if len(arg) == 0 {
|
||||
s.Select(m, m.OptionSimple(model.STORE_UID)...)
|
||||
m.Info("what %v", 123)
|
||||
args := m.OptionSimple(model.STORE_UID)
|
||||
kit.If(m.Option(model.PRODUCT_TYPE), func(p string) { args = append(args, model.TYPE, p) })
|
||||
s.Select(m, args...)
|
||||
return
|
||||
}
|
||||
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,
|
||||
s.Tables(m, s.shop, s.warehouse, s.quality, s.brand).FieldsWithCreatedAT(m, s,
|
||||
s.Key(s, model.NAME), s.Key(s, model.INFO), model.PRODUCT_TYPE,
|
||||
model.PRICE, model.STOCK, model.UNIT,
|
||||
model.SHOP_NAME, model.WAREHOUSE_NAME, model.QUALITY_NAME, model.BRAND_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, args...)
|
||||
kit.If(m.Length() == 0, func() { m.EchoInfoButton("", s.Create) })
|
||||
kit.If(!m.IsErr() && m.Length() == 0, func() { m.EchoInfoButton("", s.Create) })
|
||||
} else if len(arg) == 2 {
|
||||
s.SelectDetail(m, append(args, s.Key(s, model.UID), arg[1])...)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
m.PushAction(s.SetShop, s.SetWarehouse, s.Modify, s.Remove).Display("")
|
||||
m.PushAction(s.Modify, s.Remove).Display("")
|
||||
}
|
||||
func (s Product) SetShop(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
|
||||
func (s Product) SetWarehouse(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
|
||||
func (s Product) SetQuality(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
|
||||
func (s Product) SetBrand(m *ice.Message, arg ...string) { s.TableView.Modify(m, arg...) }
|
||||
|
||||
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 (
|
||||
|
@ -1,13 +1,9 @@
|
||||
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) }
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg)
|
||||
can.onimport.itemcards(can, msg, function(value) { return [
|
||||
{view: html.TITLE, list: [{text: value.name}]},
|
||||
{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: html.TITLE, list: [value.name, can.onimport.textView(can, value, "product_type", mdb.TYPE)]},
|
||||
{view: html.STATUS, list: ["单价:", value.price, "元", "库存:", value.stock, value.unit, value.shop_name||"", value.warehouse_name||""]},
|
||||
{view: html.OUTPUT, list: [value.info]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -9,9 +9,12 @@ import (
|
||||
|
||||
type purchase struct{ Order }
|
||||
|
||||
func (s purchase) Inputs(m *ice.Message, arg ...string) {
|
||||
s.Table.Inputs(m.Options(model.PRODUCT_TYPE, kit.Format(ProductMaterial)), arg...)
|
||||
}
|
||||
func (s purchase) List(m *ice.Message, arg ...string) {
|
||||
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{Order: Order{Table: newTable()}}) }
|
||||
func init() { ice.TeamCtxCmd(purchase{Order: newOrder()}) }
|
||||
|
@ -2,9 +2,6 @@ package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type quality struct{ Tables }
|
||||
type quality struct{ TableView }
|
||||
|
||||
func (s quality) List(m *ice.Message, arg ...string) {
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(quality{}) }
|
||||
func init() { ice.TeamCtxCmd(quality{}) }
|
||||
|
@ -12,15 +12,18 @@ type refund struct {
|
||||
}
|
||||
|
||||
func (s refund) List(m *ice.Message, arg ...string) {
|
||||
if !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
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,
|
||||
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()
|
||||
s.Select(m, 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])
|
||||
s.SelectDetail(m, model.FROM_STORE_UID, arg[0], s.Key(s, model.UID), arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
@ -1,11 +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.shareTitle(can, msg, "uid", "amount")
|
||||
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: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "refund_status", mdb.STATUS)]},
|
||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at)]},
|
||||
{view: html.STATUS, list: [value.company_name, ": ", value.open_id]},
|
||||
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -12,15 +12,17 @@ type Return struct {
|
||||
}
|
||||
|
||||
func (s Return) List(m *ice.Message, arg ...string) {
|
||||
if !s.checkListRole(m, arg...) {
|
||||
return
|
||||
}
|
||||
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,
|
||||
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()
|
||||
s.Select(m, 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])
|
||||
s.SelectDetail(m, model.FROM_STORE_UID, arg[0], s.Key(s, model.UID), arg[1])
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
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) }
|
||||
_init: function(can, msg) { can.onimport.shareTitle(can, msg, "uid", "amount")
|
||||
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: html.TITLE, list: [value.user_name, can.onimport.textView(can, value, "return_status", mdb.STATUS)]},
|
||||
{view: html.STATUS, list: [value.uid.slice(0, 6), can.base.TimeTrim(value.created_at)]},
|
||||
{view: html.STATUS, list: [value.company_name+":", value.open_id]},
|
||||
{view: html.STATUS, list: ["订单:", value.order_uid.slice(0, 6), "金额:", value.amount||"0", "数量:", value.total||"0"]},
|
||||
] })
|
||||
},
|
||||
})
|
@ -9,9 +9,12 @@ import (
|
||||
|
||||
type sell struct{ Order }
|
||||
|
||||
func (s sell) Inputs(m *ice.Message, arg ...string) {
|
||||
s.Table.Inputs(m.Options(model.PRODUCT_TYPE, kit.Format(ProductGoods)), arg...)
|
||||
}
|
||||
func (s sell) List(m *ice.Message, arg ...string) {
|
||||
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{Order: Order{Table: newTable()}}) }
|
||||
func init() { ice.TeamCtxCmd(sell{Order: newOrder()}) }
|
||||
|
@ -1,44 +1,12 @@
|
||||
package gongyinglian
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type Shop struct {
|
||||
Table
|
||||
TableView
|
||||
fields string `data:"name,address"`
|
||||
create string `name:"create name* address" role:"boss"`
|
||||
modify string `name:"modify name* address" role:"boss"`
|
||||
remove string `name:"remove" role:"boss"`
|
||||
}
|
||||
|
||||
func (s Shop) 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{}) }
|
||||
|
@ -1,9 +1,17 @@
|
||||
package gongyinglian
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/enterprise/src/gongyinglian/model"
|
||||
)
|
||||
|
||||
type store struct{ Table }
|
||||
|
||||
func (s store) Lock(m *ice.Message, arg ...string) *ice.Message {
|
||||
return m.Cmd(s, s.SelectForUpdate, model.UID, m.Option(model.STORE_UID))
|
||||
}
|
||||
|
||||
func init() { ice.TeamCtxCmd(store{}) }
|
||||
|
||||
type StoreType int
|
||||
|
@ -1,10 +0,0 @@
|
||||
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{}) }
|
@ -44,8 +44,8 @@ func init() { ice.TeamCtxCmd(userStore{}) }
|
||||
type UserStoreRole int
|
||||
|
||||
const (
|
||||
UserStoreCreator UserStoreRole = iota
|
||||
UserStoreVisitor
|
||||
UserStoreVisitor UserStoreRole = iota
|
||||
UserStoreCreator
|
||||
UserStoreBoss
|
||||
UserStoreWorker
|
||||
UserStoreVendor
|
||||
|
@ -15,18 +15,13 @@ type Table struct {
|
||||
|
||||
func (s Table) Inputs(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case model.GROUP_TYPE:
|
||||
for k, v := range GroupTypeList {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
case model.USER_GROUP_ROLE:
|
||||
for k, v := range UserGroupRoleList {
|
||||
if k != UserGroupCreator && k != UserGroupVisitor {
|
||||
m.Push(arg[0], k).Push(model.NAME, v)
|
||||
}
|
||||
}
|
||||
m.SortInt(arg[0]).DisplayInputKeyNameIconTitle()
|
||||
s.InputsListRole(m, UserGroupRoleList)
|
||||
case model.GROUP_TYPE:
|
||||
s.InputsList(m, GroupTypeList)
|
||||
case model.COMPANY_UID:
|
||||
m.Cmdy(Company{}, s.Select).Cut(model.UID, model.NAME).RenameAppend(model.UID, arg[0])
|
||||
m.DisplayInputKeyNameIconTitle()
|
||||
default:
|
||||
s.Table.Inputs(m, arg...)
|
||||
}
|
||||
@ -57,10 +52,7 @@ func (s Table) recordEvent(m *ice.Message, info string, arg ...string) *ice.Mess
|
||||
return m
|
||||
}
|
||||
|
||||
type Tables struct {
|
||||
Table
|
||||
portal string `data:"true"`
|
||||
}
|
||||
type Tables struct{ Table }
|
||||
|
||||
func (s Tables) BeforeMigrate(m *ice.Message, arg ...string) {}
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
},
|
||||
"value": {
|
||||
"user_group_role": {
|
||||
"creator": "创建人",
|
||||
"visitor": "访客",
|
||||
"creator": "创建人",
|
||||
"leader": "管理人员",
|
||||
"worker": "工作人员",
|
||||
"server": "服务人员",
|
||||
|
@ -46,16 +46,16 @@ func init() { ice.TeamCtxCmd(userGroup{}) }
|
||||
type UserGroupRole int
|
||||
|
||||
const (
|
||||
UserGroupCreator UserGroupRole = iota
|
||||
UserGroupVisitor
|
||||
UserGroupVisitor UserGroupRole = iota
|
||||
UserGroupCreator
|
||||
UserGroupLeader
|
||||
UserGroupWorker
|
||||
UserGroupServer
|
||||
)
|
||||
|
||||
var UserGroupRoleList = map[UserGroupRole]string{
|
||||
UserGroupCreator: "creator",
|
||||
UserGroupVisitor: "visitor",
|
||||
UserGroupCreator: "creator",
|
||||
UserGroupLeader: "leader",
|
||||
UserGroupWorker: "worker",
|
||||
UserGroupServer: "server",
|
||||
|
@ -82,6 +82,12 @@
|
||||
"time": "2024-08-04 09:53:53.608"
|
||||
}
|
||||
},
|
||||
"a89a7c09e326295aaa7e7ea3d66fb28a": {
|
||||
"meta": {
|
||||
"index": "web.team.gonganxitong.support",
|
||||
"time": "2024-08-20 12:10:11.957"
|
||||
}
|
||||
},
|
||||
"bdec92d5849b2a60a8811cff494f2391": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
|
@ -21,7 +21,7 @@
|
||||
"enable": "true",
|
||||
"icons": "https://img.icons8.com/officel/80/activity-grid.png",
|
||||
"index": "web.team.guanlixitong.service",
|
||||
"name": "系统服务",
|
||||
"name": "服务发现",
|
||||
"order": "100",
|
||||
"role": "creator",
|
||||
"time": "2024-08-16 11:24:44.777"
|
||||
@ -69,6 +69,14 @@
|
||||
"time": "2024-08-05 01:14:22.409"
|
||||
}
|
||||
},
|
||||
"9fffbe375e2d2a1a8e6cb1f341e35b55": {
|
||||
"meta": {
|
||||
"icons": "https://img.icons8.com/officel/80/multiple-smartphones.png",
|
||||
"index": "web.team.guanlixitong.recent",
|
||||
"name": "最近访问",
|
||||
"time": "2024-08-20 12:06:32.015"
|
||||
}
|
||||
},
|
||||
"c36d47e2611b0d1e7a14088bc3293d04": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
@ -83,6 +91,14 @@
|
||||
"time": "2024-08-05 01:14:22.416"
|
||||
}
|
||||
},
|
||||
"d25f3f88261ead2a0079415a26aa6853": {
|
||||
"meta": {
|
||||
"icons": "https://img.icons8.com/officel/80/test-partial-passed.png",
|
||||
"index": "web.team.guanlixitong.message",
|
||||
"name": "消息待办",
|
||||
"time": "2024-08-20 12:06:32.017"
|
||||
}
|
||||
},
|
||||
"fa5ff99e330772f88b929de7762a36f1": {
|
||||
"meta": {
|
||||
"_target": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user