瀏覽代碼

feature(合同):
1、回款管理、回款计划管理、发票管理权限
2、项目转A参数文件保存

ZZH-wl 2 年之前
父節點
當前提交
6633941e80

+ 3 - 0
opms_parent/app/dao/contract/internal/ctr_contract.go

@@ -35,6 +35,7 @@ type ctrContractColumns struct {
 	CustId            string // 关联客户
 	CustName          string // 客户名称
 	ProductLine       string // 产品线
+	IsBig             string // 是否为大项目
 	CustProvinceId    string // 所在省ID
 	CustProvince      string // 所在省
 	CustCityId        string // 所在市ID
@@ -80,6 +81,7 @@ var (
 			CustId:            "cust_id",
 			CustName:          "cust_name",
 			ProductLine:       "product_line",
+			IsBig:             "is_big",
 			CustProvinceId:    "cust_province_id",
 			CustProvince:      "cust_province",
 			CustCityId:        "cust_city_id",
@@ -127,6 +129,7 @@ func NewCtrContractDao(tenant string) CtrContractDao {
 			CustId:            "cust_id",
 			CustName:          "cust_name",
 			ProductLine:       "product_line",
+			IsBig:             "is_big",
 			CustProvinceId:    "cust_province_id",
 			CustProvince:      "cust_province",
 			CustCityId:        "cust_city_id",

+ 16 - 9
opms_parent/app/dao/contract/internal/ctr_contract_collection.go

@@ -706,13 +706,20 @@ func (d *CtrContractCollectionDao) Unscoped() *CtrContractCollectionDao {
 }
 
 // DataScope enables the DataScope feature.
-func (d *CtrContractCollectionDao) DataScope(ctx context.Context, userCol ...string) *CtrContractCollectionDao {
+func (d *CtrContractCollectionDao) DataScope(ctx context.Context, args ...interface{}) *CtrContractCollectionDao {
 	cs := ctx.Value("contextService")
 	dataScope := gconv.Map(cs)["dataScope"].(g.Map)
 	if dataScope != nil {
-		tableAs := d.TableAs
-		if d.TableAs != "" {
-			tableAs += "."
+		var specialFlag bool
+		var tableAs string
+		if d.TableAs != "" && len(args) <= 1 {
+			tableAs = d.TableAs + "."
+		}
+		if len(args) > 1 {
+			specialFlag = true
+			if val, ok := args[1].(string); ok {
+				tableAs = val + "."
+			}
 		}
 		userIds, ok := dataScope["userIds"]
 		delete(dataScope, "userIds")
@@ -720,10 +727,10 @@ func (d *CtrContractCollectionDao) DataScope(ctx context.Context, userCol ...str
 		var orValues []interface{}
 		if ok && userIds != "-1" {
 			column := "created_by"
-			if len(userCol) == 1 {
-				column = userCol[0]
+			if len(args) > 0 {
+				column = args[0].(string)
 			}
-			if ok, _ := d.M.HasField(column); ok {
+			if ok, _ := d.M.HasField(column); ok || specialFlag {
 				orColumns = append(orColumns, tableAs+column+" IN (?) ")
 				orValues = append(orValues, userIds)
 			}
@@ -739,7 +746,7 @@ func (d *CtrContractCollectionDao) DataScope(ctx context.Context, userCol ...str
 		// 非销售工程师权限加成
 		if !salesEngineerFlag {
 			bigColumns := "is_big"
-			if ok, _ := d.M.HasField("is_big"); ok {
+			if ok, _ := d.M.HasField("is_big"); ok || specialFlag {
 				if val, ok := dataScope[bigColumns]; ok && val != "" {
 					orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
 					orValues = append(orValues, val)
@@ -749,7 +756,7 @@ func (d *CtrContractCollectionDao) DataScope(ctx context.Context, userCol ...str
 			var andColumns []string
 			var andValues []interface{}
 			for k, v := range dataScope {
-				if ok, _ := d.M.HasField(k); ok {
+				if ok, _ := d.M.HasField(k); ok || specialFlag {
 					andColumns = append(andColumns, tableAs+k+" IN (?) ")
 					andValues = append(andValues, v)
 				}

+ 16 - 9
opms_parent/app/dao/contract/internal/ctr_contract_collection_plan.go

@@ -703,13 +703,20 @@ func (d *CtrContractCollectionPlanDao) Unscoped() *CtrContractCollectionPlanDao
 }
 
 // DataScope enables the DataScope feature.
-func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ...string) *CtrContractCollectionPlanDao {
+func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, args ...interface{}) *CtrContractCollectionPlanDao {
 	cs := ctx.Value("contextService")
 	dataScope := gconv.Map(cs)["dataScope"].(g.Map)
 	if dataScope != nil {
-		tableAs := d.TableAs
-		if d.TableAs != "" {
-			tableAs += "."
+		var specialFlag bool
+		var tableAs string
+		if d.TableAs != "" && len(args) <= 1 {
+			tableAs = d.TableAs + "."
+		}
+		if len(args) > 1 {
+			specialFlag = true
+			if val, ok := args[1].(string); ok {
+				tableAs = val + "."
+			}
 		}
 		userIds, ok := dataScope["userIds"]
 		delete(dataScope, "userIds")
@@ -717,10 +724,10 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
 		var orValues []interface{}
 		if ok && userIds != "-1" {
 			column := "created_by"
-			if len(userCol) == 1 {
-				column = userCol[0]
+			if len(args) > 0 {
+				column = args[0].(string)
 			}
-			if ok, _ := d.M.HasField(column); ok {
+			if ok, _ := d.M.HasField(column); ok || specialFlag {
 				orColumns = append(orColumns, tableAs+column+" IN (?) ")
 				orValues = append(orValues, userIds)
 			}
@@ -736,7 +743,7 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
 		// 非销售工程师权限加成
 		if !salesEngineerFlag {
 			bigColumns := "is_big"
-			if ok, _ := d.M.HasField("is_big"); ok {
+			if ok, _ := d.M.HasField("is_big"); ok || specialFlag {
 				if val, ok := dataScope[bigColumns]; ok && val != "" {
 					orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
 					orValues = append(orValues, val)
@@ -746,7 +753,7 @@ func (d *CtrContractCollectionPlanDao) DataScope(ctx context.Context, userCol ..
 			var andColumns []string
 			var andValues []interface{}
 			for k, v := range dataScope {
-				if ok, _ := d.M.HasField(k); ok {
+				if ok, _ := d.M.HasField(k); ok || specialFlag {
 					andColumns = append(andColumns, tableAs+k+" IN (?) ")
 					andValues = append(andValues, v)
 				}

+ 16 - 9
opms_parent/app/dao/contract/internal/ctr_contract_invoice.go

@@ -712,13 +712,20 @@ func (d *CtrContractInvoiceDao) Unscoped() *CtrContractInvoiceDao {
 }
 
 // DataScope enables the DataScope feature.
-func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, userCol ...string) *CtrContractInvoiceDao {
+func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, args ...interface{}) *CtrContractInvoiceDao {
 	cs := ctx.Value("contextService")
 	dataScope := gconv.Map(cs)["dataScope"].(g.Map)
 	if dataScope != nil {
-		tableAs := d.TableAs
-		if d.TableAs != "" {
-			tableAs += "."
+		var specialFlag bool
+		var tableAs string
+		if d.TableAs != "" && len(args) <= 1 {
+			tableAs = d.TableAs + "."
+		}
+		if len(args) > 1 {
+			specialFlag = true
+			if val, ok := args[1].(string); ok {
+				tableAs = val + "."
+			}
 		}
 		userIds, ok := dataScope["userIds"]
 		delete(dataScope, "userIds")
@@ -726,10 +733,10 @@ func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, userCol ...string
 		var orValues []interface{}
 		if ok && userIds != "-1" {
 			column := "created_by"
-			if len(userCol) == 1 {
-				column = userCol[0]
+			if len(args) > 0 {
+				column = args[0].(string)
 			}
-			if ok, _ := d.M.HasField(column); ok {
+			if ok, _ := d.M.HasField(column); ok || specialFlag {
 				orColumns = append(orColumns, tableAs+column+" IN (?) ")
 				orValues = append(orValues, userIds)
 			}
@@ -745,7 +752,7 @@ func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, userCol ...string
 		// 非销售工程师权限加成
 		if !salesEngineerFlag {
 			bigColumns := "is_big"
-			if ok, _ := d.M.HasField("is_big"); ok {
+			if ok, _ := d.M.HasField("is_big"); ok || specialFlag {
 				if val, ok := dataScope[bigColumns]; ok && val != "" {
 					orColumns = append(orColumns, tableAs+bigColumns+" = ? ")
 					orValues = append(orValues, val)
@@ -755,7 +762,7 @@ func (d *CtrContractInvoiceDao) DataScope(ctx context.Context, userCol ...string
 			var andColumns []string
 			var andValues []interface{}
 			for k, v := range dataScope {
-				if ok, _ := d.M.HasField(k); ok {
+				if ok, _ := d.M.HasField(k); ok || specialFlag {
 					andColumns = append(andColumns, tableAs+k+" IN (?) ")
 					andValues = append(andValues, v)
 				}

+ 1 - 0
opms_parent/app/model/contract/internal/ctr_contract.go

@@ -16,6 +16,7 @@ type CtrContract struct {
 	CustId            int         `orm:"cust_id"             json:"custId"`            // 关联客户
 	CustName          string      `orm:"cust_name"           json:"custName"`          // 客户名称
 	ProductLine       string      `orm:"product_line"        json:"productLine"`       // 产品线
+	IsBig             string      `orm:"is_big"              json:"isBig"`             // 是否为大项目
 	CustProvinceId    int         `orm:"cust_province_id"    json:"custProvinceId"`    // 所在省ID
 	CustProvince      string      `orm:"cust_province"       json:"custProvince"`      // 所在省
 	CustCityId        int         `orm:"cust_city_id"        json:"custCityId"`        // 所在市ID

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

@@ -45,6 +45,8 @@ type AddPlatFollowupReq struct {
 	NextTime      *gtime.Time               `orm:"next_time"      json:"nextTime"`                                               // 下次联系时间
 	Remark        string                    `orm:"remark"         json:"remark"`                                                 // 备注
 	Files         []*AddPlatFollowupFileReq `json:"files"`                                                                       // 附件
+	//FollowContentType string      `orm:"follow_content_type" json:"followContentType" v:"required#跟进内容类型不能为空"`               // 跟进内容类型
+	//SupportName       string      `orm:"support_name"   json:"supportName"`                                                            // 总部支持人员
 }
 
 // 跟进记录详情展示,且展示第一级评论数据

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

@@ -375,6 +375,7 @@ func (s CtrContractService) Add(ctx context.Context, req *model.CtrContractAddRe
 		CustName:          nbo.CustName,
 		NboId:             nbo.Id,
 		NboName:           nbo.NboName,
+		IsBig:             nbo.IsBig,
 		ProductLine:       nbo.ProductLine,
 		CustProvinceId:    nbo.CustProvinceId,
 		CustProvince:      nbo.CustProvince,
@@ -761,6 +762,7 @@ func (s CtrContractService) Update(ctx context.Context, req *model.CtrContractUp
 		toupdate["cust_name"] = nbo.CustName
 		toupdate["nbo_id"] = nbo.Id
 		toupdate["nbo_name"] = nbo.NboName
+		toupdate["is_big"] = nbo.IsBig
 		toupdate["product_line"] = nbo.ProductLine
 		toupdate["cust_province_id"] = nbo.CustProvinceId
 		toupdate["cust_province"] = nbo.CustProvince

+ 10 - 4
opms_parent/app/service/contract/ctr_contract_collection.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"database/sql"
 	"fmt"
+	"github.com/gogf/gf/frame/g"
 
 	dao "dashoo.cn/micro/app/dao/contract"
 	model "dashoo.cn/micro/app/model/contract"
@@ -22,8 +23,9 @@ type CtrContractCollectionService struct {
 	planSrv     *CtrContractCollectionPlanService
 	ctrSrv      *CtrContractService
 
-	Tenant   string
-	userInfo request.UserInfo
+	Tenant    string
+	userInfo  request.UserInfo
+	DataScope g.Map `json:"dataScope"`
 }
 
 func NewCtrContractCollectionService(ctx context.Context) (*CtrContractCollectionService, error) {
@@ -53,11 +55,15 @@ func NewCtrContractCollectionService(ctx context.Context) (*CtrContractCollectio
 		ctrSrv:      ctrSrv,
 		Tenant:      tenant,
 		userInfo:    userInfo,
+		DataScope:   userInfo.DataScope,
 	}, nil
 }
 
 func (s CtrContractCollectionService) List(ctx context.Context, req *model.CtrContractCollectionListReq) (int, []*model.CtrContractCollection, error) {
-	dao := &s.Dao.CtrContractCollectionDao
+	ctx = context.WithValue(ctx, "contextService", s)
+	dao := s.Dao.As("collection").LeftJoin(dao.CtrContract.Table, "contract", "contract.id=collection.contract_id").
+		DataScope(ctx, "incharge_id", "contract")
+
 	if req.SearchText != "" {
 		likestr := fmt.Sprintf("%%%s%%", req.SearchText)
 		dao = dao.Where("(cust_name LIKE ? || contract_code LIKE ?)", likestr, likestr)
@@ -106,7 +112,7 @@ func (s CtrContractCollectionService) List(ctx context.Context, req *model.CtrCo
 	dao = dao.Order(orderby)
 
 	ents := []*model.CtrContractCollection{}
-	err = dao.Structs(&ents)
+	err = dao.Fields("collection.*").Structs(&ents)
 	if err != nil && err != sql.ErrNoRows {
 		return 0, nil, err
 	}

+ 9 - 4
opms_parent/app/service/contract/ctr_contract_collection_plan.go

@@ -4,6 +4,7 @@ import (
 	"context"
 	"database/sql"
 	"fmt"
+	"github.com/gogf/gf/frame/g"
 
 	dao "dashoo.cn/micro/app/dao/contract"
 	model "dashoo.cn/micro/app/model/contract"
@@ -22,8 +23,9 @@ type CtrContractCollectionPlanService struct {
 	ContractDao   *dao.CtrContractDao
 	ctrSrv        *CtrContractService
 
-	Tenant   string
-	userInfo request.UserInfo
+	Tenant    string
+	userInfo  request.UserInfo
+	DataScope g.Map `json:"dataScope"`
 }
 
 func NewCtrContractCollectionPlanService(ctx context.Context) (*CtrContractCollectionPlanService, error) {
@@ -50,6 +52,7 @@ func NewCtrContractCollectionPlanService(ctx context.Context) (*CtrContractColle
 		ctrSrv:        ctrSrv,
 		Tenant:        tenant,
 		userInfo:      userInfo,
+		DataScope:     userInfo.DataScope,
 	}, nil
 }
 
@@ -75,7 +78,9 @@ func (s CtrContractCollectionPlanService) Get(ctx context.Context, id int) (*mod
 }
 
 func (s CtrContractCollectionPlanService) List(ctx context.Context, req *model.CtrContractCollectionPlanListReq) (int, []*model.CtrContractCollectionPlan, error) {
-	dao := &s.Dao.CtrContractCollectionPlanDao
+	ctx = context.WithValue(ctx, "contextService", s)
+	dao := s.Dao.As("plan").LeftJoin(dao.CtrContract.Table, "contract", "contract.id=plan.contract_id").
+		DataScope(ctx, "incharge_id", "contract")
 	if req.SearchText != "" {
 		likestr := fmt.Sprintf("%%%s%%", req.SearchText)
 		dao = dao.Where("(cust_name LIKE ? || contract_code LIKE ?)", likestr, likestr)
@@ -118,7 +123,7 @@ func (s CtrContractCollectionPlanService) List(ctx context.Context, req *model.C
 	dao = dao.Order(orderby)
 
 	ents := []*model.CtrContractCollectionPlan{}
-	err = dao.Structs(&ents)
+	err = dao.Fields("plan.*").Structs(&ents)
 	if err != nil && err != sql.ErrNoRows {
 		return 0, nil, err
 	}

+ 7 - 2
opms_parent/app/service/contract/ctr_contract_invoice.go

@@ -5,6 +5,7 @@ import (
 	"database/sql"
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/frame/g"
 	"strconv"
 	"strings"
 
@@ -32,6 +33,7 @@ type CtrContractInvoiceService struct {
 	ctrSrv      *CtrContractService
 	Tenant      string
 	userInfo    request.UserInfo
+	DataScope   g.Map `json:"dataScope"`
 }
 
 func NewCtrContractInvoiceService(ctx context.Context) (*CtrContractInvoiceService, error) {
@@ -56,11 +58,14 @@ func NewCtrContractInvoiceService(ctx context.Context) (*CtrContractInvoiceServi
 		ctrSrv:      ctrSrv,
 		Tenant:      tenant,
 		userInfo:    userInfo,
+		DataScope:   userInfo.DataScope,
 	}, nil
 }
 
 func (s CtrContractInvoiceService) List(ctx context.Context, req *model.CtrContractInvoiceListReq) (int, []*model.CtrContractInvoice, error) {
-	dao := &s.Dao.CtrContractInvoiceDao
+	ctx = context.WithValue(ctx, "contextService", s)
+	dao := s.Dao.As("invoice").LeftJoin(dao.CtrContract.Table, "contract", "contract.id=invoice.contract_id").
+		DataScope(ctx, "incharge_id", "contract")
 	if req.SearchText != "" {
 		likestr := fmt.Sprintf("%%%s%%", req.SearchText)
 		dao = dao.Where("(cust_name LIKE ? || contract_code LIKE ?)", likestr, likestr)
@@ -113,7 +118,7 @@ func (s CtrContractInvoiceService) List(ctx context.Context, req *model.CtrContr
 	dao = dao.Order(orderby)
 
 	ents := []*model.CtrContractInvoice{}
-	err = dao.Structs(&ents)
+	err = dao.Fields("invoice.*").Structs(&ents)
 	if err != nil && err != sql.ErrNoRows {
 		return 0, nil, err
 	}

+ 21 - 1
opms_parent/app/service/proj/business.go

@@ -700,7 +700,10 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
 			FileSize: resp.Dentry.Size,
 			FileType: resp.Dentry.Extension,
 		}}
-
+		err = p.txCreateBusinessFile(business.Id, file)
+		if err != nil {
+			return err
+		}
 		processCode := &BusinessUpgradeARequestProcessCode
 		dingReq = &workflow.StartProcessInstanceRequest{
 			ProcessCode: processCode,
@@ -784,6 +787,23 @@ func (p *businessService) BusUpgradeDingEvent(business *model.ProjBusiness, req
 	return nil
 }
 
+// 采用大数参数文件记录
+func (p *businessService) txCreateBusinessFile(busId int, files []contractModel.DingFileInfo) error {
+	dataList := make([]model.ProjBusinessFile, 0)
+	for _, v := range files {
+		data := new(model.ProjBusinessFile)
+		data.BusId = busId
+		data.FileName = v.FileName
+		data.FileSource = "项目转为A类采用大数参数文件"
+		data.FileSize = gconv.String(v.FileSize)
+		data.FileUrl = strings.Join([]string{"dingtalk", v.SpaceId, v.FileId}, ":")
+		service.SetCreatedInfo(data, p.GetCxtUserId(), p.GetCxtUserName())
+		dataList = append(dataList)
+	}
+	_, err := projDao.NewProjBusinessFileDao(p.Tenant).Insert(&dataList)
+	return err
+}
+
 // BusinessUpgradeNotify 项目升级 审批结果通知
 func (p *businessService) BusinessUpgradeNotify(flow *workflowModel.PlatWorkflow, msg *message.MixMessage) error {
 	business, err := p.checkDingTalkNotify(flow, msg)