Browse Source

客户管理

wangxingcheng 3 years ago
parent
commit
087a67e58f

+ 0 - 0
opms_parent/app/dao/cust/.gitkeep


+ 36 - 0
opms_parent/app/dao/cust/cust_customer.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package cust
+
+import (
+	"dashoo.cn/micro/app/dao/cust/internal"
+)
+
+// custCustomerDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type custCustomerDao struct {
+	internal.CustCustomerDao
+}
+
+var (
+	// CustCustomer is globally public accessible object for table cust_customer operations.
+	CustCustomer = custCustomerDao{
+		internal.CustCustomer,
+	}
+)
+
+type CustCustomerDao struct {
+	internal.CustCustomerDao
+}
+
+func NewCustCustomerDao(tenant string) *CustCustomerDao {
+	dao := internal.NewCustCustomerDao(tenant)
+	return &CustCustomerDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 36 - 0
opms_parent/app/dao/cust/cust_customer_belong.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package cust
+
+import (
+	"dashoo.cn/micro/app/dao/cust/internal"
+)
+
+// custCustomerBelongDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type custCustomerBelongDao struct {
+	internal.CustCustomerBelongDao
+}
+
+var (
+	// CustCustomerBelong is globally public accessible object for table cust_customer_belong operations.
+	CustCustomerBelong = custCustomerBelongDao{
+		internal.CustCustomerBelong,
+	}
+)
+
+type CustCustomerBelongDao struct {
+	internal.CustCustomerBelongDao
+}
+
+func NewCustCustomerBelongDao(tenant string) *CustCustomerBelongDao {
+	dao := internal.NewCustCustomerBelongDao(tenant)
+	return &CustCustomerBelongDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 36 - 0
opms_parent/app/dao/cust/cust_customer_contact.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package cust
+
+import (
+	"dashoo.cn/micro/app/dao/cust/internal"
+)
+
+// custCustomerContactDao is the manager for logic model data accessing
+// and custom defined data operations functions management. You can define
+// methods on it to extend its functionality as you wish.
+type custCustomerContactDao struct {
+	internal.CustCustomerContactDao
+}
+
+var (
+	// CustCustomerContact is globally public accessible object for table cust_customer_contact operations.
+	CustCustomerContact = custCustomerContactDao{
+		internal.CustCustomerContact,
+	}
+)
+
+type CustCustomerContactDao struct {
+	internal.CustCustomerContactDao
+}
+
+func NewCustCustomerContactDao(tenant string) *CustCustomerContactDao {
+	dao := internal.NewCustCustomerContactDao(tenant)
+	return &CustCustomerContactDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 457 - 0
opms_parent/app/dao/cust/internal/cust_customer.go

@@ -0,0 +1,457 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"time"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+
+	model "dashoo.cn/micro/app/model/cust"
+)
+
+// CustCustomerDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type CustCustomerDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns custCustomerColumns
+}
+
+// CustCustomerColumns defines and stores column names for table cust_customer.
+type custCustomerColumns struct {
+	Id           string // 主键
+	CustCode     string // 客户编号
+	CustName     string // 客户名称
+	AbbrName     string // 助记名
+	CustLocation string // 所在地区
+	CustAddress  string // 详细地址
+	CustStatus   string // 客户状态(10正常20)
+	IsPublic     string // 公海客户(10是20否)
+	DeptId       string // 所属部门ID
+	DeptName     string // 所属部门
+	SalesId      string // 所属销售ID
+	SalesName    string // 所属销售
+	FollowUpDate string // 最后跟进时间
+	Remark       string // 备注
+	CreatedBy    string // 创建者
+	CreatedName  string // 创建人
+	CreatedTime  string // 创建时间
+	UpdatedBy    string // 更新者
+	UpdatedName  string // 更新人
+	UpdatedTime  string // 更新时间
+	DeletedTime  string // 删除时间
+}
+
+var (
+	// CustCustomer is globally public accessible object for table cust_customer operations.
+	CustCustomer = CustCustomerDao{
+		M:     g.DB("default").Model("cust_customer").Safe(),
+		DB:    g.DB("default"),
+		Table: "cust_customer",
+		Columns: custCustomerColumns{
+			Id:           "id",
+			CustCode:     "cust_code",
+			CustName:     "cust_name",
+			AbbrName:     "abbr_name",
+			CustLocation: "cust_location",
+			CustAddress:  "cust_address",
+			CustStatus:   "cust_status",
+			IsPublic:     "is_public",
+			DeptId:       "dept_id",
+			DeptName:     "dept_name",
+			SalesId:      "sales_id",
+			SalesName:    "sales_name",
+			FollowUpDate: "follow_up_date",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+)
+
+func NewCustCustomerDao(tenant string) CustCustomerDao {
+	var dao CustCustomerDao
+	dao = CustCustomerDao{
+		M:     g.DB(tenant).Model("cust_customer").Safe(),
+		DB:    g.DB(tenant),
+		Table: "cust_customer",
+		Columns: custCustomerColumns{
+			Id:           "id",
+			CustCode:     "cust_code",
+			CustName:     "cust_name",
+			AbbrName:     "abbr_name",
+			CustLocation: "cust_location",
+			CustAddress:  "cust_address",
+			CustStatus:   "cust_status",
+			IsPublic:     "is_public",
+			DeptId:       "dept_id",
+			DeptName:     "dept_name",
+			SalesId:      "sales_id",
+			SalesName:    "sales_name",
+			FollowUpDate: "follow_up_date",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *CustCustomerDao) Ctx(ctx context.Context) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *CustCustomerDao) As(as string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *CustCustomerDao) TX(tx *gdb.TX) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *CustCustomerDao) Master() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *CustCustomerDao) Slave() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *CustCustomerDao) Args(args ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerDao) LeftJoin(table ...string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerDao) RightJoin(table ...string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerDao) InnerJoin(table ...string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerDao) Fields(fieldNamesOrMapStruct ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *CustCustomerDao) Option(option int) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *CustCustomerDao) OmitEmpty() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *CustCustomerDao) Filter() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *CustCustomerDao) Where(where interface{}, args ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *CustCustomerDao) WherePri(where interface{}, args ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *CustCustomerDao) And(where interface{}, args ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *CustCustomerDao) Or(where interface{}, args ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *CustCustomerDao) Group(groupBy string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *CustCustomerDao) Order(orderBy ...string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *CustCustomerDao) Limit(limit ...int) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *CustCustomerDao) Offset(offset int) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *CustCustomerDao) Page(page, limit int) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *CustCustomerDao) Batch(batch int) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *CustCustomerDao) Cache(duration time.Duration, name ...string) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *CustCustomerDao) Data(data ...interface{}) *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.CustCustomer.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerDao) All(where ...interface{}) ([]*model.CustCustomer, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomer
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.CustCustomer.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerDao) One(where ...interface{}) (*model.CustCustomer, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomer
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *CustCustomerDao) FindOne(where ...interface{}) (*model.CustCustomer, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomer
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *CustCustomerDao) FindAll(where ...interface{}) ([]*model.CustCustomer, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomer
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *CustCustomerDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *CustCustomerDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *CustCustomerDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *CustCustomerDao) Chunk(limit int, callback func(entities []*model.CustCustomer, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.CustCustomer
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *CustCustomerDao) LockUpdate() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *CustCustomerDao) LockShared() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *CustCustomerDao) Unscoped() *CustCustomerDao {
+	return &CustCustomerDao{M: d.M.Unscoped()}
+}

