wangxingcheng 2 年之前
父节点
当前提交
6d720e8231

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

@@ -51,6 +51,29 @@ func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistribut
 	return nil
 }
 
+//详情
+func (p *DistributorHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq, 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
+	}
+	list, err := distributorServer.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 (p *DistributorHandler) UpdateById(ctx context.Context, req *model.UpdateDistributorReq, rsp *comm_def.CommonMsg) error {
 

+ 3 - 3
opms_parent/app/handler/cust/contant.go

@@ -68,8 +68,8 @@ func (c *CustomerContantHeader) UpdateById(ctx context.Context, req *model.Updat
 	return nil
 }
 
-//客户联系人详情
-func (c *CustomerContantHeader) GetEntityById(ctx context.Context, req *model.ContactSeq, rsp *comm_def.CommonMsg) error {
+//客户联系人详情 //GetEntityById
+func (c *CustomerContantHeader) GetList(ctx context.Context, req *model.ContactSeq, rsp *comm_def.CommonMsg) error {
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
 		return err
 	}
@@ -78,7 +78,7 @@ func (c *CustomerContantHeader) GetEntityById(ctx context.Context, req *model.Co
 		g.Log().Error(err)
 		return gerror.New("系统异常,请重新尝试")
 	}
-	list, err := customerServer.GetEntityById(req.CustId)
+	list, err := customerServer.GetList(req.CustId)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)

+ 16 - 6
opms_parent/app/handler/cust/customer.go

@@ -117,8 +117,8 @@ func (c *CustomerHeader) GetEntityById(ctx context.Context, req *comm_def.IdsReq
 }
 
 //转移客户
-func (c *CustomerHeader) UpdateBytransfer(ctx context.Context, req *model.CustSalesReq, rsp *comm_def.CommonMsg) error {
-	if len(req.Ids) == 0 || req.SalesIds == 0 {
+func (c *CustomerHeader) UpdateBytransfer(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)
@@ -126,7 +126,11 @@ func (c *CustomerHeader) UpdateBytransfer(ctx context.Context, req *model.CustSa
 		g.Log().Error(err)
 		return gerror.New("系统异常,请重新尝试")
 	}
-	_, err = customerServer.UpdateBytransfer(req)
+	err = customerServer.UpdateBytransfer(req)
+	if err != nil {
+		return gerror.New("转移失败")
+
+	}
 	var Ids []int64
 	Ids = append(Ids, gconv.Int64(req.Ids))
 	//转移客户
@@ -151,12 +155,17 @@ func (c *CustomerHeader) DistriCustomer(ctx context.Context, req *model.DistriCu
 		return gerror.New("系统异常,请重新尝试")
 	}
 	err = customerServer.DistriCustomer(req)
-
+	if err != nil {
+		return err
+	}
+	var behavior string
 	if req.Receive == "" {
-		c.WriteCustLog(ctx, DistriCustomer, req.Ids, req)
+		behavior = DistriCustomer
+		//c.WriteCustLog(ctx, DistriCustomer, req.Ids, req)
 	} else {
-		c.WriteCustLog(ctx, Receive, req.Ids, req)
+		behavior = Receive
 	}
+	c.WriteCustLog(ctx, behavior, req.Ids, req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -300,6 +309,7 @@ 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 {
 
 	customerServer, err := server.NewCustomerService(ctx)

+ 14 - 14
opms_parent/app/model/base/base_distributor.go

@@ -39,20 +39,20 @@ type AddDistributor struct {
 
 //列表返回字段
 type DistributorRonp struct {
-	Id            int         `orm:"id,primary"      json:"id"`            // 主健
-	DistCode      string      `orm:"dist_code"       json:"distCode"`      // 经销商编码
-	DistName      string      `orm:"dist_name"       json:"distName"`      // 经销商名字
-	AbbrName      string      `orm:"abbr_name"       json:"abbrName"`      // 助记名
-	DistBoss      string      `orm:"dist_boss"       json:"distBoss"`      // 负责人
-	DistBossPhone int         `orm:"dist_boss_phone" json:"distBossPhone"` // 负责人电话
-	BelongSale    string      `orm:"belong_sale"     json:"belongSale"`    // 销售
-	ProvinceDesc  string      `orm:"province_desc"   json:"provinceDesc"`  // 省份描述
-	ProvinceId    string      `orm:"province_id"   json:"provinceId"`      // 省份Id
-	BusinessScope string      `orm:"business_scope"  json:"businessScope"` // 业务范围
-	CreatedName   string      `orm:"created_name"    json:"createdName"`   // 创建人名字
-	CreatedTime   *gtime.Time `orm:"created_time"    json:"createdTime"`   // 创建时间
-	DistDesc      string      `orm:"dist_desc"    json:"distDesc"`         // 说明
-	//District      *BaseDistrict `orm:"with:id=province_id"`
+	Id            int           `orm:"id,primary"      json:"id"`            // 主健
+	DistCode      string        `orm:"dist_code"       json:"distCode"`      // 经销商编码
+	DistName      string        `orm:"dist_name"       json:"distName"`      // 经销商名字
+	AbbrName      string        `orm:"abbr_name"       json:"abbrName"`      // 助记名
+	DistBoss      string        `orm:"dist_boss"       json:"distBoss"`      // 负责人
+	DistBossPhone int           `orm:"dist_boss_phone" json:"distBossPhone"` // 负责人电话
+	BelongSale    string        `orm:"belong_sale"     json:"belongSale"`    // 销售
+	ProvinceDesc  string        `orm:"province_desc"   json:"provinceDesc"`  // 省份描述
+	ProvinceId    string        `orm:"province_id"   json:"provinceId"`      // 省份Id
+	BusinessScope string        `orm:"business_scope"  json:"businessScope"` // 业务范围
+	CreatedName   string        `orm:"created_name"    json:"createdName"`   // 创建人名字
+	CreatedTime   *gtime.Time   `orm:"created_time"    json:"createdTime"`   // 创建时间
+	DistDesc      string        `orm:"dist_desc"    json:"distDesc"`         // 说明
+	District      *BaseDistrict `orm:"with:id=province_id"`
 	//*Contanct
 }
 

+ 2 - 1
opms_parent/app/model/cust/cust_customer.go

@@ -108,9 +108,10 @@ type CustSalesReq struct {
 	SalesIds  int64   `json:"salesIds,omitempty"`
 	SalesName string  `json:"salesName,omitempty"`
 	Remark    string  `json:"remark,omitempty"`
+	Receive   string  `json:"receive,omitempty"` //有值领取 无值分配
 }
 
-//分配客户参数
+//分配 领取 转移 客户参数
 type DistriCustomer struct {
 	Ids       []int64 `json:"ids,omitempty"`       //客户id
 	SalesId   int64   `json:"salesId,omitempty"`   //分配到销售人员的id

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

@@ -55,10 +55,7 @@ func (d *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 		err = gerror.New("获取总行数失败")
 		return
 	}
-	if req.PageNum == 0 {
-		req.PageNum = 1
-	}
-	err = distributorModel.Page(req.PageNum, req.PageSize).Order("id desc").Scan(&distributorList)
+	err = distributorModel.Page(req.GetPage()).Order("id desc").Scan(&distributorList)
 	g.Log().Info("返回列表", distributorList)
 	return
 }
@@ -81,7 +78,16 @@ func (d *distributorService) Create(req *model.AddDistributor) (err error) {
 	return
 }
 
-//修改
+//详情
+func (p *distributorService) GetEntityById(id int64) (distributorInfo *model.DistributorRonp, err error) {
+	err = p.Dao.Where(base.BaseProduct.Columns.Id, id).Scan(&distributorInfo)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取经销商数据失败")
+	}
+	return
+}
+
 //修改数据
 func (p *distributorService) UpdateById(req *model.UpdateDistributorReq) (err error) {
 	//uptime := gtime.New(time.Now())

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

@@ -86,11 +86,6 @@ func (d *districtService) ListToRegions() (region []*model.Region) {
 		})
 	}
 	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)

+ 22 - 22
opms_parent/app/service/base/base_product.go

@@ -50,6 +50,16 @@ func (p *productService) GetList(req *model.BaseProductSearchReq) (total int, pr
 	return
 }
 
+//编辑查询单条查询
+func (p *productService) GetEntityById(id int64) (product *model.BaseProduct, err error) {
+	err = p.Dao.Where(base.BaseProduct.Columns.Id, id).Scan(&product)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取用户数据失败")
+	}
+	return
+}
+
 //添加信息
 func (p *productService) Create(req *model.AddBaseProductReq) (err error) {
 	productData := new(model.BaseProduct)
@@ -67,24 +77,6 @@ func (p *productService) Create(req *model.AddBaseProductReq) (err error) {
 	return
 }
 
-//删掉数据
-func (p *productService) DeleteByIds(dicIds []int64) (err error) {
-	_, err = base.BaseProduct.Fields(base.BaseProduct.Columns.CreatedTime).
-		Where(base.BaseProduct.Columns.Id+" in (?) ", dicIds).All()
-	if err != nil {
-		g.Log().Error(err)
-		err = gerror.New("没有要删除的数据")
-		return
-	}
-	_, err = p.Dao.Delete(base.BaseProduct.Columns.Id+" in (?) ", dicIds)
-	if err != nil {
-		g.Log().Error(err)
-		err = gerror.New("删除数据失败")
-		return err
-	}
-	return
-}
-
 //修改数据
 func (p *productService) UpdateById(req *model.UpdateBaseProductReq) (err error) {
 	//uptime := gtime.New(time.Now())
@@ -112,12 +104,20 @@ func (p *productService) UpdateById(req *model.UpdateBaseProductReq) (err error)
 	return
 }
 
-//编辑查询单条查询
-func (p *productService) GetEntityById(id int64) (product *model.BaseProduct, err error) {
-	err = p.Dao.Where(base.BaseProduct.Columns.Id, id).Scan(&product)
+//删掉数据
+func (p *productService) DeleteByIds(dicIds []int64) (err error) {
+	_, err = base.BaseProduct.Fields(base.BaseProduct.Columns.CreatedTime).
+		Where(base.BaseProduct.Columns.Id+" in (?) ", dicIds).All()
 	if err != nil {
 		g.Log().Error(err)
-		return nil, gerror.New("获取用户数据失败")
+		err = gerror.New("没有要删除的数据")
+		return
+	}
+	_, err = p.Dao.Delete(base.BaseProduct.Columns.Id+" in (?) ", dicIds)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("删除数据失败")
+		return err
 	}
 	return
 }

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

@@ -53,7 +53,6 @@ func (p *salesRegionService) Create(req *model.AddRegionReq) (err error) {
 	}
 	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

+ 0 - 1
opms_parent/app/service/base/base_sales_region_detail.go

@@ -108,7 +108,6 @@ func (p *salesRegionDetailService) Create(req *model.AddBaseRegionDetailReq) (er
 	if err = gconv.Struct(req, detailData); err != nil {
 		return
 	}
-	service.SetCreatedInfo(detailData, p.GetCxtUserId(), p.GetCxtUserName())
 	detailData.RegionId = req.RegionId
 	detailData.ProvinceCode = req.ProvinceCode
 	service.SetCreatedInfo(detailData, p.GetCxtUserId(), p.GetCxtUserName())

+ 2 - 0
opms_parent/app/service/context.go

@@ -11,12 +11,14 @@ import (
 // Context 上下文管理服务
 type ContextService struct {
 	Tenant  string            `json:"tenant"`
+	Ctx     context.Context   `json:"ctx"`
 	CxtUser *request.UserInfo `json:"cxtUser"`
 }
 
 // Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改。
 func (c *ContextService) Init(ctx context.Context) (*ContextService, error) {
 	c = new(ContextService)
+	c.Ctx = ctx
 	// 获取租户码
 	tenant, err := micro_srv.GetTenant(ctx)
 	if err != nil {

+ 1 - 0
opms_parent/app/service/contract/ctr_contract.go

@@ -206,6 +206,7 @@ func (s CtrContractService) BindProduct(tx *gdb.TX, id int, product []model.CtrA
 			DeletedTime:   gtime.Now(),
 		})
 	}
+
 	if len(tocreate) != 0 {
 		_, err = tx.Insert("ctr_contract_product", tocreate)
 		if err != nil {

+ 97 - 60
opms_parent/app/service/cust/cust_customer.go

@@ -56,7 +56,6 @@ func NewCustomerService(ctx context.Context) (svc *CustomerService, err error) {
 //导出数据
 func (c *CustomerService) Derive(req *model.CustCustomerExport) (content *model.CustExport, err error) {
 	var con model.CustExport
-	req.CustCustomerSearchReq.TargetType = "11"
 	total, data, err := c.GetList(&req.CustCustomerSearchReq)
 	if err != nil {
 		return
@@ -71,18 +70,41 @@ func (c *CustomerService) Derive(req *model.CustCustomerExport) (content *model.
 
 		for ck, item := range data {
 			for index, v := range req.Columns {
-				if v == "经销商编码" {
+				if v == "客户编码" {
 					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustCode)
 				}
-				if v == "经销商名称" {
+				if v == "客户名称" {
 					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustName)
 				}
 				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.)
-				//}
+				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.CustLocation)
+				}
+				if v == "客户行业" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustIndustry)
+				}
+				if v == "客户级别" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CustLevel)
+				}
+				if v == "客户状态" {
+					var CustStatus string
+					CustStatus = "正常"
+					if item.CustStatus != "10" {
+						CustStatus = "异常"
+					}
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), CustStatus)
+				}
+				if v == "最后跟进时间" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.FollowUpDate)
+				}
+				if v == "创建时间" {
+					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.CreatedTime)
+				}
 			}
 
 		}
