瀏覽代碼

客户管理

wangxingcheng 3 年之前
父節點
當前提交
9b258b7482

+ 22 - 0
opms_parent/app/handler/base/distributor.go

@@ -6,6 +6,7 @@ import (
 	"dashoo.cn/common_definition/comm_def"
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/util/gvalid"
 
 	model "dashoo.cn/micro/app/model/base"
 	server "dashoo.cn/micro/app/service/base"
@@ -29,3 +30,24 @@ func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistrib
 	rsp.Data = g.Map{"list": list, "total": total}
 	return nil
 }
+
+// 创建
+func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistributor, rsp *comm_def.CommonMsg) error {
+
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	distributorServer, err := server.NewDistributorService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	distributorServer.Create(req)
+
+	return nil
+
+}
+
+// 编辑
+
+//删掉

+ 2 - 2
opms_parent/app/handler/base/district.go

@@ -11,14 +11,14 @@ import (
 
 type DistrictHandler struct{}
 
-//GetList 所区域列表
+//GetList 所区域列表
 func (d *DistrictHandler) GetList(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
 	districtServer, err := server.NewDistrictService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return err
 	}
-	list := districtServer.ListToTree(int(req.Id))
+	list := districtServer.ListToRegions()
 	g.Log().Info("ID", req.Id)
 	rsp.Data = g.Map{"list": list}
 	return nil

+ 118 - 0
opms_parent/app/handler/base/region.go

@@ -1 +1,119 @@
 package base
+
+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/base"
+	server "dashoo.cn/micro/app/service/base"
+)
+
+type RegionHandler struct{}
+
+//区域列表
+func (r *RegionHandler) GetList(ctx context.Context, req *model.SecBaseRegionDetailReq, rsp *comm_def.CommonMsg) error {
+	regionServer, err := server.NewSalesRegionDetailService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	total, list, err := regionServer.GetList(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	g.Log().Info("qr3r3", list)
+	rsp.Data = g.Map{"list": list, "total": total}
+	return nil
+}
+
+//创建区域
+func (r *RegionHandler) Create(ctx context.Context, req *model.AddBaseRegionDetailReq, rsp *comm_def.CommonMsg) error {
+	g.Log().Info("参数", req)
+
+	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
+		return err
+	}
+	productServer, err := server.NewSalesRegionDetailService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	err = productServer.Create(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+}
+
+//获取区域
+func (p *RegionHandler) GetRegion(ctx context.Context, null, rsp *comm_def.CommonMsg) error {
+	regionServer, err := server.NewSalesRegionService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	list := regionServer.GetListRegion()
+	g.Log().Info("region", list)
+	rsp.Data = g.Map{"list": list}
+	return nil
+}
+
+//修改
+func (p *RegionHandler) UpdateById(ctx context.Context, req *model.UpdateBaseRegionDetailReq, rsp *comm_def.CommonMsg) error {
+	regionServer, err := server.NewSalesRegionDetailService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return gerror.New("系统异常,请重新尝试")
+	}
+	err = regionServer.UpdateById(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+}
+
+//创建销售区域
+func (p *RegionHandler) CreateRegion(ctx context.Context, req *model.AddRegionReq, rsp *comm_def.CommonMsg) error {
+	regionServer, err := server.NewSalesRegionService(ctx)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	err = regionServer.Create(req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+}
+
+//删除区域省份
+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)
+		return err
+	}
+	err = regionDetailServer.DeleteByIds(req.Ids)
+	g.Log().Info("req", req)
+	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
+	if err != nil {
+		g.Log().Error(err)
+		return err
+	}
+	return nil
+
+	return nil
+}

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

