feat:完善项目
This commit is contained in:
@ -42,14 +42,13 @@ func initModel() {
|
||||
return &model.SysUser{Account: "admin", Name: "超级管理员", Mobile: "13888888888", Password: "123456",
|
||||
IsAdmin: model.SysUserAdministratorForAdmin, Remark: "超级管理员"}
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysUserTenant()},
|
||||
&synchronized{iModel: model.NewSysDepartment()},
|
||||
&synchronized{iModel: model.NewSysRole()}, &synchronized{iModel: model.NewSysRoleMenu()}, &synchronized{iModel: model.NewSysRoleAuth()},
|
||||
&synchronized{iModel: model.NewSysUserRole()},
|
||||
// 日志管理
|
||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||
// 功能信息
|
||||
&synchronized{iModel: model.NewManageSupplier()},
|
||||
&synchronized{iModel: model.NewManageMaterial()}, &synchronized{iModel: model.NewManageMaterialPurchase()},
|
||||
)
|
||||
}
|
||||
func initCacheMode() {
|
||||
|
@ -4,6 +4,7 @@ package model
|
||||
type ManageEquipment struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||
Image
|
||||
Config string `gorm:"column:config;type:varchar(255);default:null;comment:配置" json:"config"`
|
||||
|
@ -4,15 +4,26 @@ package model
|
||||
type ManageMaterial struct {
|
||||
Model
|
||||
ModelTenant
|
||||
SupplierID uint64 `gorm:"column:supplier_id;type:int;default:0;comment:供应商ID" json:"supplier_id"`
|
||||
SupplierID uint64 `gorm:"column:supplier_id;type:int;default:0;comment:供应商ID" json:""`
|
||||
Code string `gorm:"column:code;type:varchar(35);default:null;comment:编号" json:"code"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||
Image
|
||||
Unit int `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||
Stock int `gorm:"column:stock;type:int(8);default:0;comment:库存数" json:"stock"`
|
||||
FrozenStock int `gorm:"column:frozen_stock;type:int(8);default:0;comment:冻结的库存数" json:"-"`
|
||||
Unit ManageMaterialUnit `gorm:"column:unit;type:tinyint(1);default:0;comment:单位" json:"unit"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ManageMaterialUnit 单位类型
|
||||
type ManageMaterialUnit int
|
||||
|
||||
const (
|
||||
// ManageMaterialUnitForIndividual 个
|
||||
ManageMaterialUnitForIndividual ManageMaterialUnit = iota + 1
|
||||
)
|
||||
|
||||
func (m *ManageMaterial) TableName() string {
|
||||
return "manage_material"
|
||||
}
|
||||
|
@ -3,10 +3,11 @@ package model
|
||||
// ManageMaterialPurchase 维修器材采购数据明细
|
||||
type ManageMaterialPurchase struct {
|
||||
Model
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialID uint64 `gorm:"column:material_id;type:int(6);default:0;comment:器材ID" json:"material_id"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(30);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialID uint64 `gorm:"column:material_id;type:int(6);default:0;comment:器材ID" json:"-"`
|
||||
Price float64 `gorm:"column:price;type:decimal(10,2);default:0;comment:采购单价" json:"price"`
|
||||
Number int `gorm:"column:number;type:int(6);default:0;comment:采购数量" json:"number"`
|
||||
Number int `gorm:"column:number;type:int(8);default:0;comment:采购数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:采购备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
|
@ -3,9 +3,10 @@ package model
|
||||
// ManageMaterialWarehouse 维修器材采购入库明细
|
||||
type ManageMaterialWarehouse struct {
|
||||
Model
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
OrderNo string `gorm:"column:order_no;type:varchar(20);default:null;comment:采购单号" json:"order_no"`
|
||||
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"material_purchase_id"`
|
||||
Number int `gorm:"column:number;type:int(6);default:0;comment:入库数量" json:"number"`
|
||||
Number int `gorm:"column:number;type:int(8);default:0;comment:入库数量" json:"number"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:入库备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
|
@ -1,7 +1,11 @@
|
||||
package model
|
||||
|
||||
// ManageMaterialWork 维修器材工单明细
|
||||
type ManageMaterialWork struct {
|
||||
Model
|
||||
WorkID uint64 `gorm:"column:work_id;type:int(11);default:0;comment:工单ID" json:"work_id"`
|
||||
MaterialPurchaseID uint64 `gorm:"column:material_purchase_id;type:int(11);default:0;comment:器材采购ID" json:"material_purchase_id"`
|
||||
Number int `json:"number"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ type (
|
||||
// EquipmentInfo 装备信息
|
||||
EquipmentInfo struct {
|
||||
basic.CommonIDString
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
@ -62,7 +63,7 @@ func (c *Equipment) List(title string, page, pageSize int) (*basic.PageDataRespo
|
||||
}
|
||||
var count int64
|
||||
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "title", "image", "created_at"},
|
||||
if err := model2.PagesFields(mManageEquipment.ManageEquipment, &out, []string{"id", "code", "title", "image", "created_at"},
|
||||
page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -71,9 +72,9 @@ func (c *Equipment) List(title string, page, pageSize int) (*basic.PageDataRespo
|
||||
for _, v := range out {
|
||||
list = append(list, &EquipmentInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
CreatedAt: v.CreatedAt,
|
||||
Code: v.Code, Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
CreatedAt: v.CreatedAt,
|
||||
})
|
||||
}
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
|
@ -5,30 +5,250 @@ import (
|
||||
"ArmedPolice/app/controller/basic"
|
||||
"ArmedPolice/app/model"
|
||||
"ArmedPolice/app/service"
|
||||
"ArmedPolice/config"
|
||||
"ArmedPolice/lib"
|
||||
"ArmedPolice/serve/orm"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Material struct{ *service.Session }
|
||||
|
||||
type MaterialHandle func(session *service.Session) *Material
|
||||
|
||||
func (c *Material) List(title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
out := make([]*model2.ManageMaterial, 0)
|
||||
type (
|
||||
// MaterialInfo 基本信息
|
||||
MaterialInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.ManageMaterialInfo
|
||||
}
|
||||
// MaterialParams 基本参数
|
||||
MaterialParams struct {
|
||||
ID, SupplierID uint64
|
||||
Code, Title, Image, Remark string
|
||||
Unit int
|
||||
}
|
||||
// MaterialPurchaseInfo 采购信息
|
||||
MaterialPurchaseInfo struct {
|
||||
basic.CommonIDString
|
||||
*model.ManageMaterialPurchaseInfo
|
||||
}
|
||||
)
|
||||
|
||||
func (c *MaterialParams) isExistForCode(iModel model2.IModel) (bool, error) {
|
||||
var count int64
|
||||
|
||||
model2.PagesFields(mManageMaterial.ManageMaterial, &out, []string{"id", "title"}, page, pageSize, &count)
|
||||
|
||||
return &basic.PageDataResponse{Data: nil, Count: 0}, nil
|
||||
if err := model2.Count(iModel, &count, model2.NewWhere("code", c.Code),
|
||||
model2.NewWhere("supplier_id", c.SupplierID)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (c *Material) Form() error {
|
||||
return nil
|
||||
func (c *MaterialParams) isExistForTitle(iModel model2.IModel) (bool, error) {
|
||||
var count int64
|
||||
|
||||
if err := model2.Count(iModel, &count, model2.NewWhere("title", c.Title),
|
||||
model2.NewWhere("supplier_id", c.SupplierID)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (c *Material) Delete() error {
|
||||
return nil
|
||||
// List 列表信息
|
||||
func (c *Material) List(supplierID uint64, code, title string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if supplierID > 0 {
|
||||
where = append(where, model2.NewWhere("m.supplier_id", supplierID))
|
||||
}
|
||||
if code != "" {
|
||||
where = append(where, model2.NewWhereLike("m.code", code))
|
||||
}
|
||||
if title != "" {
|
||||
where = append(where, model2.NewWhereLike("m.title", title))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageMaterial.Materials(page, pageSize, &count)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*MaterialInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
v.Image.Image = v.Analysis(config.SettingInfo.Domain)
|
||||
list = append(list, &MaterialInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
ManageMaterialInfo: v,
|
||||
})
|
||||
}
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func (c *Material) Form(params *MaterialParams) error {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
if params.ID > 0 {
|
||||
mManageMaterial.ID = params.ID
|
||||
|
||||
isExist, err := model2.First(mManageMaterial.ManageMaterial)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,器材信息不存在")
|
||||
}
|
||||
if mManageMaterial.SupplierID != params.SupplierID {
|
||||
|
||||
}
|
||||
if mManageMaterial.Code != params.Code {
|
||||
if isExist, err = params.isExistForCode(mManageMaterial); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前供应商下已存在此编码")
|
||||
}
|
||||
}
|
||||
if mManageMaterial.Title != params.Title {
|
||||
if isExist, err = params.isExistForTitle(mManageMaterial); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前供应商下已存在此名称")
|
||||
}
|
||||
}
|
||||
}
|
||||
mManageMaterial.SupplierID = params.SupplierID
|
||||
mManageMaterial.Code = params.Code
|
||||
mManageMaterial.Title = params.Title
|
||||
mManageMaterial.Unit = model2.ManageMaterialUnit(params.Unit)
|
||||
mManageMaterial.Remark = params.Remark
|
||||
|
||||
if mManageMaterial.ID > 0 {
|
||||
mManageMaterial.UpdatedAt = time.Now()
|
||||
return model2.Updates(mManageMaterial.ManageMaterial, mManageMaterial.ManageMaterial)
|
||||
}
|
||||
isExist, err := params.isExistForCode(mManageMaterial)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前供应商下已存在此编码")
|
||||
}
|
||||
if isExist, err = params.isExistForTitle(mManageMaterial); err != nil {
|
||||
return err
|
||||
} else if isExist {
|
||||
return errors.New("操作错误,当前供应商下已存在此名称")
|
||||
}
|
||||
mManageMaterial.TenantID = c.TenantID
|
||||
return model2.Create(mManageMaterial.ManageMaterial)
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Material) Delete(id uint64) error {
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
mManageMaterial.ID = id
|
||||
return model2.Delete(mManageMaterial.ManageMaterial)
|
||||
}
|
||||
|
||||
// Purchase 采购信息
|
||||
func (c *Material) Purchase(orderNo, supplierName, materialTitle string, page, pageSize int) (*basic.PageDataResponse, error) {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if orderNo != "" {
|
||||
where = append(where, model2.NewWhereLike("p.order_no", orderNo))
|
||||
}
|
||||
if supplierName != "" {
|
||||
where = append(where, model2.NewWhereLike("s.name", supplierName))
|
||||
}
|
||||
if materialTitle != "" {
|
||||
where = append(where, model2.NewWhereLike("m.title", materialTitle))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageMaterialPurchase.Purchases(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*MaterialPurchaseInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &MaterialPurchaseInfo{
|
||||
CommonIDString: basic.CommonIDString{ID: v.GetEncodeID()},
|
||||
ManageMaterialPurchaseInfo: v,
|
||||
})
|
||||
}
|
||||
return &basic.PageDataResponse{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// PurchaseLaunch 采购发起
|
||||
func (c *Material) PurchaseLaunch(materialID uint64, price float64, number int, remark string) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
mManageMaterialPurchase.UID = c.UID
|
||||
mManageMaterialPurchase.OrderNo = lib.OrderNo()
|
||||
mManageMaterialPurchase.MaterialID = materialID
|
||||
mManageMaterialPurchase.Price = price
|
||||
mManageMaterialPurchase.Number = number
|
||||
mManageMaterialPurchase.Remark = remark
|
||||
return model2.Create(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||
}
|
||||
|
||||
// PurchaseDelete 采购删除
|
||||
func (c *Material) PurchaseDelete(id uint64) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
mManageMaterialPurchase.ID = id
|
||||
return model2.Delete(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||
}
|
||||
|
||||
func (c *Material) Warehouse() {
|
||||
|
||||
}
|
||||
|
||||
// WarehouseLaunch 入库发起
|
||||
func (c *Material) WarehouseLaunch(materialPurchaseID uint64, number int, remark string) error {
|
||||
mManageMaterialPurchase := model.NewManageMaterialPurchase()
|
||||
mManageMaterialPurchase.ID = materialPurchaseID
|
||||
|
||||
isExist, err := model2.FirstWhere(mManageMaterialPurchase.ManageMaterialPurchase)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,未找到相应的采购单")
|
||||
}
|
||||
mManageMaterialWarehouse := model.NewManageMaterialWarehouse()
|
||||
mManageMaterialWarehouse.UID = c.UID
|
||||
mManageMaterialWarehouse.MaterialPurchaseID = materialPurchaseID
|
||||
mManageMaterialWarehouse.Number = number
|
||||
mManageMaterialWarehouse.Remark = remark
|
||||
|
||||
return orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
if err = model2.Create(mManageMaterialWarehouse.ManageMaterialWarehouse); err != nil {
|
||||
return err
|
||||
}
|
||||
// 同步库存
|
||||
mManageMaterial := model.NewManageMaterial()
|
||||
|
||||
if err = model2.Updates(mManageMaterial.ManageMaterial, map[string]interface{}{
|
||||
"stock": gorm.Expr("stock + ?", number),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// WarehouseDelete 入库删除
|
||||
func (c *Material) WarehouseDelete(id uint64) error {
|
||||
mManageMaterialWarehouse := model.NewManageMaterialWarehouse()
|
||||
mManageMaterialWarehouse.ID = id
|
||||
return model2.Delete(mManageMaterialWarehouse.ManageMaterialWarehouse)
|
||||
}
|
||||
|
||||
func NewMaterial() MaterialHandle {
|
||||
|
9
app/model/base.go
Normal file
9
app/model/base.go
Normal file
@ -0,0 +1,9 @@
|
||||
package model
|
||||
|
||||
import "ArmedPolice/app/common/model"
|
||||
|
||||
type PageParams struct {
|
||||
Page, PageSize int
|
||||
Count *int64
|
||||
Where []*model.ModelWhere
|
||||
}
|
@ -3,6 +3,7 @@ package model
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
"ArmedPolice/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageMaterial struct {
|
||||
@ -10,11 +11,30 @@ type ManageMaterial struct {
|
||||
}
|
||||
|
||||
type ManageMaterialInfo struct {
|
||||
Title string `json:"title"`
|
||||
*model.ManageMaterial
|
||||
SupplierName string `json:"supplier_name"`
|
||||
}
|
||||
|
||||
func (m *ManageMaterial) Materials() {
|
||||
orm.GetDB().Table(m.TableName() + " AS m").Select("")
|
||||
func (m *ManageMaterial) Materials(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageMaterialInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS m").
|
||||
Select("m.*", "s.name AS supplier_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m.supplier_id = s.id", model.NewManageSupplier().TableName()))
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageMaterialInfo, 0)
|
||||
|
||||
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
|
||||
}
|
||||
|
||||
func NewManageMaterial() *ManageMaterial {
|
||||
|
47
app/model/manage_materiral_purchase.go
Normal file
47
app/model/manage_materiral_purchase.go
Normal file
@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/app/common/model"
|
||||
"ArmedPolice/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageMaterialPurchase struct {
|
||||
*model.ManageMaterialPurchase
|
||||
}
|
||||
|
||||
// ManageMaterialPurchaseInfo 器材采购信息
|
||||
type ManageMaterialPurchaseInfo struct {
|
||||
*model.ManageMaterialPurchase
|
||||
MaterialTitle string `json:"material_title"`
|
||||
SupplierName string `json:"supplier_name"`
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
func (m *ManageMaterialPurchase) Purchases(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageMaterialPurchaseInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||
Select("p.*", "m.title AS material_title", "s.name AS supplier_names", "u.name AS username").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS m ON p.material_id = m.id", model.NewManageMaterial().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS s ON m.supplier_id = s.id", model.NewManageSupplier().TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON p.uid = u.uuid", model.NewSysUser().TableName())).
|
||||
Where("p.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageMaterialPurchaseInfo, 0)
|
||||
|
||||
if err := db.Order("p.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageMaterialPurchase() *ManageMaterialPurchase {
|
||||
return &ManageMaterialPurchase{}
|
||||
}
|
11
app/model/manage_materiral_warehouse.go
Normal file
11
app/model/manage_materiral_warehouse.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "ArmedPolice/app/common/model"
|
||||
|
||||
type ManageMaterialWarehouse struct {
|
||||
*model.ManageMaterialWarehouse
|
||||
}
|
||||
|
||||
func NewManageMaterialWarehouse() *ManageMaterialWarehouse {
|
||||
return &ManageMaterialWarehouse{}
|
||||
}
|
13
lib/order.go
Normal file
13
lib/order.go
Normal file
@ -0,0 +1,13 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderNo 订单号
|
||||
func OrderNo() string {
|
||||
now := time.Now()
|
||||
return fmt.Sprintf("%s%d%05d", now.Format("20060102"), now.Unix(), rand.Intn(100000))
|
||||
}
|
11
lib/order_test.go
Normal file
11
lib/order_test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package lib
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestOrderNo(t *testing.T) {
|
||||
i := 0
|
||||
for i < 20 {
|
||||
t.Log(OrderNo())
|
||||
i++
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user