Parcourir la source

feature(bug、优化):
1、经销商创建删除问题修改
2、项目必填字段失效问题
3、项目审批线上调试修改
4、跟进任务添加跟进人过滤
5、我的客户、下属的客户数据范围调整

ZZH-wl il y a 2 ans
Parent
commit
f266e1dd1b

+ 1 - 1
opms_admin/app/model/sys_user.go

@@ -59,7 +59,7 @@ type SetUserReq struct {
 	NickName string `p:"nickName" v:"required#用户昵称不能为空"`
 	Email    string `p:"email" v:"email#邮箱格式错误"` //邮箱
 	Phone    string `p:"phone" v:"required|phone#手机号不能为空|手机号格式错误"`
-	Sex      string `p:"sex" v:"in:10,20,30#状态只能为10、20、30"`
+	Sex      string `p:"sex" v:"in:10,20,30#性别只能为10、20、30"`
 	Status   string `p:"status" v:"required|in:10,20#状态不能为空|状态只能为10或20"`
 	Remark   string `p:"remark"`
 	IsAdmin  int    `p:"isAdmin"` // 是否后台管理员 1 是  0   否

+ 4 - 4
opms_admin/app/service/sys_user_datascope.go

@@ -158,7 +158,7 @@ func (s *UserService) GetDataScope(userId int) (where g.Map, err error) {
 		return g.Map{"userIds": userId}, nil
 	}
 	// 数据集合权限 10:全部数据权限 20:自定数据权限 30:本部门数据权限 40:本部门及以下数据权限 50:仅本人数据权限
-	userIdArr := gset.New()
+	userIdArr := gset.NewIntSet()
 	deptFlag, deptAndSonFlag := false, false
 	for _, role := range roles {
 		switch role.DataScope {
@@ -171,7 +171,7 @@ func (s *UserService) GetDataScope(userId int) (where g.Map, err error) {
 			if err != nil {
 				return nil, err
 			}
-			userIdArr.Add(gconv.Interfaces(userIds)...)
+			userIdArr.Add(gconv.Ints(userIds)...)
 		case "30": // 本部门数据权限
 			if deptAndSonFlag || deptFlag {
 				continue
@@ -181,7 +181,7 @@ func (s *UserService) GetDataScope(userId int) (where g.Map, err error) {
 			if err != nil {
 				return nil, err
 			}
-			userIdArr.Add(gconv.Interfaces(userIds)...)
+			userIdArr.Add(gconv.Ints(userIds)...)
 		case "40": // 本部门及以下数据权限
 			if deptAndSonFlag {
 				continue
@@ -197,7 +197,7 @@ func (s *UserService) GetDataScope(userId int) (where g.Map, err error) {
 			if err != nil {
 				return nil, err
 			}
-			userIdArr.Add(gconv.Interfaces(userIds)...)
+			userIdArr.Add(gconv.Ints(userIds)...)
 		case "50": // 仅本人数据权限
 			userIdArr.Add(userId)
 		}

+ 4 - 12
opms_parent/app/handler/base/distributor.go

@@ -30,15 +30,13 @@ func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistrib
 	return nil
 }
 
-//Create 创建
+// Create 创建
 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 {
-
 		return err
 	}
 	_, err = distributorServer.Create(req)
@@ -48,46 +46,40 @@ func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistribut
 	return nil
 }
 
-//GetEntityById 详情
+// GetEntityById 详情
 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 {
-
 		return err
 	}
 	list, err := distributorServer.GetEntityById(req.Id)
 	if err != nil {
-
 		return err
 	}
 	rsp.Data = g.Map{"list": list}
 	return nil
 }
 
-//UpdateById 编辑
+// UpdateById 编辑
 func (p *DistributorHandler) UpdateById(ctx context.Context, req *model.UpdateDistributorReq, rsp *comm_def.CommonMsg) error {
-
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
 		return err
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-
 		return err
 	}
 	err = distributorServer.UpdateById(req)
 	if err != nil {
-
 		return err
 	}
 	return nil
 }
 
-//DeleteByIds 删掉
+// DeleteByIds 删掉
 func (p *DistributorHandler) DeleteByIds(ctx context.Context, req *model.DeleteDistributorReq, rsp *comm_def.CommonMsg) error {
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {

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

@@ -25,17 +25,17 @@ type BaseDistributorSearchReq struct {
 
 // 创建经销商字段
 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#归属销售不能为空"`             // 归属销售
-	InvoiceHeader string `json:"invoiceHeader"`                                                           // 开票抬头
+	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|min:1#所属省份Id不能为空|所属省份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|min:1#|归属销售ID不能为空"`           // 归属销售ID
+	BelongSale    string `orm:"belong_sale"     json:"belongSale"      v:"required#归属销售不能为空"`                   // 归属销售
+	InvoiceHeader string `json:"invoiceHeader"`                                                                 // 开票抬头
 }
 
 // 列表返回字段

+ 2 - 1
opms_parent/app/model/plat/plat_followup.go

@@ -24,7 +24,8 @@ type SearchPlatFollowupReq struct {
 	TargetId        string `json:"targetId"`
 	ManagerId       string `json:"managerId"`
 	DaysBeforeToday int    `json:"daysBeforeToday"`
-	IsMyself        string `json:"isMyself"` // IsMyself为1时,查询本人的数据
+	IsMyself        string `json:"isMyself"`    // IsMyself为1时,查询本人的数据
+	CreatedName     string `json:"createdName"` // 跟进对象
 	request.PageReq
 }
 

+ 31 - 31
opms_parent/app/model/proj/proj_business.go

@@ -39,14 +39,14 @@ type ProjBusinessRes struct {
 
 type AddProjBusinessReq struct {
 	NboName          string `json:"nboName"        v:"required#项目名称不能为空"`                                   // 项目名称
-	CustId           int    `json:"custId"        v:"required#关联客户不能为空"`                                    // 关联客户
+	CustId           int    `json:"custId"        v:"required|min:1#|关联客户不能为空"`                             // 关联客户
 	CustName         string `json:"custName"        v:"required#关联客户不能为空"`                                  // 客户名称
 	NboSource        string `json:"nboSource"        v:"required#项目来源不能为空"`                                 // 项目来源
-	ContactId        int    `json:"contactId"        v:"required#关联联系人不能为空"`                                // 关联联系人
+	ContactId        int    `json:"contactId"        v:"required|min:1#|关联联系人不能为空"`                         // 关联联系人
 	ContactName      string `json:"contactName"        v:"required#联系人姓名不能为空"`                              // 联系人姓名
 	ContactPostion   string `json:"contactPostion"`                                                         // 联系人岗位
 	ContactTelephone string `json:"contactTelephone"`                                                       // 联系人电话
-	SaleId           int    `json:"saleId"        v:"required#归属销售不能为空"`                                    // 归属销售
+	SaleId           int    `json:"saleId"        v:"required|min:1#|归属销售不能为空"`                             // 归属销售
 	SaleName         string `json:"saleName"        v:"required#销售姓名不能为空"`                                  // 销售姓名
 	SalesModel       string `json:"salesModel"        v:"required|in:10,20,30#销售模式不能为空|销售模式不存在"`            // 销售模式(10直销20经销30代理)
 	DistributorId    int    `json:"distributorId"        v:"required-unless:salesModel,10#经销商/代理商不能为空"`     // 经销商/代理商ID
@@ -82,30 +82,30 @@ type UpdateProjBusinessReq struct {
 
 // BusinessProduct 项目产品
 type BusinessProduct struct {
-	Id         int     `json:"id"`                                   // 主键
-	BusId      int     `json:"busId"`                                // 关联项目
-	ProdId     int     `json:"prodId"         v:"required#关联产品不能为空"` // 关联产品
-	ProdName   string  `json:"prodName"       v:"required#产品名称不能为空"` // 产品名称
-	ProdCode   string  `json:"prodCode"       v:"required#产品编码不能为空"` // 产品编码
-	ProdClass  string  `json:"prodClass"      v:"required#产品类别不能为空"` // 产品类别
-	ProdNum    int     `json:"prodNum"        v:"required#产品数量不能为空"` // 产品数量
-	ProdPrice  float64 `json:"prodPrice"      v:"required#产品售价不能为空"` // 产品售价
-	GuidPrice  float64 `json:"guidPrice"`                            // 建议成交价
-	ProdUnit   string  `json:"prodUnit"`                             // 产品单位
-	TotalPrice int     `json:"totalPrice"`                           // 总价
-	Remark     string  `json:"remark"`                               // 备注
+	Id         int     `json:"id"`                                          // 主键
+	BusId      int     `json:"busId"`                                       // 关联项目
+	ProdId     int     `json:"prodId"         v:"required|min:1#|关联产品不能为空"` // 关联产品
+	ProdName   string  `json:"prodName"       v:"required#产品名称不能为空"`        // 产品名称
+	ProdCode   string  `json:"prodCode"       v:"required#产品编码不能为空"`        // 产品编码
+	ProdClass  string  `json:"prodClass"      v:"required#产品类别不能为空"`        // 产品类别
+	ProdNum    int     `json:"prodNum"        v:"required#产品数量不能为空"`        // 产品数量
+	ProdPrice  float64 `json:"prodPrice"      v:"required#产品售价不能为空"`        // 产品售价
+	GuidPrice  float64 `json:"guidPrice"`                                   // 建议成交价
+	ProdUnit   string  `json:"prodUnit"`                                    // 产品单位
+	TotalPrice int     `json:"totalPrice"`                                  // 总价
+	Remark     string  `json:"remark"`                                      // 备注
 }
 
 // BusinessUpgradeReq 项目升级请求
 type BusinessUpgradeReq struct {
-	Id                      int         `json:"id"                      v:"required# id不能为空"`                     // 主键
-	NboType                 string      `json:"nboType"                 v:"required|in:10,20,30#项目级别不能为空|项目级别错误"` // 项目级别
-	NboBudget               float64     `json:"nboBudget"               v:"required#项目预算不能为空"`                    // 项目预算
-	DistributorId           int         `json:"distributorId"           `                                         // 经销商/代理商ID
-	DistributorName         string      `json:"distributorName"         `                                         // 经销商/代理商名称
-	TechnicalSupportName    string      `json:"technicalSupportName"    v:"required# 技术支持人员不能为空"`                 // 技术支持人员
-	TechnicalSupportContent string      `json:"technicalSupportContent" v:"required# 技术支持内容不能为空"`                 // 技术支持内容
-	TechnicalSupportTime    *gtime.Time `json:"technicalSupportTime"    v:"required# 技术支持时间不能为空"`                 // 技术支持时间
+	Id                      int         `json:"id"                      v:"required|min:1#|id不能为空"`                                // 主键
+	NboType                 string      `json:"nboType"                 v:"required|in:10,20,30#项目级别不能为空|项目级别错误"`                  // 项目级别
+	NboBudget               float64     `json:"nboBudget"               v:"required-unless:nboType,30|min:0.01#项目预算不能为空|项目预算应大于0"` // 项目预算
+	DistributorId           int         `json:"distributorId"           `                                                          // 经销商/代理商ID
+	DistributorName         string      `json:"distributorName"         `                                                          // 经销商/代理商名称
+	TechnicalSupportName    string      `json:"technicalSupportName"    v:"required-unless:nboType,30#技术支持人员不能为空"`                 // 技术支持人员
+	TechnicalSupportContent string      `json:"technicalSupportContent" v:"required-unless:nboType,30#技术支持内容不能为空"`                 // 技术支持内容
+	TechnicalSupportTime    *gtime.Time `json:"technicalSupportTime"    v:"required-unless:nboType,30#技术支持时间不能为空"`                 // 技术支持时间
 	//CustomerSatisfaction      string      `json:"customerSatisfaction"`      // 客户满意度 (10很满意、20满意、30较满意、40一般、50不满意)
 	ParentReceiver            string      `json:"parentReceiver"`                                                  // 总部对接人
 	NboBudgetTime             *gtime.Time `json:"nboBudgetTime"`                                                   // 项目预算期限
@@ -127,7 +127,7 @@ type BusinessUpgradeReq struct {
 
 // BusinessDowngradeReq 项目降级请求
 type BusinessDowngradeReq struct {
-	Id                      int         `json:"id"        v:"required# id不能为空"`                             // 主键
+	Id                      int         `json:"id"        v:"required|min:1#|id不能为空"`                       // 主键
 	NboType                 string      `json:"nboType"        v:"required|in:10,20,30,50#项目级别不能为空|项目级别错误"` // 项目级别
 	TechnicalSupportName    string      `json:"technicalSupportName"`                                       // 技术支持人员
 	TechnicalSupportContent string      `json:"technicalSupportContent"`                                    // 技术支持内容
@@ -137,7 +137,7 @@ type BusinessDowngradeReq struct {
 
 // BusinessTransferReq 项目转移请求
 type BusinessTransferReq struct {
-	Id       int    `json:"id"        v:"required# id不能为空"`        // 主键
+	Id       int    `json:"id"        v:"required|min:1#|id不能为空"`  // 主键
 	UserId   int    `json:"userId"        v:"required# 负责人不能为空"`   // 负责人
 	UserName string `json:"userName"        v:"required# 负责人不能为空"` // 负责人
 	Remark   string `json:"remark"`                                // 备注
@@ -145,13 +145,13 @@ type BusinessTransferReq struct {
 
 // BusinessToReserveReq 项目转为储备项目
 type BusinessToReserveReq struct {
-	Id                   int    `json:"id"        v:"required# id不能为空"`                       // 主键
+	Id                   int    `json:"id"        v:"required|min:1#|id不能为空"`                 // 主键
 	ProjConversionReason string `json:"projConversionReason"        v:"required# 项目转化原因不能为空"` // 项目转化原因
 }
 
 // BusinessPrimacyContactReq 设置首要联系人请求
 type BusinessPrimacyContactReq struct {
-	Id               int    `json:"id"        v:"required# id不能为空"`            // 主键
+	Id               int    `json:"id"        v:"required|min:1#|id不能为空"`      // 主键
 	ContactId        int    `json:"contactId"        v:"required#关联联系人不能为空"`   // 关联联系人
 	ContactName      string `json:"contactName"        v:"required#联系人姓名不能为空"` // 联系人姓名
 	ContactPostion   string `json:"contactPostion"`                            // 联系人岗位
@@ -161,20 +161,20 @@ type BusinessPrimacyContactReq struct {
 
 // UpdateBusinessStatusReq 更新项目状态请求
 type UpdateBusinessStatusReq struct {
-	Id        int    `json:"id"        v:"required# id不能为空"`                              // 主键
+	Id        int    `json:"id"        v:"required|min:1#|id不能为空"`                        // 主键
 	NboStatus string `json:"nboStatus"        v:"required|in:10,20,30# 项目状态不能为空|项目状态不存在"` // 项目状态
 	Remark    string `json:"remark"`                                                      // 备注
 }
 
 // BusinessReq 获取项目关联信息
 type BusinessReq struct {
-	BusId int64 `json:"busId"        v:"required# 关联项目不能为空"` // 主键
+	BusId int64 `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 主键
 	request.PageReq
 }
 
 // BusinessDynamicsReq 获取项目关联信息
 type BusinessDynamicsReq struct {
-	BusId   int64  `json:"busId"        v:"required# 关联项目不能为空"` // 主键
-	OpnType string `json:"opnType"`                             // 操作类型
+	BusId   int64  `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 主键
+	OpnType string `json:"opnType"`                                   // 操作类型
 	request.PageReq
 }

+ 6 - 6
opms_parent/app/model/proj/proj_business_contact.go

@@ -32,14 +32,14 @@ type BusinessContact struct {
 
 // BusinessContactSearchReq 获取项目关联联系人信息
 type BusinessContactSearchReq struct {
-	BusId    int64  `json:"busId"        v:"required# 关联项目不能为空"` // 主键
-	CuctId   int    `json:"cuctId"`                              // 客户联系人
-	CuctName string `json:"cuctName"`                            // 客户联系人姓名
+	BusId    int64  `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 主键
+	CuctId   int    `json:"cuctId"`                                    // 客户联系人
+	CuctName string `json:"cuctName"`                                  // 客户联系人姓名
 	request.PageReq
 }
 
 type BusinessContactReq struct {
-	BusId      int    `json:"busId"        v:"required#关联项目不能为空"`     // 关联项目
-	ContactIds []int  `json:"contactIds"        v:"required#联系人不能为空"` // 联系人主键
-	Remark     string `json:"remark"`                                 // 备注
+	BusId      int    `json:"busId"        v:"required|min:1#|关联项目不能为空"` // 关联项目
+	ContactIds []int  `json:"contactIds"        v:"required#联系人不能为空"`    // 联系人主键
+	Remark     string `json:"remark"`                                    // 备注
 }

+ 17 - 36
opms_parent/app/service/base/base_distributor.go

@@ -2,14 +2,9 @@ package base
 
 import (
 	"context"
-	"fmt"
-	"github.com/gogf/gf/container/garray"
-	"strconv"
-
 	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/container/garray"
 	"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/base"
@@ -60,20 +55,30 @@ func (s *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 	return
 }
 
+// 获取经销商编号
+func (s *distributorService) getDistributorCode(distCode string) (string, error) {
+	sequence, err := service.Sequence(s.Dao.DB, "distributor_code")
+	if err != nil {
+		return "", err
+	}
+	return distCode + sequence, nil
+}
+
 // Create 经销商创建
 func (s *distributorService) Create(req *model.AddDistributor) (lastId int64, err error) {
 	DistributorData := new(model.BaseDistributor)
 	if err = gconv.Struct(req, DistributorData); err != nil {
 		return
 	}
+	DistributorData.DistCode, err = s.getDistributorCode("JXS")
+	if err != nil {
+		return 0, err
+	}
 	service.SetCreatedInfo(DistributorData, s.GetCxtUserId(), s.GetCxtUserName())
-	DistributorData.DistCode = gstr.SubStr(strconv.Itoa(int(gtime.Now().UnixNano()/1e6))+"Code", 0, -5)
 	lastId, err = s.Dao.InsertAndGetId(DistributorData)
 	if err != nil {
-
 		return 0, err
 	}
-
 	return
 }
 
@@ -88,7 +93,6 @@ func (s *distributorService) GetEntityById(id int64) (distributorInfo *model.Dis
 
 // UpdateById 修改数据
 func (s *distributorService) UpdateById(req *model.UpdateDistributorReq) (err error) {
-
 	count, err := s.Dao.Where("id = ", req.Id).Count()
 	if err != nil {
 		g.Log().Error(err)
@@ -115,32 +119,9 @@ func (s *distributorService) UpdateById(req *model.UpdateDistributorReq) (err er
 
 // DeleteByIds 删除
 func (s *distributorService) DeleteByIds(ids []int64) (err error) {
-	if len(ids) == 1 {
-		count, err := s.Dao.WherePri(ids[0]).Count()
-		if err != nil {
-			g.Log().Error(err)
-			return err
-		}
-		if count == 0 {
-			return myerrors.TipsError("数据不存在或已被删除,请刷新页面")
-		}
-	} else {
-		_, err := s.Dao.WhereIn(s.Dao.C.Id, ids).LockShared().Count()
-		if err != nil {
-			g.Log().Error(err)
-			return err
-		}
-		result, err := s.Dao.WhereIn(s.Dao.C.Id, ids).Delete()
-		if err != nil {
-			g.Log().Error(err)
-			return err
-		}
-		rows, err := result.RowsAffected()
-		if err == nil {
-			if len(ids) != int(rows) {
-				return myerrors.TipsError(fmt.Sprintf("应更新%s行,实际更新%s行", len(ids), int(rows)))
-			}
-		}
+	_, err = s.Dao.WhereIn(s.Dao.C.Id, ids).Delete()
+	if err != nil {
+		return err
 	}
 	return
 

+ 5 - 4
opms_parent/app/service/cust/cust_customer.go

@@ -72,12 +72,13 @@ func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 	if req.IsPublic {
 		Model = Model.Where(s.Dao.C.IsPublic, isPublic)
 	} else {
-		Model = Model.DataScope(s.Ctx, "sales_id").Where(s.Dao.C.IsPublic, noPublic)
+		Model = Model.Where(s.Dao.C.IsPublic, noPublic)
 		if req.TargetType == "self" {
 			Model = Model.Where(s.Dao.C.SalesId, s.CxtUser.Id)
-		}
-		if req.TargetType == "other" {
-			Model = Model.WhereNot(s.Dao.C.SalesId, s.CxtUser.Id)
+		} else if req.TargetType == "other" {
+			Model = Model.Where(s.Dao.C.SalesId, s.DataScope["userIds"]).WhereNot(s.Dao.C.SalesId, s.CxtUser.Id)
+		} else {
+			Model = Model.DataScope(s.Ctx, "sales_id").Where(s.Dao.C.IsPublic, noPublic)
 		}
 	}
 

+ 3 - 0
opms_parent/app/service/plat/plat_followup.go

@@ -135,6 +135,9 @@ func (s *followupService) GetListByDay(req *model.SearchPlatFollowupReq) (total
 	if req.TargetName != "" {
 		followupModel = followupModel.WhereLike("target_name", "%"+req.TargetName+"%")
 	}
+	if req.CreatedName != "" {
+		followupModel = followupModel.WhereLike("created_name", "%"+req.CreatedName+"%")
+	}
 	// 负责人查询
 	if req.ManagerId != "" {
 		followupModel = followupModel.Where("created_by", req.ManagerId)

+ 46 - 46
opms_parent/app/service/proj/business.go

@@ -235,7 +235,7 @@ func (p *businessService) Create(req *model.AddProjBusinessReq) (err error) {
 			OpnType: OpnCreate,
 			Remark:  businessData.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, businessData)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, businessData)
 		return err
 	})
 
@@ -321,7 +321,7 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) error {
 			OpnType: OpnUpdate,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, req)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, req)
 		return err
 	})
 	return err
@@ -366,7 +366,7 @@ func (p *businessService) BusinessTransfer(req *model.BusinessTransferReq) error
 			OpnType: OpnTransfer,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
 		if err != nil {
 			g.Log().Error(err)
 			return err
@@ -444,7 +444,7 @@ func (p *businessService) BusinessTransferNotify(flow *workflowModel.PlatWorkflo
 	if msg.ProcessType == "terminate" {
 		data[p.Dao.C.ApproStatus] = ApprovalReturn
 	}
-	if msg.ProcessType == "finish" && msg.Result != "refuse" {
+	if msg.ProcessType == "finish" && msg.Result == "refuse" {
 		data[p.Dao.C.ApproStatus] = ApprovalRejection
 	}
 	if msg.ProcessType == "finish" && msg.Result == "agree" {
@@ -472,7 +472,7 @@ func (p *businessService) BusinessTransferNotify(flow *workflowModel.PlatWorkflo
 		BusId:   business.Id,
 		OpnType: OpnTransferApproval,
 	}
-	err = p.CreateProjBusinessDynamics(nil, dynamics, data)
+	_, err = p.CreateProjBusinessDynamics(nil, dynamics, data)
 	if err != nil {
 		return err
 	}
@@ -534,7 +534,7 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
 			OpnType: OpnUpgrade,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
 		if err != nil {
 			return err
 		}
@@ -548,18 +548,18 @@ func (p *businessService) BusinessUpgrade(req *model.BusinessUpgradeReq) error {
 func (p *businessService) getBusDingUpgradeType(dbNboType, reqNboType string) string {
 	var upgradeType string
 	switch true {
-	case dbNboType == StatusReserve && reqNboType == StatusC: // 储备转C
-		upgradeType = "option_0"
-	case dbNboType == StatusReserve && reqNboType == StatusB: // 储备转B
-		upgradeType = "option_1"
-	case dbNboType == StatusReserve && reqNboType == StatusA: // 储备转A
-		upgradeType = "option_KTAX3Y9K5340"
-	case dbNboType == StatusC && reqNboType == StatusB: // C转B
-		upgradeType = "option_0"
-	case dbNboType == StatusC && reqNboType == StatusA: // C转A
-		upgradeType = "option_0"
-	case dbNboType == StatusB && reqNboType == StatusA: // B转A
-		upgradeType = "option_1"
+	case dbNboType == StatusReserve && reqNboType == StatusC: // 储备转C/option_0
+		upgradeType = "储备转C"
+	case dbNboType == StatusReserve && reqNboType == StatusB: // 储备转B/option_1
+		upgradeType = "储备转B"
+	case dbNboType == StatusReserve && reqNboType == StatusA: // 储备转A/option_KTAX3Y9K5340
+		upgradeType = "储备转A"
+	case dbNboType == StatusC && reqNboType == StatusB: // C转B/option_0
+		upgradeType = "C转B"
+	case dbNboType == StatusC && reqNboType == StatusA: // C转A/option_0
+		upgradeType = "C转A"
+	case dbNboType == StatusB && reqNboType == StatusA: // B转A/option_1
+		upgradeType = "B转A"
 	default:
 	}
 	return upgradeType
@@ -610,7 +610,7 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
 				{
 					Id:    utils.String("TextareaField_1LO81IKHH91C0"),
 					Name:  utils.String("转化原因"),
-					Value: utils.String(req.Remark),
+					Value: utils.String(req.ProjConversionReason),
 				},
 			},
 		}
@@ -707,7 +707,7 @@ func (p *businessService) BusinessUpgradeNotify(flow *workflowModel.PlatWorkflow
 	if msg.ProcessType == "terminate" {
 		data[p.Dao.C.ApproStatus] = ApprovalReturn
 	}
-	if msg.ProcessType == "finish" && msg.Result != "refuse" {
+	if msg.ProcessType == "finish" && msg.Result == "refuse" {
 		data[p.Dao.C.ApproStatus] = ApprovalRejection
 	}
 	if msg.ProcessType == "finish" && msg.Result == "agree" {
@@ -734,7 +734,7 @@ func (p *businessService) BusinessUpgradeNotify(flow *workflowModel.PlatWorkflow
 		BusId:   business.Id,
 		OpnType: OpnUpgradeApproval,
 	}
-	err = p.CreateProjBusinessDynamics(nil, dynamics, data)
+	_, err = p.CreateProjBusinessDynamics(nil, dynamics, data)
 	if err != nil {
 		return err
 	}
@@ -745,18 +745,18 @@ func (p *businessService) BusinessUpgradeNotify(flow *workflowModel.PlatWorkflow
 func (p *businessService) getBusDingDowngradeType(dbNboType, reqNboType string) string {
 	var downgradeType string
 	switch true {
-	case dbNboType == StatusB && reqNboType == StatusC:
-		downgradeType = "option_0"
-	case dbNboType == StatusA && reqNboType == StatusB:
-		downgradeType = "option_1"
-	case dbNboType == StatusA && reqNboType == StatusC:
-		downgradeType = "option_2"
-	case dbNboType == StatusA && reqNboType == StatusReserve:
-		downgradeType = "option_YZMFJYQQK6O0"
-	case dbNboType == StatusB && reqNboType == StatusReserve:
-		downgradeType = "option_232GR5NMFCSG0"
-	case dbNboType == StatusC && reqNboType == StatusReserve:
-		downgradeType = "option_1ZV2GJLDKQOW0"
+	case dbNboType == StatusB && reqNboType == StatusC: // B转C/option_0
+		downgradeType = "B转C"
+	case dbNboType == StatusA && reqNboType == StatusB: // A转B/option_1
+		downgradeType = "A转B"
+	case dbNboType == StatusA && reqNboType == StatusC: // A转C/option_2
+		downgradeType = "A转C"
+	case dbNboType == StatusA && reqNboType == StatusReserve: // A转储备/option_YZMFJYQQK6O0
+		downgradeType = "A转储备"
+	case dbNboType == StatusB && reqNboType == StatusReserve: // B转储备/option_232GR5NMFCSG0
+		downgradeType = "B转储备"
+	case dbNboType == StatusC && reqNboType == StatusReserve: // C转储备/option_1ZV2GJLDKQOW0
+		downgradeType = "C转储备"
 	default:
 	}
 	return downgradeType
@@ -796,7 +796,7 @@ func (p *businessService) BusinessDowngrade(req *model.BusinessDowngradeReq) err
 			OpnType: OpnDowngrade,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
 		if err != nil {
 			return err
 		}
@@ -872,7 +872,7 @@ func (p *businessService) BusinessDowngradeNotify(flow *workflowModel.PlatWorkfl
 	if msg.ProcessType == "terminate" {
 		data[p.Dao.C.ApproStatus] = ApprovalReturn
 	}
-	if msg.ProcessType == "finish" && msg.Result != "refuse" {
+	if msg.ProcessType == "finish" && msg.Result == "refuse" {
 		data[p.Dao.C.ApproStatus] = ApprovalRejection
 	}
 	if msg.ProcessType == "finish" && msg.Result == "agree" {
@@ -899,7 +899,7 @@ func (p *businessService) BusinessDowngradeNotify(flow *workflowModel.PlatWorkfl
 		BusId:   business.Id,
 		OpnType: OpnDowngradeApproval,
 	}
-	err = p.CreateProjBusinessDynamics(nil, dynamics, data)
+	_, err = p.CreateProjBusinessDynamics(nil, dynamics, data)
 	if err != nil {
 		return err
 	}
@@ -940,7 +940,7 @@ func (p *businessService) SetPrimacyContact(req *model.BusinessPrimacyContactReq
 			OpnType: OpnPrimacyContact,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
 		return err
 	})
 	return err
@@ -975,14 +975,14 @@ func (p *businessService) UpdateBusinessStatus(req *model.UpdateBusinessStatusRe
 			OpnType: OpnStatus,
 			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
 		return err
 	})
 	return err
 }
 
 // CreateProjBusinessDynamics 创建项目动态
-func (p *businessService) CreateProjBusinessDynamics(tx *gdb.TX, dynamics model.ProjBusinessDynamics, opnContent interface{}) error {
+func (p *businessService) CreateProjBusinessDynamics(tx *gdb.TX, dynamics model.ProjBusinessDynamics, opnContent interface{}) (int64, error) {
 	if v, ok := opnContent.(g.Map); ok {
 		opnContent = utils.MapKeySnakeCamelCase(v)
 	}
@@ -996,8 +996,8 @@ func (p *businessService) CreateProjBusinessDynamics(tx *gdb.TX, dynamics model.
 	if tx != nil {
 		dao = dao.TX(tx)
 	}
-	_, err := dao.Insert(&dynamics)
-	return err
+	lastId, err := dao.InsertAndGetId(&dynamics)
+	return lastId, err
 }
 
 // ConvertToReserve 转为储备项目
@@ -1030,7 +1030,7 @@ func (p *businessService) ConvertToReserve(req *model.BusinessToReserveReq) erro
 			OpnType: OpnToReserve,
 			Remark:  req.ProjConversionReason,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, businessMap)
+		_, err = p.CreateProjBusinessDynamics(tx, dynamics, businessMap)
 		if err != nil {
 			return err
 		}
@@ -1056,9 +1056,9 @@ func (p *businessService) ConvertToReserve(req *model.BusinessToReserveReq) erro
 					Value: utils.String(business.CustName),
 				},
 				{
-					Id:    utils.String("TextField_57000M1HBVO0"),
+					Id:    utils.String("DDSelectField_VBY9YAIOK5C0"),
 					Name:  utils.String("项目级别"),
-					Value: utils.String(nboType[business.NboType]),
+					Value: utils.String(convertToReserveType[business.NboType]),
 				},
 				{
 					Id:    utils.String("TextField_1NDD3TY8KJB40"),
@@ -1092,7 +1092,7 @@ func (p *businessService) ConvertToReserveNotify(flow *workflowModel.PlatWorkflo
 	if msg.ProcessType == "terminate" {
 		data[p.Dao.C.ApproStatus] = ApprovalReturn
 	}
-	if msg.ProcessType == "finish" && msg.Result != "refuse" {
+	if msg.ProcessType == "finish" && msg.Result == "refuse" {
 		data[p.Dao.C.ApproStatus] = ApprovalRejection
 	}
 	if msg.ProcessType == "finish" && msg.Result == "agree" {
@@ -1110,7 +1110,7 @@ func (p *businessService) ConvertToReserveNotify(flow *workflowModel.PlatWorkflo
 		BusId:   business.Id,
 		OpnType: OpnToReserveApproval,
 	}
-	err = p.CreateProjBusinessDynamics(nil, dynamics, data)
+	_, err = p.CreateProjBusinessDynamics(nil, dynamics, data)
 	if err != nil {
 		return err
 	}

+ 2 - 2
opms_parent/app/service/proj/business_contact.go

@@ -78,7 +78,7 @@ func (p *businessContactService) Create(req *projModel.BusinessContactReq) (err
 			BusId:   req.BusId,
 			OpnType: OpnAssociation,
 		}
-		err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		_, err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
 		return err
 	})
 	return
@@ -103,7 +103,7 @@ func (p *businessContactService) DeleteByIds(ids []int64) (err error) {
 			BusId:   result.BusId,
 			OpnType: OpnDisassociation,
 		}
-		err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		_, err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
 		return err
 	})
 	return

+ 17 - 10
opms_parent/app/service/proj/const.go

@@ -50,22 +50,29 @@ var (
 
 // 钉钉 项目级别
 var nboType = g.MapStrStr{
-	"10": "A",
-	"20": "B",
-	"30": "C",
-	"40": "成交",
-	"50": "储备",
+	StatusA:       "A",
+	StatusB:       "B",
+	StatusC:       "C",
+	StatusDeal:    "成交",
+	StatusReserve: "储备",
+}
+
+// 钉钉 转储备类型
+var convertToReserveType = g.MapStrStr{
+	StatusA: "A转储备", // A转储备/option_0
+	StatusB: "B转储备", // B转储备/option_1
+	StatusC: "C转储备", // C转储备/option_2
 }
 
 // 钉钉 采购方式
 var purchasingWayType = g.MapStrStr{
-	"10": "option_0", // 直采
-	"20": "option_1", // 招标
-	"90": "option_2", // 其他
+	"10": "直采", // 直采/option_0
+	"20": "招标", // 招标/option_1
+	"90": "其他", // 其他/option_2
 }
 
 // 钉钉 是否
 var yesOrNoType = g.MapStrStr{
-	"10": "option_0", // 是
-	"20": "option_1", // 否
+	"10": "是", // 是/option_0
+	"20": "否", // 否/option_1
 }