diff --git a/app/admin/hdl/hdl_enterprise.go b/app/admin/hdl/hdl_enterprise.go index 942611a..63e3714 100644 --- a/app/admin/hdl/hdl_enterprise.go +++ b/app/admin/hdl/hdl_enterprise.go @@ -27,6 +27,9 @@ func EnterpriseList(c *gin.Context) { if req.Name != "" { engine.And("enterprise.name like ?", "%"+req.Name+"%") } + if req.InsideName != "" { + engine.And("enterprise.inside_name like ?", "%"+req.InsideName+"%") + } if req.Memo != "" { engine.And("enterprise.memo like ?", "%"+req.Memo+"%") } @@ -50,6 +53,7 @@ func EnterpriseList(c *gin.Context) { Id: v.Enterprise.Id, State: v.Enterprise.State, Name: v.Enterprise.Name, + InsideName: v.Enterprise.InsideName, Memo: v.Enterprise.Memo, CompanyName: v.Company.Name, CompanyId: v.Company.Id, @@ -140,12 +144,13 @@ func EnterpriseAdd(c *gin.Context) { now := time.Now() enterprise := model.Enterprise{ - Name: req.Name, - CompanyId: req.CompanyId, - State: enum.EnterpriseStateForNormal, - Memo: req.Memo, - CreateAt: now.Format("2006-01-02 15:04:05"), - UpdateAt: now.Format("2006-01-02 15:04:05"), + Name: req.Name, + InsideName: req.InsideName, + CompanyId: req.CompanyId, + State: enum.EnterpriseStateForNormal, + Memo: req.Memo, + CreateAt: now.Format("2006-01-02 15:04:05"), + UpdateAt: now.Format("2006-01-02 15:04:05"), } _, err = enterpriseDb.EnterpriseInsert(&enterprise) if err != nil { @@ -179,10 +184,11 @@ func EnterpriseUpdate(c *gin.Context) { } now := time.Now() enterprise.Name = req.Name - enterprise.Memo = req.Name + enterprise.InsideName = req.InsideName + enterprise.Memo = req.Memo enterprise.CompanyId = req.CompanyId enterprise.UpdateAt = now.Format("2006-01-02 15:04:05") - _, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "memo", "update_at") + _, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "memo", "update_at", "inside_name") if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return diff --git a/app/admin/md/md_enterprise.go b/app/admin/md/md_enterprise.go index 761dcc8..9e3c579 100644 --- a/app/admin/md/md_enterprise.go +++ b/app/admin/md/md_enterprise.go @@ -1,18 +1,20 @@ package md type EnterpriseListReq struct { - Limit int `json:"limit"` - Page int `json:"page" ` - Name string `json:"name" label:"名称"` - Memo string `json:"memo" label:"备注"` - LeadName string `json:"lead_name" label:"负责人姓名"` - LeadPhone string `json:"lead_phone" label:"负责人手机号"` + Limit int `json:"limit"` + Page int `json:"page" ` + Name string `json:"name" label:"名称"` + InsideName string `json:"inside_name" label:"名称"` + Memo string `json:"memo" label:"备注"` + LeadName string `json:"lead_name" label:"负责人姓名"` + LeadPhone string `json:"lead_phone" label:"负责人手机号"` } type EnterpriseListResp struct { Id int `json:"id" binding:"required" label:"公司id"` State int32 `json:"state" label:"状态"` Name string `json:"name" binding:"required" label:"名称"` + InsideName string `json:"inside_name" label:"名称"` Memo string `json:"memo" label:"备注"` CompanyName string `json:"company_name" label:"公司名称"` CompanyId int `json:"company_id" label:"公司Id"` @@ -32,14 +34,16 @@ type EnterpriseDeleteReq struct { } type EnterpriseAddReq struct { - Name string `json:"name" binding:"required" label:"名称"` - CompanyId int `json:"company_id" binding:"required" label:"所属公司id"` - Memo string `json:"memo" label:"备注"` + Name string `json:"name" binding:"required" label:"名称"` + InsideName string `json:"inside_name" label:"名称"` + CompanyId int `json:"company_id" binding:"required" label:"所属公司id"` + Memo string `json:"memo" label:"备注"` } type EnterpriseUpdateReq struct { - Id int `json:"id" binding:"required" label:"公司id"` - Name string `json:"name" binding:"required" label:"名称"` - CompanyId int `json:"company_id" binding:"required" label:"所属公司id"` - Memo string `json:"memo" label:"备注"` + Id int `json:"id" binding:"required" label:"公司id"` + Name string `json:"name" binding:"required" label:"名称"` + InsideName string `json:"inside_name" label:"名称"` + CompanyId int `json:"company_id" binding:"required" label:"所属公司id"` + Memo string `json:"memo" label:"备注"` } diff --git a/app/admin/svc/order/svc_order_list.go b/app/admin/svc/order/svc_order_list.go index 10d8b7b..e4e1d77 100644 --- a/app/admin/svc/order/svc_order_list.go +++ b/app/admin/svc/order/svc_order_list.go @@ -39,9 +39,11 @@ func OrderList(c *gin.Context) { isCanCancel = "0" } enterpriseName := "" + insideEnterpriseName := "" _, ok := enterpriseMap[v.EnterpriseId] if ok { enterpriseName = enterpriseMap[v.EnterpriseId].Name + insideEnterpriseName = enterpriseMap[v.EnterpriseId].InsideName } var tmp = map[string]string{ "buy_phone": v1.BuyPhone, @@ -56,6 +58,7 @@ func OrderList(c *gin.Context) { "create_at": v1.CreateAt.Format("2006-01-02 15:04:05"), "is_can_cancel": isCanCancel, "enterprise_name": enterpriseName, + "inside_name": insideEnterpriseName, } data = append(data, tmp) } diff --git a/app/db/db_order_list.go b/app/db/db_order_list.go index 5f847bb..4df999c 100644 --- a/app/db/db_order_list.go +++ b/app/db/db_order_list.go @@ -76,6 +76,15 @@ func GetOrderList(eg *xorm.Engine, param map[string]string) (*[]model.Order, int } sess.In("enterprise_id", oids) } + if param["inside_name"] != "" { + var enterprise []model.Enterprise + eg.Where("inside_name like ?", "%"+param["inside_name"]+"%").Find(&enterprise) + oids := []int{-1} + for _, v := range enterprise { + oids = append(oids, v.Id) + } + sess.In("enterprise_id", oids) + } size := utils.StrToInt(param["limit"]) start := (utils.StrToInt(param["page"]) - 1) * size count, err := sess.Limit(size, start).OrderBy("id desc").FindAndCount(&order) diff --git a/app/db/model/enterprise.go b/app/db/model/enterprise.go index d9c90b5..f435c12 100644 --- a/app/db/model/enterprise.go +++ b/app/db/model/enterprise.go @@ -1,11 +1,12 @@ package model type Enterprise struct { - Id int `json:"id" xorm:"not null pk autoincr INT(11)"` - Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` - CompanyId int `json:"company_id" xorm:"not null default 0 comment('所属公司id') INT(11)"` - State int32 `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` - Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` + InsideName string `json:"inside_name" xorm:"not null default '' comment('名称') VARCHAR(255)"` + CompanyId int `json:"company_id" xorm:"not null default 0 comment('所属公司id') INT(11)"` + State int32 `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` + Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` + CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` }