瀏覽代碼

Merge branch 'develop' of http://code.dashoo.cn/chengjian/opms_backend into develop

liuyaqi 2 年之前
父節點
當前提交
9073e4c983

+ 1 - 0
opms_admin/.gitignore

@@ -28,3 +28,4 @@ admin
 
 .idea/
 /go.sum
+/opms_admin

+ 4 - 0
opms_admin/app/dao/internal/sys_menu.go

@@ -11,6 +11,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
 	"time"
+
 	"dashoo.cn/micro/app/model"
 )
 
@@ -28,6 +29,7 @@ type sysMenuColumns struct {
 	Id          string // 菜单ID
 	MenuName    string // 菜单名称
 	ParentId    string // 父菜单ID
+	Name        string // 路由名称
 	Path        string // 路由地址
 	Component   string // 组件路径
 	Query       string // 路由参数
@@ -62,6 +64,7 @@ var (
 			Id:          "id",
 			MenuName:    "menu_name",
 			ParentId:    "parent_id",
+			Name:        "name",
 			Path:        "path",
 			Component:   "component",
 			Query:       "query",
@@ -98,6 +101,7 @@ func NewSysMenuDao(tenant string) SysMenuDao {
 			Id:          "id",
 			MenuName:    "menu_name",
 			ParentId:    "parent_id",
+			Name:        "name",
 			Path:        "path",
 			Component:   "component",
 			Query:       "query",

+ 1 - 0
opms_admin/app/model/internal/sys_menu.go

@@ -13,6 +13,7 @@ type SysMenu struct {
 	Id          int         `orm:"id,primary"   json:"id"`          // 菜单ID
 	MenuName    string      `orm:"menu_name"    json:"menuName"`    // 菜单名称
 	ParentId    int         `orm:"parent_id"    json:"parentId"`    // 父菜单ID
+	Name        string      `orm:"name"         json:"name"`        // 路由名称
 	Path        string      `orm:"path"         json:"path"`        // 路由地址
 	Component   string      `orm:"component"    json:"component"`   // 组件路径
 	Query       string      `orm:"query"        json:"query"`       // 路由参数

+ 3 - 5
opms_admin/app/model/sys_dict_data.go

@@ -57,15 +57,13 @@ type DictDataAddReq struct {
 	DictSort  int    `p:"dictSort"  v:"integer#排序只能为整数"`
 	CssClass  string `p:"cssClass"`
 	ListClass string `p:"listClass"`
-	//IsDefault string `p:"isDefault" v:"required|in:10,20#系统默认不能为空|默认值只能为10或20"`
-	Status   string `p:"status"    v:"required|in:10,20#状态不能为空|状态只能为10或20"`
-	Remark   string `p:"remark"`
-	CreateBy uint64
+	IsDefault string `p:"isDefault" v:"required|in:10,20#系统默认不能为空|默认值只能为10或20"`
+	Status    string `p:"status"    v:"required|in:10,20#状态不能为空|状态只能为10或20"`
+	Remark    string `p:"remark"`
 }
 
 // EditDictDataReq 修改字典数据操作请求参数
 type EditDictDataReq struct {
 	DictCode int `p:"dictCode" v:"required|min:1#主键ID不能为空|主键ID不能小于1"`
-	UpdateBy uint64
 	DictDataAddReq
 }

+ 4 - 0
opms_admin/app/model/sys_menu.go

@@ -20,6 +20,7 @@ type SysMenuReq struct {
 	Id         int    `json:"id"`                             // ID
 	ParentId   int    `json:"parentId"`                       // 父菜单ID
 	MenuName   string `json:"menuName" v:"required#菜单名称不能为空"` // 菜单名称
+	Name       string `json:"name"`                           // 路由名称
 	Path       string `json:"path"`                           // 路由地址
 	Component  string `json:"component"`                      // 组件路径
 	Query      string `json:"query"`                          // 路由参数
@@ -58,6 +59,9 @@ type Meta struct {
 }
 
 func (m SysMenu) ConvName() string {
+	if m.Name != "" {
+		return m.Name
+	}
 	name := m.Path
 	if strings.Contains(m.Path, "/") {
 		nameList := strings.Split(m.Path, "/")

+ 1 - 1
opms_admin/app/service/context.go

@@ -156,7 +156,7 @@ func (c *contextService) GetCxtUserName() string {
 	if c.CxtUser == nil {
 		return "-1"
 	}
-	return c.CxtUser.UserName
+	return c.CxtUser.NickName
 }
 
 func (c *contextService) GetCxtUserDeptId() int {

+ 4 - 0
opms_admin/app/service/sys_dict_type.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"dashoo.cn/micro/app/dao"
 	"dashoo.cn/micro/app/model"
+	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/errors/gerror"
@@ -113,6 +114,9 @@ func (s *dictTypeService) UpdateById(req *model.SysDictTypeEditReq) error {
 		if err != nil {
 			return err
 		}
+		if dt == nil {
+			return myerrors.NewMsgError(nil, "字典不存在")
+		}
 		//修改字典类型
 		data := new(model.SysDictType)
 		if err := gconv.Struct(req, data); err != nil {

+ 2 - 2
opms_admin/app/service/sys_user.go

@@ -111,7 +111,7 @@ func (s *userService) GetUserList(req *model.SysUserSearchReq) (total int, userL
 		err = gerror.New("获取总行数失败")
 		return
 	}
-	err = userModel.Fields("sys_user.*").Page(req.PageNum, req.PageSize).Order("id asc").Scan(&userList)
+	err = userModel.Fields("sys_user.*").Group("sys_user.id").Page(req.PageNum, req.PageSize).Order("id asc").Scan(&userList)
 	return
 }
 
@@ -316,7 +316,7 @@ func (s *userService) CreateUser(req *model.AddUserReq) (err error) {
 	}
 	userData.UserSalt = grand.S(10)
 	userData.Password = utils.EncryptPassword(userData.Password, userData.UserSalt)
-	g.Log("xxxxpassword",userData.Password)
+	g.Log("xxxxpassword", userData.Password)
 	SetCreatedInfo(userData, s.GetCxtUserId(), s.GetCxtUserName())
 	res, err := Model.Insert(userData)
 	if err != nil {

+ 1 - 0
opms_parent/.gitignore

@@ -29,3 +29,4 @@ admin
 .idea/
 gen.sh
 swaggerui/swagger.yml
+/opms_parent

+ 6 - 0
opms_parent/app/dao/proj/internal/proj_business.go

@@ -27,7 +27,9 @@ type ProjBusinessDao struct {
 // ProjBusinessColumns defines and stores column names for table proj_business.
 type projBusinessColumns struct {
 	Id               string // 主键
+	NboCode          string // 项目编号
 	NboName          string // 项目名称
+	NboStatus        string // 项目状态
 	CustId           string // 关联客户
 	CustName         string // 客户名称
 	NboType          string // 项目类别(A类B类C类)
@@ -78,7 +80,9 @@ var (
 		Table: "proj_business",
 		Columns: projBusinessColumns{
 			Id:               "id",
+			NboCode:          "nbo_code",
 			NboName:          "nbo_name",
+			NboStatus:        "nbo_status",
 			CustId:           "cust_id",
 			CustName:         "cust_name",
 			NboType:          "nbo_type",
@@ -131,7 +135,9 @@ func NewProjBusinessDao(tenant string) ProjBusinessDao {
 		Table: "proj_business",
 		Columns: projBusinessColumns{
 			Id:               "id",
+			NboCode:          "nbo_code",
 			NboName:          "nbo_name",
+			NboStatus:        "nbo_status",
 			CustId:           "cust_id",
 			CustName:         "cust_name",
 			NboType:          "nbo_type",

+ 13 - 15
opms_parent/app/handler/base/distributor.go

@@ -18,7 +18,7 @@ type DistributorHandler struct{}
 func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistributorSearchReq, rsp *comm_def.CommonMsg) error {
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	total, list, err := distributorServer.GetList(req)
@@ -31,7 +31,7 @@ func (p *DistributorHandler) GetList(ctx context.Context, req *model.BaseDistrib
 	return nil
 }
 
-// 创建
+//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 {
@@ -39,19 +39,19 @@ func (p *DistributorHandler) Create(ctx context.Context, req *model.AddDistribut
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	distributorServer.Create(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	return nil
 }
 
-//详情
+//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 {
@@ -59,22 +59,20 @@ func (p *DistributorHandler) GetEntityById(ctx context.Context, req *comm_def.Id
 	}
 	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
 }
 
-//删掉
-
-// 编辑
+//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 {
@@ -82,27 +80,27 @@ func (p *DistributorHandler) UpdateById(ctx context.Context, req *model.UpdateDi
 	}
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	distributorServer.UpdateById(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	return nil
 }
 
-//删掉
+//DeleteByIds 删掉
 func (p *DistributorHandler) DeleteByIds(ctx context.Context, req *model.DeleteDistributorReq, rsp *comm_def.CommonMsg) error {
 	distributorServer, err := server.NewDistributorService(ctx)
 	if err != nil {
-		g.Log().Error(err)
+
 		return err
 	}
 	err = distributorServer.DeleteByIds(req.Ids)
-	g.Log().Info("req", req)
+
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)

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

@@ -18,7 +18,7 @@ func (d *DistrictHandler) GetList(ctx context.Context, req *comm_def.IdReq, rsp
 	if err != nil {
 		return err
 	}
-	list, err := districtServer.ListToTree(req.Id)
+	list, err := districtServer.GetProvincesList(req.Id)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err
@@ -33,7 +33,7 @@ func (s *DistrictHandler) GetRegionList(ctx context.Context, req *comm_def.IdReq
 	if err != nil {
 		return err
 	}
-	list, err := districtServer.ListToRegions()
+	list, err := districtServer.GetRegionsProvinceList()
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		return err

+ 7 - 5
opms_parent/app/model/base/base_district.go

@@ -14,16 +14,18 @@ import (
 type BaseDistrict internal.BaseDistrict
 
 // Fill with you ideas below.
+
 type BaseDistrictSearchReq struct {
 	Id int `json:"id"` //  省份ID
 	request.PageReq
 }
 
-type T struct {
-	Id       int    `json:"id"`
-	ParentId int    `json:"parentId"`
-	DistName string `json:"distName" `
-	Children []*T   `json:"children"`
+//Provinces  省市区三级结构
+type ProvincesTree struct {
+	Id       int              `json:"id"`
+	ParentId int              `json:"parentId"`
+	DistName string           `json:"distName" `
+	Children []*ProvincesTree `json:"children"`
 }
 type Province struct {
 	Id       int    `json:"id"`

+ 5 - 5
opms_parent/app/model/cust/cust_customer.go

@@ -53,11 +53,11 @@ type CustomerAddSeq struct {
 	FollowUpDate *gtime.Time `p:"followUpDate"    json:"followUpDate"   `                     //跟进时间
 	CustIndustry string      `p:"custIndustry"    json:"custIndustry"  v:"required#客户行业不能为空"` //客户行业
 	CustLevel    string      `p:"custLevel"       json:"custLevel"     v:"required#客户级别不能为空"` //客户级别
-	CustSource   string      `p:"custSource"      json:"source"        v:"required#客户来源不能为空"` //客户级别
-	CustDistCode int         `p:"custDistCode"    json:"custDistCode"  v:"required#省份不能为空" `  // 省份Id
-	Remark       string      `p:"remark"          json:"remark""`                             //备注
-	SalesName    string      `p:"salesName"       json:"salesName"   `                        //
-	SalesId      int         `p:"salesId"         json:"salesId"   `                          //
+	CustSource   string      `p:"custSource"      json:"source"        v:"required#客户来源不能为空"`
+	CustDistCode int         `p:"custDistCode"    json:"custDistCode"  v:"required#省份不能为空" ` // 省份Id
+	Remark       string      `p:"remark"          json:"remark""`                            //备注
+	SalesName    string      `p:"salesName"       json:"salesName"   `                       //
+	SalesId      int         `p:"salesId"         json:"salesId"   `                         //
 }
 
 // 客户联系人信息

+ 2 - 0
opms_parent/app/model/proj/internal/proj_business.go

@@ -11,7 +11,9 @@ import (
 // ProjBusiness is the golang structure for table proj_business.
 type ProjBusiness struct {
 	Id               int         `orm:"id,primary"         json:"id"`               // 主键
+	NboCode          string      `orm:"nbo_code"           json:"nboCode"`          // 项目编号
 	NboName          string      `orm:"nbo_name"           json:"nboName"`          // 项目名称
+	NboStatus        string      `orm:"nbo_status"         json:"nboStatus"`        // 项目状态
 	CustId           int         `orm:"cust_id"            json:"custId"`           // 关联客户
 	CustName         string      `orm:"cust_name"          json:"custName"`         // 客户名称
 	NboType          string      `orm:"nbo_type"           json:"nboType"`          // 项目类别(A类B类C类)

+ 2 - 1
opms_parent/app/model/proj/proj_business.go

@@ -55,7 +55,7 @@ type AddProjBusinessReq struct {
 	FollowUserName string      `json:"followUserName"`                            // 跟进负责人姓名
 	FollowContent  string      `json:"followContent"       v:"required#跟进内容不能为空"` // 跟进内容
 
-	Products []BusinessProduct `json:"products"` // 产品列表
+	Products []BusinessProduct `json:"products"      v:"required#产品列表不能为空"` // 产品列表
 }
 
 type UpdateProjBusinessReq struct {
@@ -83,6 +83,7 @@ type BusinessProduct struct {
 type BusinessGradationReq struct {
 	Id      int    `json:"id"        v:"required# id不能为空"`                             // 主键
 	NboType string `json:"nboType"        v:"required|in:A,B,C#项目类别不能为空|项目类别只能为A、B、C"` // 项目类别(A类B类C类)
+	Remark  string `json:"remark"`                                                     // 备注
 }
 
 // BusinessTransferReq 项目转移请求

+ 0 - 3
opms_parent/app/service/base/base_distributor.go

@@ -6,7 +6,6 @@ import (
 	"strconv"
 
 	"dashoo.cn/opms_libary/myerrors"
-	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/text/gstr"
@@ -52,11 +51,9 @@ func (s *distributorService) GetList(req *model.BaseDistributorSearchReq) (total
 	total, err = distributorModel.Count()
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
 		return
 	}
 	err = distributorModel.Page(req.GetPage()).Order("id desc").Scan(&distributorList)
-	g.Log().Info("返回列表", distributorList)
 	return
 }
 

+ 24 - 8
opms_parent/app/service/base/base_district.go

@@ -29,18 +29,18 @@ func NewDistrictService(ctx context.Context) (svc *districtService, err error) {
 	return svc, nil
 }
 
-//ListToTree 所属区域列表
-func (s *districtService) ListToTree(Id int64) (treeList []*model.T, err error) {
-	ms := make(map[int]*model.T)
+//GetProvincesList 所属区域列表
+func (s *districtService) GetProvincesList(Id int64) (treeList []*model.ProvincesTree, err error) {
+	ms := make(map[int]*model.ProvincesTree)
 	var distributorList []model.BaseDistrict
-	err = s.Dao.Order("parent_id asc").Scan(&distributorList)
+	err = s.Dao.Order("id asc").Scan(&distributorList)
 	if err != nil {
 		g.Log().Error(err)
 		return
 	}
 
 	for _, v := range distributorList {
-		ms[v.Id] = &model.T{
+		ms[v.Id] = &model.ProvincesTree{
 			Id:       v.Id,
 			ParentId: v.ParentId,
 			DistName: v.DistName,
@@ -53,9 +53,26 @@ func (s *districtService) ListToTree(Id int64) (treeList []*model.T, err error)
 		}
 		treeList = append(treeList, v)
 	}
+	s.SortToProvince(treeList)
 	return
 }
 
+// SortToProvince 省市区排序
+func (s *districtService) SortToProvince(treeList []*model.ProvincesTree) []*model.ProvincesTree {
+	length := len(treeList)
+	for i := 0; i < length-1; i++ {
+		for j := i + 1; j < length; j++ {
+			if treeList[i].Id > treeList[j].Id {
+				treeList[i], treeList[j] = treeList[j], treeList[i]
+			}
+		}
+	}
+	for i := 0; i < length; i++ {
+		treeList[i].Children = s.SortToProvince(treeList[i].Children)
+	}
+	return treeList
+}
+
 // GetProvinceList 返回所有省份的
 func (s *districtService) GetProvinceList() (list []*model.Province, err error) {
 
@@ -68,8 +85,8 @@ func (s *districtService) GetProvinceList() (list []*model.Province, err error)
 	return
 }
 
-//ListToRegions 区域下所有的省份
-func (s *districtService) ListToRegions() (region []*model.Region, err error) {
+//GetRegionsProvinceList 区域下所有的省份
+func (s *districtService) GetRegionsProvinceList() (region []*model.Region, err error) {
 
 	err = s.RegionDao.Fields(s.RegionDao.Columns.RegionDesc, s.RegionDao.Columns.Id).Scan(&region)
 	if err != nil {
@@ -97,6 +114,5 @@ func (s *districtService) ListToRegions() (region []*model.Region, err error) {
 	for _, v := range region {
 		v.Children = ms[v.Id]
 	}
-	g.Log().Info("return", region)
 	return
 }

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

@@ -5,7 +5,6 @@ import (
 	"fmt"
 
 	"dashoo.cn/opms_libary/myerrors"
-	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gconv"
 
@@ -52,7 +51,6 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 	total, err = Model.Count()
 	if err != nil {
 		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
 		return
 	}
 	if req.PageNum == 0 {
@@ -61,7 +59,6 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 	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
@@ -82,8 +79,7 @@ func (s *salesRegionDetailService) GetList(req *model.SecBaseRegionDetailReq) (t
 	if req.CustIndustry != "" {
 		CustModel = CustModel.Where(s.CustomerDao.Columns.CustIndustry+" like ?", "%"+req.CustIndustry+"%")
 	}
-	total, err = Model.Fields().Count()
-
+	
 	dist, _ := s.District.Fields("dist_name,dist_code").Where("dist_code in (?)", districtList).All()
 	custDist, _ := CustModel.Group("cust_dist_code").All()
 

+ 1 - 1
opms_parent/app/service/context.go

@@ -63,7 +63,7 @@ func (c *ContextService) GetCxtUserName() string {
 	if c.CxtUser == nil {
 		return "-1"
 	}
-	return c.CxtUser.UserName
+	return c.CxtUser.NickName
 }
 
 func (c *ContextService) GetCxtUserDeptId() int {

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

@@ -7,11 +7,10 @@ import (
 	"math"
 	"strconv"
 
-	"github.com/gogf/gf/database/gdb"
-	"github.com/gogf/gf/encoding/gjson"
-
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/360EntSecGroup-Skylar/excelize"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/encoding/gjson"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
@@ -361,6 +360,10 @@ func (s *CustomerService) CustAbstract(Id int64) (followInfo *model.Follow, err
 		g.Log().Error(err)
 		return
 	}
+	if followTime == nil {
+		err = myerrors.NewMsgError(nil, "获取客户信息不存在")
+		return
+	}
 	now := gtime.Now()
 	var hours float64
 	if followTime.FollowUpDate == nil {
@@ -417,7 +420,7 @@ func (s *CustomerService) ChangeCustBelong(Ids []int64, salesId int64, salesName
 	return
 }
 
-//CreateDynamics 创建客户动态信息
+// CreateDynamics 创建客户动态信息
 func (s *CustomerService) CreateDynamics(opnTpye string, content interface{}, ids ...int64) (err error) {
 	datas := make([]*model.CustCustomerDynamics, 0)
 	for _, id := range ids {
@@ -450,7 +453,7 @@ func (s *CustomerService) GetDynamicsList(req *model.CustomerDynameicsReq) (tota
 	}
 	dynamics := []*model.CustomerDynameicsRep{}
 
-	err = s.DynamicsDao.Where("cust_id = ?", req.CustId).Order("created_time desc").Scan(&dynamics)
+	err = s.DynamicsDao.Where("cust_id =  ", req.CustId).Order("created_time desc").Scan(&dynamics)
 	if err != nil {
 		g.Log().Error(err)
 		return
@@ -634,6 +637,9 @@ func (s *CustomerService) Export(req *model.CustCustomerExport) (content *model.
 					}
 					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.CreatedName)
+				}
 				if v == "最后跟进时间" {
 					f.SetCellValue("Sheet1", service.Div(index+1)+strconv.Itoa(ck+2), item.FollowUpDate)
 				}

+ 2 - 2
opms_parent/app/service/cust/cust_customer_belong.go

@@ -28,7 +28,7 @@ func NewCustomerBelongService(ctx context.Context) (svc *CustomerbelongService,
 
 //GetList 获取客户归属信息
 func (s *CustomerbelongService) GetList(req *model.ReqCustomerBelongReq) (total int, Info []*model.CustomerBelongInfo, err error) {
-	err = s.Dao.Where("cust_id = ", req.CustId).Scan(&Info)
+	err = s.Dao.Where("cust_id = ", req.CustId).Order(" created_time desc ").Scan(&Info)
 	if err != nil {
 		g.Log().Error(err)
 		return
@@ -43,7 +43,7 @@ func (s *CustomerbelongService) GetList(req *model.ReqCustomerBelongReq) (total
 
 //Create 插入归属销售
 func (s *CustomerbelongService) Create(req *model.CustomerBelongAddSeq) (err error) {
-	
+
 	cusTomerBelong := new(model.CustCustomerBelong)
 	if err = gconv.Struct(req, cusTomerBelong); err != nil {
 		g.Log().Error(err)

+ 6 - 0
opms_parent/app/service/plat/plat_task.go

@@ -268,6 +268,9 @@ func (s *taskService) ChangeStatus(req *model.ChangeStatusReq) (err error) {
 	if err != nil {
 		return err
 	}
+	if task == nil {
+		return fmt.Errorf("数据异常,无匹配数据")
+	}
 	// 状态数据一致性判断
 	if (req.Type == "TaskStatus" && task.TaskStatus != req.OldStatus) || (req.Type == "IsOverdue" && task.IsOverdue != req.OldStatus) {
 		return fmt.Errorf("状态不匹配,进行该操作")
@@ -319,6 +322,9 @@ func (s *taskService) Handle(req *model.HandleReq) (err error) {
 		if err != nil {
 			return err
 		}
+		if task == nil {
+			return fmt.Errorf("数据异常,无匹配数据")
+		}
 		// 构造更新数据
 		handleData := g.Map{
 			"task_status":      "20",

+ 22 - 13
opms_parent/app/service/proj/business.go

@@ -12,6 +12,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
+	"strconv"
 	"strings"
 )
 
@@ -65,8 +66,8 @@ func (p *businessService) GetBusinessProduct(id int64) (productList []*model.Pro
 	return
 }
 
-func (p *businessService) GetBusinessDynamics(req *model.BusinessReq) (total int, result g.ListStrAny, err error) {
-	result = make(g.ListStrAny, 0)
+func (p *businessService) GetBusinessDynamics(req *model.BusinessReq) (total int, result g.MapStrAny, err error) {
+	result = make(g.MapStrAny, 0)
 	dynamicsDao := projDao.NewProjBusinessDynamicsDao(p.Tenant).ProjBusinessDynamicsDao.Where(projDao.ProjBusinessDynamics.Columns.BusId, req.BusId)
 	total, err = dynamicsDao.Count()
 	if err != nil {
@@ -74,8 +75,7 @@ func (p *businessService) GetBusinessDynamics(req *model.BusinessReq) (total int
 		return
 	}
 	dynamicsList, err := dynamicsDao.Page(req.GetPage()).Order("created_time desc").All()
-	if err != nil || len(dynamicsList) == 0 {
-		g.Log().Error(err)
+	if err != nil || dynamicsList == nil {
 		return
 	}
 	// 数据树格式转换
@@ -83,10 +83,11 @@ func (p *businessService) GetBusinessDynamics(req *model.BusinessReq) (total int
 	for k, v := range dynamicsList {
 		opnDate := gtime.New(v.OpnDate).Format("Y-m-d")
 		if opnDateFlag == opnDate && k != 0 {
-			result[len(result)-1][opnDate] = append(result[len(result)-1][opnDate].(g.ListStrAny), g.Map{
+			result[opnDate] = append(result[opnDate].(g.ListStrAny), g.Map{
 				"opnPeople":  v.OpnPeople,
 				"opnDate":    v.OpnDate,
 				"opnType":    v.OpnType,
+				"remark":     v.Remark,
 				"opnContent": gconv.Map(v.OpnContent),
 			})
 		} else {
@@ -95,11 +96,10 @@ func (p *businessService) GetBusinessDynamics(req *model.BusinessReq) (total int
 				"opnPeople":  v.OpnPeople,
 				"opnDate":    v.OpnDate,
 				"opnType":    v.OpnType,
+				"remark":     v.Remark,
 				"opnContent": gconv.Map(v.OpnContent),
 			})
-			result = append(result, g.Map{
-				opnDate: temp,
-			})
+			result[opnDate] = temp
 		}
 	}
 	return
@@ -145,7 +145,8 @@ func (p *businessService) Create(req *model.AddProjBusinessReq) (err error) {
 		totalPrice += v.TotalPrice
 		service.SetCreatedInfo(v, p.GetCxtUserId(), p.GetCxtUserName())
 	}
-
+	businessData.NboCode = "NBO" + strconv.Itoa(int(gtime.Timestamp()))
+	businessData.NboStatus = "10"
 	businessData.NboType = "C"
 	businessData.ApproStatus = "10"
 	businessData.EstTransPrice = totalPrice
@@ -200,6 +201,7 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) (err erro
 	}
 	var totalPrice float64
 	for _, v := range products {
+		v.Id = 0
 		v.TotalPrice = v.ProdPrice * float64(v.ProdNum)
 		totalPrice += v.TotalPrice
 		service.SetCreatedInfo(v, p.GetCxtUserId(), p.GetCxtUserName())
@@ -213,7 +215,12 @@ func (p *businessService) UpdateById(req *model.UpdateProjBusinessReq) (err erro
 			return err
 		}
 		// 添加项目产品
-		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Save(products)
+		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Where(projDao.ProjBusinessProduct.Columns.BusId, req.Id).Delete()
+		if err != nil {
+			return err
+		}
+		// 添加项目产品
+		_, err = projDao.NewProjBusinessProductDao(p.Tenant).TX(tx).Insert(products)
 		if err != nil {
 			return err
 		}
@@ -285,10 +292,8 @@ func (p *businessService) BusinessGradation(req *model.BusinessGradationReq) err
 		return myerrors.NewMsgError(nil, "同级无法进行调级。")
 	}
 	opnType := "40"
-	opnContent := "项目升级 " + business.NboType + " => " + req.NboType
 	// A < B return -1 项目降级
 	if strings.Compare(business.NboType, req.NboType) < 0 {
-		opnContent = "项目降级 " + business.NboType + " => " + req.NboType
 		opnType = "50"
 	}
 
@@ -306,8 +311,12 @@ func (p *businessService) BusinessGradation(req *model.BusinessGradationReq) err
 		dynamics := model.ProjBusinessDynamics{
 			BusId:   business.Id,
 			OpnType: opnType,
+			Remark:  req.Remark,
 		}
-		err = p.CreateProjBusinessDynamics(tx, dynamics, opnContent)
+		err = p.CreateProjBusinessDynamics(tx, dynamics, g.Map{
+			"origNboType": business.NboType,
+			"nboType":     req.NboType,
+		})
 		return err
 	})
 	return err

+ 38 - 3
opms_parent/app/service/proj/business_contact.go

@@ -6,6 +6,8 @@ import (
 	projDao "dashoo.cn/micro/app/dao/proj"
 	projModel "dashoo.cn/micro/app/model/proj"
 	"dashoo.cn/micro/app/service"
+	"dashoo.cn/opms_libary/myerrors"
+	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 )
 
@@ -38,7 +40,7 @@ func (p *businessContactService) GetList(req *projModel.BusinessReq) (total int,
 		return
 	}
 
-	err = db.Fields("bus.id AS id, bus.*, contact.*").Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
+	err = db.Fields("bus.*, contact.*,bus.id AS id").Page(req.GetPage()).Order("bus.id desc").Scan(&contactList)
 	return
 }
 
@@ -52,11 +54,44 @@ func (p *businessContactService) Create(req *projModel.BusinessContactReq) (err
 		service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
 		contactList = append(contactList, data)
 	}
-	_, err = p.Dao.Insert(&contactList)
+	b, _ := NewBusinessService(p.Ctx)
+	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		_, err = p.Dao.Insert(&contactList)
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := projModel.ProjBusinessDynamics{
+			BusId:   req.BusId,
+			OpnType: "70",
+		}
+		err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		return err
+	})
 	return
 }
 
 func (p *businessContactService) DeleteByIds(ids []int64) (err error) {
-	_, err = p.Dao.WhereIn(projDao.ProjBusinessContact.Columns.Id, ids).Delete()
+	result, err := p.Dao.Where(projDao.ProjBusinessContact.Columns.Id+" IN(?)", ids).One()
+	if err != nil {
+		return err
+	}
+	if result == nil {
+		return myerrors.NewMsgError(nil, "联系人不存在")
+	}
+	b, _ := NewBusinessService(p.Ctx)
+	err = p.Dao.Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		_, err = p.Dao.WhereIn(projDao.ProjBusinessContact.Columns.Id, ids).Delete()
+		if err != nil {
+			return err
+		}
+		// 添加项目动态
+		dynamics := projModel.ProjBusinessDynamics{
+			BusId:   result.BusId,
+			OpnType: "80",
+		}
+		err = b.CreateProjBusinessDynamics(tx, dynamics, nil)
+		return err
+	})
 	return
 }