Ver Fonte

feature:任务单增加经销商信息

sunxinyuan há 1 ano atrás
pai
commit
0f75f7af5c

+ 96 - 241
opms_parent/app/dao/work/internal/deliver_order.go

@@ -7,13 +7,9 @@ package internal
 import (
 	"context"
 	"database/sql"
-	"fmt"
-	"github.com/gogf/gf/container/garray"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	"github.com/gogf/gf/util/gconv"
-	"strings"
 	"time"
 
 	model "dashoo.cn/micro/app/model/work"
@@ -30,40 +26,38 @@ type DeliverOrderDao struct {
 
 // DeliverOrderColumns defines and stores column names for table deliver_order.
 type deliverOrderColumns struct {
-	Id                           string // 主键
-	OrderCode                    string // 交付订单号
-	OrderStatus                  string // 交付状态(10项目立项 20 完成)
-	OrderType                    string // 交付类型(10 软件 20 硬件)
-	CustId                       string // 关联客户ID
-	CustName                     string // 关联客户名称
-	ProjectId                    string // 关联项目ID
-	ProjectName                  string // 关联项目名称
-	ContractId                   string // 关联合同ID
-	ContractCode                 string // 关联合同编号
-	ProjectManId                 string // 项目经理
-	ProjectManName               string // 项目经理
-	DeliverManId                 string // 交付经理
-	DeliverManName               string // 交付经理
-	Product                      string // 产品线
-	FinishRemark                 string // 完成信息
-	FinishTime                   string // 完成时间
-	FinishBy                     string // 完成操作人
-	FinishByName                 string // 完成操作人
-	RequiredDeliveryTime         string // 要求发货时间
-	ReceivingInfo                string // 收货信息
-	SpecialRequirements          string // 特殊要求说明
-	RealDeliveryTime             string // 实际发货时间
-	SoftwareRequiredDeliveryTime string // (软件)要求交付时间
-	SoftwareSpecialRequirements  string // (软件)特殊事项说明
-	IsDelay                      string // 是否延期(10(或为空)未延期,20已延期)
-	Remark                       string // 备注
-	CreatedBy                    string // 创建者
-	CreatedName                  string // 创建人
-	CreatedTime                  string // 创建时间
-	UpdatedBy                    string // 更新者
-	UpdatedName                  string // 更新人
-	UpdatedTime                  string // 更新时间
-	DeletedTime                  string // 删除时间
+	Id                   string // 主键
+	OrderCode            string // 交付订单号
+	OrderStatus          string // 交付状态(0发起 10项目立项 15进行中 20完成 30审批拒绝 40关闭)
+	OrderType            string // 交付类型(10 软件 20 硬件)
+	CustId               string // 关联客户ID
+	CustName             string // 关联客户名称
+	ProjectId            string // 关联项目ID
+	ProjectName          string // 关联项目名称
+	ContractId           string // 关联合同ID
+	ContractCode         string // 关联合同编号
+	ProjectManId         string // 项目经理
+	ProjectManName       string // 项目经理
+	DeliverManId         string // 交付经理
+	DeliverManName       string // 交付经理
+	DistributorId        string // 经销商id
+	DistributorName      string // 经销商名称
+	Product              string // 产品线
+	FinishRemark         string // 完成信息
+	FinishTime           string // 完成时间
+	FinishBy             string // 完成操作人
+	FinishByName         string // 完成操作人
+	RequiredDeliveryTime string // 要求发货时间
+	ReceivingInfo        string // 收货信息
+	SpecialRequirements  string // 特殊要求说明
+	Remark               string // 备注
+	CreatedBy            string // 创建者
+	CreatedName          string // 创建人
+	CreatedTime          string // 创建时间
+	UpdatedBy            string // 更新者
+	UpdatedName          string // 更新人
+	UpdatedTime          string // 更新时间
+	DeletedTime          string // 删除时间
 }
 
 var (
@@ -73,40 +67,38 @@ var (
 		DB:    g.DB("default"),
 		Table: "deliver_order",
 		C: deliverOrderColumns{
-			Id:                           "id",
-			OrderCode:                    "order_code",
-			OrderStatus:                  "order_status",
-			OrderType:                    "order_type",
-			CustId:                       "cust_id",
-			CustName:                     "cust_name",
-			ProjectId:                    "project_id",
-			ProjectName:                  "project_name",
-			ContractId:                   "contract_id",
-			ContractCode:                 "contract_code",
-			ProjectManId:                 "project_man_id",
-			ProjectManName:               "project_man_name",
-			DeliverManId:                 "deliver_man_id",
-			DeliverManName:               "deliver_man_name",
-			Product:                      "product",
-			FinishRemark:                 "finish_remark",
-			FinishTime:                   "finish_time",
-			FinishBy:                     "finish_by",
-			FinishByName:                 "finish_by_name",
-			RequiredDeliveryTime:         "required_delivery_time",
-			ReceivingInfo:                "receiving_info",
-			SpecialRequirements:          "special_requirements",
-			RealDeliveryTime:             "real_delivery_time",
-			SoftwareRequiredDeliveryTime: "software_required_delivery_time",
-			SoftwareSpecialRequirements:  "software_special_requirements",
-			IsDelay:                      "is_delay",
-			Remark:                       "remark",
-			CreatedBy:                    "created_by",
-			CreatedName:                  "created_name",
-			CreatedTime:                  "created_time",
-			UpdatedBy:                    "updated_by",
-			UpdatedName:                  "updated_name",
-			UpdatedTime:                  "updated_time",
-			DeletedTime:                  "deleted_time",
+			Id:                   "id",
+			OrderCode:            "order_code",
+			OrderStatus:          "order_status",
+			OrderType:            "order_type",
+			CustId:               "cust_id",
+			CustName:             "cust_name",
+			ProjectId:            "project_id",
+			ProjectName:          "project_name",
+			ContractId:           "contract_id",
+			ContractCode:         "contract_code",
+			ProjectManId:         "project_man_id",
+			ProjectManName:       "project_man_name",
+			DeliverManId:         "deliver_man_id",
+			DeliverManName:       "deliver_man_name",
+			DistributorId:        "distributor_id",
+			DistributorName:      "distributor_name",
+			Product:              "product",
+			FinishRemark:         "finish_remark",
+			FinishTime:           "finish_time",
+			FinishBy:             "finish_by",
+			FinishByName:         "finish_by_name",
+			RequiredDeliveryTime: "required_delivery_time",
+			ReceivingInfo:        "receiving_info",
+			SpecialRequirements:  "special_requirements",
+			Remark:               "remark",
+			CreatedBy:            "created_by",
+			CreatedName:          "created_name",
+			CreatedTime:          "created_time",
+			UpdatedBy:            "updated_by",
+			UpdatedName:          "updated_name",
+			UpdatedTime:          "updated_time",
+			DeletedTime:          "deleted_time",
 		},
 	}
 )
@@ -118,40 +110,38 @@ func NewDeliverOrderDao(tenant string) DeliverOrderDao {
 		DB:    g.DB(tenant),
 		Table: "deliver_order",
 		C: deliverOrderColumns{
-			Id:                           "id",
-			OrderCode:                    "order_code",
-			OrderStatus:                  "order_status",
-			OrderType:                    "order_type",
-			CustId:                       "cust_id",
-			CustName:                     "cust_name",
-			ProjectId:                    "project_id",
-			ProjectName:                  "project_name",
-			ContractId:                   "contract_id",
-			ContractCode:                 "contract_code",
-			ProjectManId:                 "project_man_id",
-			ProjectManName:               "project_man_name",
-			DeliverManId:                 "deliver_man_id",
-			DeliverManName:               "deliver_man_name",
-			Product:                      "product",
-			FinishRemark:                 "finish_remark",
-			FinishTime:                   "finish_time",
-			FinishBy:                     "finish_by",
-			FinishByName:                 "finish_by_name",
-			RequiredDeliveryTime:         "required_delivery_time",
-			ReceivingInfo:                "receiving_info",
-			SpecialRequirements:          "special_requirements",
-			RealDeliveryTime:             "real_delivery_time",
-			SoftwareRequiredDeliveryTime: "software_required_delivery_time",
-			SoftwareSpecialRequirements:  "software_special_requirements",
-			IsDelay:                      "is_delay",
-			Remark:                       "remark",
-			CreatedBy:                    "created_by",
-			CreatedName:                  "created_name",
-			CreatedTime:                  "created_time",
-			UpdatedBy:                    "updated_by",
-			UpdatedName:                  "updated_name",
-			UpdatedTime:                  "updated_time",
-			DeletedTime:                  "deleted_time",
+			Id:                   "id",
+			OrderCode:            "order_code",
+			OrderStatus:          "order_status",
+			OrderType:            "order_type",
+			CustId:               "cust_id",
+			CustName:             "cust_name",
+			ProjectId:            "project_id",
+			ProjectName:          "project_name",
+			ContractId:           "contract_id",
+			ContractCode:         "contract_code",
+			ProjectManId:         "project_man_id",
+			ProjectManName:       "project_man_name",
+			DeliverManId:         "deliver_man_id",
+			DeliverManName:       "deliver_man_name",
+			DistributorId:        "distributor_id",
+			DistributorName:      "distributor_name",
+			Product:              "product",
+			FinishRemark:         "finish_remark",
+			FinishTime:           "finish_time",
+			FinishBy:             "finish_by",
+			FinishByName:         "finish_by_name",
+			RequiredDeliveryTime: "required_delivery_time",
+			ReceivingInfo:        "receiving_info",
+			SpecialRequirements:  "special_requirements",
+			Remark:               "remark",
+			CreatedBy:            "created_by",
+			CreatedName:          "created_name",
+			CreatedTime:          "created_time",
+			UpdatedBy:            "updated_by",
+			UpdatedName:          "updated_name",
+			UpdatedTime:          "updated_time",
+			DeletedTime:          "deleted_time",
 		},
 	}
 	return dao
@@ -750,138 +740,3 @@ func (d *DeliverOrderDao) LockShared() *DeliverOrderDao {
 func (d *DeliverOrderDao) Unscoped() *DeliverOrderDao {
 	return &DeliverOrderDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
 }
-
-// DataScope enables the DataScope feature.
-func (d *DeliverOrderDao) DataScope(ctx context.Context, args ...interface{}) *DeliverOrderDao {
-	cs := ctx.Value("contextService")
-	dataScope := gconv.Map(gconv.String(gconv.Map(cs)["dataScope"]))
-	if dataScope != nil {
-		// 销售工程师判断
-		var salesEngineerFlag bool
-		if roles, ok := dataScope["roles"]; ok {
-			arr := garray.NewArrayFrom(roles.([]interface{}), true)
-			if arr.Len() == 1 && arr.Contains("SalesEngineer") {
-				salesEngineerFlag = true
-			}
-		}
-		userIds, ok := dataScope["userIds"]
-		specialFlag, userCols, orColsMap := d.checkColumnsName(dataScope, args...)
-
-		var orColumns []string
-		var orValues []interface{}
-		if ok && userIds != "-1" {
-			for _, column := range userCols {
-				if ok, _ := d.M.HasField(column); ok || specialFlag {
-					orColumns = append(orColumns, column+" IN (?) ")
-					orValues = append(orValues, userIds)
-				}
-			}
-		}
-		for col, params := range orColsMap {
-			if ok, _ := d.M.HasField(col); ok || specialFlag {
-				orColumns = append(orColumns, fmt.Sprintf(" ( %s IN (?) )", col))
-				orValues = append(orValues, params)
-			}
-		}
-
-		// 销售工程师权限加成
-		if !salesEngineerFlag {
-			var andColumns []string
-			var andValues []interface{}
-			for col, params := range dataScope {
-				if ok, _ := d.M.HasField(col); ok || specialFlag {
-					andColumns = append(andColumns, fmt.Sprintf(" ( %s IN (?) )", col))
-					andValues = append(andValues, params)
-				}
-			}
-			if len(andColumns) > 0 {
-				andWhereSql := strings.Join(andColumns, " AND ")
-				orColumns = append(orColumns, "("+andWhereSql+")")
-				orValues = append(orValues, andValues...)
-			}
-		}
-
-		whereSql := strings.Join(orColumns, " OR ")
-		return &DeliverOrderDao{M: d.M.Where(whereSql, orValues...).Ctx(ctx), Table: d.Table, TableAs: d.TableAs}
-	}
-	return d
-}
-
-// args 1、字段
-// args 2、字段、表名
-// args 3、字段对应关系
-func (d *DeliverOrderDao) checkColumnsName(dataScope map[string]interface{}, args ...interface{}) (bool, []string, map[string]interface{}) {
-	var userCols []string
-	tableAs, specialFlag := "", false
-	orColsMap, colsContrast := map[string]interface{}{}, map[string]interface{}{}
-
-	if d.TableAs != "" && len(args) <= 1 {
-		tableAs = d.TableAs + "."
-	}
-	if len(args) > 1 {
-		specialFlag = true
-		if val, ok := args[1].(string); ok {
-			tableAs = val + "."
-		}
-	}
-	if len(args) > 0 {
-		userCols = []string{"created_by"}
-		if column, ok := args[0].(string); ok {
-			userCols = []string{tableAs + column}
-		}
-		if cols, ok := args[0].([]string); ok {
-			for _, v := range cols {
-				userCols = append(userCols, tableAs+v)
-			}
-		}
-		if val, ok := args[0].(map[string]interface{}); ok {
-			specialFlag = true
-			colsContrast = val
-			if orcols, ok := val["orcols"]; ok {
-				if col, ok := orcols.(string); ok && gconv.String(val[col]) != "" {
-					orColsMap[col] = val[col]
-					delete(colsContrast, col)
-				}
-				if cols, ok := orcols.([]string); ok {
-					for _, col := range cols {
-						if gconv.String(val[col]) == "" {
-							continue
-						}
-						orColsMap[col] = val[col]
-						delete(colsContrast, col)
-					}
-				}
-			}
-			delete(colsContrast, "orcols")
-		}
-	}
-	bigColumns := "is_big"
-	if isBig, ok := dataScope[bigColumns]; ok {
-		if bigCol, ok := colsContrast[bigColumns]; ok {
-			orColsMap[bigCol.(string)] = isBig
-			delete(colsContrast, bigCol.(string))
-		} else {
-			if ok, _ := d.M.HasField(bigColumns); ok && specialFlag {
-				orColsMap[tableAs+bigColumns] = isBig
-			}
-		}
-	}
-
-	delete(dataScope, "userIds")
-	delete(dataScope, "roles")
-	delete(dataScope, "posts")
-	delete(dataScope, bigColumns)
-	if len(colsContrast) > 0 {
-		for k, v := range dataScope {
-			if data, ok := colsContrast[k]; ok {
-				dataScope[data.(string)] = v
-			}
-			delete(dataScope, k)
-			delete(colsContrast, k)
-		}
-		for k, v := range colsContrast {
-			dataScope[k] = v
-		}
-	}
-	return specialFlag, userCols, orColsMap
-}

+ 32 - 34
opms_parent/app/model/work/internal/deliver_order.go

@@ -10,38 +10,36 @@ import (
 
 // DeliverOrder is the golang structure for table deliver_order.
 type DeliverOrder struct {
-	Id                           int         `orm:"id,primary"                       json:"id"`                           // 主键
-	OrderCode                    string      `orm:"order_code"                       json:"orderCode"`                    // 交付订单号
-	OrderStatus                  string      `orm:"order_status"                     json:"orderStatus"`                  // 交付状态(10项目立项 20 完成)
-	OrderType                    string      `orm:"order_type"                       json:"orderType"`                    // 交付类型(10 软件 20 硬件)
-	CustId                       int         `orm:"cust_id"                          json:"custId"`                       // 关联客户ID
-	CustName                     string      `orm:"cust_name"                        json:"custName"`                     // 关联客户名称
-	ProjectId                    int         `orm:"project_id"                       json:"projectId"`                    // 关联项目ID
-	ProjectName                  string      `orm:"project_name"                     json:"projectName"`                  // 关联项目名称
-	ContractId                   int         `orm:"contract_id"                      json:"contractId"`                   // 关联合同ID
-	ContractCode                 string      `orm:"contract_code"                    json:"contractCode"`                 // 关联合同编号
-	ProjectManId                 int         `orm:"project_man_id"                   json:"projectManId"`                 // 项目经理
-	ProjectManName               string      `orm:"project_man_name"                 json:"projectManName"`               // 项目经理
-	DeliverManId                 int         `orm:"deliver_man_id"                   json:"deliverManId"`                 // 交付经理
-	DeliverManName               string      `orm:"deliver_man_name"                 json:"deliverManName"`               // 交付经理
-	Product                      string      `orm:"product"                          json:"product"`                      // 产品线
-	FinishRemark                 string      `orm:"finish_remark"                    json:"finishRemark"`                 // 完成信息
-	FinishTime                   *gtime.Time `orm:"finish_time"                      json:"finishTime"`                   // 完成时间
-	FinishBy                     int         `orm:"finish_by"                        json:"finishBy"`                     // 完成操作人
-	FinishByName                 string      `orm:"finish_by_name"                   json:"finishByName"`                 // 完成操作人
-	RequiredDeliveryTime         *gtime.Time `orm:"required_delivery_time"           json:"requiredDeliveryTime"`         // 要求发货时间
-	ReceivingInfo                string      `orm:"receiving_info"                   json:"receivingInfo"`                // 收货信息
-	SpecialRequirements          string      `orm:"special_requirements"             json:"specialRequirements"`          // 特殊要求说明
-	RealDeliveryTime             *gtime.Time `orm:"real_delivery_time"               json:"realDeliveryTime"`             // 实际发货时间
-	SoftwareRequiredDeliveryTime *gtime.Time `orm:"software_required_delivery_time"  json:"softwareRequiredDeliveryTime"` // (软件)要求交付时间
-	SoftwareSpecialRequirements  string      `orm:"software_special_requirements"    json:"softwareSpecialRequirements"`  // (软件)特殊事项说明
-	IsDelay                      string      `orm:"is_delay"                         json:"isDelay"`                      // 是否延期(10(或为空)未延期,20已延期)
-	Remark                       string      `orm:"remark"                           json:"remark"`                       // 备注
-	CreatedBy                    int         `orm:"created_by"                       json:"createdBy"`                    // 创建者
-	CreatedName                  string      `orm:"created_name"                     json:"createdName"`                  // 创建人
-	CreatedTime                  *gtime.Time `orm:"created_time"                     json:"createdTime"`                  // 创建时间
-	UpdatedBy                    int         `orm:"updated_by"                       json:"updatedBy"`                    // 更新者
-	UpdatedName                  string      `orm:"updated_name"                     json:"updatedName"`                  // 更新人
-	UpdatedTime                  *gtime.Time `orm:"updated_time"                     json:"updatedTime"`                  // 更新时间
-	DeletedTime                  *gtime.Time `orm:"deleted_time"                     json:"deletedTime"`                  // 删除时间
+	Id                   int         `orm:"id,primary"             json:"id"`                   // 主键
+	OrderCode            string      `orm:"order_code"             json:"orderCode"`            // 交付订单号
+	OrderStatus          string      `orm:"order_status"           json:"orderStatus"`          // 交付状态(0发起 10项目立项 15进行中 20完成 30审批拒绝 40关闭)
+	OrderType            string      `orm:"order_type"             json:"orderType"`            // 交付类型(10 软件 20 硬件)
+	CustId               int         `orm:"cust_id"                json:"custId"`               // 关联客户ID
+	CustName             string      `orm:"cust_name"              json:"custName"`             // 关联客户名称
+	ProjectId            int         `orm:"project_id"             json:"projectId"`            // 关联项目ID
+	ProjectName          string      `orm:"project_name"           json:"projectName"`          // 关联项目名称
+	ContractId           int         `orm:"contract_id"            json:"contractId"`           // 关联合同ID
+	ContractCode         string      `orm:"contract_code"          json:"contractCode"`         // 关联合同编号
+	ProjectManId         int         `orm:"project_man_id"         json:"projectManId"`         // 项目经理
+	ProjectManName       string      `orm:"project_man_name"       json:"projectManName"`       // 项目经理
+	DeliverManId         int         `orm:"deliver_man_id"         json:"deliverManId"`         // 交付经理
+	DeliverManName       string      `orm:"deliver_man_name"       json:"deliverManName"`       // 交付经理
+	DistributorId        int         `orm:"distributor_id"         json:"distributorId"`        // 经销商id
+	DistributorName      string      `orm:"distributor_name"       json:"distributorName"`      // 经销商名称
+	Product              string      `orm:"product"                json:"product"`              // 产品线
+	FinishRemark         string      `orm:"finish_remark"          json:"finishRemark"`         // 完成信息
+	FinishTime           *gtime.Time `orm:"finish_time"            json:"finishTime"`           // 完成时间
+	FinishBy             int         `orm:"finish_by"              json:"finishBy"`             // 完成操作人
+	FinishByName         string      `orm:"finish_by_name"         json:"finishByName"`         // 完成操作人
+	RequiredDeliveryTime *gtime.Time `orm:"required_delivery_time" json:"requiredDeliveryTime"` // 要求发货时间
+	ReceivingInfo        string      `orm:"receiving_info"         json:"receivingInfo"`        // 收货信息
+	SpecialRequirements  string      `orm:"special_requirements"   json:"specialRequirements"`  // 特殊要求说明
+	Remark               string      `orm:"remark"                 json:"remark"`               // 备注
+	CreatedBy            int         `orm:"created_by"             json:"createdBy"`            // 创建者
+	CreatedName          string      `orm:"created_name"           json:"createdName"`          // 创建人
+	CreatedTime          *gtime.Time `orm:"created_time"           json:"createdTime"`          // 创建时间
+	UpdatedBy            int         `orm:"updated_by"             json:"updatedBy"`            // 更新者
+	UpdatedName          string      `orm:"updated_name"           json:"updatedName"`          // 更新人
+	UpdatedTime          *gtime.Time `orm:"updated_time"           json:"updatedTime"`          // 更新时间
+	DeletedTime          *gtime.Time `orm:"deleted_time"           json:"deletedTime"`          // 删除时间
 }

+ 23 - 21
opms_parent/app/service/work/deliver_order.go

@@ -425,27 +425,29 @@ func DeliverOrderAdd(tx *gdb.TX, contractId int, userInfo request.UserInfo, prod
 
 		// 交付状态(0发起 10项目立项 15进行中 20 完成 30审批拒绝40关闭)
 		o := work.DeliverOrder{
-			OrderCode:      fmt.Sprintf("%s%s", c.ContractCode, orderType),
-			OrderStatus:    state,
-			OrderType:      orderType,
-			CustId:         c.CustId,
-			CustName:       c.CustName,
-			ProjectId:      c.NboId,
-			ProjectName:    c.NboName,
-			ContractId:     c.Id,
-			ContractCode:   c.ContractCode,
-			ProjectManId:   projectManId,
-			ProjectManName: projectManName,
-			DeliverManId:   deliverManId,
-			DeliverManName: deliverManName,
-			Product:        line,
-			Remark:         remark,
-			CreatedBy:      userInfo.Id,
-			CreatedName:    userInfo.NickName,
-			CreatedTime:    gtime.Now(),
-			UpdatedBy:      userInfo.Id,
-			UpdatedName:    userInfo.NickName,
-			UpdatedTime:    gtime.Now(),
+			OrderCode:       fmt.Sprintf("%s%s", c.ContractCode, orderType),
+			OrderStatus:     state,
+			OrderType:       orderType,
+			CustId:          c.CustId,
+			CustName:        c.CustName,
+			ProjectId:       c.NboId,
+			ProjectName:     c.NboName,
+			ContractId:      c.Id,
+			ContractCode:    c.ContractCode,
+			ProjectManId:    projectManId,
+			ProjectManName:  projectManName,
+			DeliverManId:    deliverManId,
+			DeliverManName:  deliverManName,
+			DistributorId:   c.DistributorId,
+			DistributorName: c.DistributorName,
+			Product:         line,
+			Remark:          remark,
+			CreatedBy:       userInfo.Id,
+			CreatedName:     userInfo.NickName,
+			CreatedTime:     gtime.Now(),
+			UpdatedBy:       userInfo.Id,
+			UpdatedName:     userInfo.NickName,
+			UpdatedTime:     gtime.Now(),
 		}
 		op := work.DeliverOrderProduct{
 			DeliverOrderId: 0,