@@ -15,6 +15,30 @@ import (
 
 type CustomerHeader struct{}
 
+var isPublic, noPublic = "10", "20" // 公海,非公海
+var noCustomer = true               // 区分公海列表 和 客户列表 true  公海
+
+//公海列表
+func (c *CustomerHeader) PublicGetList(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
+	}
+	req.IsPublic = noCustomer
+	g.Log().Info("publicGetlist", req)
+
+	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) GetList(ctx context.Context, req *model.CustCustomerSearchReq, rsp *comm_def.CommonMsg) error {
 	customerServer, err := server.NewCustomerService(ctx)
@@ -114,3 +138,5 @@ func (c *CustomerHeader) DistriCustomer(ctx context.Context, req *model.DistriCu
 	return nil
 
 }
+
+//删除用户

+ 15 - 0
opms_parent/app/model/base/base_distributor.go

@@ -23,6 +23,20 @@ type BaseDistributorSearchReq struct {
 	request.PageReq
 }
 
+//创建经销商字段
+type AddDistributor struct {
+	DistName      string `orm:"dist_name"       json:"distName"      v:"required#经销商名称不能为空"`              // 经销商名称
+	AbbrName      string `orm:"abbr_name"       json:"abbrName"`                                          // 助记名
+	DistDesc      string `orm:"dist_desc"       json:"distDesc"`                                          // 经销商说明
+	DistBoss      string `orm:"dist_boss"       json:"distBoss"       v:"required#负责人不能为空" `              // 负责人
+	DistBossPhone string `orm:"dist_boss_phone" json:"distBossPhone"  v:"required|phone#手机号不能为空|手机号格式错误"` // 负责人电话
+	ProvinceId    int    `orm:"province_id"     json:"provinceId"     v:"required#所属省份Id不能为空"`            // 所属省份ID
+	ProvinceDesc  string `orm:"province_desc"   json:"provinceDesc"   v:"required#所属省份Id不能为空"`            // 所属省份
+	BusinessScope string `orm:"business_scope"  json:"businessScope"  v:"required#业务范围不能为空"`              // 业务范围
+	BelongSaleId  int    `orm:"belong_sale_id"  json:"belongSaleId"   v:"required#归属销售ID不能为空"`            // 归属销售ID
+	BelongSale    string `orm:"belong_sale"     json:"belongSale"      v:"required#归属销售不能为空"`             // 归属销售
+}
+
 //列表返回字段
 type DistributorRonp struct {
 	Id            int         `orm:"id,primary"      json:"id"`            // 主健
@@ -36,6 +50,7 @@ type DistributorRonp struct {
 	BusinessScope string      `orm:"business_scope"  json:"businessScope"` // 业务范围
 	CreatedName   string      `orm:"created_name"    json:"createdName"`   // 创建人名字
 	CreatedTime   *gtime.Time `orm:"created_time"    json:"createdTime"`   // 创建时间
+	Pid           int
 	//District      *BaseDistrict `orm:"with:id=province_id"`
 	//*Contanct
 }

+ 12 - 0
opms_parent/app/model/base/base_district.go

@@ -30,3 +30,15 @@ type Province struct {
 	ParentId int    `json:"parentId"`
 	DistName string `json:"distName" `
 }
+
+type Region struct {
+	Id         int         `json:"id"`
+	RegionDesc string      `json:"regionDesc" `
+	Children   []*District `json:"children" `
+}
+
+type District struct {
+	RegionDesc string `json:"regionDesc" `
+	RegionId   int    `json:"RegionId" `
+	Id         int    `json:"id" `
+}

+ 1 - 1
opms_parent/app/model/base/base_product.go

@@ -35,7 +35,7 @@ type AddBaseProductReq struct {
 //修改数据
 type UpdateBaseProductReq struct {
 	*AddBaseProductReq
-	Id int `p:"id" v:"required# id不能为空"`
+	Id int `p:"id" json:"id" v:"required# id不能为空"`
 }
 
 //批量删除

+ 22 - 2
opms_parent/app/model/base/base_sales_region.go

@@ -2,13 +2,33 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package base
 
 import (
-	"dashoo.cn/micro/app/model/internal"
+	"dashoo.cn/opms_libary/request"
+
+	"dashoo.cn/micro/app/model/base/internal"
 )
 
 // BaseSalesRegion is the golang structure for table base_sales_region.
 type BaseSalesRegion internal.BaseSalesRegion
 
 // Fill with you ideas below.
+type RegionSeq struct {
+	RegionId int `json:"regionId" `
+	request.PageReq
+}
+
+//创建值
+type AddRegionReq struct {
+	RegionDesc string `p:"regionDesc"    json:"regionDesc"   v:"required#创建描述不能为空"`
+	UserName   string `p:"userName"    json:"userName"      v:"required#区域负责人不能为空"`
+	Remark     string
+}
+
+//只返回区域
+type RegionRep struct {
+	Id         int    `p:"id" json:"id" `
+	RegionDesc string `p:"regionDesc" json:"regionDesc" `
+	RegionCode string `p:"regionCode" json:"regionCode" `
+}

+ 47 - 2
opms_parent/app/model/base/base_sales_region_detail.go

@@ -2,13 +2,58 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package base
 
 import (
-	"dashoo.cn/micro/app/model/internal"
+	"dashoo.cn/opms_libary/request"
+	"github.com/gogf/gf/os/gtime"
+
+	"dashoo.cn/micro/app/model/base/internal"
 )
 
 // BaseSalesRegionDetail is the golang structure for table base_sales_region_detail.
 type BaseSalesRegionDetail internal.BaseSalesRegionDetail
 
 // Fill with you ideas below.
+//条件搜索
+type SecBaseRegionDetailReq struct {
+	RegionId     int    `p:"regionId"    json:"regionId"`
+	CustCode     string `p:"custCode"    json:"custCode"`
+	CustName     string `p:"custName"    json:"custName"`
+	CustIndustry string `p:"custIndustry"    json:"custIndustry"`
+	request.PageReq
+}
+
+//创建区域
+type AddBaseRegionDetailReq struct {
+	RegionId     int `p:"regionId"        json:"regionId"   v:"required#关联销售区域"`
+	ProvinceCode int `p:"provinceCode"    json:"provinceCode"   v:"required#区域编码不能为空"`
+	Remark       string
+}
+
+//列表字段
+type BaseRegionDetailRep struct {
+	Id           int        `p:"id"         json:"id"   `
+	RegionId     int        `p:"regionId"         json:"regionId"   `
+	ProvinceCode int        `p:"provinceCode"    json:"provinceCode" `
+	CreatedName  string     `p:"createdName"    json:"createdName" `
+	Count        int        `p:"count"    json:"count" `
+	DistName     string     `p:"distName"    json:"distName" `
+	CreatedTime  gtime.Time `p:"createdTime"    json:"createdTime" `
+	Remark       string     `p:"remark"    json:"remark" `
+}
+
+//更新
+
+type UpdateBaseRegionDetailReq struct {
+	*BaseSalesRegionDetail
+	Id int `p:"id"  json:"id" v:"required# id不能为空"`
+}
+
+type BaseRegionCustomer struct {
+	CustDistCode string `p:"custDistCode"  json:"custDistCode"   `
+	Count        int    `p:"count"         json:"count"   `
+}
+type DeleteBaseRegionDetailReq struct {
+	Ids int `json:"ids" v:"required# id不能为空"`
+}

+ 10 - 6
opms_parent/app/model/cust/cust_customer.go

@@ -17,10 +17,11 @@ type CustCustomer internal.CustCustomer
 // Fill with you ideas below.
 //列表搜索参数
 type CustCustomerSearchReq struct {
-	CustCode string `json:"custCode"`
-	CustName string `json:"custName"`
-	IndusTry string `json:"indusTry"`
-	Level    string `json:"level"`
+	IsPublic     bool   `json:"isPublic,omitempty"` //区分是否是公海用户列表
+	CustCode     string `json:"custCode"`
+	CustName     string `json:"custName"`
+	CustIndustry string `json:"custIndustry"`
+	CustLevel    string `json:"custLevel"`
 	request.PageReq
 }
 
@@ -65,8 +66,11 @@ type CustList struct {
 	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"` // 最后跟进时间
-	IndusTry     string      `json:"indusTry"`
-	Level        string      `json:"level"`
+	CustIndustry string      `orm:"cust_industry"  json:"custIndustry"` // 客户行业
+	CustLevel    string      `orm:"cust_level"     json:"custLlevel"`   // 客户级别(10 重点客户 20 普通客户 30非优客户)
+	CreatedName  string      `orm:"created_name"   json:"createdName"`  // 创建人
+	CreatedTime  *gtime.Time `orm:"created_time"   json:"createdTime"`  // 创建时间
+
 }
 
 //转移客户参数

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

@@ -5,6 +5,8 @@
 package cust
 
 import (
+	"github.com/gogf/gf/os/gtime"
+
 	"dashoo.cn/micro/app/model/cust/internal"
 )
 
@@ -12,3 +14,12 @@ import (
 type CustCustomerBelong internal.CustCustomerBelong
 
 // Fill with you ideas below.
+
+type AddCustomerBelong struct {
+	CustId       int         `       json:"custId" v:"required#关联客户ID不能为空"` // 关联客户
+	SaleName     string      `      json:"saleName" v:"required#归属销售不能为空"`  // 归属销售
+	OrigSaleName string      `      json:"origSaleName"   `                 // 原来归属
+	OpnType      string      `      json:"opnType"`                         // 操作方式(10分配20转移)
+	OpnPeople    string      `      json:"opnPeople" v:"required#操作人必填"`    // 操作人
+	OpnDatetime  *gtime.Time `   json:"opnDatetime" v:"required#操作时间必填"`    // 操作时间
+}

+ 21 - 2
opms_parent/app/model/cust/cust_customer_dynamics.go

@@ -2,13 +2,32 @@
 // This is auto-generated by gf cli tool. Fill this file as you wish.
 // ==========================================================================
 
-package model
+package cust
 
 import (
-	"dashoo.cn/micro/app/model/internal"
+	"github.com/gogf/gf/os/gtime"
+
+	"dashoo.cn/micro/app/model/cust/internal"
 )
 
 // CustCustomerDynamics is the golang structure for table cust_customer_dynamics.
 type CustCustomerDynamics internal.CustCustomerDynamics
 
 // Fill with you ideas below.
+
+//写入字段
+type AddCustomerDynameicsReq struct {
+	OpnPeopleId int         ` json:"opnPeopleId"` // 操作人ID
+	OpnPeople   string      ` json:"opnPeople"`   // 操作人
+	OpnDate     *gtime.Time ` json:"opnDate"`     // 操作日期
+	OpnType     string      ` json:"opnType"`     // 操作类型
+	OpnContent  string      ` json:"opnContent"`  // 操作内容
+}
+
+//详情
+type CustomerDynameicsRep struct {
+	OpnPeople  string      `    json:"opnPeople"` // 操作人
+	OpnDate    *gtime.Time `      json:"opnDate"` // 操作日期
+	OpnType    string      `     json:"opnType"`  // 操作类型
+	OpnContent string      `   json:"opnContent"` // 操作内容
+}

+ 23 - 21
opms_parent/app/model/cust/internal/cust_customer.go

@@ -10,27 +10,29 @@ import (
 
 // 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"`  // 删除时间
+	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"`   // 详细地址
+	CustIndustry string      `orm:"cust_industry"   json:"custIndustry"` //客户行业
+	CustLevel    string      `orm:"cust_level"   json:"custLevel"`       //客户级别(10 重点客户 20 普通客户 30非优客户)
+	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"`   // 删除时间
 	//Distributor  *base.BaseDistributor `orm:"with:belong_sale_id =sales_id"`      //
 	Contact *CustCustomerContact `orm:"with:cust_id=id"`
 }

+ 26 - 5
opms_parent/app/service/base/base_distributor.go

@@ -2,9 +2,11 @@ package base
 
 import (
 	"context"
+	"fmt"
 
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/util/gconv"
 
 	"dashoo.cn/micro/app/dao/base"
 	model "dashoo.cn/micro/app/model/base"
@@ -26,22 +28,23 @@ func NewDistributorService(ctx context.Context) (svc *distributorService, err er
 	return svc, nil
 }
 
-//经销商信息列表 distributorList []*model.BaseDistributorRonp
+//经销商信息列表
 func (d *distributorService) GetList(req *model.BaseDistributorSearchReq) (total int, distributorList []*model.DistributorRonp, err error) {
 	distributorModel := d.Dao.M
 
 	if req.DistCode != "" {
-		distributorModel = distributorModel.Where("dist_code", req.DistCode)
+		distributorModel = distributorModel.Where(d.Dao.Columns.DistCode+"like ?", "%"+req.DistCode+"%")
 	}
 	if req.DistName != "" {
-		distributorModel = distributorModel.Where("dist_name like ?", "%"+req.DistName+"%")
+		distributorModel = distributorModel.Where(d.Dao.Columns.DistName+"like ?", "%"+req.DistName+"%")
 	}
 	if req.BelongSale != "" {
-		distributorModel = distributorModel.Where("belong_sale like ?", "%"+req.BelongSale+"%")
+		distributorModel = distributorModel.Where(d.Dao.Columns.BelongSale+"like ?", "%"+req.BelongSale+"%")
 	}
 	if req.ProvinceId > 0 {
-		distributorModel = distributorModel.Where("province_id in (?)", req.ProvinceId)
+		distributorModel = distributorModel.Where(d.Dao.Columns.ProvinceId+" in (?)", req.ProvinceId)
 	}
+
 	g.Log().Info("搜索条件", req.ProvinceId)
 	total, err = distributorModel.Count()
 	if err != nil {
@@ -56,3 +59,21 @@ func (d *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 	g.Log().Info("返回列表", distributorList)
 	return
 }
+
+//经销商创建
+func (d *distributorService) Create(req *model.AddDistributor) (err error) {
+	DistributorData := new(model.BaseDistributor)
+	if err = gconv.Struct(req, DistributorData); err != nil {
+		return
+	}
+	service.SetCreatedInfo(DistributorData, d.GetCxtUserId(), d.GetCxtUserName())
+	Model := d.Dao.M
+	res, err := Model.Insert(DistributorData)
+	if err != nil {
+		return
+	}
+	InsertId, _ := res.LastInsertId()
+	fmt.Println(InsertId)
+	return
+
+}

+ 98 - 0
opms_parent/app/service/base/base_district.go

@@ -1 +1,99 @@
 package base
+
+import (
+	"context"
+
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/util/gconv"
+
+	"dashoo.cn/micro/app/dao/base"
+	model "dashoo.cn/micro/app/model/base"
+	"dashoo.cn/micro/app/service"
+)
+
+type districtService struct {
+	*service.ContextService
+	Dao       *base.BaseDistrictDao
+	DetailDao *base.BaseSalesRegionDetailDao
+	RegionDao *base.BaseSalesRegionDao
+}
+
+func NewDistrictService(ctx context.Context) (svc *districtService, err error) {
+	svc = new(districtService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = base.NewBaseDistrictDao(svc.Tenant)
+	svc.DetailDao = base.NewBaseSalesRegionDetailDao(svc.Tenant)
+	svc.RegionDao = base.NewBaseSalesRegionDao(svc.Tenant)
+	return svc, nil
+}
+func (d *districtService) ListToTree(Id int) []*model.T {
+	Model := d.Dao.M
+	ms := make(map[int]*model.T)
+	var distributorList []model.BaseDistrict
+	treeList := []*model.T{}
+	if Id != 0 {
+		Model = Model.Where("parent_id =", Id).WhereOr("id =", Id)
+	}
+	Model.Order("parent_id asc").Scan(&distributorList)
+	g.Log().Info("distributorList", distributorList)
+
+	for _, v := range distributorList {
+		ms[v.Id] = &model.T{
+			Id:       v.Id,
+			ParentId: v.ParentId,
+			DistName: v.DistName,
+		}
+	}
+	for _, v := range ms {
+		//if _, ok := ms[v.ParentId]; ok {
+		//	ms[v.ParentId].Children = append(ms[v.ParentId].Children, v)
+		//	continue
+		//}
+		treeList = append(treeList, v)
+	}
+	return treeList
+}
+func (d *districtService) GetProvinceInfo() (list []*model.Province) {
+
+	Model := d.Dao.M
+	err := Model.Where(base.BaseDistrict.Columns.ParentId, 0).Scan(&list)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+		return
+	}
+
+	return
+}
+func (d *districtService) ListToRegions() (region []*model.Region) {
+	RegModel := d.RegionDao.M
+	RegModel.Fields(d.RegionDao.Columns.RegionDesc, d.RegionDao.Columns.Id).Scan(&region)
+	var districtList []int
+	for _, v := range region {
+		districtList = append(districtList, v.Id)
+	}
+	Model := d.Dao.M
+	list, _ := Model.As("dis").RightJoin("base_sales_region_detail deftail", "dis.id = deftail.province_code").
+		Fields("dis.dist_name,dis.id,deftail.region_id").Where("deftail.region_id in (?)", districtList).All()
+	ms := make(map[int][]*model.District)
+	for _, v := range list.List() {
+		ms[gconv.Int(v["region_id"])] = append(ms[gconv.Int(v["region_id"])], &model.District{
+			Id:         gconv.Int(v["id"]),
+			RegionDesc: gconv.String(v["dist_name"]),
+			RegionId:   gconv.Int(v["region_id"]),
+		})
+	}
+	for _, v := range region {
+		g.Log().Info("msssss", ms[v.Id])
+		//if _, ok := ms[v.Id]; ok {
+		//	v.Children = ms[v.Id]
+		//	continue
+		//}
+		v.Children = ms[v.Id]
+	}
+	g.Log().Info("return", region)
+	return
+}

+ 61 - 0
opms_parent/app/service/base/base_sales_region.go

@@ -1 +1,62 @@
 package base
+
+import (
+	"context"
+	"strconv"
+
+	"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/base"
+	model "dashoo.cn/micro/app/model/base"
+	"dashoo.cn/micro/app/service"
+)
+
+type salesRegionService struct {
+	*service.ContextService
+	Dao    *base.BaseSalesRegionDao
+	Detail *base.BaseSalesRegionDetailDao
+}
+
+func NewSalesRegionService(ctx context.Context) (svc *salesRegionService, err error) {
+	svc = new(salesRegionService)
+	if svc.ContextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = base.NewBaseSalesRegionDao(svc.Tenant)
+	svc.Detail = base.NewBaseSalesRegionDetailDao(svc.Tenant)
+
+	return svc, nil
+}
+
+//获取区域
+func (p *salesRegionService) GetListRegion() (RegionList []*model.RegionRep) {
+	regionModel := p.Dao.M
+	err := regionModel.Order("id asc").Scan(&RegionList)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+		return
+	}
+	return
+}
+
+//创建区域
+func (p *salesRegionService) Create(req *model.AddRegionReq) (err error) {
+
+	Model := p.Dao.M
+	regionData := new(model.BaseSalesRegion)
+	if err = gconv.Struct(req, regionData); err != nil {
+		return
+	}
+	service.SetCreatedInfo(regionData, p.GetCxtUserId(), p.GetCxtUserName())
+	regionData.RegionCode = strconv.Itoa(int(gtime.Timestamp()))
+	service.SetCreatedInfo(regionData, p.GetCxtUserId(), p.GetCxtUserName())
+	_, err = Model.Insert(regionData)
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 131 - 28
opms_parent/app/service/base/base_sales_region_detail.go

@@ -5,37 +5,48 @@ import (
 
 	"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/base"
+	"dashoo.cn/micro/app/dao/cust"
 	model "dashoo.cn/micro/app/model/base"
 	"dashoo.cn/micro/app/service"
 )
 
-type salesRegionService struct {
+var EgionDetailFieldEx = []interface{}{
+	"id", "created_by",
+	"created_name",
+	"created_time",
+	"province_code",
+	"remark",
+	"updated_by",
+	"updated_name",
+	"updated_time",
+}
+
+type salesRegionDetailService struct {
 	*service.ContextService
-	Dao    *base.BaseSalesRegionDao
-	Detail *base.BaseSalesRegionDetailDao
+	Dao         *base.BaseSalesRegionDetailDao
+	District    *base.BaseDistrictDao
+	CustomerDao *cust.CustCustomerDao
 }
 
-func NewSalesRegionService(ctx context.Context) (svc *salesRegionService, err error) {
-	svc = new(salesRegionService)
+func NewSalesRegionDetailService(ctx context.Context) (svc *salesRegionDetailService, err error) {
+	svc = new(salesRegionDetailService)
 	if svc.ContextService, err = svc.Init(ctx); err != nil {
 		return nil, err
 	}
-	svc.Dao = base.NewBaseSalesRegionDao(svc.Tenant)
-	svc.Detail = base.NewBaseSalesRegionDetailDao(svc.Tenant)
-
+	svc.Dao = base.NewBaseSalesRegionDetailDao(svc.Tenant)
+	svc.District = base.NewBaseDistrictDao(svc.Tenant)
+	svc.CustomerDao = cust.NewCustCustomerDao(svc.Tenant)
 	return svc, nil
 }
-func (p *salesRegionService) GetList(req *model.RegionSeq) (total int, RegionList []*model.BaseSalesRegion, err error) {
-
-	regionModel := p.Dao.M
-	//if req.KeyWords != "" {
-	//	regionModel = regionModel.Where("prod_code", req.KeyWords)
-	//
-	//}
-	total, err = regionModel.Count()
+func (p *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (total int, RegionList []*model.BaseRegionDetailRep, err error) {
+
+	Model := p.Dao.M
+	Model = Model.Where(p.Dao.Columns.RegionId, req.RegionId).Where(p.Dao.Columns.DeletedTime + " is null")
+	total, err = Model.Count()
 	if err != nil {
 		g.Log().Error(err)
 		err = gerror.New("获取总行数失败")
@@ -44,23 +55,62 @@ func (p *salesRegionService) GetList(req *model.RegionSeq) (total int, RegionLis
 	if req.PageNum == 0 {
 		req.PageNum = 1
 	}
+	err = Model.Page(req.PageNum, req.PageSize).Order("id asc").Scan(&RegionList)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取数据失败")
+		return
+	}
+	var districtList []int
+	for _, v := range RegionList {
+		districtList = append(districtList, v.ProvinceCode)
+	}
+	CustModel := p.CustomerDao.M
+	CustModel = CustModel.Fields("count(*) as count,cust_dist_code").Where("cust_dist_code in (?)", districtList)
+	if req.CustName != "" {
+		g.Log().Info("custName", req.CustName)
 
-	err = regionModel.Page(req.PageNum, req.PageSize).Order("id asc").Scan(&RegionList)
+		CustModel = CustModel.Where(p.CustomerDao.Columns.CustName+" like ?", "%"+req.CustName+"%")
+	}
+	if req.CustCode != "" {
+		g.Log().Info("客户编码搜索", req)
+		CustModel = CustModel.Where(p.CustomerDao.Columns.CustCode+" like ?", "%"+req.CustCode+"%")
+	}
+	if req.CustIndustry != "" {
+		CustModel = CustModel.Where(p.CustomerDao.Columns.CustIndustry+" like ?", "%"+req.CustIndustry+"%")
+	}
+	total, err = Model.Fields().Count()
+
+	dist, _ := p.District.M.Fields("dist_name,dist_code").Where("dist_code in (?)", districtList).All()
+	custDist, _ := CustModel.Group("cust_dist_code").All()
+
+	for _, v := range RegionList {
+
+		for _, v2 := range dist {
+			if v.ProvinceCode == gconv.Int(v2["dist_code"]) {
+				v.DistName = gconv.String(v2["dist_name"])
+			}
+		}
+		for _, v3 := range custDist {
+			if v.ProvinceCode == gconv.Int(v3["cust_dist_code"]) {
+				v.Count = gconv.Int(v3["count"])
+			}
+		}
+	}
+	g.Log().Info("List", RegionList)
 	return
 }
 
 //创建区域
-func (p *salesRegionService) Create(req *model.AddBaseRegionReq) (err error) {
-	Model := p.Detail.M
+func (p *salesRegionDetailService) Create(req *model.AddBaseRegionDetailReq) (err error) {
+	Model := p.Dao.M
 	detailData := new(model.BaseSalesRegionDetail)
-
 	if err = gconv.Struct(req, detailData); err != nil {
 		return
 	}
 	service.SetCreatedInfo(detailData, p.GetCxtUserId(), p.GetCxtUserName())
-
-	detailData.RegionId = req.Id
-	detailData.ProvinceCode = req.RegionCode
+	detailData.RegionId = req.RegionId
+	detailData.ProvinceCode = req.ProvinceCode
 	service.SetCreatedInfo(detailData, p.GetCxtUserId(), p.GetCxtUserName())
 	_, err = Model.Insert(detailData)
 	if err != nil {
@@ -70,14 +120,67 @@ func (p *salesRegionService) Create(req *model.AddBaseRegionReq) (err error) {
 
 }
 
-//获取区域列表
-func (p *salesRegionService) GetRegion() (RegionList []*model.RegionRep) {
-	regionModel := p.Dao.M
-	err := regionModel.Order("id asc").Scan(&RegionList)
+//更新
+func (p *salesRegionDetailService) UpdateById(req *model.UpdateBaseRegionDetailReq) (err error) {
+	//uptime := gtime.New(time.Now())
+	db := p.Dao.M
+	record, err := db.FindOne("Id", req.Id)
+	if err != nil || record.IsEmpty() {
+		err = gerror.New("该数据不存在")
+		return err
+	}
+
+	productData := new(model.BaseSalesRegionDetail)
+	if err = gconv.Struct(req, productData); err != nil {
+		return
+	}
+	service.SetUpdatedInfo(productData, p.GetCxtUserId(), p.GetCxtUserName())
+	_, err = db.FieldsEx(base.BaseSalesRegionDetail.Columns.CreatedTime, base.BaseSalesRegionDetail.Columns.CreatedBy, base.BaseSalesRegionDetail.Columns.CreatedName).
+		WherePri(base.BaseSalesRegionDetail.Columns.Id, req.Id).Update(productData)
+
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("获取数据失败")
+		err = gerror.New("修改信息失败")
 		return
 	}
 	return
 }
+
+//删除
+func (p *salesRegionDetailService) DeleteByIds(req int) (err error) {
+	Model := p.Dao.M
+	regionDetail := new(model.BaseSalesRegionDetail)
+	err = Model.Where(base.BaseProduct.Columns.Id, req).Scan(&regionDetail)
+	//g.Log().Info("DeleteByIds", one)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("没有要删除的数据")
+		return
+	}
+	regionDetail.DeletedTime = gtime.Now()
+	_, err = Model.FieldsEx(EgionDetailFieldEx).
+		WherePri(p.Dao.Columns.Id, req).Update(regionDetail)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("删除数据失败")
+		return err
+	}
+	return
+
+}
+
+//省份客户
+//func (p *salesRegionDetailService) GetCustomerList(distributor []string) (list []*model.BaseRegionCustomer, err error) {
+//	Model := p.CustomerDao.M
+//	Model.Where("cust_location", "%%")
+//
+//	//if req.CustName != "" {
+//	//	Model = Model.Where("cust_name ", req.CustName)
+//	//}
+//	////客户编码
+//	//if req.CustCode != "" {
+//	//	Model = Model.Where("cust_name ", req.CustCode)
+//	//}
+//	//err = Model.Fields("count(*) counts").Page(req.PageNum, req.PageSize).Order("id desc").Scan($list)
+//	return
+//}

+ 108 - 45
opms_parent/app/service/cust/cust_customer.go

@@ -16,10 +16,15 @@ import (
 
 type customerService struct {
 	*service.ContextService
-	Dao       *cust.CustCustomerDao
-	BelongDao *cust.CustCustomerBelongDao
+	Dao         *cust.CustCustomerDao
+	BelongDao   *cust.CustCustomerBelongDao
+	DynamicsDao *cust.CustCustomerDynamicsDao
 }
 
+var isPublic, noPublic = "10", "20" // 公海,非公海
+var isTransfer int8 = 1             //转移
+var isAllocation int8 = 2           //分配 Allocation
+
 func NewCustomerService(ctx context.Context) (svc *customerService, err error) {
 	svc = new(customerService)
 	if svc.ContextService, err = svc.Init(ctx); err != nil {
@@ -27,79 +32,109 @@ func NewCustomerService(ctx context.Context) (svc *customerService, err error) {
 	}
 	svc.Dao = cust.NewCustCustomerDao(svc.Tenant)
 	svc.BelongDao = cust.NewCustCustomerBelongDao(svc.Tenant)
+	svc.DynamicsDao = cust.NewCustCustomerDynamicsDao(svc.Tenant)
 	return svc, nil
 }
 
 //创建客户
 func (c *customerService) Create(req *model.Customer) (insertId int64, err error) {
 	cusTomer := new(model.CustCustomer)
-	custBelong := new(model.CustCustomerBelong)
 	if err = gconv.Struct(req, cusTomer); err != nil {
 		g.Log().Info("error", err)
 		return
 	}
 	g.Log().Info(err)
 	Model := c.Dao.M
-	record, err := Model.Where(
-		g.Map{
-			"cust_name": req.CustName,
-		},
-	).One()
+	record, err := Model.Where(g.Map{"cust_name": req.CustName}).One()
 	g.Log().Info("recordE", record.IsEmpty())
 	if err != nil || !record.IsEmpty() {
 		err = gerror.New("该客户信息已存在,不可重复添加")
 		return
 	}
+	//OpnPeopleId int         ` json:"opnPeopleId"` // 操作人ID
+	//OpnPeople   string      ` json:"opnPeople"`   // 操作人
+	//OpnDate     *gtime.Time ` json:"opnDate"`     // 操作日期
+	//OpnType     string      ` json:"opnType"`     // 操作类型
+	//OpnContent  string      ` json:"opnContent"`  // 操作内容
+
+	//c.OperationLog()
+
+	g.Log().Info("部门ID", c.CxtUser.DeptId)
 	service.SetCreatedInfo(cusTomer, c.GetCxtUserId(), c.GetCxtUserName())
 	cusTomer.CustCode = strconv.Itoa(int(gtime.Timestamp()))
-	cusTomer.IsPublic = "20"
-	cusTomer.DeptId = c.GetCxtUserDeptId()  //部门id
-	cusTomer.DeptId = c.GetCxtUserDeptId()  //部门名称
-	cusTomer.SalesId = c.GetCxtUserId()     //  销售id
-	cusTomer.SalesName = c.GetCxtUserName() //  销售名称
+	cusTomer.IsPublic = isPublic
+	//if c.CxtUser.DeptId == 2 {
+	//	cusTomer.IsPublic = noPublic            //   非公海用户
+	//	cusTomer.DeptId = c.GetCxtUserDeptId()  //   部门id
+	//	cusTomer.DeptId = c.GetCxtUserDeptId()  //   部门名称
+	//	cusTomer.SalesId = c.GetCxtUserId()     //   销售id
+	//	cusTomer.SalesName = c.GetCxtUserName() //   销售名称
+	//}
 	res, err := Model.Insert(cusTomer)
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("cusTomer表插入失败")
+		err = gerror.New("创建失败")
+		return
 	}
 	insertId, _ = res.LastInsertId()
-	if c.CxtUser.Id == 1 { //
-		service.SetCreatedInfo(custBelong, c.GetCxtUserId(), c.GetCxtUserName())
-		custBelong.CustId = int(insertId)
-		custBelong.OpnType = "10"
-		custBelong.OpnDatetime = gtime.Now()
-		service.SetCreatedInfo(custBelong, c.GetCxtUserId(), c.GetCxtUserName())
-		_, err = c.BelongDao.Insert(custBelong)
-		if err != nil {
-			g.Log().Error(err)
-			err = gerror.New("创建失败")
-			return
-		}
-	}
+	//销售人员创建条件成立 同步belong 表
+	//custBelong := new(model.AddCustomerBelong)
+	//custBelong.CustId = int(insertId)
+	//custBelong.SaleName = "xxx"
+	//custBelong.OpnPeople = "xxxx"
+	//custBelong.OpnDatetime = gtime.Now()
+	//err = c.CreateBelong()
 	return
 }
 
+//销售人员创建 直接认领客户
+func (c *customerService) CreateBelong(req *model.AddCustomerBelong) (err error) {
+	cusTomerBelong := new(model.CustCustomerBelong)
+	if err = gconv.Struct(req, cusTomerBelong); err != nil {
+		g.Log().Info("error", err)
+		return
+	}
+	service.SetCreatedInfo(cusTomerBelong, c.GetCxtUserId(), c.GetCxtUserName())
+
+	cusTomerBelong.OpnType = isPublic
+	cusTomerBelong.OpnDatetime = gtime.Now()
+	service.SetCreatedInfo(cusTomerBelong, c.GetCxtUserId(), c.GetCxtUserName())
+	_, err = c.BelongDao.Insert(cusTomerBelong)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("创建失败")
+		return
+	}
+	return nil
+
+}
+
 //客户列表列表
 func (c *customerService) GetList(req *model.CustCustomerSearchReq) (total int, customerList []*model.CustList, err error) {
-	Model := c.Dao.M //非公海客户
-	Model.Where("is_public", 20)
+	g.Log().Info("serverS", req)
+	Model := c.Dao.M
+	if !req.IsPublic {
+		Model = Model.Where(c.Dao.Columns.SalesId, c.CxtUser.Id).Where(c.Dao.Columns.IsPublic, noPublic)
+	} else {
+		g.Log().Info("serverS", req)
+		Model = Model.Where(c.Dao.Columns.IsPublic, isPublic)
+	}
 	//客户名称
 	if req.CustName != "" {
-		Model = Model.Where("cust_name ", req.CustName)
+		Model = Model.Where(c.Dao.Columns.CustName+" like ?", "%"+req.CustName+"%")
 	}
 	//客户编码
 	if req.CustCode != "" {
-		Model = Model.Where("cust_name ", req.CustCode)
+		Model = Model.Where(c.Dao.Columns.CustCode+" like ?", "%"+req.CustCode+"%")
 	}
-
 	//客户行业
-	//if req.SalesName != "" {
-	//	Model = Model.Where("c.sales_name ?", req.SalesName)
-	//}
+	if req.CustIndustry != "" {
+		Model = Model.Where(c.Dao.Columns.CustIndustry+" like ?", "%"+req.CustIndustry+"%")
+	}
 	//客户级别
-	//if req.Telephone != "" {
-	//	Model = Model.Where("ct.telephone ?", req.Telephone)
-	//}
+	if req.CustLevel != "" {
+		Model = Model.Where(c.Dao.Columns.CustLevel, req.CustLevel)
+	}
 	total, err = Model.Fields().Count()
 	if err != nil {
 		g.Log().Error(err)
@@ -109,8 +144,7 @@ func (c *customerService) GetList(req *model.CustCustomerSearchReq) (total int,
 	if req.PageNum == 0 {
 		req.PageNum = 1
 	}
-	fields := "id,cust_code,cust_name,abbr_name,'' as indus_try,'' as level,cust_location,cust_status,follow_up_date,created_name,created_time"
-	err = Model.Fields(fields).Page(req.PageNum, req.PageSize).Order("id desc").Scan(&customerList)
+	err = Model.Page(req.PageNum, req.PageSize).Order("id desc").Scan(&customerList)
 	return
 }
 
@@ -128,12 +162,12 @@ func (c *customerService) DistriCustomer(req *model.DistriCustomer) error {
 			}
 	*/
 	custModel := c.Dao.M
-	rep, err := custModel.Where(cust.CustCustomer.Columns.Id+" in (?)  ", req.Ids).Where(cust.CustCustomer.Columns.IsPublic, 10).All()
+	rep, err := custModel.Where(cust.CustCustomer.Columns.Id+" in (?)  ", req.Ids).Where(cust.CustCustomer.Columns.IsPublic, isPublic).All()
 	if err != nil || rep.IsEmpty() {
 		err = gerror.New("该数据不存在")
 		return err
 	}
-	err = c.UpdateCustomer(req.Ids, req.SalesId, 2)
+	err = c.UpdateCustomer(req.Ids, req.SalesId, isAllocation)
 	if err != nil {
 		err = gerror.New("可配客户失败")
 		return err
@@ -163,7 +197,7 @@ func (c *customerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo
 		err = gerror.New("该数据不存在")
 		return
 	}
-	err = c.UpdateCustomer(req.Ids, req.SalesIds, 1)
+	err = c.UpdateCustomer(req.Ids, req.SalesIds, isTransfer)
 	if err != nil {
 		err = gerror.New("转移客户失败")
 		return
@@ -206,10 +240,10 @@ func (c *customerService) UpdateCustomer(ids []int64, salesId int64, behavior in
 	switch behavior {
 	case 1:
 		custCustomerData.SalesName = "转移销售"
-		custCustomerData.IsPublic = "10"
+		custCustomerData.IsPublic = isPublic
 	case 2:
 		custCustomerData.SalesName = "分配销售"
-		custCustomerData.IsPublic = "20"
+		custCustomerData.IsPublic = noPublic
 	}
 	service.SetUpdatedInfo(custCustomerData, c.GetCxtUserId(), c.GetCxtUserName())
 	_, err := custModel.FieldsEx(
@@ -231,3 +265,32 @@ func (c *customerService) UpdateCustomer(ids []int64, salesId int64, behavior in
 	}
 	return nil
 }
+
+//客户操作日志
+func (c *customerService) OperationLog(req *model.AddCustomerDynameicsReq) (err error) {
+	cusDynameics := new(model.CustCustomerDynamics)
+	if err = gconv.Struct(req, cusDynameics); err != nil {
+		g.Log().Info("error", err)
+		return
+	}
+	Model := c.Dao.M
+	service.SetCreatedInfo(cusDynameics, c.GetCxtUserId(), c.GetCxtUserName())
+	_, err = Model.Insert(cusDynameics)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("创建失败")
+		return
+	}
+	return
+}
+
+//日志详情
+func (c *customerService) OperationLogInfo(id int64) (dynamics *model.CustomerDynameicsRep, err error) {
+	Model := c.Dao.M
+	err = Model.Where(cust.CustCustomerDynamics.Columns.Id, id).Scan(&dynamics)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取用户数据失败")
+	}
+	return
+}

+ 53 - 0
opms_parent/app/service/cust/customer_dynamics.go

@@ -1 +1,54 @@
 package cust
+
+import (
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"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 customerDynamicsService struct {
+	*service.ContextService
+	Dao *cust.CustCustomerDynamicsDao
+}
+
+//func NewCustomerDynamicsService(ctx context.Context) (svc *customerDynamicsService, err error) {
+//	svc = new(customerDynamicsService)
+//	if svc.ContextService, err = svc.Init(ctx); err != nil {
+//		return nil, err
+//	}
+//	svc.Dao = cust.NewCustCustomerDynamicsDao(svc.Tenant)
+//	return svc, nil
+//}
+
+//客户操作日志
+func (c *customerDynamicsService) Create(req *model.AddCustomerDynameicsReq) (err error) {
+	cusDynameics := new(model.CustCustomerDynamics)
+	if err = gconv.Struct(req, cusDynameics); err != nil {
+		g.Log().Info("error", err)
+		return
+	}
+	Model := c.Dao.M
+	service.SetCreatedInfo(cusDynameics, c.GetCxtUserId(), c.GetCxtUserName())
+	_, err = Model.Insert(cusDynameics)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("创建失败")
+		return
+	}
+	return
+}
+
+//日志详情
+func (c *customerDynamicsService) GetEntityById(id int64) (dynamics *model.CustomerDynameicsRep, err error) {
+	Model := c.Dao.M
+	err = Model.Where(cust.CustCustomerDynamics.Columns.Id, id).Scan(&dynamics)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取用户数据失败")
+	}
+	return
+}

+ 1 - 0
opms_parent/main.go

@@ -19,6 +19,7 @@ func main() {
 	s.RegisterName("Product", new(base.ProductHandler), "")
 	s.RegisterName("Distributor", new(base.DistributorHandler), "")
 	s.RegisterName("District", new(base.DistrictHandler), "")
+	s.RegisterName("Region", new(base.RegionHandler), "")
 	s.RegisterName("Customer", new(cust.CustomerHeader), "")
 	s.RegisterName("Contant", new(cust.CustomerContantHeader), "")