wangxingcheng 3 years ago
parent
commit
bd97c918c0

+ 439 - 0
opms_parent/app/dao/work/internal/work_order_dynamics.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/work"
+)
+
+// WorkOrderDynamicsDao is the manager for logic model data accessing
+// and custom defined data operations functions management.
+type WorkOrderDynamicsDao struct {
+	gmvc.M
+	DB      gdb.DB
+	Table   string
+	Columns workOrderDynamicsColumns
+}
+
+// WorkOrderDynamicsColumns defines and stores column names for table work_order_dynamics.
+type workOrderDynamicsColumns struct {
+	Id          string // 主键
+	OrderId     string // 关联工单
+	OpnPeopleId string // 操作人ID
+	OpnPeople   string // 操作人
+	OpnDate     string // 操作日期
+	OpnType     string // 操作类型
+	OpnContent  string // 操作内容
+	Remark      string // 备注
+	CreatedBy   string // 创建者
+	CreatedName string // 创建人
+	CreatedTime string // 创建时间
+	UpdatedBy   string // 更新者
+	UpdatedName string // 更新人
+	UpdatedTime string // 更新时间
+	DeletedTime string // 删除时间
+}
+
+var (
+	// WorkOrderDynamics is globally public accessible object for table work_order_dynamics operations.
+	WorkOrderDynamics = WorkOrderDynamicsDao{
+		M:     g.DB("default").Model("work_order_dynamics").Safe(),
+		DB:    g.DB("default"),
+		Table: "work_order_dynamics",
+		Columns: workOrderDynamicsColumns{
+			Id:          "id",
+			OrderId:     "order_id",
+			OpnPeopleId: "opn_people_id",
+			OpnPeople:   "opn_people",
+			OpnDate:     "opn_date",
+			OpnType:     "opn_type",
+			OpnContent:  "opn_content",
+			Remark:      "remark",
+			CreatedBy:   "created_by",
+			CreatedName: "created_name",
+			CreatedTime: "created_time",
+			UpdatedBy:   "updated_by",
+			UpdatedName: "updated_name",
+			UpdatedTime: "updated_time",
+			DeletedTime: "deleted_time",
+		},
+	}
+)
+
+func NewWorkOrderDynamicsDao(tenant string) WorkOrderDynamicsDao {
+	var dao WorkOrderDynamicsDao
+	dao = WorkOrderDynamicsDao{
+		M:     g.DB(tenant).Model("work_order_dynamics").Safe(),
+		DB:    g.DB(tenant),
+		Table: "work_order_dynamics",
+		Columns: workOrderDynamicsColumns{
+			Id:          "id",
+			OrderId:     "order_id",
+			OpnPeopleId: "opn_people_id",
+			OpnPeople:   "opn_people",
+			OpnDate:     "opn_date",
+			OpnType:     "opn_type",
+			OpnContent:  "opn_content",
+			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 *WorkOrderDynamicsDao) Ctx(ctx context.Context) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (d *WorkOrderDynamicsDao) As(as string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (d *WorkOrderDynamicsDao) TX(tx *gdb.TX) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (d *WorkOrderDynamicsDao) Master() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Slave() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Slave()}
+}
+
+// Args sets custom arguments for model operation.
+func (d *WorkOrderDynamicsDao) Args(args ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) LeftJoin(table ...string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) RightJoin(table ...string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) InnerJoin(table ...string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Fields(fieldNamesOrMapStruct ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) FieldsEx(fieldNamesOrMapStruct ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (d *WorkOrderDynamicsDao) Option(option int) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) OmitEmpty() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (d *WorkOrderDynamicsDao) Filter() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Where(where interface{}, args ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) WherePri(where interface{}, args ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (d *WorkOrderDynamicsDao) And(where interface{}, args ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (d *WorkOrderDynamicsDao) Or(where interface{}, args ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (d *WorkOrderDynamicsDao) Group(groupBy string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (d *WorkOrderDynamicsDao) Order(orderBy ...string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Limit(limit ...int) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Offset(offset int) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Page(page, limit int) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (d *WorkOrderDynamicsDao) Batch(batch int) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Cache(duration time.Duration, name ...string) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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 *WorkOrderDynamicsDao) Data(data ...interface{}) *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{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.WorkOrderDynamics.
+// 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 *WorkOrderDynamicsDao) All(where ...interface{}) ([]*model.WorkOrderDynamics, error) {
+	all, err := d.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrderDynamics
+	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.WorkOrderDynamics.
+// 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 *WorkOrderDynamicsDao) One(where ...interface{}) (*model.WorkOrderDynamics, error) {
+	one, err := d.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrderDynamics
+	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 *WorkOrderDynamicsDao) FindOne(where ...interface{}) (*model.WorkOrderDynamics, error) {
+	one, err := d.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *model.WorkOrderDynamics
+	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 *WorkOrderDynamicsDao) FindAll(where ...interface{}) ([]*model.WorkOrderDynamics, error) {
+	all, err := d.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*model.WorkOrderDynamics
+	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 *WorkOrderDynamicsDao) 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 *WorkOrderDynamicsDao) 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 *WorkOrderDynamicsDao) Scan(pointer interface{}, where ...interface{}) error {
+	return d.M.Scan(pointer, where...)
+}
+
+// Chunk iterates the table with given size and callback function.
+func (d *WorkOrderDynamicsDao) Chunk(limit int, callback func(entities []*model.WorkOrderDynamics, err error) bool) {
+	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*model.WorkOrderDynamics
+		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 *WorkOrderDynamicsDao) LockUpdate() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (d *WorkOrderDynamicsDao) LockShared() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (d *WorkOrderDynamicsDao) Unscoped() *WorkOrderDynamicsDao {
+	return &WorkOrderDynamicsDao{M: d.M.Unscoped()}
+}

+ 36 - 0
opms_parent/app/dao/work/work_order.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package work
+
+import (
+	"dashoo.cn/micro/app/dao/work/internal"
+)
+
+// workOrderDao 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 workOrderDao struct {
+	internal.WorkOrderDao
+}
+
+var (
+	// WorkOrder is globally public accessible object for table work_order operations.
+	WorkOrder = workOrderDao{
+		internal.WorkOrder,
+	}
+)
+
+type WorkOrderDao struct {
+	internal.WorkOrderDao
+}
+
+func NewWorkOrderDao(tenant string) *WorkOrderDao {
+	dao := internal.NewWorkOrderDao(tenant)
+	return &WorkOrderDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 36 - 0
opms_parent/app/dao/work/work_order_type.go

@@ -0,0 +1,36 @@
+// ============================================================================
+// This is auto-generated by gf cli tool only once. Fill this file as you wish.
+// ============================================================================
+
+package work
+
+import (
+	"dashoo.cn/micro/app/dao/work/internal"
+)
+
+// workOrderTypeDao 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 workOrderTypeDao struct {
+	internal.WorkOrderTypeDao
+}
+
+var (
+	// WorkOrderType is globally public accessible object for table work_order_type operations.
+	WorkOrderType = workOrderTypeDao{
+		internal.WorkOrderType,
+	}
+)
+
+type WorkOrderTypeDao struct {
+	internal.WorkOrderTypeDao
+}
+
+func NewWorkOrderTypeDao(tenant string) *WorkOrderTypeDao {
+	dao := internal.NewWorkOrderTypeDao(tenant)
+	return &WorkOrderTypeDao{
+		dao,
+	}
+}
+
+// Fill with you ideas below.

+ 1 - 1
opms_parent/app/handler/base/region.go

@@ -100,7 +100,7 @@ func (p *RegionHandler) CreateRegion(ctx context.Context, req *model.AddRegionRe
 }
 
 //删除区域省份
-func (p *RegionHandler) DeleteById(ctx context.Context, req *model.DeleteBaseRegionDetailReq, rsp *comm_def.CommonMsg) error {
+func (p *RegionHandler) DeleteByIds(ctx context.Context, req *model.DeleteBaseRegionDetailReq, rsp *comm_def.CommonMsg) error {
 	regionDetailServer, err := server.NewSalesRegionDetailService(ctx)
 	if err != nil {
 		g.Log().Error(err)

+ 26 - 19
opms_parent/app/handler/cust/customer.go

@@ -27,6 +27,7 @@ const (
 	MoveToPubic      = "移入公海"
 	Mergecustomer    = "合并客户"
 	UpdateById       = "修改客户"
+	Receive          = "领取"
 )
 
 //公海列表
@@ -59,6 +60,7 @@ func (c *CustomerHeader) GetList(ctx context.Context, req *model.CustCustomerSea
 		return err
 	}
 	total, list, err := customerServer.GetList(req)
+
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -142,6 +144,7 @@ func (c *CustomerHeader) DistriCustomer(ctx context.Context, req *model.DistriCu
 	if len(req.Ids) == 0 || req.SalesId == 0 {
 		return gerror.New("参数有误!")
 	}
+	g.Log().Info("DistriCustomer", req.Ids)
 	customerServer, err := server.NewCustomerService(ctx)
 	if err != nil {
 		g.Log().Error(err)
@@ -149,7 +152,11 @@ func (c *CustomerHeader) DistriCustomer(ctx context.Context, req *model.DistriCu
 	}
 	err = customerServer.DistriCustomer(req)
 
-	c.WriteCustLog(ctx, DistriCustomer, req.Ids, req)
+	if req.Receive == "" {
+		c.WriteCustLog(ctx, DistriCustomer, req.Ids, req)
+	} else {
+		c.WriteCustLog(ctx, Receive, req.Ids, req)
+	}
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -293,21 +300,21 @@ func (c *CustomerHeader) WriteCustLog(ctx context.Context, custType string, cust
 	CustomerService.OperationLog(ctx, custId, custDynameics)
 }
 
-//func (c *CustomerHeader) DeriveList(ctx context.Context, req *model.CustCustomerExport, rsp *comm_def.CommonMsg) error {
-//	//s := g.Server()
-//	customerServer, err := server.NewCustomerService(ctx)
-//	if err != nil {
-//		g.Log().Error(err)
-//		return gerror.New("系统异常,请重新尝试")
-//	}
-//	//g.Server()
-//	//r := new(ghttp.Request)
-//	buffer, _ := customerServer.Derive(req)
-//	//fileName := gconv.String(gtime.Now()) + ".csv"
-//	//r.Response.Header().Set("Content-Type", "text/csv")
-//	//r.Response.Header().Set("Content-Disposition", "attachment;filename="+fileName)
-//	//r.Response.Write(buffer.Bytes())
-//
-//	rsp.Data = g.Map{"list": buffer}
-//	return nil
-//}
+func (c *CustomerHeader) DeriveList(ctx context.Context, req *model.CustCustomerExport, rsp *comm_def.CommonMsg) error {
+	//s := g.Server()
+	customerServer, err := server.NewCustomerService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("系统异常,请重新尝试")
+	}
+	//g.Server()
+	//r := new(ghttp.Request)
+	buffer, _ := customerServer.Derive(req)
+	//fileName := gconv.String(gtime.Now()) + ".csv"
+	//r.Response.Header().Set("Content-Type", "text/csv")
+	//r.Response.Header().Set("Content-Disposition", "attachment;filename="+fileName)
+	//r.Response.Write(buffer.Bytes())
+
+	rsp.Data = g.Map{"list": buffer}
+	return nil
+}

+ 33 - 5
opms_parent/app/handler/work/workorder.go

@@ -32,8 +32,36 @@ func (w *WorkOrderHandler) GetList(ctx context.Context, req *model.WorkOrderSear
 
 }
 
-//新增工单
-//func (w *WorkOrderHandler) Create(ctx context.Context, req *model., rsp *comm_def.CommonMsg) error {
-//	return nil
-//
-//}
+//导出
+func (w *WorkOrderHandler) DeriveList(ctx context.Context, req *model.WorkOrderExport, rsp *comm_def.CommonMsg) error {
+	orderServer, err := server.NewOrderService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	con, err := orderServer.DeriveList(req)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	rsp.Data = g.Map{"list": con}
+	return nil
+
+}
+
+//工单详情
+func (w *WorkOrderHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
+	orderServer, err := server.NewOrderService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	detail, err := orderServer.GetEntityById(req)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	rsp.Data = g.Map{"list": detail}
+	return nil
+
+}

+ 13 - 12
opms_parent/app/model/cust/cust_customer.go

@@ -73,18 +73,18 @@ type Information struct {
 
 //返回信息
 type CustList 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)
-	FollowUpDate *gtime.Time `orm:"follow_up_date" json:"followUpDate"` // 最后跟进时间
-	CustIndustry string      `orm:"cust_industry"  json:"custIndustry"` // 客户行业
-	CustLevel    string      `orm:"cust_level"     json:"custLevel"`    // 客户级别(10 重点客户 20 普通客户 30非优客户)
-	CreatedName  string      `orm:"created_name"   json:"createdName"`  // 创建人
-	CreatedTime  *gtime.Time `orm:"created_time"   json:"createdTime"`  // 创建时间
+	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)
+	FollowUpDate string `orm:"follow_up_date" json:"followUpDate"` // 最后跟进时间
+	CustIndustry string `orm:"cust_industry"  json:"custIndustry"` // 客户行业
+	CustLevel    string `orm:"cust_level"     json:"custLevel"`    // 客户级别(10 重点客户 20 普通客户 30非优客户)
+	CreatedName  string `orm:"created_name"   json:"createdName"`  // 创建人
+	CreatedTime  string `orm:"created_time"   json:"createdTime"`  // 创建时间
 	//Follow       *Follow     `json:"follow"`
 }
 
@@ -115,6 +115,7 @@ type DistriCustomer struct {
 	SalesId   int64   `json:"salesId,omitempty"`   //分配到销售人员的id
 	SalesName string  `json:"salesName,omitempty"` //分配到销售人员的姓名
 	Remark    string  `json:"remark,omitempty"`
+	Receive   string  `json:"receive,omitempty"` //有值领取 无值分配
 }
 
 //删除客户参数

+ 32 - 0
opms_parent/app/model/work/internal/work_order.go

@@ -0,0 +1,32 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// WorkOrder is the golang structure for table work_order.
+type WorkOrder struct {
+	Id             int         `orm:"id,primary"       json:"id"`             // 主键
+	OrderTypeId    int         `orm:"order_type_id"    json:"orderTypeId"`    // 工单类型
+	OrderTypeDesc  string      `orm:"order_type_desc"  json:"orderTypeDesc"`  // 工单类型描述
+	OrderStatus    string      `orm:"order_status"     json:"orderStatus"`    // 工单状态(10发起20审批中30审批通过40审批拒绝50关闭)
+	WorkflowId     int         `orm:"workflow_id"      json:"workflowId"`     // 关联工作流
+	FormId         int         `orm:"form_id"          json:"formId"`         // 关联表单
+	FormData       string      `orm:"form_data"        json:"formData"`       // 表单信息
+	AssignUserId   int         `orm:"assign_user_id"   json:"assignUserId"`   // 分派人员ID
+	AssignUserName string      `orm:"assign_user_name" json:"assignUserName"` // 分派人员姓名
+	Feedback       string      `orm:"feedback"         json:"feedback"`       // 反馈信息
+	File           string      `orm:"file"             json:"file"`           // 相关文件
+	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"`    // 删除时间
+}

+ 28 - 0
opms_parent/app/model/work/internal/work_order_dynamics.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"
+)
+
+// WorkOrderDynamics is the golang structure for table work_order_dynamics.
+type WorkOrderDynamics struct {
+	Id          int         `orm:"id"            json:"id"`          // 主键
+	OrderId     int         `orm:"order_id"      json:"orderId"`     // 关联工单
+	OpnPeopleId int         `orm:"opn_people_id" json:"opnPeopleId"` // 操作人ID
+	OpnPeople   string      `orm:"opn_people"    json:"opnPeople"`   // 操作人
+	OpnDate     *gtime.Time `orm:"opn_date"      json:"opnDate"`     // 操作日期
+	OpnType     string      `orm:"opn_type"      json:"opnType"`     // 操作类型
+	OpnContent  string      `orm:"opn_content"   json:"opnContent"`  // 操作内容
+	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"` // 删除时间
+}

+ 25 - 0
opms_parent/app/model/work/internal/work_order_type.go

@@ -0,0 +1,25 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. DO NOT EDIT THIS FILE MANUALLY.
+// ==========================================================================
+
+package internal
+
+import (
+	"github.com/gogf/gf/os/gtime"
+)
+
+// WorkOrderType is the golang structure for table work_order_type.
+type WorkOrderType struct {
+	Id          int         `orm:"id,primary"   json:"id"`          // 主键
+	Desc        string      `orm:"desc"         json:"desc"`        // 描述
+	WorkflowId  int         `orm:"workflow_id"  json:"workflowId"`  // 关联流程
+	FormId      int         `orm:"form_id"      json:"formId"`      // 关联表单
+	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"` // 删除时间
+}

+ 60 - 0
opms_parent/app/model/work/work_order.go

@@ -0,0 +1,60 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package work
+
+import (
+	"dashoo.cn/opms_libary/request"
+	"github.com/gogf/gf/os/gtime"
+
+	internal2 "dashoo.cn/micro/app/model/work/internal"
+)
+
+// WorkOrder is the golang structure for table work_order.
+type WorkOrder internal2.WorkOrder
+
+// Fill with you ideas below.
+
+type WorkOrderSearchReq struct {
+	OrderTypeId    int    `json:"orderTypeId,omitempty"` //工单类型
+	OrderStatus    string `json:"orderStatus"`           //工单状态
+	AssignUserName string `json:"assignUserName"`        // 分派人员姓名
+	request.PageReq
+}
+
+//列表返回字段
+type WorkOrderList struct {
+	Id             int         `  json:"id"`             // 主健
+	OrderTypeId    string      `  json:"orderTypeId"`    // 工单类型
+	OrderTypeDesc  string      `  json:"orderTypeDesc"`  // 工单类型描述
+	OrderStatus    string      `  json:"orderStatus"`    // 工单状态
+	AssignUserName string      `  json:"assignUserName"` // 分派人员姓名
+	FeedBack       string      `  json:"feedBack"`       // 反馈信息
+	CreatedName    string      `  json:"createName"`     //创建人
+	CreatedTime    *gtime.Time `  json:"createTime"`     //创建时间
+}
+
+//导出
+type WorkOrderExport struct {
+	WorkOrderSearchReq
+	Columns []string `json:"columns"` // 导出列
+}
+
+//导出字节流
+
+type WorkByteExport struct {
+	Content []byte `json:"content"` // 导出数据流
+}
+
+//详情返回字段
+type WorkDetail struct {
+	Id             int         `  json:"id"`             // 主健
+	OrderTypeDesc  string      `  json:"orderTypeDesc"`  // 工单类型描述
+	OrderStatus    string      `  json:"orderStatus"`    // 工单状态
+	AssignUserName string      `  json:"assignUserName"` // 分派人员姓名
+	FeedBack       string      `  json:"feedBack"`       // 反馈信息
+	CreatedName    string      `  json:"createName"`     //创建人
+	CreatedTime    *gtime.Time `  json:"createTime"`     //创建时间
+
+}

+ 14 - 0
opms_parent/app/model/work/work_order_dynamics.go

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

+ 14 - 0
opms_parent/app/model/work/work_order_type.go

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

+ 36 - 44
opms_parent/app/service/cust/cust_customer.go

@@ -11,6 +11,7 @@ import (
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/text/gstr"
 	"github.com/gogf/gf/util/gconv"
 
 	"dashoo.cn/micro/app/dao/cust"
@@ -33,7 +34,7 @@ type CustomerService struct {
 var isPublic, noPublic = "10", "20" // 公海,非公海
 var isTransfer int8 = 1             //转移
 var isAllocation int8 = 2           //分配 Allocation
-var OperaTion, AllocaTion = "20", "10"
+var OperaTion, AllocaTion, Receive = "20", "10", "30"
 
 type OpnType struct {
 	OperaTion string
@@ -76,8 +77,11 @@ func (c *CustomerService) Derive(req *model.CustCustomerExport) (content *model.
 				if v == "经销商名称" {
 					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustName)
 				}
-				//if v == "" {
-				//	f.SetCe
+				if v == "助记名" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.AbbrName)
+				}
+				//if v == "所在地区" {
+				//	f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.)
 				//}
 			}
 
@@ -91,32 +95,6 @@ func (c *CustomerService) Derive(req *model.CustCustomerExport) (content *model.
 	con.Content = buffer.Bytes()
 
 	return &con, err
-
-	//bytesBuffer = &bytes.Buffer{}
-	//bytesBuffer.WriteString("xEFxBBxBF")
-	//
-	//w := csv.NewWriter(bytesBuffer)
-	//// 写入数据
-	//w.Write(derivetable)
-	//w.Flush()
-	//// Map写入
-	//m := make(map[int][]string)
-	//for k, v := range data {
-	//	m[k] = []string{v.CustCode, v.CustName, v.AbbrName, v.CustLocation, v.CustIndustry, v.CustLevel, v.CustStatus,
-	//		gconv.String(v.FollowUpDate), v.CreatedName, gconv.String(v.CreatedTime)}
-	//}
-	//// 按照key排序
-	//var keys []int
-	//for k := range m {
-	//	keys = append(keys, k)
-	//}
-	//sort.Ints(keys)
-	//for _, key := range keys {
-	//	w.Write(m[key])
-	//	// 刷新缓冲
-	//}
-	//w.Flush()
-	//return
 }
 
 //创建客户
@@ -235,6 +213,11 @@ func (c *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 		req.PageNum = 1
 	}
 	err = Model.Page(req.PageNum, req.PageSize).Order("id desc").Scan(&customerList)
+	for _, v := range customerList {
+		times := gconv.String(v.CreatedTime)
+		v.FollowUpDate = gstr.SubStr(v.FollowUpDate, 0, 16)
+		v.CreatedTime = gstr.SubStr(times, 0, 16)
+	}
 	return
 }
 
@@ -325,15 +308,6 @@ func (c *CustomerService) MoveToPubic(ids []int64) error {
 
 //分配客户
 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, isPublic).All()
 	if err != nil || rep.IsEmpty() {
@@ -348,11 +322,16 @@ func (c *CustomerService) DistriCustomer(req *model.DistriCustomer) error {
 	}
 	var maps = make(map[string]string)
 	maps["remark"] = req.Remark
-	maps["opn_type"] = AllocaTion
+	if req.Receive != "" {
+		maps["opn_type"] = AllocaTion
+	} else {
+		maps["opn_type"] = Receive
+	}
 	maps["sale_name"] = req.SalesName
+	maps["opn_people"] = c.GetCxtUserName()
 	err = c.belongInsters(rep.List(), maps)
 	if err != nil {
-		err = gerror.New("转移客户失败")
+		err = gerror.New("分配客户失败")
 		return err
 	}
 	return nil
@@ -436,6 +415,7 @@ func (c *CustomerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo
 	maps["remark"] = req.Remark
 	maps["opn_type"] = OperaTion
 	maps["sale_name"] = req.SalesName
+
 	err = c.belongInsters(rep.List(), maps)
 	if err != nil {
 		err = gerror.New("转移客户失败")
@@ -514,7 +494,7 @@ func (c *CustomerService) DynamicsList(req *model.CustomerDynameicsReq) (total i
 		req.PageNum = 1
 	}
 	dynamics := []*model.CustomerDynameicsRep{}
-	err = Model.Page(req.PageNum, req.PageSize).Where("cust_id = ", req.CustId).Order("id desc").Scan(&dynamics)
+	err = Model.Page(req.PageNum, req.PageSize).Where("cust_id = ", req.CustId).Order("created_time desc").Scan(&dynamics)
 	dynamicsList := make(map[string][]*model.CustomerDynameicsRep)
 
 	for _, v := range dynamics {
@@ -528,8 +508,20 @@ func (c *CustomerService) DynamicsList(req *model.CustomerDynameicsReq) (total i
 		})
 
 	}
-	g.Log().Info("DynamicsList----", dynamicsList)
+	g.Log().Info("DynamicsList----", dynamics)
+	//var ks []string
+	//for k, _ := range dynamicsList {
+	//	ks = append(ks, k)
+	//}
+	//sort.Sort(sort.Reverse(ks))
 	result = append(result, dynamicsList)
+	//var sslice []string
+	//for key, _ := range result {
+	//	sslice = append(sslice, key)
+	//}
+	//sort.Strings(sslice)
+
+	g.Log().Info("Dy---", result)
 	return
 }
 
@@ -646,9 +638,9 @@ func (c *CustomerService) belongInsters(rep []map[string]interface{}, parameter
 		belong["sale_name"] = parameter["sale_name"]
 		belong["orig_sale_name"] = orig_sale_name
 		belong["opn_type"] = parameter["opn_type"]
-		belong["opn_people"] = 1
+		belong["opn_people"] = parameter["opn_people"]
 		belong["opn_datetime"] = date_time
-		belong["created_by"] = 1
+		belong["created_by"] = parameter["created_by"]
 		belong["remark"] = parameter["remark"]
 		belong["created_name"] = "admin"
 		belong["created_time"] = date_time

+ 70 - 0
opms_parent/app/service/work/work_order.go

@@ -1,8 +1,12 @@
 package work
 
 import (
+	"bytes"
 	"context"
+	"strconv"
 
+	"dashoo.cn/common_definition/comm_def"
+	"github.com/360EntSecGroup-Skylar/excelize"
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 
@@ -56,3 +60,69 @@ func (w *OrderService) GetList(req *model.WorkOrderSearchReq) (total int, OrderL
 	}
 	return
 }
+
+// 导出
+func (w *OrderService) DeriveList(req *model.WorkOrderExport) (content *model.WorkByteExport, err error) {
+	var con model.WorkByteExport
+	req.WorkOrderSearchReq.PageSize = 10
+	total, data, err := w.GetList(&req.WorkOrderSearchReq)
+	if err != nil {
+		return
+	}
+	f := excelize.NewFile()
+	index := f.NewSheet("Sheet1")
+	for index, item := range req.Columns {
+		sheetPosition := service.Div(index+1) + "1"
+		f.SetCellValue("Sheet1", sheetPosition, item)
+	}
+	if total > 0 {
+
+		for ck, item := range data {
+			for index, v := range req.Columns {
+				if v == "工单类型" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.OrderTypeDesc)
+				}
+				if v == "工单状态" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), MapStatus[item.OrderStatus])
+				}
+				if v == "分派人员" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.AssignUserName)
+				}
+				if v == "反馈信息" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.FeedBack)
+				}
+				if v == "创建人" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CreatedName)
+				}
+				if v == "创建时间" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CreatedTime)
+				}
+			}
+
+		}
+
+	}
+	f.SetActiveSheet(index)
+	var buffer *bytes.Buffer
+	buffer, _ = f.WriteToBuffer()
+	con.Content = buffer.Bytes()
+	return &con, err
+}
+
+//详情
+func (w *OrderService) GetEntityById(req *comm_def.IdReq) (detail *model.WorkDetail, err error) {
+	Model := w.Dao.M
+	err = Model.Where(w.Dao.Columns.DeletedTime+" is null ").Where(w.Dao.Columns.Id, req.Id).Scan(&detail)
+	if err != nil {
+		g.Log().Error(err)
+		gerror.New("获取详情失败")
+		return
+	}
+	return
+}
+
+//删除
+
+//修改
+
+//动态