@@ -161,7 +183,6 @@ func (c *CustomerService) CreateBelong(req *model.AddCustomerBelong) (err error)
 
 	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)
@@ -180,10 +201,10 @@ func (c *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 	Model = Model.Where(c.Dao.Columns.DeletedTime + " is null")
 	if req.TargetType == "" {
 		if !req.IsPublic {
-			g.Log().Info("ISPUblic", "xxxxxx")
+
 			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)
 		}
 	}
@@ -313,29 +334,45 @@ func (c *CustomerService) MoveToPubic(ids []int64) error {
 
 //分配客户
 func (c *CustomerService) DistriCustomer(req *model.DistriCustomer) error {
-	custModel := c.Dao.M
+	custModel := c.Dao
 	rep, err := custModel.Where(cust.CustCustomer.Columns.Id+" in (?)  ", req.Ids).Where(cust.CustCustomer.Columns.IsPublic, isPublic).All()
-	if err != nil {
+
+	g.Log().Info("fdasfsa", len(rep))
+	if err != nil || len(rep) == 0 {
 		err = gerror.New("该数据不存在")
 		return err
 	}
+	//cust := new(model.CustCustomer)
+	var custMap = make(map[int]string)
+	for _, v := range rep {
+		custMap[v.Id] = v.SalesName
+	}
+	g.Log().Info("fadfadsfaf", custMap)
+	for _, v := range req.Ids {
+		g.Log().Info("req.Ids", v)
+		if custMap[gconv.Int(v)] != "" {
+			err = gerror.New("ID" + gconv.String(v) + "已被认领")
+			return err
+		}
+	}
 	err = c.updateCustomer(req.Ids, req.SalesId, req.SalesName)
 	if err != nil {
 		err = gerror.New("可配客户失败")
 		return err
 
 	}
-	var maps = make(map[string]string)
-	maps["remark"] = req.Remark
+
+	//belongServer := new(CustomerbelongService)
+
 	if req.Receive != "" {
-		maps["opn_type"] = AllocaTion
+		req.Receive = Receive
 	} else {
-		maps["opn_type"] = Receive
+		req.Receive = AllocaTion
 	}
-	maps["sale_name"] = req.SalesName
-	maps["opn_people"] = c.GetCxtUserName()
-	//maps["created_by"] = c.GetCxtUserId()
-	err = c.belongInsters(rep.List(), maps)
+
+	err = c.Createbelong(rep, req)
+	g.Log().Info("errr", req)
+
 	if err != nil {
 		err = gerror.New("分配客户失败")
 		return err
@@ -356,6 +393,7 @@ func (c *CustomerService) GetEntityById(ids []int64) (entityInfo []*model.CustLi
 	if err != nil {
 		g.Log().Error(err)
 		return nil, gerror.New("获取用户数据失败")
+
 	}
 	return
 }
@@ -369,7 +407,8 @@ func (c *CustomerService) CustAbstract(id int64) (followInfo *model.Follow, err
 	g.Log().Info("count", count)
 	if err != nil {
 		g.Log().Error(err)
-		return nil, gerror.New("获取用户数据失败")
+		gerror.New("获取用户数据失败")
+		return
 	}
 
 	followInfo = new(model.Follow)
@@ -380,7 +419,8 @@ func (c *CustomerService) CustAbstract(id int64) (followInfo *model.Follow, err
 
 	if err != nil {
 		g.Log().Error(err)
-		return nil, gerror.New("获取用户数据失败")
+		gerror.New("获取用户数据失败")
+		return
 	}
 
 	findOne := find.Map()
@@ -408,25 +448,22 @@ func (c *CustomerService) CustAbstract(id int64) (followInfo *model.Follow, err
 }
 
 //转移客户
-func (c *CustomerService) UpdateBytransfer(req *model.CustSalesReq) (entityInfo []*model.CustCustomer, err error) {
-	custModel := c.Dao.M
+func (c *CustomerService) UpdateBytransfer(req *model.DistriCustomer) (err error) {
+	custModel := c.Dao
 	rep, err := custModel.Fields("sales_id,sales_name,id").Where(cust.CustCustomer.Columns.Id+" in (?)", req.Ids).All()
-	if err != nil || rep.IsEmpty() {
+	if err != nil || len(rep) == 0 {
 		err = gerror.New("该数据不存在")
 		return
 	}
-	err = c.updateCustomer(req.Ids, req.SalesIds, req.SalesName)
+	err = c.updateCustomer(req.Ids, req.SalesId, req.SalesName)
 	if err != nil {
 		err = gerror.New("转移客户失败")
 		return
 	}
 
-	var maps = make(map[string]string)
-	maps["remark"] = req.Remark
-	maps["opn_type"] = OperaTion
-	maps["sale_name"] = req.SalesName
+	err = c.Createbelong(rep, req)
 
-	err = c.belongInsters(rep.List(), maps)
+	g.Log().Info("err", err)
 	if err != nil {
 		err = gerror.New("转移客户失败")
 		return
@@ -539,6 +576,13 @@ func (c *CustomerService) Mergecustomer(req *model.MergecustomerRep) (err error)
 	//所选客户联系人信息
 	List, err := ContactModel.Where(c.ContactDao.Columns.CustId+" in (?)", req.ChooseId).All()
 	g.Log().Info("list", List.List())
+	if err != nil || List.Len() > 0 {
+		err = c.Createcontact(req.Id, req.ChooseId, List.List())
+		if err != nil {
+			err = gerror.New("合并失败")
+			return
+		}
+	}
 	CustomertData := new(model.Customer)
 	if err = gconv.Struct(req, CustomertData); err != nil {
 		return
@@ -554,13 +598,7 @@ func (c *CustomerService) Mergecustomer(req *model.MergecustomerRep) (err error)
 		return
 	}
 	Model.Data(g.Map{"deleted_time": gtime.Now()}).Where(c.ContactDao.Columns.Id+" in (?)", req.ChooseId).Update()
-	if err != nil || List.Len() > 0 {
-		err = c.contactInster(req.Id, req.ChooseId, List.List())
-		if err != nil {
-			err = gerror.New("合并失败")
-			return
-		}
-	}
+
 	////所选客户销售联系人信息
 	BelongList, err := BelongDao.Where(c.BelongDao.Columns.CustId+" in (?)", req.ChooseId).All()
 	if err != nil || BelongList.Len() > 0 {
@@ -574,7 +612,7 @@ func (c *CustomerService) Mergecustomer(req *model.MergecustomerRep) (err error)
 }
 
 //联系人
-func (c *CustomerService) contactInster(id int, Ids []int64, list []map[string]interface{}) (err error) {
+func (c *CustomerService) Createcontact(id int, Ids []int64, list []map[string]interface{}) (err error) {
 	ContactModel := c.ContactDao.M
 	ContactModel.Data(g.Map{"deleted_time": gtime.Now()}).Where(c.ContactDao.Columns.CustId+" in (?)", Ids).Update()
 	maps := []map[string]interface{}{}
@@ -597,7 +635,7 @@ func (c *CustomerService) contactInster(id int, Ids []int64, list []map[string]i
 	_, err = ContactModel.Insert(maps)
 	if err != nil {
 		err = gerror.New("操作失败")
-		g.Log().Info("contactInster", err)
+		g.Log().Info("Createcontact", err)
 		return
 
 	}
@@ -626,32 +664,31 @@ func (c *CustomerService) belongInster(Id int, BelongIds []int64, SaleName strin
 	return
 }
 
-//批量插入客户归属记录表
-func (c *CustomerService) belongInsters(rep []map[string]interface{}, parameter map[string]string) (err error) {
-	belongModel := c.BelongDao.M
-	maps := []map[string]interface{}{}
+//批量插入客户归属记录表//parameter map[string]string
+func (c *CustomerService) Createbelong(rep []*model.CustCustomer, req *model.DistriCustomer) (err error) {
+	belongModel := c.BelongDao
+	var belongData []*model.CustCustomerBelong
 	date_time := gtime.Now()
+	userName := c.GetCxtUserName()
 	for _, v := range rep {
-		orig_sale_name := v["sales_name"]
-		belong := map[string]interface{}{}
-		belong["cust_id"] = v["id"].(int)
-		belong["sale_name"] = parameter["sale_name"]
-		belong["orig_sale_name"] = orig_sale_name
-		belong["opn_type"] = parameter["opn_type"]
-		belong["opn_people"] = parameter["opn_people"]
-		belong["opn_datetime"] = date_time
-		belong["created_by"] = c.GetCxtUserId()
-		belong["remark"] = parameter["remark"]
-		belong["created_name"] = c.GetCxtUserName()
-		belong["created_time"] = date_time
-		belong["opn_datetime"] = date_time
-		maps = append(maps, belong)
-	}
-	_, err = belongModel.Insert(maps)
+		orig_sale_name := v.SalesName
+		belong := new(model.CustCustomerBelong) //map[string]interface{}{}
+		belong.CustId = v.Id
+		belong.SaleName = req.SalesName
+		belong.OrigSaleName = orig_sale_name
+		belong.OpnType = req.Receive
+		belong.OpnPeople = userName
+		belong.CreatedName = userName
+		belong.OpnDatetime = date_time
+		belong.Remark = req.Remark
+		belong.CreatedBy = c.GetCxtUserId()
+		belongData = append(belongData, belong)
+	}
+	_, err = belongModel.Insert(belongData)
+	g.Log().Info("belong", belongData)
 	if err != nil {
 		err = gerror.New("插入失败")
 		return err
 	}
-
 	return
 }

+ 35 - 4
opms_parent/app/service/cust/cust_customer_belong.go

@@ -5,19 +5,20 @@ import (
 
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
 
 	"dashoo.cn/micro/app/dao/cust"
 	model "dashoo.cn/micro/app/model/cust"
 	"dashoo.cn/micro/app/service"
 )
 
-type customerbelongService struct {
+type CustomerbelongService struct {
 	*service.ContextService
 	Dao *cust.CustCustomerBelongDao
 }
 
-func NewCustomerBelongService(ctx context.Context) (svc *customerbelongService, err error) {
-	svc = new(customerbelongService)
+func NewCustomerBelongService(ctx context.Context) (svc *CustomerbelongService, err error) {
+	svc = new(CustomerbelongService)
 	if svc.ContextService, err = svc.Init(ctx); err != nil {
 		return nil, err
 	}
@@ -26,7 +27,7 @@ func NewCustomerBelongService(ctx context.Context) (svc *customerbelongService,
 }
 
 //获取客户归属信息
-func (c *customerbelongService) GetEntityById(CustId int) (Info []*model.CustomerBelongInfo, err error) {
+func (c *CustomerbelongService) GetEntityById(CustId int) (Info []*model.CustomerBelongInfo, err error) {
 	Model := c.Dao.M
 	err = Model.Where(c.Dao.Columns.CustId, CustId).Where(c.Dao.Columns.DeletedTime + " is null ").Scan(&Info)
 	if err != nil {
@@ -36,3 +37,33 @@ func (c *customerbelongService) GetEntityById(CustId int) (Info []*model.Custome
 	}
 	return
 }
+
+//批量插入客户归属记录表
+func (c *CustomerbelongService) Create(rep []*model.CustCustomer, req *model.DistriCustomer) (err error) {
+	belongModel := c.Dao
+	var belongData []*model.CustCustomerBelong
+	date_time := gtime.Now()
+	userName := c.GetCxtUserName()
+	for _, v := range rep {
+		orig_sale_name := v.SalesName
+		belong := new(model.CustCustomerBelong) //map[string]interface{}{}
+		belong.CustId = v.Id
+		belong.SaleName = req.SalesName
+		belong.OrigSaleName = orig_sale_name
+		belong.OpnType = req.Receive
+		belong.OpnPeople = userName
+		belong.CreatedName = userName
+		belong.OpnDatetime = date_time
+		belong.Remark = req.Remark
+		belong.CreatedBy = c.GetCxtUserId()
+		belongData = append(belongData, belong)
+	}
+	_, err = belongModel.Insert(belongData)
+	g.Log().Info("belong", belongData)
+	if err != nil {
+		err = gerror.New("插入失败")
+		return err
+	}
+	return
+
+}

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

@@ -76,7 +76,7 @@ func (c *customercontactService) UpdateById(req *model.UpdateCustCustomerContact
 }
 
 //获取联系人信息
-func (c *customercontactService) GetEntityById(CustId int) (Info []*model.CustCustomerContactInfo, err error) {
+func (c *customercontactService) GetList(CustId int) (Info []*model.CustCustomerContactInfo, err error) {
 	Model := c.Dao.M
 	err = Model.Where(c.Dao.Columns.CustId, CustId).Where(c.Dao.Columns.DeletedTime + " is null").Scan(&Info)
 	if err != nil {