|
@@ -7,13 +7,9 @@ package internal
|
|
|
import (
|
|
import (
|
|
|
"context"
|
|
"context"
|
|
|
"database/sql"
|
|
"database/sql"
|
|
|
- "fmt"
|
|
|
|
|
- "github.com/gogf/gf/container/garray"
|
|
|
|
|
"github.com/gogf/gf/database/gdb"
|
|
"github.com/gogf/gf/database/gdb"
|
|
|
"github.com/gogf/gf/frame/g"
|
|
"github.com/gogf/gf/frame/g"
|
|
|
"github.com/gogf/gf/frame/gmvc"
|
|
"github.com/gogf/gf/frame/gmvc"
|
|
|
- "github.com/gogf/gf/util/gconv"
|
|
|
|
|
- "strings"
|
|
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
model "dashoo.cn/micro/app/model/work"
|
|
model "dashoo.cn/micro/app/model/work"
|
|
@@ -30,40 +26,38 @@ type DeliverOrderDao struct {
|
|
|
|
|
|
|
|
// DeliverOrderColumns defines and stores column names for table deliver_order.
|
|
// DeliverOrderColumns defines and stores column names for table deliver_order.
|
|
|
type deliverOrderColumns struct {
|
|
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 (
|
|
var (
|
|
@@ -73,40 +67,38 @@ var (
|
|
|
DB: g.DB("default"),
|
|
DB: g.DB("default"),
|
|
|
Table: "deliver_order",
|
|
Table: "deliver_order",
|
|
|
C: deliverOrderColumns{
|
|
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),
|
|
DB: g.DB(tenant),
|
|
|
Table: "deliver_order",
|
|
Table: "deliver_order",
|
|
|
C: deliverOrderColumns{
|
|
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
|
|
return dao
|
|
@@ -750,138 +740,3 @@ func (d *DeliverOrderDao) LockShared() *DeliverOrderDao {
|
|
|
func (d *DeliverOrderDao) Unscoped() *DeliverOrderDao {
|
|
func (d *DeliverOrderDao) Unscoped() *DeliverOrderDao {
|
|
|
return &DeliverOrderDao{M: d.M.Unscoped(), Table: d.Table, TableAs: d.TableAs}
|
|
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
|
|
|
|
|
-}
|
|
|