+ 439 - 0
opms_parent/app/dao/cust/internal/cust_customer_belong.go

@@ -0,0 +1,439 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"time"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+
+	model "dashoo.cn/micro/app/model/cust"
+)
+
+// CustCustomerBelongDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type CustCustomerBelongDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns custCustomerBelongColumns
+}
+
+// CustCustomerBelongColumns defines and stores column names for table cust_customer_belong.
+type custCustomerBelongColumns struct {
+	Id           string // 主键
+	CustId       string // 关联客户
+	SaleName     string // 归属销售
+	OrigSaleName string // 原来归属
+	OpnType      string // 操作方式(10分配20转移)
+	OpnPeople    string // 操作人
+	OpnDatetime  string // 操作时间
+	Remark       string // 备注
+	CreatedBy    string // 创建者
+	CreatedName  string // 创建人
+	CreatedTime  string // 创建时间
+	UpdatedBy    string // 更新者
+	UpdatedName  string // 更新人
+	UpdatedTime  string // 更新时间
+	DeletedTime  string // 删除时间
+}
+
+var (
+	// CustCustomerBelong is globally public accessible object for table cust_customer_belong operations.
+	CustCustomerBelong = CustCustomerBelongDao{
+		M:     g.DB("default").Model("cust_customer_belong").Safe(),
+		DB:    g.DB("default"),
+		Table: "cust_customer_belong",
+		Columns: custCustomerBelongColumns{
+			Id:           "id",
+			CustId:       "cust_id",
+			SaleName:     "sale_name",
+			OrigSaleName: "orig_sale_name",
+			OpnType:      "opn_type",
+			OpnPeople:    "opn_people",
+			OpnDatetime:  "opn_datetime",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+)
+
+func NewCustCustomerBelongDao(tenant string) CustCustomerBelongDao {
+	var dao CustCustomerBelongDao
+	dao = CustCustomerBelongDao{
+		M:     g.DB(tenant).Model("cust_customer_belong").Safe(),
+		DB:    g.DB(tenant),
+		Table: "cust_customer_belong",
+		Columns: custCustomerBelongColumns{
+			Id:           "id",
+			CustId:       "cust_id",
+			SaleName:     "sale_name",
+			OrigSaleName: "orig_sale_name",
+			OpnType:      "opn_type",
+			OpnPeople:    "opn_people",
+			OpnDatetime:  "opn_datetime",
+			Remark:       "remark",
+			CreatedBy:    "created_by",
+			CreatedName:  "created_name",
+			CreatedTime:  "created_time",
+			UpdatedBy:    "updated_by",
+			UpdatedName:  "updated_name",
+			UpdatedTime:  "updated_time",
+			DeletedTime:  "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *CustCustomerBelongDao) Ctx(ctx context.Context) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *CustCustomerBelongDao) As(as string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *CustCustomerBelongDao) TX(tx *gdb.TX) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *CustCustomerBelongDao) Master() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *CustCustomerBelongDao) Slave() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *CustCustomerBelongDao) Args(args ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerBelongDao) LeftJoin(table ...string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerBelongDao) RightJoin(table ...string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerBelongDao) InnerJoin(table ...string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerBelongDao) Fields(fieldNamesOrMapStruct ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerBelongDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *CustCustomerBelongDao) Option(option int) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *CustCustomerBelongDao) OmitEmpty() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *CustCustomerBelongDao) Filter() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *CustCustomerBelongDao) Where(where interface{}, args ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *CustCustomerBelongDao) WherePri(where interface{}, args ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *CustCustomerBelongDao) And(where interface{}, args ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *CustCustomerBelongDao) Or(where interface{}, args ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *CustCustomerBelongDao) Group(groupBy string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *CustCustomerBelongDao) Order(orderBy ...string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *CustCustomerBelongDao) Limit(limit ...int) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *CustCustomerBelongDao) Offset(offset int) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *CustCustomerBelongDao) Page(page, limit int) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *CustCustomerBelongDao) Batch(batch int) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *CustCustomerBelongDao) Cache(duration time.Duration, name ...string) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *CustCustomerBelongDao) Data(data ...interface{}) *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.CustCustomerBelong.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerBelongDao) All(where ...interface{}) ([]*model.CustCustomerBelong, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomerBelong
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.CustCustomerBelong.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerBelongDao) One(where ...interface{}) (*model.CustCustomerBelong, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomerBelong
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *CustCustomerBelongDao) FindOne(where ...interface{}) (*model.CustCustomerBelong, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomerBelong
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *CustCustomerBelongDao) FindAll(where ...interface{}) ([]*model.CustCustomerBelong, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomerBelong
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *CustCustomerBelongDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *CustCustomerBelongDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *CustCustomerBelongDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *CustCustomerBelongDao) Chunk(limit int, callback func(entities []*model.CustCustomerBelong, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.CustCustomerBelong
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *CustCustomerBelongDao) LockUpdate() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *CustCustomerBelongDao) LockShared() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *CustCustomerBelongDao) Unscoped() *CustCustomerBelongDao {
+	return &CustCustomerBelongDao{M: d.M.Unscoped()}
+}

+ 442 - 0
opms_parent/app/dao/cust/internal/cust_customer_contact.go

@@ -0,0 +1,442 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"context"
+	"database/sql"
+	"time"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+
+	model "dashoo.cn/micro/app/model/cust"
+)
+
+// CustCustomerContactDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type CustCustomerContactDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns custCustomerContactColumns
+}
+
+// CustCustomerContactColumns defines and stores column names for table cust_customer_contact.
+type custCustomerContactColumns struct {
+	Id          string // 主键
+	CustId      string // 关联客户
+	CuctName    string // 姓名
+	CuctGender  string // 性别(10男20女)
+	Postion     string // 职位
+	Telephone   string // 电话
+	Wechat      string // 微信
+	Email       string // 邮箱
+	Remark      string // 备注
+	CreatedBy   string // 创建者
+	CreatedName string // 创建人
+	CreatedTime string // 创建时间
+	UpdatedBy   string // 更新者
+	UpdatedName string // 更新人
+	UpdatedTime string // 更新时间
+	DeletedTime string // 删除时间
+}
+
+var (
+	// CustCustomerContact is globally public accessible object for table cust_customer_contact operations.
+	CustCustomerContact = CustCustomerContactDao{
+		M:     g.DB("default").Model("cust_customer_contact").Safe(),
+		DB:    g.DB("default"),
+		Table: "cust_customer_contact",
+		Columns: custCustomerContactColumns{
+			Id:          "id",
+			CustId:      "cust_id",
+			CuctName:    "cuct_name",
+			CuctGender:  "cuct_gender",
+			Postion:     "postion",
+			Telephone:   "telephone",
+			Wechat:      "wechat",
+			Email:       "email",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+)
+
+func NewCustCustomerContactDao(tenant string) CustCustomerContactDao {
+	var dao CustCustomerContactDao
+	dao = CustCustomerContactDao{
+		M:     g.DB(tenant).Model("cust_customer_contact").Safe(),
+		DB:    g.DB(tenant),
+		Table: "cust_customer_contact",
+		Columns: custCustomerContactColumns{
+			Id:          "id",
+			CustId:      "cust_id",
+			CuctName:    "cuct_name",
+			CuctGender:  "cuct_gender",
+			Postion:     "postion",
+			Telephone:   "telephone",
+			Wechat:      "wechat",
+			Email:       "email",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+	return dao
+}
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (d *CustCustomerContactDao) Ctx(ctx context.Context) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *CustCustomerContactDao) As(as string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *CustCustomerContactDao) TX(tx *gdb.TX) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *CustCustomerContactDao) Master() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (d *CustCustomerContactDao) Slave() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *CustCustomerContactDao) Args(args ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Args(args...)}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerContactDao) LeftJoin(table ...string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.LeftJoin(table...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerContactDao) RightJoin(table ...string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.RightJoin(table...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (d *CustCustomerContactDao) InnerJoin(table ...string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.InnerJoin(table...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerContactDao) Fields(fieldNamesOrMapStruct ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+// The parameter <fieldNamesOrMapStruct> can be type of string/map/*map/struct/*struct.
+func (d *CustCustomerContactDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *CustCustomerContactDao) Option(option int) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (d *CustCustomerContactDao) OmitEmpty() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *CustCustomerContactDao) Filter() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (d *CustCustomerContactDao) Where(where interface{}, args ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as M.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but M.Where treats the condition
+// as string "123".
+func (d *CustCustomerContactDao) WherePri(where interface{}, args ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *CustCustomerContactDao) And(where interface{}, args ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *CustCustomerContactDao) Or(where interface{}, args ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *CustCustomerContactDao) Group(groupBy string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *CustCustomerContactDao) Order(orderBy ...string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (d *CustCustomerContactDao) Limit(limit ...int) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (d *CustCustomerContactDao) Offset(offset int) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (d *CustCustomerContactDao) Page(page, limit int) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *CustCustomerContactDao) Batch(batch int) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (d *CustCustomerContactDao) Cache(duration time.Duration, name ...string) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (d *CustCustomerContactDao) Data(data ...interface{}) *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*model.CustCustomerContact.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerContactDao) All(where ...interface{}) ([]*model.CustCustomerContact, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomerContact
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *model.CustCustomerContact.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of M.Where function,
+// see M.Where.
+func (d *CustCustomerContactDao) One(where ...interface{}) (*model.CustCustomerContact, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomerContact
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by M.WherePri and M.One.
+// Also see M.WherePri and M.One.
+func (d *CustCustomerContactDao) FindOne(where ...interface{}) (*model.CustCustomerContact, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.CustCustomerContact
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by M.WherePri and M.All.
+// Also see M.WherePri and M.All.
+func (d *CustCustomerContactDao) FindAll(where ...interface{}) ([]*model.CustCustomerContact, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.CustCustomerContact
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Struct retrieves one record from table and converts it into given struct.
+// The parameter <pointer> should be type of *struct/**struct. If type **struct is given,
+// it can create the struct internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not nil.
+//
+// Eg:
+// user := new(User)
+// err  := dao.User.Where("id", 1).Struct(user)
+//
+// user := (*User)(nil)
+// err  := dao.User.Where("id", 1).Struct(&user)
+func (d *CustCustomerContactDao) Struct(pointer interface{}, where ...interface{}) error {
+	return d.M.Struct(pointer, where...)
+}
+
+// Structs retrieves records from table and converts them into given struct slice.
+// The parameter <pointer> should be type of *[]struct/*[]*struct. It can create and fill the struct
+// slice internally during converting.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved with the given conditions
+// from table and <pointer> is not empty.
+//
+// Eg:
+// users := ([]User)(nil)
+// err   := dao.User.Structs(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Structs(&users)
+func (d *CustCustomerContactDao) Structs(pointer interface{}, where ...interface{}) error {
+	return d.M.Structs(pointer, where...)
+}
+
+// Scan automatically calls Struct or Structs function according to the type of parameter <pointer>.
+// It calls function Struct if <pointer> is type of *struct/**struct.
+// It calls function Structs if <pointer> is type of *[]struct/*[]*struct.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+//
+// Note that it returns sql.ErrNoRows if there's no record retrieved and given pointer is not empty or nil.
+//
+// Eg:
+// user  := new(User)
+// err   := dao.User.Where("id", 1).Scan(user)
+//
+// user  := (*User)(nil)
+// err   := dao.User.Where("id", 1).Scan(&user)
+//
+// users := ([]User)(nil)
+// err   := dao.User.Scan(&users)
+//
+// users := ([]*User)(nil)
+// err   := dao.User.Scan(&users)
+func (d *CustCustomerContactDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *CustCustomerContactDao) Chunk(limit int, callback func(entities []*model.CustCustomerContact, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.CustCustomerContact
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (d *CustCustomerContactDao) LockUpdate() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *CustCustomerContactDao) LockShared() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *CustCustomerContactDao) Unscoped() *CustCustomerContactDao {
+	return &CustCustomerContactDao{M: d.M.Unscoped()}
+}

+ 0 - 0
opms_parent/app/handler/cust/.gitkeep


+ 118 - 0
opms_parent/app/handler/cust/customer.go

@@ -0,0 +1,118 @@
+package cust
+
+import (
+	"context"
+
+	"dashoo.cn/common_definition/comm_def"
+	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/util/gvalid"
+
+	model "dashoo.cn/micro/app/model/cust"
+	server "dashoo.cn/micro/app/service/cust"
+)
+
+type CustomerHeader struct{}
+
+//客户列表
+func (c *CustomerHeader) GetList(ctx context.Context, req *model.CustCustomerSearchReq, rsp *comm_def.CommonMsg) error {
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	total, list, err := customerServer.GetList(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	rsp.Data = g.Map{"list": list, "total": total}
+	return nil
+
+}
+
+//创建客户信息
+func (c *CustomerHeader) Create(ctx context.Context, req *model.AddCustCustomerReq, rsp *comm_def.CommonMsg) error {
+	if err := gvalid.CheckStruct(ctx, req.Cust, nil); err != nil {
+		return err
+	}
+	if err := gvalid.CheckStruct(ctx, req.Info, nil); err != nil {
+		return err
+	}
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	err = customerServer.Create(req)
+	g.Log().Info("error", err)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+}
+
+//客户详情
+func (c *CustomerHeader) GetEntityById(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
+	if req.Id == 0 {
+		return gerror.New("参数有误!")
+	}
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("系统异常,请重新尝试")
+	}
+	list, err := customerServer.GetEntityById(req.Id)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	rsp.Data = g.Map{"list": list}
+	return nil
+}
+
+//转移客户
+func (c *CustomerHeader) UpdateBytransfer(ctx context.Context, req *model.CustSalesReq, rsp *comm_def.CommonMsg) error {
+	if len(req.Ids) == 0 || req.SalesIds == 0 {
+		return gerror.New("参数有误!")
+	}
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("系统异常,请重新尝试")
+	}
+	_, err = customerServer.UpdateBytransfer(req)
+	//g.Log().Info("List", list)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+}
+
+//分配客户
+func (c *CustomerHeader) DistriCustomer(ctx context.Context, req *model.DistriCustomer, rsp *comm_def.CommonMsg) error {
+	if len(req.Ids) == 0 || req.SalesId == 0 {
+		return gerror.New("参数有误!")
+	}
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = customerServer.DistriCustomer(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+
+	return nil
+
+}

+ 0 - 0
opms_parent/app/model/base/.gitkeep


+ 0 - 0
opms_parent/app/model/cust/.gitkeep


+ 71 - 0
opms_parent/app/model/cust/cust_customer.go

@@ -0,0 +1,71 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package cust
+
+import (
+	"dashoo.cn/opms_libary/request"
+
+	"dashoo.cn/micro/app/model/cust/internal"
+)
+
+// CustCustomer is the golang structure for table cust_customer.
+type CustCustomer internal.CustCustomer
+
+// Fill with you ideas below.
+//列表搜索参数
+type CustCustomerSearchReq struct {
+	KeyWords   string `json:"custCode"`
+	CustName   string `json:"custName"`
+	CuctName   string `json:"cuctName"`
+	SalesName  string `json:"salesName"`
+	Telephone  string `json:"telePhone"`
+	CustStatus string `json:"custStatus"` //客户状态
+	request.PageReq
+}
+
+// 添加客户信息表
+type AddCustCustomerReq struct {
+	Cust *Customer
+	Info *Information
+}
+
+type Customer struct {
+	CustName     string `p:"custName"        json:"custName"   v:"required#客户名称不能为空"`
+	AbbrName     string `p:"abbrName"        json:"abbrName"   `     // 助计名
+	CustLocation string `p:"custLocation"    json:"custLocation"   ` // 所在地区
+	CustAddress  string `p:"custAddress"     json:"custAddress"   `  // 详细地址
+	SalesName    string `p:"salesName"       json:"salesName"   `    //
+	SalesId      string `p:"salesId"         json:"salesId"   `      //
+}
+
+//客户联系人信息
+type Information struct {
+	CuctName   string `p:"cuctName"    json:"cuctName"     v:"required#联系人名字不能为空"`
+	TelePhone  string `p:"telePhone"   json:"telePhone"    v:"required|phone#手机号不能为空|手机号格式错误" orm:"telephone"`
+	CuctGender string `p:"cuctGender"  json:"cuctGender"   `                                 // 尊称  性别
+	Postion    string `p:"postion"     json:"postion"   `                                    // 职位
+	Email      string `p:"email"       json:"email"         v:"email#邮箱格式错误" orm:"email"   ` // 邮箱
+	Remark     string `p:"remark"      json:"remark"   `                                     // 备注
+}
+
+//返回信息
+type CustList struct {
+	*CustCustomer
+	CuctName  string `p:"cuctName"      json:"cuctName"`
+	TelePhone string `p:"telePhone"      json:"telePhone"`
+}
+
+//转移客户参数
+type CustSalesReq struct {
+	Ids      []int64 `json:"ids,omitempty"`
+	SalesIds int64   `json:"salesids,omitempty"`
+	Remark   string  `json:"remark,omitempty"`
+}
+
+//分配客户参数
+type DistriCustomer struct {
+	Ids     []int64 `json:"ids,omitempty"`     //客户id
+	SalesId int64   `json:"salesid,omitempty"` //分配到销售人员的id
+}

+ 14 - 0
opms_parent/app/model/cust/cust_customer_belong.go

@@ -0,0 +1,14 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package cust
+
+import (
+	"dashoo.cn/micro/app/model/cust/internal"
+)
+
+// CustCustomerBelong is the golang structure for table cust_customer_belong.
+type CustCustomerBelong internal.CustCustomerBelong
+
+// Fill with you ideas below.

+ 14 - 0
opms_parent/app/model/cust/cust_customer_contact.go

@@ -0,0 +1,14 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package cust
+
+import (
+	"dashoo.cn/micro/app/model/cust/internal"
+)
+
+// CustCustomerContact is the golang structure for table cust_customer_contact.
+type CustCustomerContact internal.CustCustomerContact
+
+// Fill with you ideas below.

+ 35 - 0
opms_parent/app/model/cust/internal/cust_customer.go

@@ -0,0 +1,35 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// CustCustomer is the golang structure for table cust_customer.
+type CustCustomer struct {
+	Id           int                  `orm:"id,primary"     json:"id"`           // 主键
+	CustCode     string               `orm:"cust_code"      json:"custCode"`     // 客户编号
+	CustName     string               `orm:"cust_name"      json:"custName"`     // 客户名称
+	AbbrName     string               `orm:"abbr_name"      json:"abbrName"`     // 助记名
+	CustLocation string               `orm:"cust_location"  json:"custLocation"` // 所在地区
+	CustAddress  string               `orm:"cust_address"   json:"custAddress"`  // 详细地址
+	CustStatus   string               `orm:"cust_status"    json:"custStatus"`   // 客户状态(10正常20)
+	IsPublic     string               `orm:"is_public"      json:"isPublic"`     // 公海客户(10是20否)
+	DeptId       int                  `orm:"dept_id"        json:"deptId"`       // 所属部门ID
+	DeptName     string               `orm:"dept_name"      json:"deptName"`     // 所属部门
+	SalesId      int                  `orm:"sales_id"       json:"salesId"`      // 所属销售ID
+	SalesName    string               `orm:"sales_name"     json:"salesName"`    // 所属销售
+	FollowUpDate *gtime.Time          `orm:"follow_up_date" json:"followUpDate"` // 最后跟进时间
+	Remark       string               `orm:"remark"         json:"remark"`       // 备注
+	CreatedBy    int                  `orm:"created_by"     json:"createdBy"`    // 创建者
+	CreatedName  string               `orm:"created_name"   json:"createdName"`  // 创建人
+	CreatedTime  *gtime.Time          `orm:"created_time"   json:"createdTime"`  // 创建时间
+	UpdatedBy    int                  `orm:"updated_by"     json:"updatedBy"`    // 更新者
+	UpdatedName  string               `orm:"updated_name"   json:"updatedName"`  // 更新人
+	UpdatedTime  *gtime.Time          `orm:"updated_time"   json:"updatedTime"`  // 更新时间
+	DeletedTime  *gtime.Time          `orm:"deleted_time"   json:"deletedTime"`  // 删除时间
+	Contact      *CustCustomerContact `orm:"with:cust_id=id"`                    //关联客户联系人表模型
+}

+ 28 - 0
opms_parent/app/model/cust/internal/cust_customer_belong.go

@@ -0,0 +1,28 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// CustCustomerBelong is the golang structure for table cust_customer_belong.
+type CustCustomerBelong struct {
+	Id           int         `orm:"id,primary"     json:"id"`           // 主键
+	CustId       int         `orm:"cust_id"        json:"custId"`       // 关联客户
+	SaleName     string      `orm:"sale_name"      json:"saleName"`     // 归属销售
+	OrigSaleName string      `orm:"orig_sale_name" json:"origSaleName"` // 原来归属
+	OpnType      string      `orm:"opn_type"       json:"opnType"`      // 操作方式(10分配20转移)
+	OpnPeople    string      `orm:"opn_people"     json:"opnPeople"`    // 操作人
+	OpnDatetime  *gtime.Time `orm:"opn_datetime"   json:"opnDatetime"`  // 操作时间
+	Remark       string      `orm:"remark"         json:"remark"`       // 备注
+	CreatedBy    int         `orm:"created_by"     json:"createdBy"`    // 创建者
+	CreatedName  string      `orm:"created_name"   json:"createdName"`  // 创建人
+	CreatedTime  *gtime.Time `orm:"created_time"   json:"createdTime"`  // 创建时间
+	UpdatedBy    int         `orm:"updated_by"     json:"updatedBy"`    // 更新者
+	UpdatedName  string      `orm:"updated_name"   json:"updatedName"`  // 更新人
+	UpdatedTime  *gtime.Time `orm:"updated_time"   json:"updatedTime"`  // 更新时间
+	DeletedTime  *gtime.Time `orm:"deleted_time"   json:"deletedTime"`  // 删除时间
+}

+ 29 - 0
opms_parent/app/model/cust/internal/cust_customer_contact.go

@@ -0,0 +1,29 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// CustCustomerContact is the golang structure for table cust_customer_contact.
+type CustCustomerContact struct {
+	Id          int         `orm:"id,primary"   json:"id"`                               // 主键
+	CustId      int         `orm:"cust_id"      json:"custId" `                          // 关联客户
+	CuctName    string      `orm:"cuct_name"    json:"cuctName"  v:"required#联系人名字不能为空"` // 姓名
+	CuctGender  string      `orm:"cuct_gender"  json:"cuctGender"`                       // 性别(10男20女)
+	Postion     string      `orm:"postion"      json:"postion"`                          // 职位
+	Telephone   string      `orm:"telephone"    json:"telephone"`                        // 电话
+	Wechat      string      `orm:"wechat"       json:"wechat"`                           // 微信
+	Email       string      `orm:"email"        json:"email"`                            // 邮箱
+	Remark      string      `orm:"remark"       json:"remark"`                           // 备注
+	CreatedBy   int         `orm:"created_by"   json:"createdBy"`                        // 创建者
+	CreatedName string      `orm:"created_name" json:"createdName"`                      // 创建人
+	CreatedTime *gtime.Time `orm:"created_time" json:"createdTime"`                      // 创建时间
+	UpdatedBy   int         `orm:"updated_by"   json:"updatedBy"`                        // 更新者
+	UpdatedName string      `orm:"updated_name" json:"updatedName"`                      // 更新人
+	UpdatedTime *gtime.Time `orm:"updated_time" json:"updatedTime"`                      // 更新时间
+	DeletedTime *gtime.Time `orm:"deleted_time" json:"deletedTime"`                      // 删除时间
+}

+ 0 - 0
opms_parent/app/service/cust/.gitkeep


+ 252 - 0
opms_parent/app/service/cust/cust_customer.go

@@ -0,0 +1,252 @@
+package cust
+
+import (
+	"context"
+	"strconv"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gconv"
+
+	"dashoo.cn/micro/app/dao/cust"
+	model "dashoo.cn/micro/app/model/cust"
+	"dashoo.cn/micro/app/service"
+)
+
+type customerService struct {
+	*service.ContextService
+	Dao       *cust.CustCustomerDao
+	BelongDao *cust.CustCustomerBelongDao
+}
+
+func NewCustomerService(ctx context.Context) (svc *customerService, err error) {
+	svc = new(customerService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = cust.NewCustCustomerDao(svc.Tenant)
+	svc.BelongDao = cust.NewCustCustomerBelongDao(svc.Tenant)
+	return svc, nil
+}
+
+//创建客户
+func (c *customerService) Create(req *model.AddCustCustomerReq) (err error) {
+
+	cusTomer := new(model.CustCustomer)
+	conTact := new(model.CustCustomerContact)
+	if err = gconv.Struct(req.Cust, cusTomer); err != nil {
+		g.Log().Info("error", err)
+		return
+	}
+	if err = gconv.Struct(req.Info, conTact); err != nil {
+		return
+	}
+	g.Log().Info(err)
+	Model := c.Dao.M
+	record, err := Model.As("c").LeftJoin("cust_customer_contact ct", "c.id=ct.cust_id").Fields("c.*").Where(
+		g.Map{
+			"ct.telephone": req.Info.TelePhone,
+			"ct.cuct_name": req.Info.CuctName,
+			"c.cust_name":  req.Cust.CustName,
+		},
+	).One()
+	g.Log().Info("recordE", record.IsEmpty())
+	if err != nil || !record.IsEmpty() {
+		err = gerror.New("该客户信息已存在,不可重复添加")
+		return err
+	}
+
+	cusTomer.CustCode = strconv.Itoa(int(gtime.Timestamp()))
+	cusTomer.IsPublic = "10"
+
+	service.SetCreatedInfo(cusTomer, c.GetCxtUserId(), c.GetCxtUserName())
+	var tx *gdb.TX
+	tx, err = g.DB().Begin()
+	if err != nil {
+		err = gerror.New("事务开启失败")
+		return
+	}
+	cus_res, err := Model.Insert(cusTomer)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("cusTomer表插入失败")
+		tx.Rollback()
+		return
+	}
+	InsertId, _ := cus_res.LastInsertId()
+	conTact.CustId = int(InsertId)
+	service.SetCreatedInfo(conTact, c.GetCxtUserId(), c.GetCxtUserName())
+	_, err = cust.CustCustomerContact.Insert(conTact)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("conTact表插入失败")
+		tx.Rollback()
+		return
+	}
+	/**
+		预留逻辑判断当前登录角色是否是销售人员
+	     if 销售人员 {
+		  cusTomer.SalesId  =  当前销售人员id
+		  cusTomer.SalesName = 当前销售人员姓名
+
+	      c.BelongDao.M.Insert()
+
+		}
+
+	*/
+
+	tx.Commit()
+	return
+}
+
+//客户列表列表
+func (c *customerService) GetList(req *model.CustCustomerSearchReq) (total int, customerList []*model.CustList, err error) {
+
+	Model := c.Dao.M.As("c").LeftJoin("cust_customer_contact ct", "c.id=ct.cust_id").Where("c.is_public ", 20) //非公海客户
+	//客户名称
+	if req.CustName != "" {
+		Model = Model.Where("c.cust_name ", req.CustName)
+	}
+	//联系人
+	if req.CuctName != "" {
+		Model = Model.Where("ct.cuct_name", req.CuctName)
+	}
+	// 联系人姓名
+	if req.CustStatus != "" {
+		Model = Model.Where("ct.cuct_name", req.CuctName)
+	}
+	//所属销售
+	if req.SalesName != "" {
+		Model = Model.Where("c.sales_name ?", req.SalesName)
+	}
+	//联系人电话
+	if req.Telephone != "" {
+		Model = Model.Where("ct.telephone ?", req.Telephone)
+	}
+	total, err = Model.Fields("c.id").Count()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取总行数失败")
+		return
+	}
+	if req.PageNum == 0 {
+		req.PageNum = 1
+	}
+	fields := "c.*,ct.cuct_name,ct.telephone"
+	err = Model.Fields(fields).Page(req.PageNum, req.PageSize).Order("id asc").Scan(&customerList)
+	return
+}
+
+//分配客户
+func (c *customerService) DistriCustomer(req *model.DistriCustomer) error {
+	/**
+	   待写逻辑(销售总监或销售助理将公海客户分配给指定销售工程师)
+	   if c.user.id != 销售总监 || c.user.id!=销售助理 {
+
+	      err = gerror.New("该账号无权限操作!")
+			return
+
+			}
+	*/
+	custModel := c.Dao.M
+	rep, err := custModel.Where(cust.CustCustomer.Columns.Id+" in (?)  ", req.Ids).Where(cust.CustCustomer.Columns.IsPublic, 10).All()
+	if err != nil || rep.IsEmpty() {
+		err = gerror.New("该数据不存在")
+		return err
+	}
+	err = c.Customer(req.Ids, req.SalesId, 2)
+	if err != nil {
+		err = gerror.New("可配客户失败")
+		return err
+
+	}
+
+	return nil
+}
+
+//客户详情
+func (c *customerService) GetEntityById(id int64) (entityInfo []*model.CustCustomer, err error) {
+	Model := c.Dao.M
+
+	err = Model.Where(cust.CustCustomer.Columns.Id, id).WithAll().Scan(&entityInfo)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取用户数据失败")
+	}
+	return
+}
+
+//转移客户
+func (c *customerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo []*model.CustCustomer, err error) {
+	custModel := c.Dao.M
+	rep, err := custModel.Fields("sales_id,sales_name,id").Where(cust.CustCustomer.Columns.Id+" in (?)", req.Ids).All()
+	if err != nil || rep.IsEmpty() {
+		err = gerror.New("该数据不存在")
+		return
+	}
+	c.Customer(req.Ids, req.SalesIds, 1)
+	belongModel := c.BelongDao.M
+	maps := []map[string]interface{}{}
+	date_time := gtime.Now()
+	for _, v := range rep {
+		old_id := v.GMap().Get("id")
+		orig_sale_name := v.GMap().Get("sales_name")
+		g.Log().Info("orig_sale_name", orig_sale_name)
+		belong := map[string]interface{}{}
+		belong["cust_id"] = old_id.(int)
+		belong["sale_name"] = ""
+		belong["orig_sale_name"] = orig_sale_name
+		belong["opn_type"] = "20"
+		belong["opn_people"] = 1
+		belong["opn_datetime"] = date_time
+		belong["created_by"] = 1
+		belong["remark"] = req.Remark
+		belong["created_name"] = "admin"
+		belong["created_time"] = date_time
+		belong["opn_datetime"] = date_time
+		maps = append(maps, belong)
+	}
+	_, err = belongModel.Insert(maps)
+	if err != nil {
+		err = gerror.New("转移客户失败")
+		return
+	}
+
+	return
+}
+
+func (c *customerService) Customer(ids []int64, salesId int64, behavior int8) error {
+	custModel := c.Dao.M
+	custCustomerData := new(model.CustCustomer)
+	custCustomerData.SalesId = int(salesId)
+	switch behavior {
+	case 1:
+		custCustomerData.SalesName = "转移销售"
+		custCustomerData.IsPublic = "10"
+	case 2:
+		custCustomerData.SalesName = "分配销售"
+		custCustomerData.IsPublic = "20"
+	}
+	service.SetUpdatedInfo(custCustomerData, c.GetCxtUserId(), c.GetCxtUserName())
+	_, err := custModel.FieldsEx(
+		cust.CustCustomer.Columns.CustCode,
+		cust.CustCustomer.Columns.CustName,
+		cust.CustCustomer.Columns.AbbrName,
+		cust.CustCustomer.Columns.CustLocation,
+		cust.CustCustomer.Columns.Id,
+		cust.CustCustomer.Columns.CustAddress,
+		cust.CustCustomer.Columns.CreatedTime,
+		cust.CustCustomer.Columns.CustStatus,
+		cust.CustCustomer.Columns.CreatedBy,
+		cust.CustCustomer.Columns.CreatedName).
+		WherePri(cust.CustCustomer.Columns.Id+" in (?)", ids).Update(custCustomerData)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("转移客户变更失败")
+		return err
+	}
+
+	return nil
+}

+ 1 - 0
opms_parent/app/service/cust/cust_customer_belong.go

@@ -0,0 +1 @@
+package cust

+ 1 - 0
opms_parent/app/service/cust/cust_customer_contact.go

@@ -0,0 +1 @@
+package cust

+ 2 - 0
opms_parent/main.go

@@ -4,6 +4,7 @@ import (
 	"context"
 
 	"dashoo.cn/micro/app/handler/base"
+	"dashoo.cn/micro/app/handler/cust"
 
 	"dashoo.cn/opms_libary/micro_srv"
 	"github.com/gogf/gf/frame/g"
@@ -16,6 +17,7 @@ func main() {
 	// 创建总服务包
 	s := micro_srv.CreateAndInitService(basePath)
 	s.RegisterName("Product", new(base.ProductHandler), "")
+	s.RegisterName("Customer", new(cust.CustomerHeader), "")
 
 	// 注册服务对象
 	//s.RegisterName("Auth", new(handler.Auth), "")